]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14741
authorscyrma <scyrma>
Wed, 11 Jun 2008 08:32:46 +0000 (08:32 +0000)
committerscyrma <scyrma>
Wed, 11 Jun 2008 08:32:46 +0000 (08:32 +0000)
 * enables the full xhtml ruleset by default
 * creates two distinct configuration sets (simple and advanced)
 * makes the editor work on IE and Safari
 * the administrator-specified buttons have been disabled (will be re-enabled later)

lib/editor/htmlEditor.class.php
lib/editor/tinymce.js.php

index 40a6709d34e535de35901684a89e64e616035bd4..1466301199a41f876ca0d700cdc2a1a35fac7c12 100644 (file)
@@ -17,6 +17,7 @@ class htmlEditor {
     public function configure($editor = NULL) {\r
 \r
         global $CFG;\r
+        static $configured = Array();\r
 \r
         if ($editor == '') {\r
             $editor = (isset($CFG->defaulthtmleditor) ? $CFG->defaulthtmleditor : '');\r
@@ -27,10 +28,13 @@ class htmlEditor {
         switch ($editor) {\r
 \r
             case 'tinymce':\r
-                $configuration = <<<EOF\r
+                if (!isset($configured['tinymce'])) {\r
+                    $configuration = <<<EOF\r
 <script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>\r
 <script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/tinymce.js.php"></script>\r
 EOF;\r
+                    $configured['tinymce'] = true;\r
+                }\r
                 break;\r
 \r
             case 'fckeditor':\r
@@ -82,19 +86,6 @@ EOF;
         return $configuration;\r
 \r
     }\r
-\r
-    public function activateEditor($name='', $id='') {\r
-\r
-        $configuration = <<<EOF\r
-<script type="text/javascript">\r
-createHTMLArea('$id');\r
-</script>\r
-EOF;\r
-\r
-        return $configuration;\r
-\r
-    }\r
-\r
 }\r
 \r
 ?>\r
index cdb4f4b1d94a83331009bec9764c64da61bd37c3..19355b82b95f49be5373ee2715e9427de27d173a 100644 (file)
@@ -101,7 +101,7 @@ $configuration = <<<EOF
 \r
 function createHTMLArea(id) {\r
 \r
-    random       = Math.ceil(1000*Math.random())\r
+    random       = Math.ceil(1000*Math.random());\r
     editor       = 'editor'+random;\r
     editorsubmit = 'editorsubmit'+random;\r
 \r
@@ -111,7 +111,6 @@ function createHTMLArea(id) {
         theme    : "advanced",\r
 \r
         plugins : "safari,spellchecker,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,pagebreak,imagemanager,filemanager",\r
-\r
         spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv",\r
 \r
         plugin_insertdate_dateFormat : "%Y-%m-%d",\r
@@ -120,7 +119,7 @@ function createHTMLArea(id) {
         content_css : "/$root/lib/editor/tinymce/examples/css/content.css",\r
 \r
         theme_advanced_toolbar_location : "top",\r
-        theme_advanced_toolbar_align : "left",\r
+        theme_advanced_toolbar_align : "top",\r
         theme_advanced_statusbar_location : "bottom",\r
 \r
         theme_advanced_resize_horizontal : true,\r
@@ -133,14 +132,64 @@ function createHTMLArea(id) {
 \r
     });\r
 \r
-    script = "document.getElementById(id).form."+editorsubmit+" = document.getElementById(id).form.onsubmit;";\r
-    script = script + "document.getElementById(id).form.onsubmit = function() { tinyMCE.triggerSave(); document.getElementById(id).form."+editorsubmit+"(); document.getElementById(id).form."+editorsubmit+" = null;}";\r
+    script = "document.getElementById("+id+").form."+editorsubmit+" = document.getElementById("+id+").form.onsubmit;";\r
+    script = script + "document.getElementById("+id+").form.onsubmit = function() { tinyMCE.triggerSave(); document.getElementById("+id+").form."+editorsubmit+"(); document.getElementById("+id+").form."+editorsubmit+" = null;}";\r
     eval(script);\r
 \r
 }\r
 \r
 EOF;\r
 \r
-echo $configuration;\r
+echo <<<EOF\r
+    tinyMCE.init({\r
+        mode: "textareas",\r
+        relative_urls: false,\r
+        editor_selector: "form-textarea-simple",\r
+        document_base_url: "$CFG->httpswwwroot",\r
+        theme: "simple",\r
+        skin: "o2k7",\r
+        apply_source_formatting: true, \r
+        remove_script_host: false,\r
+        entity_encoding: "raw",\r
+        language: "en",\r
+        plugins: "spellchecker,emoticons,paste,standardmenu,directionality"\r
+    });\r
+    tinyMCE.init({\r
+        mode: "textareas",\r
+        relative_urls: false,\r
+        editor_selector: "form-textarea-advanced",\r
+        document_base_url: "$CFG->httpswwwroot",\r
+        theme: "advanced",\r
+        skin: "o2k7",\r
+        apply_source_formatting: true, \r
+        remove_script_host: false,\r
+        entity_encoding: "raw",\r
+        language: "en",\r
+        plugins: "safari,spellchecker,table,style,layer,advhr,advimage,advlink,emoticons,inlinepopups,media,searchreplace,paste,standardmenu,directionality,fullscreen,moodleimage,moodlelink,dragmath,nonbreaking",\r
+        theme_standard_buttons1: "fontselect,fontsiizeselect,formatselect,|",\r
+        theme_standard_buttons1_add: "styleselect,selectall,pastetext,pasteword,insertlayer",\r
+        theme_standard_buttons2: "bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,sub,sup,undo,redo,cleanup,removeformat,code,|",\r
+        theme_standard_buttons2_add: "styleprops,ltr,rtl,table,nonbreaking,media,advhr,emoticons,charmap,dragmath,spellchecker,search,code,fullscreen",\r
+        theme_standard_buttons3: "bullist,numlist,outdent,indent,forecolor,backcolor,link,unlink,anchor,image,charmap,|",\r
+        theme_standard_buttons3_add: "media,emotions,emoticons,charmap,dragmath,spellchecker,search,code,fullscreen",\r
+        theme_standard_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", \r
+        moodleimage_course_id: $COURSE->id,\r
+        theme_advanced_resize_horizontal: true,\r
+        theme_advanced_resizing: true,\r
+        theme_advanced_toolbar_location : "top",\r
+        theme_advanced_statusbar_location : "bottom",\r
 \r
+EOF;\r
+// the xhtml ruleset must be the last one - no comma at the end of the file\r
+readfile('tinymce/xhtml_ruleset.txt');\r
+echo <<<EOF\r
+    });\r
+    function toggleEditor(id) {\r
+        var elm = document.getElementById(id);\r
+        if (tinyMCE.getInstanceById(id) == null)\r
+                   tinyMCE.execCommand('mceAddControl', false, id);\r
+           else\r
+                   tinyMCE.execCommand('mceRemoveControl', false, id);\r
+    }\r
+EOF;\r
 ?>\r