From 07f8fecad53e56513d3943f6a09f0def945e841f Mon Sep 17 00:00:00 2001 From: scyrma Date: Wed, 2 Jul 2008 06:11:55 +0000 Subject: [PATCH] MDL-14739: some minor modifications to allow per-editor customization, and changing ("dos2unix") the format of some files. --- lib/editor/htmlEditor.class.php | 190 ++++++------ lib/editor/tinymce.js.php | 424 +++++++++++++-------------- lib/editor/tinymce/messages.php | 366 +++++++++++------------ lib/editor/tinymce/staff.php | 140 ++++----- lib/editor/tinymce/student.php | 106 +++---- lib/editor/tinymce/xhtml_ruleset.txt | 180 ++++++------ 6 files changed, 703 insertions(+), 703 deletions(-) diff --git a/lib/editor/htmlEditor.class.php b/lib/editor/htmlEditor.class.php index 385277005f..fe40d6ecd8 100644 --- a/lib/editor/htmlEditor.class.php +++ b/lib/editor/htmlEditor.class.php @@ -1,95 +1,95 @@ -htmleditor) { - return; - } - - if ($editor == '') { - $editor = (isset($CFG->defaulthtmleditor) ? $CFG->defaulthtmleditor : ''); - } - - $configuration = ''; - - switch ($editor) { - - case 'tinymce': - if (!isset($configured['tinymce'])) { - $configuration = << - -EOF; - $configured['tinymce'] = true; - } - break; - - case 'fckeditor': - $configuration = << - -EOF; - break; - - - case 'xinha': - $configuration = << - _editor_url = "{$CFG->wwwroot}/lib/editor/xinha/" - _editor_lang = "en"; - _editor_skin = "blue-look"; - - - -EOF; - break; - - case 'yuirte': - $configuration = << - - - - - - - - - - - - - - - -EOF; - break; - - default: - break; - - } - - return $configuration; - - } -} - -?> +htmleditor) or (!$CFG->htmleditor)) { + return; + } + + if ($editor == '') { + $editor = (isset($CFG->defaulthtmleditor) ? $CFG->defaulthtmleditor : ''); + } + + $configuration = ''; + + switch ($editor) { + + case 'tinymce': + if (!isset($configured['tinymce'])) { + $configuration = << + +EOF; + $configured['tinymce'] = true; + } + break; + + case 'fckeditor': + $configuration = << + +EOF; + break; + + + case 'xinha': + $configuration = << + _editor_url = "{$CFG->wwwroot}/lib/editor/xinha/" + _editor_lang = "en"; + _editor_skin = "blue-look"; + + + +EOF; + break; + + case 'yuirte': + $configuration = << + + + + + + + + + + + + + + + +EOF; + break; + + default: + break; + + } + + return $configuration; + + } +} + +?> diff --git a/lib/editor/tinymce.js.php b/lib/editor/tinymce.js.php index 4221831ceb..cee21428e7 100644 --- a/lib/editor/tinymce.js.php +++ b/lib/editor/tinymce.js.php @@ -1,212 +1,212 @@ -editorhidebuttons); - -$editorhidebuttons1 = $editorhidebuttons . ',visualaid,styleselect'; - -$editorhidebuttons = 'theme_advanced_disable : "'.$editorhidebuttons1.'",'; - -$editorhidebuttons = str_replace('fontsize', 'fontsizeselect', $editorhidebuttons); -$editorhidebuttons = str_replace('subscript', 'sub', $editorhidebuttons); -$editorhidebuttons = str_replace('superscript', 'sup', $editorhidebuttons); -$editorhidebuttons = str_replace('insertorderedlist', 'numlist', $editorhidebuttons); -$editorhidebuttons = str_replace('insertunorderedlist', 'bullist', $editorhidebuttons); -$editorhidebuttons = str_replace('createanchor', 'anchor', $editorhidebuttons); -$editorhidebuttons = str_replace('createlink', 'link', $editorhidebuttons); -$editorhidebuttons = str_replace('htmlmode', 'code', $editorhidebuttons); -$editorhidebuttons = str_replace('insertchar', 'charmap', $editorhidebuttons); -$editorhidebuttons = str_replace('insertimage', 'image', $editorhidebuttons); -$editorhidebuttons = str_replace('inserthorizontalrule', 'hr', $editorhidebuttons); -$editorhidebuttons = str_replace('formatblock', 'formatselect', $editorhidebuttons); -$editorhidebuttons = str_replace('clean', 'cleanup,removeformat', $editorhidebuttons); - -// insertsmile, - -$pieces = explode(",", $editorhidebuttons1); - -$spellcheck = ''; -if (! in_array("spellcheck", $pieces)) { - $spellcheck = 'spellchecker,'; -} -$inserttable = ''; -if (! in_array("inserttable", $pieces)) { - $inserttable = 'tablecontrols,separator,'; -} -$search_replace = ''; -if (! in_array("search_replace", $pieces)) { - $search_replace = 'search,replace,separator,'; -} -$lefttoright = ''; -if (! in_array("lefttoright", $pieces)) { - $lefttoright = 'ltr,separator,'; -} -$righttoleft = ''; -if (! in_array("righttoleft", $pieces)) { - $righttoleft = 'rtl,separator,'; -} -$cleanup = ''; -if (! in_array("cleanup", $pieces)) { - $cleanup = 'cleanup,removeformat,separator,'; -} -$fontselect = ''; -if (! in_array("fontname", $pieces)) { - $fontselect = 'fontselect,'; -} -$fontsize = ''; -if (! in_array("fontsize", $pieces)) { - $fontsize = 'fontsizeselect,'; -} -$forecolor = ''; -if (! in_array("forecolor", $pieces)) { - $forecolor = 'forecolor,'; -} -$hilitecolor = ''; -if (! in_array("hilitecolor", $pieces)) { - $hilitecolor = 'backcolor,'; -} -$popupeditor = ''; -if (! in_array("popupeditor", $pieces)) { - $popupeditor = 'fullscreen,'; -} - -$editoraddbuttons3 = 'theme_advanced_buttons3_add : "'.$fontselect.$fontsize.$forecolor.$hilitecolor.'",'; -$editoraddbuttons4 = 'theme_advanced_buttons4 : "'.$spellcheck.$search_replace.$inserttable.$lefttoright.$righttoleft.$popupeditor.$cleanup.'",'; - -/* - * - * ******************************************************************************************************** - * - */ - - -$temp = $_SERVER["REQUEST_URI"]; -$temp = explode('/', $temp); -$root = $temp[1]; - -$configuration = <<httpswwwroot", - theme: "simple", - skin: "o2k7", - apply_source_formatting: true, - remove_script_host: false, - entity_encoding: "raw", - language: "en", - plugins: "spellchecker,emoticons,paste,standardmenu,directionality" - }); - tinyMCE.init({ - mode: "textareas", - relative_urls: false, - editor_selector: "form-textarea-advanced", - document_base_url: "$CFG->httpswwwroot", - theme: "advanced", - skin: "o2k7", - apply_source_formatting: true, - remove_script_host: false, - entity_encoding: "raw", - language: "en", - plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking", - theme_advanced_layout_manager: "SimpleLayout", - theme_advanced_toolbar_align : "left", - theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,", - theme_advanced_buttons1_add: "styleselect,selectall,pastetext,pasteword,cleanup", - theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,undo,redo,removeformat,code", - theme_advanced_buttons2_add: "styleprops,ltr,rtl,nonbreaking,charmap", - theme_advanced_buttons3: "media,advhr,emoticons,dragmath,spellchecker,search,code,fullscreen,bullist,numlist,outdent,indent,forecolor,backcolor,link,unlink,anchor,image,charmap,insertlayer,table", - theme_advanced_buttons3_add: "media,emoticons,charmap,dragmath,search,code,fullscreen", - theme_advanced_fonts: "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;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", - moodleimage_course_id: $COURSE->id, - theme_advanced_resize_horizontal: true, - theme_advanced_resizing: true, - theme_advanced_toolbar_location : "top", - theme_advanced_statusbar_location : "bottom", - file_browser_callback : "moodlefilemanager", - -EOF; -// the xhtml ruleset must be the last one - no comma at the end of the file -readfile('tinymce/xhtml_ruleset.txt'); -echo <<httpswwwroot}/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id={$COURSE->id}", - width: 480, - height: 380, - resizable: "yes", - inline: "yes", - close_previous: "no" - }, { - window: win, - input: field_name - }); - return false; - } -EOF; -?> +tinymcehidebuttons); + +$editorhidebuttons1 = $editorhidebuttons . ',visualaid,styleselect'; + +$editorhidebuttons = 'theme_advanced_disable : "'.$editorhidebuttons1.'",'; + +$editorhidebuttons = str_replace('fontsize', 'fontsizeselect', $editorhidebuttons); +$editorhidebuttons = str_replace('subscript', 'sub', $editorhidebuttons); +$editorhidebuttons = str_replace('superscript', 'sup', $editorhidebuttons); +$editorhidebuttons = str_replace('insertorderedlist', 'numlist', $editorhidebuttons); +$editorhidebuttons = str_replace('insertunorderedlist', 'bullist', $editorhidebuttons); +$editorhidebuttons = str_replace('createanchor', 'anchor', $editorhidebuttons); +$editorhidebuttons = str_replace('createlink', 'link', $editorhidebuttons); +$editorhidebuttons = str_replace('htmlmode', 'code', $editorhidebuttons); +$editorhidebuttons = str_replace('insertchar', 'charmap', $editorhidebuttons); +$editorhidebuttons = str_replace('insertimage', 'image', $editorhidebuttons); +$editorhidebuttons = str_replace('inserthorizontalrule', 'hr', $editorhidebuttons); +$editorhidebuttons = str_replace('formatblock', 'formatselect', $editorhidebuttons); +$editorhidebuttons = str_replace('clean', 'cleanup,removeformat', $editorhidebuttons); + +// insertsmile, + +$pieces = explode(",", $editorhidebuttons1); + +$spellcheck = ''; +if (! in_array("spellcheck", $pieces)) { + $spellcheck = 'spellchecker,'; +} +$inserttable = ''; +if (! in_array("inserttable", $pieces)) { + $inserttable = 'tablecontrols,separator,'; +} +$search_replace = ''; +if (! in_array("search_replace", $pieces)) { + $search_replace = 'search,replace,separator,'; +} +$lefttoright = ''; +if (! in_array("lefttoright", $pieces)) { + $lefttoright = 'ltr,separator,'; +} +$righttoleft = ''; +if (! in_array("righttoleft", $pieces)) { + $righttoleft = 'rtl,separator,'; +} +$cleanup = ''; +if (! in_array("cleanup", $pieces)) { + $cleanup = 'cleanup,removeformat,separator,'; +} +$fontselect = ''; +if (! in_array("fontname", $pieces)) { + $fontselect = 'fontselect,'; +} +$fontsize = ''; +if (! in_array("fontsize", $pieces)) { + $fontsize = 'fontsizeselect,'; +} +$forecolor = ''; +if (! in_array("forecolor", $pieces)) { + $forecolor = 'forecolor,'; +} +$hilitecolor = ''; +if (! in_array("hilitecolor", $pieces)) { + $hilitecolor = 'backcolor,'; +} +$popupeditor = ''; +if (! in_array("popupeditor", $pieces)) { + $popupeditor = 'fullscreen,'; +} + +$editoraddbuttons3 = 'theme_advanced_buttons3_add : "'.$fontselect.$fontsize.$forecolor.$hilitecolor.'",'; +$editoraddbuttons4 = 'theme_advanced_buttons4 : "'.$spellcheck.$search_replace.$inserttable.$lefttoright.$righttoleft.$popupeditor.$cleanup.'",'; + +/* + * + * ******************************************************************************************************** + * + */ + + +$temp = $_SERVER["REQUEST_URI"]; +$temp = explode('/', $temp); +$root = $temp[1]; + +$configuration = <<httpswwwroot", + theme: "simple", + skin: "o2k7", + apply_source_formatting: true, + remove_script_host: false, + entity_encoding: "raw", + language: "en", + plugins: "spellchecker,emoticons,paste,standardmenu,directionality" + }); + tinyMCE.init({ + mode: "textareas", + relative_urls: false, + editor_selector: "form-textarea-advanced", + document_base_url: "$CFG->httpswwwroot", + theme: "advanced", + skin: "o2k7", + apply_source_formatting: true, + remove_script_host: false, + entity_encoding: "raw", + language: "en", + plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking", + theme_advanced_layout_manager: "SimpleLayout", + theme_advanced_toolbar_align : "left", + theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,", + theme_advanced_buttons1_add: "styleselect,selectall,pastetext,pasteword,cleanup", + theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,undo,redo,removeformat,code", + theme_advanced_buttons2_add: "styleprops,ltr,rtl,nonbreaking,charmap", + theme_advanced_buttons3: "media,advhr,emoticons,dragmath,spellchecker,search,code,fullscreen,bullist,numlist,outdent,indent,forecolor,backcolor,link,unlink,anchor,image,charmap,insertlayer,table", + theme_advanced_buttons3_add: "media,emoticons,charmap,dragmath,search,code,fullscreen", + theme_advanced_fonts: "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;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", + moodleimage_course_id: $COURSE->id, + theme_advanced_resize_horizontal: true, + theme_advanced_resizing: true, + theme_advanced_toolbar_location : "top", + theme_advanced_statusbar_location : "bottom", + file_browser_callback : "moodlefilemanager", + +EOF; +// the xhtml ruleset must be the last one - no comma at the end of the file +readfile('tinymce/xhtml_ruleset.txt'); +echo <<httpswwwroot}/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id={$COURSE->id}", + width: 480, + height: 380, + resizable: "yes", + inline: "yes", + close_previous: "no" + }, { + window: win, + input: field_name + }); + return false; + } +EOF; +?> diff --git a/lib/editor/tinymce/messages.php b/lib/editor/tinymce/messages.php index 6f8621ee32..f4406280fd 100644 --- a/lib/editor/tinymce/messages.php +++ b/lib/editor/tinymce/messages.php @@ -1,183 +1,183 @@ -editorbackgroundcolor))) { - $str .= " background-color: $CFG->editorbackgroundcolor;"; - } - - if (!(empty($CFG->editorfontfamily))) { - $str .= " font-family: $CFG->editorfontfamily;"; - } - - if (!(empty($CFG->editorfontsize))) { - $str .= " font-size: $CFG->editorfontsize;"; - } - - $str .= " }\";\n"; - $str .= "config.killWordOnPaste = "; - $str .= (empty($CFG->editorkillword)) ? "false":"true"; - $str .= ';'."\n"; - $str .= 'config.fontname = {'."\n"; - - $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array(); - $i = 1; // Counter is used to get rid of the last comma. - - foreach ($fontlist as $fontline) { - if (!empty($fontline)) { - if ($i > 1) { - $str .= ','."\n"; - } - list($fontkey, $fontvalue) = split(':', $fontline); - $str .= '"'. $fontkey ."\":\t'". $fontvalue ."'"; - - $i++; - } - } - $str .= '};'; - - if (!empty($editorhidebuttons)) { - $str .= "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n"; - } else if (!empty($CFG->editorhidebuttons)) { - $str .= "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n"; - } - - if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) { - $str .= print_speller_code($CFG->htmleditor, true); - } - - if ($return) { - return $str; - } - echo $str; -} - -function use_html_editor($name='', $editorhidebuttons='', $id='') { -} - -function use_admin_editor($name='', $editorhidebuttons='', $id='') { - echo ''; -} - -function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') { - global $CFG, $COURSE, $HTTPSPAGEREQUIRED; - $str = ''; - if ($id === '') { - $id = 'edit-'.$name; - } - if (empty($courseid)) { - $courseid = $COURSE->id; - } - if ($usehtmleditor) { - $str .= '
'."\n"; - $toggle_ed = ''; - $str .= "".$toggle_ed." "; - $str .= ''; - } else { - $str .= ''."\n"; - } - if ($return) { - return $str; - } - echo $str; -} -?> - - +editorbackgroundcolor))) { + $str .= " background-color: $CFG->editorbackgroundcolor;"; + } + + if (!(empty($CFG->editorfontfamily))) { + $str .= " font-family: $CFG->editorfontfamily;"; + } + + if (!(empty($CFG->editorfontsize))) { + $str .= " font-size: $CFG->editorfontsize;"; + } + + $str .= " }\";\n"; + $str .= "config.killWordOnPaste = "; + $str .= (empty($CFG->editorkillword)) ? "false":"true"; + $str .= ';'."\n"; + $str .= 'config.fontname = {'."\n"; + + $fontlist = isset($CFG->editorfontlist) ? explode(';', $CFG->editorfontlist) : array(); + $i = 1; // Counter is used to get rid of the last comma. + + foreach ($fontlist as $fontline) { + if (!empty($fontline)) { + if ($i > 1) { + $str .= ','."\n"; + } + list($fontkey, $fontvalue) = split(':', $fontline); + $str .= '"'. $fontkey ."\":\t'". $fontvalue ."'"; + + $i++; + } + } + $str .= '};'; + + if (!empty($editorhidebuttons)) { + $str .= "\nconfig.hideSomeButtons(\" ". $editorhidebuttons ." \");\n"; + } else if (!empty($CFG->editorhidebuttons)) { + $str .= "\nconfig.hideSomeButtons(\" ". $CFG->editorhidebuttons ." \");\n"; + } + + if (!empty($CFG->editorspelling) && !empty($CFG->aspellpath)) { + $str .= print_speller_code($CFG->htmleditor, true); + } + + if ($return) { + return $str; + } + echo $str; +} + +function use_html_editor($name='', $editorhidebuttons='', $id='') { +} + +function use_admin_editor($name='', $editorhidebuttons='', $id='') { + echo ''; +} + +function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') { + global $CFG, $COURSE, $HTTPSPAGEREQUIRED; + $str = ''; + if ($id === '') { + $id = 'edit-'.$name; + } + if (empty($courseid)) { + $courseid = $COURSE->id; + } + if ($usehtmleditor) { + $str .= '
'."\n"; + $toggle_ed = ''; + $str .= "".$toggle_ed." "; + $str .= ''; + } else { + $str .= ''."\n"; + } + if ($return) { + return $str; + } + echo $str; +} +?> + + diff --git a/lib/editor/tinymce/staff.php b/lib/editor/tinymce/staff.php index 8b6fe0800d..cf1436c4c3 100644 --- a/lib/editor/tinymce/staff.php +++ b/lib/editor/tinymce/staff.php @@ -1,70 +1,70 @@ - + diff --git a/lib/editor/tinymce/student.php b/lib/editor/tinymce/student.php index d207fa6fe2..04f6c299a8 100644 --- a/lib/editor/tinymce/student.php +++ b/lib/editor/tinymce/student.php @@ -1,53 +1,53 @@ - + diff --git a/lib/editor/tinymce/xhtml_ruleset.txt b/lib/editor/tinymce/xhtml_ruleset.txt index 840d215237..c3fbfb9cfe 100644 --- a/lib/editor/tinymce/xhtml_ruleset.txt +++ b/lib/editor/tinymce/xhtml_ruleset.txt @@ -1,90 +1,90 @@ - valid_elements : "" - +"a[accesskey|charset|class|coords|dir