]> git.mjollnir.org Git - moodle.git/commitdiff
Use HTML editor for editing HTML files
authormoodler <moodler>
Thu, 26 Dec 2002 16:26:55 +0000 (16:26 +0000)
committermoodler <moodler>
Thu, 26 Dec 2002 16:26:55 +0000 (16:26 +0000)
files/index.php

index 4d612143dc779c9ccec4a680935b405602ea3be3..c16775010470868355170b22cdc7532bc65bc100 100644 (file)
                 displaydir($wdir);
                     
             } else {
+                $streditfile = get_string("edit", "", "<B>$file</B>");
                 $fileptr  = fopen($basedir.$file, "r");
                 $contents = fread($fileptr, filesize($basedir.$file));
                 fclose($fileptr);
 
-                echo "<P>Editing <B>$file</B>:";
+                if (mimeinfo("type", $file) == "text/html") {
+                    if ($usehtmleditor = can_use_richtext_editor()) {
+                        $onsubmit = "onsubmit=\"copyrichtext(document.form.text);\"";
+                    } else {
+                        $onsubmit = "";
+                    }
+                } else {
+                    $usehtmleditor = false;
+                    $onsubmit = "";
+                }
+
+                print_heading("$streditfile");
+
                 echo "<TABLE><TR><TD COLSPAN=2>";
-                echo "<FORM ACTION=index.php METHOD=post NAME=form>";
+                echo "<FORM ACTION=\"index.php\" METHOD=\"post\" NAME=\"form\" $onsubmit>";
                 echo " <INPUT TYPE=hidden NAME=id VALUE=$id>";
                 echo " <INPUT TYPE=hidden NAME=wdir VALUE=\"$wdir\">";
                 echo " <INPUT TYPE=hidden NAME=file VALUE=\"$file\">";
                 echo " <INPUT TYPE=hidden NAME=action VALUE=edit>";
-                echo "<TEXTAREA ROWS=20 COLS=60 NAME=text>";
-                echo htmlspecialchars($contents);
-                echo "</TEXTAREA>";
+                print_textarea($usehtmleditor, 25, 80, 680, 400, "text", $contents);
                 echo "</TD></TR><TR><TD>";
                 echo " <INPUT TYPE=submit VALUE=\"".get_string("savechanges")."\">";
                 echo "</FORM>";
                 echo " <INPUT TYPE=submit VALUE=\"".get_string("cancel")."\">";
                 echo "</FORM>";
                 echo "</TD></TR></TABLE>";
+
+                if ($usehtmleditor) { 
+                    print_richedit_javascript("form", "text", "yes");
+                }
+
+
             }
             html_footer();
             break;