Permalink
Browse files

Moving old editor to htmlarea folder.

1 parent c2db12a commit 6c1e8ba8d2b6ea9fb8cdb189a46b646cd77f83b8 julmis committed Mar 4, 2006
Showing with 11,679 additions and 0 deletions.
  1. +826 −0 lib/editor/htmlarea/coursefiles.php
  2. +80 −0 lib/editor/htmlarea/dialog.js
  3. +366 −0 lib/editor/htmlarea/htmlarea.class.php
  4. +180 −0 lib/editor/htmlarea/htmlarea.css
  5. +2,517 −0 lib/editor/htmlarea/htmlarea.php
  6. +2,304 −0 lib/editor/htmlarea/htmlarea_bak.php
  7. BIN lib/editor/htmlarea/images/ed_about.gif
  8. BIN lib/editor/htmlarea/images/ed_align_center.gif
  9. BIN lib/editor/htmlarea/images/ed_align_justify.gif
  10. BIN lib/editor/htmlarea/images/ed_align_left.gif
  11. BIN lib/editor/htmlarea/images/ed_align_right.gif
  12. BIN lib/editor/htmlarea/images/ed_anchor.gif
  13. BIN lib/editor/htmlarea/images/ed_blank.gif
  14. BIN lib/editor/htmlarea/images/ed_charmap.gif
  15. BIN lib/editor/htmlarea/images/ed_color_bg.gif
  16. BIN lib/editor/htmlarea/images/ed_color_fg.gif
  17. BIN lib/editor/htmlarea/images/ed_copy.gif
  18. BIN lib/editor/htmlarea/images/ed_custom.gif
  19. BIN lib/editor/htmlarea/images/ed_cut.gif
  20. BIN lib/editor/htmlarea/images/ed_delete.gif
  21. BIN lib/editor/htmlarea/images/ed_format_bold.gif
  22. BIN lib/editor/htmlarea/images/ed_format_italic.gif
  23. BIN lib/editor/htmlarea/images/ed_format_strike.gif
  24. BIN lib/editor/htmlarea/images/ed_format_sub.gif
  25. BIN lib/editor/htmlarea/images/ed_format_sup.gif
  26. BIN lib/editor/htmlarea/images/ed_format_underline.gif
  27. BIN lib/editor/htmlarea/images/ed_help.gif
  28. BIN lib/editor/htmlarea/images/ed_hr.gif
  29. BIN lib/editor/htmlarea/images/ed_html.gif
  30. BIN lib/editor/htmlarea/images/ed_image.gif
  31. BIN lib/editor/htmlarea/images/ed_indent_less.gif
  32. BIN lib/editor/htmlarea/images/ed_indent_more.gif
  33. BIN lib/editor/htmlarea/images/ed_left_to_right.gif
  34. BIN lib/editor/htmlarea/images/ed_link.gif
  35. BIN lib/editor/htmlarea/images/ed_list_bullet.gif
  36. BIN lib/editor/htmlarea/images/ed_list_num.gif
  37. BIN lib/editor/htmlarea/images/ed_nolink.gif
  38. BIN lib/editor/htmlarea/images/ed_paste.gif
  39. BIN lib/editor/htmlarea/images/ed_redo.gif
  40. BIN lib/editor/htmlarea/images/ed_replace.gif
  41. BIN lib/editor/htmlarea/images/ed_right_to_left.gif
  42. BIN lib/editor/htmlarea/images/ed_show_border.gif
  43. BIN lib/editor/htmlarea/images/ed_splitcel.gif
  44. BIN lib/editor/htmlarea/images/ed_undo.gif
  45. BIN lib/editor/htmlarea/images/ed_unlink.gif
  46. BIN lib/editor/htmlarea/images/ed_wordclean.gif
  47. BIN lib/editor/htmlarea/images/em.icon.smile.gif
  48. BIN lib/editor/htmlarea/images/folderup.gif
  49. BIN lib/editor/htmlarea/images/fullscreen_maximize.gif
  50. BIN lib/editor/htmlarea/images/fullscreen_minimize.gif
  51. BIN lib/editor/htmlarea/images/icon_ins_char.gif
  52. BIN lib/editor/htmlarea/images/icon_smile.gif
  53. BIN lib/editor/htmlarea/images/insert_table.gif
  54. BIN lib/editor/htmlarea/images/spell-check.gif
  55. 0 lib/editor/htmlarea/index.html
  56. +63 −0 lib/editor/htmlarea/lang/en.js
  57. +88 −0 lib/editor/htmlarea/lang/en.php
  58. +13 −0 lib/editor/htmlarea/license.txt
  59. BIN lib/editor/htmlarea/plugins/SpellChecker/img/spell-check.gif
  60. +37 −0 lib/editor/htmlarea/plugins/SpellChecker/lang/en.js
  61. +37 −0 lib/editor/htmlarea/plugins/SpellChecker/lang/ro.js
  62. +115 −0 lib/editor/htmlarea/plugins/SpellChecker/readme-tech.html
  63. +155 −0 lib/editor/htmlarea/plugins/SpellChecker/spell-check-logic.cgi
  64. +10 −0 lib/editor/htmlarea/plugins/SpellChecker/spell-check-style.css
  65. +119 −0 lib/editor/htmlarea/plugins/SpellChecker/spell-check-ui.html
  66. +334 −0 lib/editor/htmlarea/plugins/SpellChecker/spell-check-ui.js
  67. +72 −0 lib/editor/htmlarea/plugins/SpellChecker/spell-checker.js
  68. BIN lib/editor/htmlarea/plugins/TableOperations/img/cell-delete.gif
  69. BIN lib/editor/htmlarea/plugins/TableOperations/img/cell-insert-after.gif
  70. BIN lib/editor/htmlarea/plugins/TableOperations/img/cell-insert-before.gif
  71. BIN lib/editor/htmlarea/plugins/TableOperations/img/cell-merge.gif
  72. BIN lib/editor/htmlarea/plugins/TableOperations/img/cell-prop.gif
  73. BIN lib/editor/htmlarea/plugins/TableOperations/img/cell-split.gif
  74. BIN lib/editor/htmlarea/plugins/TableOperations/img/col-delete.gif
  75. BIN lib/editor/htmlarea/plugins/TableOperations/img/col-insert-after.gif
  76. BIN lib/editor/htmlarea/plugins/TableOperations/img/col-insert-before.gif
  77. BIN lib/editor/htmlarea/plugins/TableOperations/img/col-split.gif
  78. BIN lib/editor/htmlarea/plugins/TableOperations/img/row-delete.gif
  79. BIN lib/editor/htmlarea/plugins/TableOperations/img/row-insert-above.gif
  80. BIN lib/editor/htmlarea/plugins/TableOperations/img/row-insert-under.gif
  81. BIN lib/editor/htmlarea/plugins/TableOperations/img/row-prop.gif
  82. BIN lib/editor/htmlarea/plugins/TableOperations/img/row-split.gif
  83. BIN lib/editor/htmlarea/plugins/TableOperations/img/table-prop.gif
  84. +90 −0 lib/editor/htmlarea/plugins/TableOperations/lang/en.js
  85. +66 −0 lib/editor/htmlarea/plugins/TableOperations/lang/fi.js
  86. +90 −0 lib/editor/htmlarea/plugins/TableOperations/lang/ro.js
  87. +7 −0 lib/editor/htmlarea/plugins/TableOperations/makefile.xml
  88. +1,167 −0 lib/editor/htmlarea/plugins/TableOperations/table-operations.js
  89. +369 −0 lib/editor/htmlarea/popupdiv.js
  90. +55 −0 lib/editor/htmlarea/popups/about.html
  91. +2 −0 lib/editor/htmlarea/popups/blank.html
  92. +68 −0 lib/editor/htmlarea/popups/createanchor.php
  93. +72 −0 lib/editor/htmlarea/popups/dialog.css
  94. +142 −0 lib/editor/htmlarea/popups/dlg_ins_char.php
  95. +125 −0 lib/editor/htmlarea/popups/dlg_ins_smile.php
  96. +16 −0 lib/editor/htmlarea/popups/editor_help.html
  97. +175 −0 lib/editor/htmlarea/popups/fullscreen.php
  98. +346 −0 lib/editor/htmlarea/popups/insert_image.php
  99. +231 −0 lib/editor/htmlarea/popups/insert_image_std.php
  100. +172 −0 lib/editor/htmlarea/popups/insert_table.php
  101. +154 −0 lib/editor/htmlarea/popups/link.php
  102. +189 −0 lib/editor/htmlarea/popups/link_std.php
  103. +86 −0 lib/editor/htmlarea/popups/popup.js
  104. +35 −0 lib/editor/htmlarea/popups/preview.php
  105. +142 −0 lib/editor/htmlarea/popups/searchandreplace.php
  106. +355 −0 lib/editor/htmlarea/popups/select_color.php
  107. +127 −0 lib/editor/htmlarea/popupwin.js
  108. +82 −0 lib/editor/htmlarea/release-notes.html
