htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: htmlArea 2: htmlArea 2 & 3 archive (read only): htmlArea v2.0 - Add-Ons:
TRYING: Simple OPEN, EDIT and SAVE (php)


The htmlArea 2 & 3 editors have been discontinued.

We've made these forums available as a read-only reference and knowledge-base for people using or developing editors based on htmlArea 2 or 3.

Anyone who is interested in taking over version 2 or 3 is free to do so. All we ask is that you choose a new name that doesn't have "htmlarea" in it to avoid confusion with this site. We'll even give you a link in the directory to make it easier for people to find you. If you are developing or hosting an htmlArea based-editor under a new name, please submit it to our directory.

 


elogicmedia
New User

Jun 12, 2004, 7:42 PM

Post #1 of 4 (43678 views)
Shortcut
TRYING: Simple OPEN, EDIT and SAVE (php) Can't Post

Hi,

I am trying to create a simple open, edit and save feature for my pages using php and htmlarea
but I seem to be having problems.

Problem One: I can only get it to edit the whole page were I would like to change this and specify
the area in which to change, while still saving the rest of the page

Problem Two: I have the page saving (full page) but it is cutting out the html, head top tags
and the bottom body and html tags.

Code is Below, anyone able to help me out here?

Thanks
ADAM

Open.php


Code
 <?php  
$file = "$filename";
$fs = fopen( $file, "a+" ) or die("error when opening the file");


while (!feof($fs)) {
$contents .= fgets($fs, 1024);
}

fclose($fs);
?>

<html>
<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "/htmlarea/"; // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>
<form action="save.php" method="post">
<input type=hidden name="file" value="<?php echo $file; ?>">
<textarea name="contents" style="width:700; height:550"><?php echo htmlspecialchars($contents); ?></textarea>
<script language="javascript1.2">
editor_generate('contents');
</script>
<input type="submit" value="SAVE">
</form>
</html>



save.php


Code
  <?php  
$fs = fopen( $_POST["file"], "w+" ) or die("error when opening the file");
fwrite($fs, $_POST["contents"]);
fclose($fs);
?>




tuusita
Novice

Jun 14, 2004, 2:03 PM

Post #2 of 4 (43644 views)
Shortcut
Re: [elogicmedia] TRYING: Simple OPEN, EDIT and SAVE (php) [In reply to] Can't Post

Hi, this is the way I show my pages:

I save the stuff created with htmlarea directly into a file (I strip slashes with PHP's stripslashes-function). Let's say this file is called htmlarea.html.

The page that I want to show my htmlarea text is called showhtml.php. It contains the following code





<HTML><BODY>
<? include "htmlarea.html"; ?>
</BODY></HTML>





This way you can insert the necessary HTML and BODY tags for the page. And they don't show up when you open htmlarea.html for editing.

Hope that helps,
tuusita


Connie
New User

Feb 16, 2005, 1:23 PM

Post #3 of 4 (43013 views)
Shortcut
Re: [tuusita] TRYING: Simple OPEN, EDIT and SAVE (php) [In reply to] Can't Post

Dear tuusita,

I just found your answer and as this is my question as well and I am absolutely new to HTMLarea, I am looking for a way to open always the same file in the HTML-Area, edit it and save it so it can be included in another php-file.

If I understood you right, that's what you are doing.
Could you help with your script? I am so new to this, but I am not new to PHP completely,

thanks in advance,

Connie


tuusita
Novice

Feb 18, 2005, 8:29 AM

Post #4 of 4 (42948 views)
Shortcut
Re: [Connie] TRYING: Simple OPEN, EDIT and SAVE (php) [In reply to] Can't Post

Hi!

Just a quick and dirty reply (it's been a long time since I've worked with HTMLArea...). Please don't get upset with me if my scripts don't work as-is. It's been a while. Smile

The way I solved this was that I saved the text coming from HTMLArea form to a file of its own (say content.html) with a php-script.
Then I created a very simple php-file like this:


(show.php)


Code
 <html><body> 
<% include "content.html"; %>
</body></html>



(end show.php)

So you see I put the base HTML-code of the page in that php-file and just included the file that holds the content created with HTMLArea.
Oh, if I recall correctly you need to stripslashes from the HTMLArea-content before saving.

Like this:

Code
 $data = stripslashes($HTTP_POST_VARS["etusivu"]);


Then save then contents of the $data-variable to the contents.html

I wrote this in a hurry, sorry for any mistakes... Smile

Teemu Uusitalo

 
 
 


Search for (options)