View
826 lib/editor/htmlarea/coursefiles.php
@@ -0,0 +1,826 @@
+<?php // $Id$
+
+// Manage all uploaded files in a course file area
+
+// This file is a hack to files/index.php that removes
+// the headers and adds some controls so that images
+// can be selected within the Richtext editor.
+
+// All the Moodle-specific stuff is in this top section
+// Configuration and access control occurs here.
+// Must define: USER, basedir, baseweb, html_header and html_footer
+// USER is a persistent variable using sessions
+
+ require("../../../config.php");
+ require_once($CFG->libdir.'/filelib.php');
+
+ $id = required_param('id', PARAM_INT);
+ $file = optional_param('file', '', PARAM_PATH);
+ $wdir = optional_param('wdir', '', PARAM_PATH);
+ $action = optional_param('action', '', PARAM_ACTION);
+ $name = optional_param('name', '', PARAM_FILE);
+ $oldname = optional_param('oldname', '', PARAM_FILE);
+ $usecheckboxes = optional_param('usecheckboxes', 1, PARAM_INT);
+
+
+ if (! $course = get_record("course", "id", $id) ) {
+ error("That's an invalid course id");
+ }
+
+ require_login($course->id);
+
+ if (! isteacheredit($course->id) ) {
+ error("Only teachers can edit files");
+ }
+
+ function html_footer() {
+ echo "\n\n</body>\n</html>";
+ }
+
+ function html_header($course, $wdir, $formfield=""){
+
+ global $CFG;
+
+ ?>
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+ <html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=<?php print_string("thischarset");?>" />
+ <title>coursefiles</title>
+ <script language="javscript" type="text/javascript">
+ <!--
+ function set_value(params) {
+ /// function's argument is an object containing necessary values
+ /// to export parent window (url,isize,itype,iwidth,iheight, imodified)
+ /// set values when user click's an image name.
+ var upper = window.parent;
+ var insimg = upper.document.getElementById('f_url');
+
+ try {
+ if(insimg != null) {
+ if(params.itype.indexOf("image/gif") == -1 && params.itype.indexOf("image/jpeg") == -1 && params.itype.indexOf("image/png") == -1) {
+ alert("<?php print_string("notimage","editor");?>");
+ return false;
+ }
+ for(field in params) {
+ var value = params[field];
+ switch(field) {
+ case "url" : upper.document.getElementById('f_url').value = value;
+ upper.ipreview.location.replace('popups/preview.php?id='+ <?php print($course->id);?> +'&imageurl='+ value);
+ break;
+ case "isize" : upper.document.getElementById('isize').value = value; break;
+ case "itype" : upper.document.getElementById('itype').value = value; break;
+ case "iwidth": upper.document.getElementById('f_width').value = value; break;
+ case "iheight": upper.document.getElementById('f_height').value = value; break;
+ }
+ }
+ } else {
+ for(field in params) {
+ var value = params[field];
+ switch(field) {
+ case "url" :
+ //upper.document.getElementById('f_href').value = value;
+ upper.opener.document.getElementById('f_href').value = value;
+ upper.close();
+ break;
+ //case "imodified" : upper.document.getElementById('imodified').value = value; break;
+ //case "isize" : upper.document.getElementById('isize').value = value; break;
+ //case "itype" : upper.document.getElementById('itype').value = value; break;
+ }
+ }
+ }
+ } catch(e) {
+ if ( window.tinyMCE != "undefined" || window.TinyMCE != "undefined" ) {
+ upper.opener.Dialog._return(params.url);
+ upper.close();
+ } else {
+ alert("Something odd just occurred!!!");
+ }
+ }
+ return false;
+ }
+
+ function set_dir(strdir) {
+ // sets wdir values
+ var upper = window.parent.document;
+ if(upper) {
+ for(var i = 0; i < upper.forms.length; i++) {
+ var f = upper.forms[i];
+ try {
+ f.wdir.value = strdir;
+ } catch (e) {
+
+ }
+ }
+ }
+ }
+
+ function set_rename(strfile) {
+ if(window.parent.document.irename != null) {
+ window.parent.document.irename.file.value = strfile;
+ }
+ return true;
+ }
+
+ function reset_value() {
+ var upper = window.parent.document;
+ for(var i = 0; i < upper.forms.length; i++) {
+ var f = upper.forms[i];
+ for(var j = 0; j < f.elements.length; j++) {
+ var e = f.elements[j];
+ if(e.type != "submit" && e.type != "button" && e.type != "hidden") {
+ try {
+ e.value = "";
+ } catch (e) {
+ }
+ }
+ }
+ }
+
+ var ren = upper.getElementById('irename');
+ if(ren != null) {
+ upper.irename.file.value = "";
+ }
+ var prev = window.parent.ipreview;
+ if(prev != null) {
+ prev.location.replace('about:blank');
+ }
+ var uploader = window.parent.document.forms['uploader'];
+ if(uploader != null) {
+ uploader.reset();
+ }
+ set_dir('<?php print(!empty($_REQUEST['wdir'])) ? $_REQUEST['wdir'] : "";?>');
+ return true;
+ }
+ -->
+ </script>
+ <style type="text/css">
+ <!--
+ body {
+ background-color: white;
+ margin-top: 2px;
+ margin-left: 4px;
+ margin-right: 4px;
+ }
+ body,p,table,td,input,select,a {
+ font-family: Tahoma, sans-serif;
+ font-size: 11px;
+ }
+ select {
+ position: absolute;
+ top: -20px;
+ left: 0px;
+ }
+ -->
+ </style>
+ </head>
+ <body onload="reset_value();">
+
+ <?php
+ }
+
+ if (! $basedir = make_upload_directory("$course->id")) {
+ error("The site administrator needs to fix the file permissions");
+ }
+
+ $baseweb = $CFG->wwwroot;
+
+// End of configuration and access control
+
+
+ if (!$wdir) {
+ $wdir="/";
+ }
+
+ if (($wdir != '/' and detect_munged_arguments($wdir, 0))
+ or ($file != '' and detect_munged_arguments($file, 0))) {
+ $message = "Error: Directories can not contain \"..\"";
+ $wdir = "/";
+ $action = "";
+ }
+
+
+ switch ($action) {
+
+ case "upload":
+ html_header($course, $wdir);
+ require_once($CFG->dirroot.'/lib/uploadlib.php');
+
+ if (!empty($save) and confirm_sesskey()) {
+ $um = new upload_manager('userfile',false,false,$course,false,0);
+ $dir = "$basedir$wdir";
+ if ($um->process_file_uploads($dir)) {
+ notify(get_string('uploadedfile'));
+ }
+ // um will take care of error reporting.
+ displaydir($wdir);
+ } else {
+ $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes);
+ $filesize = display_size($upload_max_filesize);
+
+ $struploadafile = get_string("uploadafile");
+ $struploadthisfile = get_string("uploadthisfile");
+ $strmaxsize = get_string("maxsize", "", $filesize);
+ $strcancel = get_string("cancel");
+
+ echo "<p>$struploadafile ($strmaxsize) --> <strong>$wdir</strong>";
+ echo "<table border=\"0\"><tr><td colspan=\"2\">\n";
+ echo "<form enctype=\"multipart/form-data\" method=\"post\" action=\"coursefiles.php\">\n";
+ upload_print_form_fragment(1,array('userfile'),null,false,null,$course->maxbytes,0,false);
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"upload\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ echo " </td><tr><td align=\"right\">";
+ echo " <input type=\"submit\" name=\"save\" value=\"$struploadthisfile\" />\n";
+ echo "</form>\n";
+ echo "</td>\n<td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"submit\" value=\"$strcancel\" />\n";
+ echo "</form>\n";
+ echo "</td>\n</tr>\n</table>\n";
+ }
+ html_footer();
+ break;
+
+ case "delete":
+ if (!empty($confirm) and confirm_sesskey()) {
+ html_header($course, $wdir);
+ foreach ($USER->filelist as $file) {
+ $fullfile = $basedir.$file;
+ if (! fulldelete($fullfile)) {
+ echo "<br />Error: Could not delete: $fullfile";
+ }
+ }
+ clearfilelist();
+ displaydir($wdir);
+ html_footer();
+
+ } else {
+ html_header($course, $wdir);
+ if (setfilelist($_POST)) {
+ echo "<p align=center>".get_string("deletecheckwarning").":</p>";
+ print_simple_box_start("center");
+ printfilelist($USER->filelist);
+ print_simple_box_end();
+ echo "<br />";
+ $frameold = $CFG->framename;
+ $CFG->framename = "ibrowser";
+ notice_yesno (get_string("deletecheckfiles"),
+ "coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=delete&amp;confirm=1&amp;sesskey=$USER->sesskey",
+ "coursefiles.php?id=$id&amp;wdir=$wdir&amp;action=cancel");
+ $CFG->framename = $frameold;
+ } else {
+ displaydir($wdir);
+ }
+ html_footer();
+ }
+ break;
+
+ case "move":
+ html_header($course, $wdir);
+ if ($count = setfilelist($_POST) and confirm_sesskey()) {
+ $USER->fileop = $action;
+ $USER->filesource = $wdir;
+ echo "<p align=\"center\">";
+ print_string("selectednowmove", "moodle", $count);
+ echo "</p>";
+ }
+ displaydir($wdir);
+ html_footer();
+ break;
+
+ case "paste":
+ html_header($course, $wdir);
+ if (isset($USER->fileop) and $USER->fileop == "move" and confirm_sesskey()) {
+ foreach ($USER->filelist as $file) {
+ $shortfile = basename($file);
+ $oldfile = $basedir.$file;
+ $newfile = $basedir.$wdir."/".$shortfile;
+ if (!rename($oldfile, $newfile)) {
+ echo "<p>Error: $shortfile not moved";
+ }
+ }
+ }
+ clearfilelist();
+ displaydir($wdir);
+ html_footer();
+ break;
+
+ case "rename":
+ if (!empty($name) and confirm_sesskey()) {
+ html_header($course, $wdir);
+ $name = clean_filename($name);
+ $oldname = clean_filename($oldname);
+ if (file_exists($basedir.$wdir."/".$name)) {
+ echo "Error: $name already exists!";
+ } else if (!rename($basedir.$wdir."/".$oldname, $basedir.$wdir."/".$name)) {
+ echo "Error: could not rename $oldname to $name";
+ }
+ displaydir($wdir);
+
+ } else {
+ $strrename = get_string("rename");
+ $strcancel = get_string("cancel");
+ $strrenamefileto = get_string("renamefileto", "moodle", $file);
+ html_header($course, $wdir, "form.name");
+ echo "<p>$strrenamefileto:";
+ echo "<table border=\"0\">\n<tr>\n<td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"rename\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ echo " <input type=\"hidden\" name=oldname value=\"$file\" />\n";
+ echo " <input type=\"text\" name=\"name\" size=\"35\" value=\"$file\" />\n";
+ echo " <input type=\"submit\" value=\"$strrename\" />\n";
+ echo "</form>\n";
+ echo "</td><td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"submit\" value=\"$strcancel\" />\n";
+ echo "</form>";
+ echo "</td></tr>\n</table>\n";
+ }
+ html_footer();
+ break;
+
+ case "mkdir":
+ if (!empty($name) and confirm_sesskey()) {
+ html_header($course, $wdir);
+ $name = clean_filename($name);
+ if (file_exists("$basedir$wdir/$name")) {
+ echo "Error: $name already exists!";
+ } else if (! make_upload_directory("$course->id/$wdir/$name")) {
+ echo "Error: could not create $name";
+ }
+ displaydir($wdir);
+
+ } else {
+ $strcreate = get_string("create");
+ $strcancel = get_string("cancel");
+ $strcreatefolder = get_string("createfolder", "moodle", $wdir);
+ html_header($course, $wdir, "form.name");
+ echo "<p>$strcreatefolder:";
+ echo "<table border=\"0\">\n<tr><td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"mkdir\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ echo " <input type=\"text\" name=\"name\" size=\"35\" />\n";
+ echo " <input type=\"submit\" value=\"$strcreate\" />\n";
+ echo "</form>\n";
+ echo "</td><td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"submit\" value=\"$strcancel\" />\n";
+ echo "</form>\n";
+ echo "</td>\n</tr>\n</table>\n";
+ }
+ html_footer();
+ break;
+
+ case "edit":
+ html_header($course, $wdir);
+ if (isset($text) and confirm_sesskey()) {
+ $fileptr = fopen($basedir.$file,"w");
+ fputs($fileptr, stripslashes($text));
+ fclose($fileptr);
+ displaydir($wdir);
+
+ } else {
+ $streditfile = get_string("edit", "", "<strong>$file</strong>");
+ $fileptr = fopen($basedir.$file, "r");
+ $contents = fread($fileptr, filesize($basedir.$file));
+ fclose($fileptr);
+
+ print_heading("$streditfile");
+
+ echo "<table><tr><td colspan=\"2\">\n";
+ echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\" $onsubmit>\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=file value=\"$file\" />";
+ echo " <input type=\"hidden\" name=\"action\" value=\"edit\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ print_textarea(false, 25, 80, 680, 400, "text", $contents);
+ echo "</td>\n</tr>\n<tr>\n<td>\n";
+ echo " <input type=\"submit\" value=\"".get_string("savechanges")."\" />\n";
+ echo "</form>\n";
+ echo "</td>\n<td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n";
+ echo "</form>\n";
+ echo "</td></tr></table>\n";
+
+ if ($usehtmleditor) {
+ print_richedit_javascript("form", "text", "yes");
+ }
+
+
+ }
+ html_footer();
+ break;
+
+ case "zip":
+ if (!empty($name) and confirm_sesskey()) {
+ html_header($course, $wdir);
+ $name = clean_filename($name);
+
+ $files = array();
+ foreach ($USER->filelist as $file) {
+ $files[] = "$basedir/$file";
+ }
+
+ if (!zip_files($files,"$basedir/$wdir/$name")) {
+ error(get_string("zipfileserror","error"));
+ }
+
+ clearfilelist();
+ displaydir($wdir);
+
+ } else {
+ html_header($course, $wdir, "form.name");
+
+ if (setfilelist($_POST)) {
+ echo "<p align=\"center\">".get_string("youareabouttocreatezip").":</p>";
+ print_simple_box_start("center");
+ printfilelist($USER->filelist);
+ print_simple_box_end();
+ echo "<br />";
+ echo "<p align=\"center\">".get_string("whattocallzip");
+ echo "<table border=\"0\">\n<tr>\n<td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"post\" name=\"form\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"zip\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ echo " <INPUT TYPE=text name=name SIZE=35 value=\"new.zip\" />\n";
+ echo " <input type=\"submit\" value=\"".get_string("createziparchive")."\" />";
+ echo "</form>\n";
+ echo "</td>\n<td>\n";
+ echo "<form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"submit\" value=\"".get_string("cancel")."\" />\n";
+ echo "</form>\n";
+ echo "</td>\n</tr>\n</table>\n";
+ } else {
+ displaydir($wdir);
+ clearfilelist();
+ }
+ }
+ html_footer();
+ break;
+
+ case "unzip":
+ html_header($course, $wdir);
+ if (!empty($file) and confirm_sesskey()) {
+ $strok = get_string("ok");
+ $strunpacking = get_string("unpacking", "", $file);
+
+ echo "<p align=\"center\">$strunpacking:</p>";
+
+ $file = basename($file);
+
+ if (!unzip_file("$basedir/$wdir/$file")) {
+ error(get_string("unzipfileserror","error"));
+ }
+
+ echo "<center><form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"submit\" value=\"$strok\" />\n";
+ echo "</form>\n";
+ echo "</center>\n";
+ } else {
+ displaydir($wdir);
+ }
+ html_footer();
+ break;
+
+ case "listzip":
+ html_header($course, $wdir);
+ if (!empty($file) and confirm_sesskey()) {
+ $strname = get_string("name");
+ $strsize = get_string("size");
+ $strmodified = get_string("modified");
+ $strok = get_string("ok");
+ $strlistfiles = get_string("listfiles", "", $file);
+
+ echo "<p align=\"center\">$strlistfiles:</p>";
+ $file = basename($file);
+
+ include_once('../pclzip/pclzip.lib.php');
+ $archive = new PclZip("$basedir/$wdir/$file");
+ if (!$list = $archive->listContent("$basedir/$wdir")) {
+ notify($archive->errorInfo(true));
+
+ } else {
+ echo "<table cellpadding=\"4\" cellspacing=\"2\" border=\"0\">\n";
+ echo "<tr>\n<th align=\"left\">$strname</th><th align=\"right\">$strsize</th><th align=\"right\">$strmodified</th></tr>";
+ foreach ($list as $item) {
+ echo "<tr>";
+ print_cell("left", $item['filename']);
+ if (! $item['folder']) {
+ print_cell("right", display_size($item['size']));
+ } else {
+ echo "<td>&nbsp;</td>\n";
+ }
+ $filedate = userdate($item['mtime'], get_string("strftimedatetime"));
+ print_cell("right", $filedate);
+ echo "</tr>\n";
+ }
+ echo "</table>\n";
+ }
+ echo "<br /><center><form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"cancel\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ echo " <input type=\"submit\" value=\"$strok\" />\n";
+ echo "</form>\n";
+ echo "</center>\n";
+ } else {
+ displaydir($wdir);
+ }
+ html_footer();
+ break;
+
+ case "cancel":
+ clearfilelist();
+
+ default:
+ html_header($course, $wdir);
+ displaydir($wdir);
+ html_footer();
+ break;
+}
+
+
+/// FILE FUNCTIONS ///////////////////////////////////////////////////////////
+
+
+function setfilelist($VARS) {
+ global $USER;
+
+ $USER->filelist = array ();
+ $USER->fileop = "";
+
+ $count = 0;
+ foreach ($VARS as $key => $val) {
+ if (substr($key,0,4) == "file") {
+ $count++;
+ $val = rawurldecode($val);
+ if (!detect_munged_arguments($val, 0)) {
+ $USER->filelist[] = $val;
+ }
+ }
+ }
+ return $count;
+}
+
+function clearfilelist() {
+ global $USER;
+
+ $USER->filelist = array ();
+ $USER->fileop = "";
+}
+
+
+function printfilelist($filelist) {
+ global $basedir, $CFG;
+
+ foreach ($filelist as $file) {
+ if (is_dir($basedir.$file)) {
+ echo "<img src=\"$CFG->pixpath/f/folder.gif\" height=\"16\" width=\"16\" alt=\"\" /> $file<br />";
+ $subfilelist = array();
+ $currdir = opendir($basedir.$file);
+ while (false !== ($subfile = readdir($currdir))) {
+ if ($subfile <> ".." && $subfile <> ".") {
+ $subfilelist[] = $file."/".$subfile;
+ }
+ }
+ printfilelist($subfilelist);
+
+ } else {
+ $icon = mimeinfo("icon", $file);
+ echo "<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\" alt=\"\" /> $file<br />";
+ }
+ }
+}
+
+
+function print_cell($alignment="center", $text="&nbsp;") {
+ echo "<td align=\"$alignment\" nowrap=\"nowrap\">\n";
+ echo "$text";
+ echo "</td>\n";
+}
+
+function get_image_size($filepath) {
+/// This function get's the image size
+
+ /// Check if file exists
+ if(!file_exists($filepath)) {
+ return false;
+ } else {
+ /// Get the mime type so it really an image.
+ if(mimeinfo("icon", basename($filepath)) != "image.gif") {
+ return false;
+ } else {
+ $array_size = getimagesize($filepath);
+ return $array_size;
+ }
+ }
+ unset($filepath,$array_size);
+}
+
+function displaydir ($wdir) {
+// $wdir == / or /a or /a/b/c/d etc
+
+ global $basedir;
+ global $usecheckboxes;
+ global $id;
+ global $USER, $CFG;
+
+ $fullpath = $basedir.$wdir;
+
+ $directory = opendir($fullpath); // Find all files
+ while (false !== ($file = readdir($directory))) {
+ if ($file == "." || $file == "..") {
+ continue;
+ }
+
+ if (is_dir($fullpath."/".$file)) {
+ $dirlist[] = $file;
+ } else {
+ $filelist[] = $file;
+ }
+ }
+ closedir($directory);
+
+ $strfile = get_string("file");
+ $strname = get_string("name");
+ $strsize = get_string("size");
+ $strmodified = get_string("modified");
+ $straction = get_string("action");
+ $strmakeafolder = get_string("makeafolder");
+ $struploadafile = get_string("uploadafile");
+ $strwithchosenfiles = get_string("withchosenfiles");
+ $strmovetoanotherfolder = get_string("movetoanotherfolder");
+ $strmovefilestohere = get_string("movefilestohere");
+ $strdeletecompletely = get_string("deletecompletely");
+ $strcreateziparchive = get_string("createziparchive");
+ $strrename = get_string("rename");
+ $stredit = get_string("edit");
+ $strunzip = get_string("unzip");
+ $strlist = get_string("list");
+ $strchoose = get_string("choose");
+
+
+ echo "<form action=\"coursefiles.php\" method=\"post\" name=\"dirform\">\n";
+ echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\n";
+
+ if ($wdir == "/") {
+ $wdir = "";
+ } else {
+ $bdir = str_replace("/".basename($wdir),"",$wdir);
+ if($bdir == "/") {
+ $bdir = "";
+ }
+ print "<tr>\n<td colspan=\"5\">";
+ print "<a href=\"coursefiles.php?id=$id&amp;wdir=$bdir&amp;usecheckboxes=$usecheckboxes\" onclick=\"return reset_value();\">";
+ print "<img src=\"$CFG->wwwroot/lib/editor/htmlarea/images/folderup.gif\" height=\"14\" width=\"24\" border=\"0\" alt=\"Move up\" />";
+ print "</a></td>\n</tr>\n";
+ }
+
+ $count = 0;
+
+ if (!empty($dirlist)) {
+ asort($dirlist);
+ foreach ($dirlist as $dir) {
+
+ $count++;
+
+ $filename = $fullpath."/".$dir;
+ $fileurl = rawurlencode($wdir."/".$dir);
+ $filesafe = rawurlencode($dir);
+ $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
+
+ echo "<tr>";
+
+ if ($usecheckboxes) {
+ print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" onclick=\"return set_rename('$filesafe');\" />");
+ }
+ print_cell("left", "<a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl\" onclick=\"return reset_value();\"><img src=\"$CFG->pixpath/f/folder.gif\" height=\"16\" width=\"16\" border=\"0\" alt=\"folder\" /></a> <a href=\"coursefiles.php?id=$id&amp;wdir=$fileurl&amp;usecheckboxes=$usecheckboxes\" onclick=\"return reset_value();\">".htmlspecialchars($dir)."</a>");
+ print_cell("right", "&nbsp;");
+ print_cell("right", $filedate);
+
+ echo "</tr>";
+ }
+ }
+
+
+ if (!empty($filelist)) {
+ asort($filelist);
+ foreach ($filelist as $file) {
+
+ $icon = mimeinfo("icon", $file);
+ $imgtype = mimeinfo("type",$file);
+
+ $count++;
+ $filename = $fullpath."/".$file;
+ $fileurl = "$wdir/$file";
+ $filesafe = rawurlencode($file);
+ $fileurlsafe = rawurlencode($fileurl);
+ $filedate = userdate(filemtime($filename), "%d %b %Y, %I:%M %p");
+
+ $dimensions = get_image_size($filename);
+ if($dimensions) {
+ $imgwidth = $dimensions[0];
+ $imgheight = $dimensions[1];
+ } else {
+ $imgwidth = "Unknown";
+ $imgheight = "Unknown";
+ }
+ unset($dimensions);
+ echo "<tr>\n";
+
+ if ($usecheckboxes) {
+ print_cell("center", "<input type=\"checkbox\" name=\"file$count\" value=\"$fileurl\" onclick=\"return set_rename('$filesafe');\" />");
+ }
+ echo "<td align=\"left\" nowrap=\"nowrap\">";
+ if ($CFG->slasharguments) {
+ $ffurl = "/file.php/$id$fileurl";
+ } else {
+ $ffurl = "/file.php?file=/$id$fileurl";
+ }
+ link_to_popup_window ($ffurl, "display",
+ "<img src=\"$CFG->pixpath/f/$icon\" height=\"16\" width=\"16\" border=\"0\" align=\"middle\" alt=\"$strfile\" />",
+ 480, 640);
+ $file_size = filesize($filename);
+
+ echo "<a onclick=\"return set_value(info = {url: '".$CFG->wwwroot.$ffurl."',";
+ echo " isize: '".$file_size."', itype: '".$imgtype."', iwidth: '".$imgwidth."',";
+ echo " iheight: '".$imgheight."', imodified: '".$filedate."' })\" href=\"#\">$file</a>";
+ echo "</td>\n";
+
+ if ($icon == "zip.gif") {
+ $edittext = "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$fileurl&amp;action=unzip&amp;sesskey=$USER->sesskey\">$strunzip</a>&nbsp;";
+ $edittext .= "<a href=\"coursefiles.php?id=$id&amp;wdir=$wdir&amp;file=$fileurl&amp;action=listzip&amp;sesskey=$USER->sesskey\">$strlist</a> ";
+ } else {
+ $edittext = "&nbsp;";
+ }
+ print_cell("right", "$edittext ");
+ print_cell("right", $filedate);
+
+ echo "</tr>\n";
+ }
+ }
+ echo "</table>\n";
+
+ if (empty($wdir)) {
+ $wdir = "/";
+ }
+
+ echo "<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\">\n";
+ echo "<tr>\n<td>";
+ echo "<input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo "<input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo "<input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ $options = array (
+ "move" => "$strmovetoanotherfolder",
+ "delete" => "$strdeletecompletely",
+ "zip" => "$strcreateziparchive"
+ );
+ if (!empty($count)) {
+ choose_from_menu ($options, "action", "", "$strwithchosenfiles...", "javascript:document.dirform.submit()");
+ }
+ if (!empty($USER->fileop) and ($USER->fileop == "move") and ($USER->filesource <> $wdir)) {
+ echo "<form action=\"coursefiles.php\" method=\"get\">\n";
+ echo " <input type=\"hidden\" name=\"id\" value=\"$id\" />\n";
+ echo " <input type=\"hidden\" name=\"wdir\" value=\"$wdir\" />\n";
+ echo " <input type=\"hidden\" name=\"action\" value=\"paste\" />\n";
+ echo " <input type=\"hidden\" name=\"sesskey\" value=\"$USER->sesskey\" />\n";
+ echo " <input type=\"submit\" value=\"$strmovefilestohere\" />\n";
+ echo "</form>";
+ }
+ echo "</td></tr>\n";
+ echo "</table>\n";
+ echo "</form>\n";
+}
+?>
View
80 lib/editor/htmlarea/dialog.js
@@ -0,0 +1,80 @@
+// $Id$
+// Though "Dialog" looks like an object, it isn't really an object. Instead
+// it's just namespace for protecting global symbols.
+
+function Dialog(url, action, init) {
+ if (typeof init == "undefined") {
+ init = window; // pass this window object by default
+ }
+ Dialog._geckoOpenModal(url, action, init);
+};
+
+Dialog._parentEvent = function(ev) {
+ if (Dialog._modal && !Dialog._modal.closed) {
+ Dialog._modal.focus();
+ HTMLArea._stopEvent(ev);
+ }
+};
+
+// should be a function, the return handler of the currently opened dialog.
+Dialog._return = null;
+
+// constant, the currently opened dialog
+Dialog._modal = null;
+
+// the dialog will read it's args from this variable
+Dialog._arguments = null;
+
+Dialog._geckoOpenModal = function(url, action, init) {
+
+ var file = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
+ var x,y;
+ switch(file) {
+ case "insert_image": x = 730; y = 560; break;
+ case "dlg_ins_smile": x = 330; y = 320; break;
+ case "dlg_ins_char": x = 480; y = 290; break;
+ case "select_color": x = 238; y = 195; break;
+ case "insert_table": x = 420; y = 250; break;
+ case "link_std": x = 420; y = 230; break;
+ case "insert_image_std": x = 450; y = 240; break;
+ case "createanchor": x = 300; y = 140; break;
+ case "searchandreplace": x = 400; y = 250; break;
+ default: x = 50; y = 50;
+ }
+
+ var lx = (screen.width - x) / 2;
+ var tx = (screen.height - y) / 2;
+ var dlg = window.open(url, "ha_dialog", "toolbar=no,menubar=no,personalbar=no, width="+ x +",height="+ y +",scrollbars=no,resizable=no, left="+ lx +", top="+ tx +"");
+ Dialog._modal = dlg;
+ Dialog._arguments = init;
+
+ // capture some window's events
+ function capwin(w) {
+ HTMLArea._addEvent(w, "click", Dialog._parentEvent);
+ HTMLArea._addEvent(w, "mousedown", Dialog._parentEvent);
+ HTMLArea._addEvent(w, "focus", Dialog._parentEvent);
+ };
+ // release the captured events
+ function relwin(w) {
+ HTMLArea._removeEvent(w, "click", Dialog._parentEvent);
+ HTMLArea._removeEvent(w, "mousedown", Dialog._parentEvent);
+ HTMLArea._removeEvent(w, "focus", Dialog._parentEvent);
+ };
+ capwin(window);
+ // capture other frames
+ if(document.all) {
+ for (var i = 0; i < window.frames.length; capwin(window.frames[i++]));
+ }
+ // make up a function to be called when the Dialog ends.
+ Dialog._return = function (val) {
+ relwin(window);
+ // capture other frames
+ if(document.all) {
+ for (var i = 0; i < window.frames.length; relwin(window.frames[i++]));
+ }
+ if (val && action) {
+ action(val);
+ }
+ Dialog._modal = null;
+ };
+};
View
366 lib/editor/htmlarea/htmlarea.class.php
@@ -0,0 +1,366 @@
+<?php // $Id$
+
+/**
+ * This file contains the htmlarea subclass for moodle editorObject.
+ *
+ * @author Janne Mikkonen
+ * @version $Id$
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
+ * @package editorObject
+ */
+class htmlarea extends editorObject {
+
+ /**
+ * Configuration array to hold configuration data.
+ * @var array $htmlareaconf
+ */
+ var $htmlareaconf = array();
+
+ /**
+ * Configuration keys array to store possible configuration keys.
+ * @var array $htmlareaconfkeys
+ */
+ var $htmlareaconfkeys = array("width","height","statusBar","undoSteps","undoTimeout",
+ "sizeIncludesToolbar","fullPage","pageStyle","killWordOnPaste",
+ "toolbar","fontname","fontsize","formatblock","customSelects");
+
+ /**
+ * An array to store valid value types that can
+ * be passed to specific configuration key.
+ * @var array $htmlareaconfkeytypes
+ */
+ var $htmlareaconfkeytypes = array('width' => 'string', 'height' => 'string', 'statusBar' => 'bool',
+ 'undoSteps' => 'int', 'undoTimeout' => 'int',
+ 'sizeIncludeToolbar' => 'bool', 'fullPage' => 'bool',
+ 'pageStyle' => 'string', 'killWordOnPaste' => 'bool',
+ 'toolbar' => 'array', 'fontname' => 'assoc', 'fontsize' => 'assoc',
+ 'formatblock' => 'assoc', 'customSelects' => 'array');
+
+ /**
+ * Array of default configuration set via editor settings.
+ * @var array $defaults
+ */
+ var $defaults = array();
+
+ /**
+ * PHP4 style class constructor.
+ *
+ * @param int $courseid Courseid.
+ */
+ function htmlarea($courseid) {
+ parent::editorObject();
+ $this->courseid = clean_param($courseid, PARAM_INT);
+
+ $pagestyle = 'body {';
+ $pagestyle .= !empty($this->cfg->editorbackgroundcolor) ?
+ ' background-color: '. $this->cfg->editorbackgroundcolor .'; ' : '';
+ $pagestyle .= !empty($this->cfg->editorfontfamily) ?
+ ' font-family: '. $this->cfg->editorfontfamily .';' : '';
+ $pagestyle .= !empty($this->cfg->editorfontsize) ?
+ ' font-size: '. $this->cfg->editorfontsize .';' : '';
+ $pagestyle .= '}';
+
+ $this->defaults['pageStyle'] = $pagestyle;
+ $this->defaults['killWordOnPaste'] = !empty($this->cfg->editorkillword) ? true : false;
+
+ $fontlist = isset($this->cfg->editorfontlist) ? explode(';', $this->cfg->editorfontlist) : array();
+ $fonts = array();
+ foreach ( $fontlist as $fontline ) {
+ if ( !empty($fontline) ) {
+ list($fontkey, $fontvalue) = split(":", $fontline);
+ $fonts[$fontkey] = $fontvalue;
+ }
+ }
+ $this->defaults['fontname'] = $fonts;
+ $this->defaults['hideSomeButtons'] = !empty($this->cfg->editorhidebuttons) ?
+ ' '. $this->cfg->editorhidebuttons .' ' : '';
+
+ }
+
+ /**
+ * PHP5 style class constructor.
+ * @param int $courseid Course id.
+ */
+ function __construct($courseid) {
+ $this->htmlarea($courseid);
+ }
+
+ /**
+ * Check if passed configuration key is valid.
+ * @param string $key
+ * @return bool Return true if key is valid and false if it's not.
+ */
+ function __is_valid_key($key) {
+ if ( in_array($key, $this->htmlareaconfkeys) ) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Check if passed value's type is valid.
+ * @param string $key Configuration key name.
+ * @param mixed $value Configuration value.
+ * @return bool Returns true if value is valid type and false if it's not.
+ */
+ function __is_valid_value_type($key, $value) {
+
+ if ( !empty($this->htmlareaconfkeytypes[$key]) ) {
+ $keytype = $this->htmlareaconfkeytypes[$key];
+
+ switch ( $keytype ) {
+ case 'bool':
+ if ( is_bool($value) ) {
+ return true;
+ }
+ break;
+ case 'string':
+ if ( is_string($value) ) {
+ return true;
+ }
+ break;
+ case 'int':
+ if ( is_int($value) ) {
+ return true;
+ }
+ break;
+ case 'array':
+ if ( is_array($value) ) {
+ return true;
+ }
+ break;
+ case 'assoc':
+ if ( is_array($value) ) {
+ // Check first key.
+ $key = key($value);
+ if ( preg_match("/[a-z]+/i", $key) ) {
+ return true;
+ }
+ }
+ break;
+ default:
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sets configuration key and value pairs.
+ * Passed parameters can be key and value pair or
+ * an associative array of keys and values.
+ * @todo code example
+ */
+ function setconfig() {
+
+ $numargs = func_num_args();
+
+ switch ( $numargs ) {
+ case 1: // Must be an array.
+ $args = func_get_arg(0);
+ if ( !is_array($args) ) {
+ $this->error("Passed argument is not an array!!!");
+ }
+ foreach ( $args as $key => $value ) {
+ if ( !preg_match("/[a-z]+/i", $key) && !$this->__is_valid_key($key) ) {
+ $this->error("Invalid configuration key!!!");
+ }
+ if ( $this->__is_valid_value_type($key, $value) ) {
+ $this->htmlareaconf[$key] = $value;
+ } else {
+ $this->error("Invalid key, value pair!!!");
+ }
+ }
+ break;
+ case 2: // Must be key, value pair.
+ $key = func_get_arg(0);
+ $value = func_get_arg(1);
+ if ( empty($key) or !isset($value) ) {
+ $this->error("Empty key or value passed!!!");
+ }
+ if ( !preg_match("/[a-z]+/i", $key) ) {
+ $this->error("Configuration key must be a string!!");
+ }
+
+ if ( !$this->__is_valid_key($key) ) {
+ $this->error("Invalid configuration key!!!");
+ }
+
+ if ( $this->__is_valid_value_type($key, $value) ) {
+ $this->htmlareaconf[$key] = $value;
+ } else {
+ $this->error("Invalid key, value pair!!!");
+ }
+ break;
+ default:
+ if ( $numargs > 2 ) {
+ $this->error("Too many arguments!!!");
+ }
+ if ( $numargs < 1 ) {
+ $this->error("No arguments passed!!!");
+ }
+ }
+ }
+
+ /**
+ * For internal usage. Print out configuration arrays.
+ * @param string $conftype Type of configuration.
+ * @return void
+ */
+ function __printconfig($conftype='') {
+
+ $conf = NULL;
+ $assocs = array('fontname','fontsize','formatblocks');
+
+ switch( $conftype ) {
+ case 'merge': // New config overrides defaults if found.
+ $conf = array_merge($this->defaults,$this->htmlareaconf);
+ break;
+ case 'append': // Append mode leave default value if found.
+ $conf = $this->defaults;
+ $keys = array_keys($this->defaults);
+ foreach ( $this->htmlareaconf as $key => $value ) {
+ if ( in_array($key, $keys) ) {
+ continue;
+ } else {
+ $conf[$key] = $value;
+ }
+ }
+ break;
+ case 'default': // Use only default config.
+ $conf = $this->defaults;
+ break;
+ default: // Print what's in htmlareaconf.
+ $conf = $this->htmlareaconf;
+ }
+
+ echo "\n";
+ echo '<script language="javascript" type="text/javascript" defer="defer">'."\n";
+ echo '<!--'."\n";
+ echo ' var config = new HTMLArea.Config();'."\n";
+
+ foreach ( $conf as $key => $value ) {
+
+ if ( empty($value) ) {
+ continue;
+ }
+
+ echo ' config.'. $key .' = ';
+ if ( is_bool($value) ) {
+ echo $value ? "true;\n" : "false;\n";
+ } else if ( in_array($key, $assocs) ) {
+
+ echo '{'."\n";
+ $cnt = 1;
+ foreach ( $value as $key => $value ) {
+ if ( $cnt > 1 ) {
+ echo ",\n";
+ }
+ echo "\t\"$key\" : \"$value\"";
+ $cnt++;
+ }
+ echo ' };'."\n";
+
+ } else if ( $key == 'toolbar' ) {
+ // toolbar is array of arrays.
+ echo '['."\n";
+ $max = count($conf['toolbar']);
+ $cnt = 1;
+ foreach ( $conf['toolbar'] as $row ) {
+ echo "\t" . '[ ';
+ $count = count($row);
+ for ( $i = 0; $i < $count; $i++ ) {
+ if ( $i > 0 ) {
+ echo ',';
+ }
+ if ( $i != 0 && ($i % 4) == 0 ) {
+ echo "\n\t";
+ }
+ echo '"'. $row[$i] .'"';
+ }
+ if ( $cnt < $max ) {
+ echo " ],\n";
+ } else {
+ echo " ]\n";
+ }
+ $cnt++;
+ }
+ echo "\t" . '];'. "\n";
+
+ } else {
+ echo '"'. $value .'"'. "\n";
+ }
+ }
+
+ if ( !empty($this->cfg->editorspelling) && !empty($this->cfg->aspellpath) ) {
+ echo "\n";
+ $this->print_speller_code(true);
+ echo "\n";
+ }
+
+ echo ' HTMLArea.replaceAll(config);'."\n";
+ echo '// done hiding -->'."\n";
+ echo '</script>'."\n";
+
+ }
+
+ /**
+ * Print out code that start up the editor.
+ * @param string $conftype Configuration type to print.
+ */
+ function starteditor($configtype='') {
+ $this->__printconfig($configtype);
+ }
+
+ /**
+ * For backward compatibility only.
+ * @param string $name
+ * @param string $editorhidesomebuttons
+ */
+ function use_html_editor ( $name='', $editorhidebuttons='' ) {
+
+ if ( !empty($editorhidesomebuttons) ) {
+ $this->defaults['hideSomeButtons'] = $editorhidesomebuttons;
+ }
+
+ if (empty($name)) {
+ $this->starteditor('default');
+ } else {
+ $this->starteditor('default');
+ }
+
+ if ( !empty($this->cfg->editorsrc) ) {
+ unset($this->cfg->editorsrc);
+ }
+
+ }
+
+ /**
+ * Prints out needed code for spellchecking.
+ * @param bool $usehtmleditor
+ */
+ function print_speller_code ($usehtmleditor=false) {
+
+ if(!$usehtmleditor) {
+ echo "\n".'<script language="javascript" type="text/javascript">'."\n";
+ echo 'function openSpellChecker() {'."\n";
+ echo "\tvar speller = new spellChecker();\n";
+ echo "\tspeller.popUpUrl = \"" . $this->cfg->wwwroot ."/lib/speller/spellchecker.html\";\n";
+ echo "\tspeller.spellCheckScript = \"". $this->cfg->wwwroot ."/lib/speller/server-scripts/spellchecker.php\";\n";
+ echo "\tspeller.spellCheckAll();\n";
+ echo '}'."\n";
+ echo '</script>'."\n";
+ } else {
+ echo "\n\tfunction spellClickHandler(editor, buttonId) {\n";
+ echo "\t\teditor._textArea.value = editor.getHTML();\n";
+ echo "\t\tvar speller = new spellChecker( editor._textArea );\n";
+ echo "\t\tspeller.popUpUrl = \"" . $this->cfg->wwwroot ."/lib/speller/spellchecker.html\";\n";
+ echo "\t\tspeller.spellCheckScript = \"". $this->cfg->wwwroot ."/lib/speller/server-scripts/spellchecker.php\";\n";
+ echo "\t\tspeller._moogle_edit=1;\n";
+ echo "\t\tspeller._editor=editor;\n";
+ echo "\t\tspeller.openChecker();\n\t";
+ echo '}'."\n";
+ }
+ }
+
+}
+?>
View
180 lib/editor/htmlarea/htmlarea.css
@@ -0,0 +1,180 @@
+.htmlarea { background: #fff; }
+
+.htmlarea .toolbar {
+ cursor: default;
+ background: ButtonFace;
+ padding: 1px 1px 2px 1px;
+ border: 1px solid;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+.htmlarea .toolbar table { font-family: tahoma,verdana,sans-serif; font-size: 11px; }
+.htmlarea .toolbar img { border: none; }
+.htmlarea .toolbar .label { padding: 0px 3px; }
+
+.htmlarea .toolbar .button {
+ background: ButtonFace;
+ color: ButtonText;
+ border: 1px solid ButtonFace;
+ padding: 1px;
+ margin: 0px;
+}
+.htmlarea .toolbar .buttonHover {
+ border: 1px solid;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+.htmlarea .toolbar .buttonActive, .htmlarea .toolbar .buttonPressed {
+ padding: 2px 0px 0px 2px;
+ border: 1px solid;
+ border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
+}
+.htmlarea .toolbar .buttonPressed {
+ background: ButtonHighlight;
+}
+.htmlarea .toolbar .indicator {
+ padding: 0px 3px;
+ overflow: hidden;
+ width: 20px;
+ text-align: center;
+ cursor: default;
+ border: 1px solid ButtonShadow;
+}
+
+.htmlarea .toolbar .buttonDisabled { background-color: #aaa; }
+
+.htmlarea .toolbar .buttonDisabled img {
+ filter: alpha(opacity = 25);
+ -moz-opacity: 25%;
+}
+
+.htmlarea .toolbar .separator {
+ position: relative;
+ margin: 3px;
+ border-left: 1px solid ButtonShadow;
+ border-right: 1px solid ButtonHighlight;
+ width: 0px;
+ height: 16px;
+ padding: 0px;
+}
+
+.htmlarea .toolbar .space { width: 5px; }
+
+.htmlarea .toolbar select { font: 11px Tahoma,Verdana,sans-serif; }
+
+.htmlarea .toolbar select,
+.htmlarea .toolbar select:hover,
+.htmlarea .toolbar select:active { background: FieldFace; color: ButtonText; }
+
+.htmlarea .statusBar {
+ border: 1px solid;
+ border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
+ padding: 2px 4px;
+ background-color: ButtonFace;
+ color: ButtonText;
+ font: 11px Tahoma,Verdana,sans-serif;
+}
+
+.htmlarea .statusBar .statusBarTree a {
+ padding: 2px 5px;
+ color: #00f;
+}
+
+.htmlarea .statusBar .statusBarTree a:visited { color: #00f; }
+.htmlarea .statusBar .statusBarTree a:hover {
+ background-color: Highlight;
+ color: HighlightText;
+ padding: 1px 4px;
+ border: 1px solid HighlightText;
+}
+
+
+/* Hidden DIV popup dialogs (PopupDiv) */
+
+.dialog {
+ color: ButtonText;
+ background: ButtonFace;
+}
+
+.dialog .content { padding: 2px; }
+
+.dialog, .dialog button, .dialog input, .dialog select, .dialog textarea, .dialog table {
+ font: 11px Tahoma,Verdana,sans-serif;
+}
+
+.dialog table { border-collapse: collapse; }
+
+.dialog .title {
+ background: #008;
+ color: #ff8;
+ border-bottom: 1px solid #000;
+ padding: 1px 0px 2px 5px;
+ font-size: 12px;
+ font-weight: bold;
+ cursor: default;
+}
+
+.dialog .title .button {
+ float: right;
+ border: 1px solid #66a;
+ padding: 0px 1px 0px 2px;
+ margin-right: 1px;
+ color: #fff;
+ text-align: center;
+}
+
+.dialog .title .button-hilite { border-color: #88f; background: #44c; }
+
+.dialog button {
+ width: 5em;
+ padding: 0px;
+}
+
+.dialog .buttonColor {
+ padding: 1px;
+ cursor: default;
+ border: 1px solid;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+
+.dialog .buttonColor-hilite {
+ border-color: #000;
+}
+
+.dialog .buttonColor .chooser, .dialog .buttonColor .nocolor {
+ height: 0.6em;
+ border: 1px solid;
+ padding: 0px 1em;
+ border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
+}
+
+.dialog .buttonColor .nocolor { padding: 0px; }
+.dialog .buttonColor .nocolor-hilite { background-color: #fff; color: #f00; }
+
+.dialog .label { text-align: right; width: 6em; }
+.dialog .value input { width: 100%; }
+.dialog .buttons { text-align: right; padding: 2px 4px 0px 4px; }
+
+.dialog legend { font-weight: bold; }
+.dialog fieldset table { margin: 2px 0px; }
+
+.popupdiv {
+ border: 2px solid;
+ border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
+}
+
+.popupwin {
+ padding: 0px;
+ margin: 0px;
+}
+
+.popupwin .title {
+ background: #fff;
+ color: #000;
+ font-weight: bold;
+ font-size: 120%;
+ padding: 3px 10px;
+ margin-bottom: 10px;
+ border-bottom: 1px solid black;
+ letter-spacing: 2px;
+}
+
+form { margin: 0px; border: none; }
View
2,517 lib/editor/htmlarea/htmlarea.php
@@ -0,0 +1,2517 @@
+<?php
+ include("../../../config.php");
+
+ $id = optional_param('id', 0, PARAM_INT);
+
+ $lastmodified = filemtime("htmlarea.php");
+ $lifetime = 1800;
+
+ // Commenting this out since it's creating problems
+ // where solution seem to be hard to find...
+ // http://moodle.org/mod/forum/discuss.php?d=34376
+ //if ( function_exists('ob_gzhandler') ) {
+ // ob_start("ob_gzhandler");
+ //}
+
+ $charset = get_string('thischarset');
+ header("Content-type: application/x-javascript; charset: $charset"); // Correct MIME type
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");
+ header("Cache-control: max_age = $lifetime");
+ header("Pragma: ");
+
+ $lang = current_language();
+
+ if (empty($lang)) {
+ $lang = "en";
+ }
+
+ $strheading = get_string("heading", "editor");
+ $strnormal = get_string("normal", "editor");
+ $straddress = get_string("address", "editor");
+ $strpreformatted = get_string("preformatted", "editor");
+?>
+
+// htmlArea v3.0 - Copyright (c) 2002, 2003 interactivetools.com, inc.
+// This copyright notice MUST stay intact for use (see license.txt).
+//
+// Portions (c) dynarch.com, 2003-2004
+//
+// A free WYSIWYG editor replacement for <textarea> fields.
+// For full source code and docs, visit http://www.interactivetools.com/
+//
+// Version 3.0 developed by Mihai Bazon.
+// http://dynarch.com/mishoo
+//
+// $Id$
+
+if (typeof _editor_url == "string") {
+ // Leave exactly one backslash at the end of _editor_url
+ _editor_url = _editor_url.replace(/\x2f*$/, '/');
+} else {
+ //alert("WARNING: _editor_url is not set! You should set this variable to the editor files path; it should preferably be an absolute path, like in '/htmlarea', but it can be relative if you prefer. Further we will try to load the editor files correctly but we'll probably fail.");
+ _editor_url = '<?php print ($CFG->wwwroot); ?>/lib/editor/htmlarea/';
+}
+
+// make sure we have a language
+if (typeof _editor_lang == "string") {
+ _editor_lang = "en"; // should always be english in moodle.
+} else {
+ _editor_lang = "en";
+}
+
+// Creates a new HTMLArea object. Tries to replace the textarea with the given
+// ID with it.
+function HTMLArea(textarea, config) {
+ if (HTMLArea.checkSupportedBrowser()) {
+ if (typeof config == "undefined") {
+ this.config = new HTMLArea.Config();
+ } else {
+ this.config = config;
+ }
+ this._htmlArea = null;
+ this._textArea = textarea;
+ this._editMode = "wysiwyg";
+ this.plugins = {};
+ this._timerToolbar = null;
+ this._timerUndo = null;
+ this._undoQueue = new Array(this.config.undoSteps);
+ this._undoPos = -1;
+ this._customUndo = true;
+ this._mdoc = document; // cache the document, we need it in plugins
+ this.doctype = '';
+ }
+};
+
+// load some scripts
+(function() {
+ var scripts = HTMLArea._scripts = [ _editor_url + "htmlarea.js",
+ _editor_url + "dialog.js",
+ _editor_url + "popupwin.js",
+ _editor_url + "lang/" + _editor_lang + ".js" ];
+ var head = document.getElementsByTagName("head")[0];
+ // start from 1, htmlarea.js is already loaded
+ for (var i = 1; i < scripts.length; ++i) {
+ var script = document.createElement("script");
+ script.src = scripts[i];
+ head.appendChild(script);
+ }
+})();
+
+// cache some regexps
+HTMLArea.RE_tagName = /(<\/|<)\s*([^ \t\n>]+)/ig;
+HTMLArea.RE_doctype = /(<!doctype((.|\n)*?)>)\n?/i;
+HTMLArea.RE_head = /<head>((.|\n)*?)<\/head>/i;
+HTMLArea.RE_body = /<body>((.|\n)*?)<\/body>/i;
+
+HTMLArea.Config = function () {
+ this.version = "3.0";
+
+ this.width = "auto";
+ this.height = "auto";
+
+ // enable creation of a status bar?
+ this.statusBar = true;
+
+ // maximum size of the undo queue
+ this.undoSteps = 20;
+
+ // the time interval at which undo samples are taken
+ this.undoTimeout = 500; // 1/2 sec.
+
+ // the next parameter specifies whether the toolbar should be included
+ // in the size or not.
+ this.sizeIncludesToolbar = true;
+
+ // if true then HTMLArea will retrieve the full HTML, starting with the
+ // <HTML> tag.
+ this.fullPage = false;
+
+ // style included in the iframe document
+ this.pageStyle = "body { background-color: #fff; font-family: 'Times New Roman', Times; }";
+
+ // set to true if you want Word code to be cleaned upon Paste
+ this.killWordOnPaste = true;
+
+ // BaseURL included in the iframe document
+ this.baseURL = document.baseURI || document.URL;
+ if (this.baseURL && this.baseURL.match(/(.*)\/([^\/]+)/))
+ this.baseURL = RegExp.$1 + "/";
+
+ // URL-s
+ this.imgURL = "images/";
+ this.popupURL = "popups/";
+
+ this.toolbar = [
+ [ "fontname", "space",
+ "fontsize", "space",
+ "formatblock", "space",
+ "bold", "italic", "underline", "strikethrough", "separator",
+ "subscript", "superscript", "separator",
+ "copy", "cut", "paste","clean", "separator", "undo", "redo" ],
+
+ [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
+ "lefttoright", "righttoleft", "separator",
+ "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",
+ "forecolor", "hilitecolor", "separator",
+ "inserthorizontalrule", "createanchor", "createlink", "unlink", "nolink", "separator",
+ "insertimage", "inserttable",
+ "insertsmile", "insertchar", "search_replace",
+ <?php if (!empty($CFG->aspellpath) && file_exists($CFG->aspellpath) && !empty($CFG->editorspelling)) {
+ echo '"separator","spellcheck",';
+ } ?>
+ "separator", "htmlmode", "separator", "popupeditor"]
+ ];
+
+ this.fontname = {
+ "Arial": 'arial,helvetica,sans-serif',
+ "Courier New": 'courier new,courier,monospace',
+ "Georgia": 'georgia,times new roman,times,serif',
+ "Tahoma": 'tahoma,arial,helvetica,sans-serif',
+ "Times New Roman": 'times new roman,times,serif',
+ "Verdana": 'verdana,arial,helvetica,sans-serif',
+ "Impact": 'impact',
+ "WingDings": 'wingdings'
+ };
+
+ this.fontsize = {
+ "1 (8 pt)": "1",
+ "2 (10 pt)": "2",
+ "3 (12 pt)": "3",
+ "4 (14 pt)": "4",
+ "5 (18 pt)": "5",
+ "6 (24 pt)": "6",
+ "7 (36 pt)": "7"
+ };
+
+ this.formatblock = {
+ "":"",
+ "<?php echo $strheading ?> 1": "h1",
+ "<?php echo $strheading ?> 2": "h2",
+ "<?php echo $strheading ?> 3": "h3",
+ "<?php echo $strheading ?> 4": "h4",
+ "<?php echo $strheading ?> 5": "h5",
+ "<?php echo $strheading ?> 6": "h6",
+ "<?php echo $strnormal ?>": "p",
+ "<?php echo $straddress ?>": "address",
+ "<?php echo $strpreformatted ?>": "pre"
+ };
+
+ this.customSelects = {};
+
+ function cut_copy_paste(e, cmd, obj) {
+ e.execCommand(cmd);
+ };
+
+ this.btnList = {
+ bold: [ "Bold", "ed_format_bold.gif", false, function(e) {e.execCommand("bold");} ],
+ italic: [ "Italic", "ed_format_italic.gif", false, function(e) {e.execCommand("italic");} ],
+ underline: [ "Underline", "ed_format_underline.gif", false, function(e) {e.execCommand("underline");} ],
+ strikethrough: [ "Strikethrough", "ed_format_strike.gif", false, function(e) {e.execCommand("strikethrough");} ],
+ subscript: [ "Subscript", "ed_format_sub.gif", false, function(e) {e.execCommand("subscript");} ],
+ superscript: [ "Superscript", "ed_format_sup.gif", false, function(e) {e.execCommand("superscript");} ],
+ justifyleft: [ "Justify Left", "ed_align_left.gif", false, function(e) {e.execCommand("justifyleft");} ],
+ justifycenter: [ "Justify Center", "ed_align_center.gif", false, function(e) {e.execCommand("justifycenter");} ],
+ justifyright: [ "Justify Right", "ed_align_right.gif", false, function(e) {e.execCommand("justifyright");} ],
+ justifyfull: [ "Justify Full", "ed_align_justify.gif", false, function(e) {e.execCommand("justifyfull");} ],
+ insertorderedlist: [ "Ordered List", "ed_list_num.gif", false, function(e) {e.execCommand("insertorderedlist");} ],
+ insertunorderedlist: [ "Bulleted List", "ed_list_bullet.gif", false, function(e) {e.execCommand("insertunorderedlist");} ],
+ outdent: [ "Decrease Indent", "ed_indent_less.gif", false, function(e) {e.execCommand("outdent");} ],
+ indent: [ "Increase Indent", "ed_indent_more.gif", false, function(e) {e.execCommand("indent");} ],
+ forecolor: [ "Font Color", "ed_color_fg.gif", false, function(e) {e.execCommand("forecolor");} ],
+ hilitecolor: [ "Background Color", "ed_color_bg.gif", false, function(e) {e.execCommand("hilitecolor");} ],
+ inserthorizontalrule: [ "Horizontal Rule", "ed_hr.gif", false, function(e) {e.execCommand("inserthorizontalrule");} ],
+ createanchor: [ "Create anchor", "ed_anchor.gif", false, function(e) {e.execCommand("createanchor", true);} ],
+ createlink: [ "Insert Web Link", "ed_link.gif", false, function(e) {e.execCommand("createlink", true);} ],
+ unlink: [ "Remove Link", "ed_unlink.gif", false, function(e) {e.execCommand("unlink");} ],
+ nolink: [ "No link", "ed_nolink.gif", false, function(e) {e.execCommand("nolink");} ],
+ insertimage: [ "Insert/Modify Image", "ed_image.gif", false, function(e) {e.execCommand("insertimage");} ],
+ inserttable: [ "Insert Table", "insert_table.gif", false, function(e) {e.execCommand("inserttable");} ],
+ htmlmode: [ "Toggle HTML Source", "ed_html.gif", true, function(e) {e.execCommand("htmlmode");} ],
+ popupeditor: [ "Enlarge Editor", "fullscreen_maximize.gif", true, function(e) {e.execCommand("popupeditor");} ],
+ about: [ "About this editor", "ed_about.gif", true, function(e) {e.execCommand("about");} ],
+ showhelp: [ "Help using editor", "ed_help.gif", true, function(e) {e.execCommand("showhelp");} ],
+ undo: [ "Undoes your last action", "ed_undo.gif", false, function(e) {e.execCommand("undo");} ],
+ redo: [ "Redoes your last action", "ed_redo.gif", false, function(e) {e.execCommand("redo");} ],
+ cut: [ "Cut selection", "ed_cut.gif", false, cut_copy_paste ],
+ copy: [ "Copy selection", "ed_copy.gif", false, cut_copy_paste ],
+ paste: [ "Paste from clipboard", "ed_paste.gif", false, cut_copy_paste ],
+ clean: [ "Clean Word HTML", "ed_wordclean.gif", false, function(e) {e.execCommand("killword"); }],
+ lefttoright: [ "Direction left to right", "ed_left_to_right.gif", false, function(e) {e.execCommand("lefttoright");} ],
+ righttoleft: [ "Direction right to left", "ed_right_to_left.gif", false, function(e) {e.execCommand("righttoleft");} ],
+ <?php if (!empty($CFG->aspellpath) && file_exists($CFG->aspellpath) && !empty($CFG->editorspelling)) {
+ echo 'spellcheck: ["Spell-check", "spell-check.gif", false, spellClickHandler ],'."\n";
+ }?>
+ insertsmile: ["Insert Smiley", "em.icon.smile.gif", false, function(e) {e.execCommand("insertsmile");} ],
+ insertchar: [ "Insert Char", "icon_ins_char.gif", false, function(e) {e.execCommand("insertchar");} ],
+ search_replace: [ "Search and replace", "ed_replace.gif", false, function(e) {e.execCommand("searchandreplace");} ]
+ };
+
+ // initialize tooltips from the I18N module and generate correct image path
+ for (var i in this.btnList) {
+ var btn = this.btnList[i];
+ btn[1] = _editor_url + this.imgURL + btn[1];
+ if (typeof HTMLArea.I18N.tooltips[i] != "undefined") {
+ btn[0] = HTMLArea.I18N.tooltips[i];
+ }
+ }
+};
+
+HTMLArea.Config.prototype.registerButton = function(id, tooltip, image, textMode, action, context) {
+ var the_id;
+ if (typeof id == "string") {
+ the_id = id;
+ } else if (typeof id == "object") {
+ the_id = id.id;
+ } else {
+ alert("ERROR [HTMLArea.Config::registerButton]:\ninvalid arguments");
+ return false;
+ }
+ // check for existing id
+ if (typeof this.customSelects[the_id] != "undefined") {
+ // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA dropdown with the same ID already exists.");
+ }
+ if (typeof this.btnList[the_id] != "undefined") {
+ // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA button with the same ID already exists.");
+ }
+ switch (typeof id) {
+ case "string": this.btnList[id] = [ tooltip, image, textMode, action, context ]; break;
+ case "object": this.btnList[id.id] = [ id.tooltip, id.image, id.textMode, id.action, id.context ]; break;
+ }
+};
+
+HTMLArea.Config.prototype.registerDropdown = function(object) {
+ // check for existing id
+ if (typeof this.customSelects[object.id] != "undefined") {
+ // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA dropdown with the same ID already exists.");
+ }
+ if (typeof this.btnList[object.id] != "undefined") {
+ // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA button with the same ID already exists.");
+ }
+ this.customSelects[object.id] = object;
+};
+
+HTMLArea.Config.prototype.hideSomeButtons = function(remove) {
+ var toolbar = this.toolbar;
+ for (var i in toolbar) {
+ var line = toolbar[i];
+ for (var j = line.length; --j >= 0; ) {
+ if (remove.indexOf(" " + line[j] + " ") >= 0) {
+ var len = 1;
+ if (/separator|space/.test(line[j + 1])) {
+ len = 2;
+ }
+ line.splice(j, len);
+ }
+ }
+ }
+};
+
+/** Helper function: replace all TEXTAREA-s in the document with HTMLArea-s. */
+HTMLArea.replaceAll = function(config) {
+ var tas = document.getElementsByTagName("textarea");
+ for (var i = tas.length; i > 0; (new HTMLArea(tas[--i], config)).generate());
+};
+
+/** Helper function: replaces the TEXTAREA with the given ID with HTMLArea. */
+HTMLArea.replace = function(id, config) {
+ var ta = HTMLArea.getElementById("textarea", id);
+ return ta ? (new HTMLArea(ta, config)).generate() : null;
+};
+
+// Creates the toolbar and appends it to the _htmlarea
+HTMLArea.prototype._createToolbar = function () {
+ var editor = this; // to access this in nested functions
+
+ var toolbar = document.createElement("div");
+ this._toolbar = toolbar;
+ toolbar.className = "toolbar";
+ toolbar.unselectable = "1";
+ var tb_row = null;
+ var tb_objects = new Object();
+ this._toolbarObjects = tb_objects;
+
+ // creates a new line in the toolbar
+ function newLine() {
+ var table = document.createElement("table");
+ table.border = "0px";
+ table.cellSpacing = "0px";
+ table.cellPadding = "0px";
+ toolbar.appendChild(table);
+ // TBODY is required for IE, otherwise you don't see anything
+ // in the TABLE.
+ var tb_body = document.createElement("tbody");
+ table.appendChild(tb_body);
+ tb_row = document.createElement("tr");
+ tb_body.appendChild(tb_row);
+ }; // END of function: newLine
+ // init first line
+ newLine();
+
+ function setButtonStatus(id, newval) {
+ var oldval = this[id];
+ var el = this.element;
+ if (oldval != newval) {
+ switch (id) {
+ case "enabled":
+ if (newval) {
+ HTMLArea._removeClass(el, "buttonDisabled");
+ el.disabled = false;
+ } else {
+ HTMLArea._addClass(el, "buttonDisabled");
+ el.disabled = true;
+ }
+ break;
+ case "active":
+ if (newval) {
+ HTMLArea._addClass(el, "buttonPressed");
+ } else {
+ HTMLArea._removeClass(el, "buttonPressed");
+ }
+ break;
+ }
+ this[id] = newval;
+ }
+ }; // END of function: setButtonStatus
+
+ function createSelect(txt) {
+ var options = null;
+ var el = null;
+ var cmd = null;
+ var customSelects = editor.config.customSelects;
+ var context = null;
+ switch (txt) {
+ case "fontsize":
+ case "fontname":
+ case "formatblock":
+ options = editor.config[txt];
+ cmd = txt;
+ break;
+ default:
+ // try to fetch it from the list of registered selects
+ cmd = txt;
+ var dropdown = customSelects[cmd];
+ if (typeof dropdown != "undefined") {
+ options = dropdown.options;
+ context = dropdown.context;
+ } else {
+ alert("ERROR [createSelect]:\nCan't find the requested dropdown definition");
+ }
+ break;
+ }
+ if (options) {
+ el = document.createElement("select");
+ var obj = {
+ name : txt, // field name
+ element : el, // the UI element (SELECT)
+ enabled : true, // is it enabled?
+ text : false, // enabled in text mode?
+ cmd : cmd, // command ID
+ state : setButtonStatus, // for changing state
+ context : context
+ };
+ tb_objects[txt] = obj;
+ for (var i in options) {
+ var op = document.createElement("option");
+ op.appendChild(document.createTextNode(i));
+ op.value = options[i];
+ el.appendChild(op);
+ }
+ HTMLArea._addEvent(el, "change", function () {
+