]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-19211, MDL-19544 improved editor embedding, media and dragmath enabled only when...
authorskodak <skodak>
Sat, 20 Jun 2009 11:00:40 +0000 (11:00 +0000)
committerskodak <skodak>
Sat, 20 Jun 2009 11:00:40 +0000 (11:00 +0000)
lib/adminlib.php
lib/editor/textarea/lib.php
lib/editor/tinymce/extra/tinymce.js.php [deleted file]
lib/editor/tinymce/extra/tinymce_utils.js [new file with mode: 0644]
lib/editor/tinymce/lib.php
lib/editorlib.php
lib/form/editor.php
lib/weblib.php
mod/data/templates.php

index 75a74a2d99349a4b9002e77d75cea786c22b946d..66715c581de66e950f81dea74ac588ba4ab587e8 100644 (file)
@@ -1595,11 +1595,10 @@ class admin_setting_confightmleditor extends admin_setting_configtext {
         }
 
         $editor = get_preferred_texteditor(FORMAT_HTML);
-        $editorclass = $editor->get_legacy_textarea_class();
-        $editor->use_editor($this->get_id());
+        $editor->use_editor($this->get_id(), array('noclean'=>true));
 
         return format_admin_setting($this, $this->visiblename,
-                '<div class="form-textarea"><textarea class="'.$editorclass.'" rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
+                '<div class="form-textarea"><textarea rows="'. $this->rows .'" cols="'. $this->cols .'" id="'. $this->get_id() .'" name="'. $this->get_full_name() .'">'. s($data) .'</textarea></div>',
                 $this->description, true, '', $defaultinfo, $query);
     }
 }
index d6400e92ef70b903cb689ce93e7bf57cafb697ed..1258d5fc887c6cf309f52240b2827e148d451b33 100644 (file)
@@ -45,17 +45,9 @@ class textarea_texteditor extends texteditor {
         return true;
     }
 
-    public function get_editor_element_class() {
-        return 'form-textarea-simple';
-    }
-    
-    public function get_legacy_textarea_class() {
-        return 'form-textarea-legacy';
-    }
-
-    public function use_editor($elementid=null) {
+    public function use_editor($elementid, array $options=null) {
         return;
-    }    
+    }
 }
 
 
diff --git a/lib/editor/tinymce/extra/tinymce.js.php b/lib/editor/tinymce/extra/tinymce.js.php
deleted file mode 100644 (file)
index a244098..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-<?php
-
-// This file is part of Moodle - http://moodle.org/
-//
-// Moodle is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Moodle is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
-
-/**
- * On-the-fly conversion of Moodle lang strings to TinyMCE expected JS format.
- *
- * @package    moodlecore
- * @subpackage editor
- * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
- * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-define('NO_MOODLE_COOKIES', true);
-define('NO_UPGRADE_CHECK', true);
-
-require_once('../../../../config.php');
-
-$lang     = optional_param('elanguage', 'en_utf8', PARAM_SAFEDIR);
-$theme    = optional_param('etheme', 'standard', PARAM_SAFEDIR);
-$usehttps = optional_param('eusehttps', 0, PARAM_BOOL);
-
-if (file_exists("$CFG->dataroot/lang/$lang") or file_exists("$CFG->dirroot/lang/$lang")) {
-    $SESSION->lang = $lang;
-} else if (file_exists("$CFG->dataroot/lang/{$lang}_utf8") or file_exists("$CFG->dirroot/lang/{$lang}_utf8")) {
-    $SESSION->lang = $lang.'_utf8';
-}
-
-$xmlruleset = file_get_contents('xhtml_ruleset.txt');
-
-$directionality = get_string('thisdirection');
-
-$strtime = get_string('strftimetime');
-$strdate = get_string('strftimedaydate');
-
-$lang = str_replace('_utf8', '', $lang); // use more standard language codes
-
-if ($usehttps) {
-    $wwwbase = str_replace('http:', 'https:', $CFG->wwwroot);
-} else {
-    $wwwbase = $CFG->wwwroot;
-}
-
-// $contentcss should be customizable
-$contentcss = "$CFG->themewww/$theme/styles.php";
-
-//TODO: reimplement spellchecker support - the TinyMCE one is hardcoded for linux, has encoding problems, etc.
-
-$output = <<<EOF
-function mc_init_editors() {
-    tinyMCE.init({
-        mode: "textareas",
-        relative_urls: false,
-        editor_selector: "form-tinymce-legacy",
-        document_base_url: "$wwwbase",
-        content_css: "$contentcss",
-        language: "$lang",
-        directionality: "$directionality",
-        plugin_insertdate_dateFormat : "$strdate",
-        plugin_insertdate_timeFormat : "$strtime",
-        theme: "advanced",
-        skin: "o2k7",
-        skin_variant: "silver",
-        apply_source_formatting: true,
-        remove_script_host: false,
-        entity_encoding: "raw",
-        plugins: "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,media,searchreplace,paste,directionality,fullscreen,moodlenolink,dragmath,nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
-        theme_advanced_font_sizes: "1,2,3,4,5,6,7",
-        theme_advanced_layout_manager: "SimpleLayout",
-        theme_advanced_toolbar_align : "left",
-        theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,styleselect",
-        theme_advanced_buttons1_add: "|,undo,redo,|,search,replace,|,fullscreen",
-        theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym",
-        theme_advanced_buttons2_add: "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
-        theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,dragmath,advhr,nonbreaking,charmap",
-        theme_advanced_buttons3_add: "|,table,insertlayer,styleprops,visualchars,|,code,preview",
-        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",
-        theme_advanced_resize_horizontal: true,
-        theme_advanced_resizing: true,
-        theme_advanced_toolbar_location : "top",
-        theme_advanced_statusbar_location : "bottom",
-        $xmlruleset
-    });
-
-    tinyMCE.init({
-        mode: "textareas",
-        relative_urls: false,
-        editor_selector: "form-tinymce-advanced",
-        document_base_url: "$wwwbase",
-        content_css: "$contentcss",
-        language: "$lang",
-        directionality: "$directionality",
-        plugin_insertdate_dateFormat : "$strdate",
-        plugin_insertdate_timeFormat : "$strtime",
-        theme: "advanced",
-        skin: "o2k7",
-        skin_variant: "silver",
-        apply_source_formatting: true,
-        remove_script_host: false,
-        entity_encoding: "raw",
-        plugins: "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,media,searchreplace,paste,directionality,fullscreen,moodlenolink,dragmath,nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
-        theme_advanced_font_sizes: "1,2,3,4,5,6,7",
-        theme_advanced_layout_manager: "SimpleLayout",
-        theme_advanced_toolbar_align : "left",
-        theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,styleselect",
-        theme_advanced_buttons1_add: "|,undo,redo,|,search,replace,|,fullscreen",
-        theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym",
-        theme_advanced_buttons2_add: "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
-        theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,media,dragmath,advhr,nonbreaking,charmap",
-        theme_advanced_buttons3_add: "|,table,insertlayer,styleprops,visualchars,|,code,preview",
-        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",
-        theme_advanced_resize_horizontal: true,
-        theme_advanced_resizing: true,
-        theme_advanced_toolbar_location : "top",
-        theme_advanced_statusbar_location : "bottom",
-        file_browser_callback : "mce_moodlefilemanager",
-        $xmlruleset
-    });
-}
-
-function mce_toggleEditor(id) {
-    tinyMCE.execCommand('mceToggleEditor',false,id);
-}
-
-function mce_saveOnSubmit(id) {
-    var prevOnSubmit = document.getElementById(id).form.onsubmit;
-    document.getElementById(id).form.onsubmit = function() {
-        tinyMCE.triggerSave();
-        var ret = true;
-        if (prevOnSubmit != undefined) {
-          if (prevOnSubmit()) {
-            ret = true;
-            prevOnSubmit = null;
-          } else {
-            ret = false;
-          }
-        }
-        return ret;
-    };
-}
-
-function mce_moodlefilemanager(field_name, url, type, win) {
-    var client_id = id2clientid[tinyMCE.selectedInstance.editorId];
-    var picker = document.createElement('DIV');
-    picker.className = "file-picker";
-    picker.id = 'file-picker-'+client_id;
-    document.body.appendChild(picker);
-    var el = win.document.getElementById(field_name);
-    eval('open_filepicker(client_id, {"env":"editor","target":el,"filetype":type})');
-}
-
-// finally init editors
-mc_init_editors();
-
-EOF;
-
-
-$lifetime = '10'; // TODO: increase later
-header('Content-type: text/javascript; charset=utf-8');
-header('Content-length: '.strlen($output));
-header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
-header('Cache-control: max-age='.$lifetime);
-header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .'GMT');
-header('Pragma: ');
-
-echo $output;
diff --git a/lib/editor/tinymce/extra/tinymce_utils.js b/lib/editor/tinymce/extra/tinymce_utils.js
new file mode 100644 (file)
index 0000000..c73ca82
--- /dev/null
@@ -0,0 +1,58 @@
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * TinyMCE helper javascript functions
+ *
+ * @package    moodlecore
+ * @subpackage editor
+ * @copyright  1999 onwards Martin Dougiamas (http://dougiamas.com)
+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+function mce_init_editor(elementid, params) {
+       tinyMCE.init(params);
+}
+
+function mce_toggleEditor(id) {
+    tinyMCE.execCommand('mceToggleEditor',false,id);
+}
+
+function mce_saveOnSubmit(id) {
+    var prevOnSubmit = document.getElementById(id).form.onsubmit;
+    document.getElementById(id).form.onsubmit = function() {
+        tinyMCE.triggerSave();
+        var ret = true;
+        if (prevOnSubmit != undefined) {
+          if (prevOnSubmit()) {
+            ret = true;
+            prevOnSubmit = null;
+          } else {
+            ret = false;
+          }
+        }
+        return ret;
+    };
+}
+
+function mce_moodlefilemanager(field_name, url, type, win) {
+    var client_id = id2clientid[tinyMCE.selectedInstance.editorId];
+    var picker = document.createElement('DIV');
+    picker.className = "file-picker";
+    picker.id = 'file-picker-'+client_id;
+    document.body.appendChild(picker);
+    var el = win.document.getElementById(field_name);
+    eval('open_filepicker(client_id, {"env":"editor","target":el,"filetype":type})');
+}
index 3e2ef835b91c84802b20fd33b80630a5d73aceda..2d66a6a5f15844b8fa4dc5ef89796ca1fc47d99a 100644 (file)
@@ -35,7 +35,7 @@ class tinymce_texteditor extends texteditor {
         } else if (check_browser_version('Opera', 9)) {
             return true;
         }
-        
+
         return true;
     }
 
@@ -51,22 +51,85 @@ class tinymce_texteditor extends texteditor {
         return true;
     }
 
-    public function get_editor_element_class() {
-        return 'form-tinymce-advanced';
-    }
-    
-    public function get_legacy_textarea_class() {
-        return 'form-tinymce-legacy';
+    public function use_editor($elementid, array $options=null) {
+        global $CFG, $PAGE;
+
+        $PAGE->requires->js('/lib/editor/tinymce/tiny_mce_src.js');
+        $PAGE->requires->js('/lib/editor/tinymce/extra/tinymce_utils.js');
+        $PAGE->requires->js_function_call('mce_init_editor', array($elementid, $this->get_init_params($elementid, $options)));
     }
 
-    public function use_editor($elementid=null) {
+    protected function get_init_params($elementid, array $options=null) {
         global $CFG, $PAGE;
-        $usehttps = (int)($CFG->httpswwwroot !== $CFG->wwwroot); //hmm, is there a better test?
 
-        //TODO: requirements manager does not support parameters :-(
+        //TODO: we need to implement user preferences that affec tthe editor setup too
+
+        //TODO: reimplement rulesets, maybe it would be better to implement it some other way
+        //$xmlruleset     = file_get_contents('extra/xhtml_ruleset.txt');
+
+        $directionality = get_string('thisdirection');
+        $strtime        = get_string('strftimetime');
+        $strdate        = get_string('strftimedaydate');
+        $lang           = str_replace('_utf8', '', current_language());     // use more standard language codes
+        $contentcss     = $CFG->themewww.'/'.current_theme().'/styles.php'; // should be customizable
+
+        $context = empty($options['context']) ? get_context_instance(CONTEXT_SYSTEM) : $options['context'];
+        if (!empty($options['legacy'])) {
+            $xmedia = '';
+        } else {
+            if (!empty($options['noclean']) or !empty($options['trusted'])) {
+                $xmedia = 'media,';
+            } else {
+                $xmedia = '';
+            }
+        }
+
+        $filters = filter_get_active_in_context($context);
+        if (array_key_exists('filter/tex', $filters)) {
+            $xdragmath = 'dragmath,';
+        } else {
+            $xdragmath = '';
+        }
+
+        $params = array(
+                    'mode' => "exact",
+                    'elements' => $elementid,
+                    'relative_urls' => false,
+                    'document_base_url' => $CFG->httpswwwroot,
+                    'content_css' => $contentcss,
+                    'language' => $lang,
+                    'directionality' => $directionality,
+                    'plugin_insertdate_dateFormat ' => $strdate,
+                    'plugin_insertdate_timeFormat ' => $strtime,
+                    'theme' => "advanced",
+                    'skin' => "o2k7",
+                    'skin_variant' => "silver",
+                    'apply_source_formatting' => true,
+                    'remove_script_host' => false,
+                    'entity_encoding' => "raw",
+                    'plugins' => "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,{$xmedia}searchreplace,paste,directionality,fullscreen,moodlenolink,{$xdragmath}nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
+                    'theme_advanced_font_sizes' => "1,2,3,4,5,6,7",
+                    'theme_advanced_layout_manager' => "SimpleLayout",
+                    'theme_advanced_toolbar_align' => "left",
+                    'theme_advanced_buttons1' => "fontselect,fontsizeselect,formatselect,styleselect",
+                    'theme_advanced_buttons1_add' => "|,undo,redo,|,search,replace,|,fullscreen",
+                    'theme_advanced_buttons2' => "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym",
+                    'theme_advanced_buttons2_add' => "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
+                    'theme_advanced_buttons3' => "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,{$xmedia}{$xdragmath}advhr,nonbreaking,charmap",
+                    'theme_advanced_buttons3_add' => "|,table,insertlayer,styleprops,visualchars,|,code,preview",
+                    '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",
+                    'theme_advanced_resize_horizontal' => true,
+                    'theme_advanced_resizing' => true,
+                    'theme_advanced_toolbar_location' => "top",
+                    'theme_advanced_statusbar_location' => "bottom",
+                  );
+
+        if (empty($options['legacy'])) {
+            if (isset($options['maxfiles']) and $options['maxfiles'] != 0) {
+                $params['file_browser_callback'] = "mce_moodlefilemanager";
+            }
+        }
 
-        $PAGE->requires->js($CFG->httpswwwroot.'/lib/editor/tinymce/tiny_mce_src.js', true);
-        $PAGE->requires->js($CFG->httpswwwroot.'/lib/editor/tinymce/extra/tinymce.js.php?elanguage='.current_language().'&amp;etheme='.current_theme().'&amp;eusehttps='.$usehttps, true);
+        return $params;
     }
-    
-}
\ No newline at end of file
+}
index f42ed7eb5a252902dca06956a31a0644b798b188..cb629f48c1a15749b336457b2314298cf6a8ecb7 100644 (file)
@@ -143,23 +143,13 @@ abstract class texteditor {
      */
     public abstract function supports_repositories();
 
-    /**
-     * Returns textarea class in formslib editor element
-     * @return string
-     */
-    public abstract function get_editor_element_class();
-
-    /**
-     * Returns textarea class for legacy text editor
-     * @return string
-     */
-    public abstract function get_legacy_textarea_class();
-
     /**
      * Add required JS needed for editor
+     * @param string $elementid id of text area to be converted to editor
+     * @param array $options
      * @return void
      */
-    public abstract function use_editor($elementid=null);
+    public abstract function use_editor($elementid, array $options=null);
 }
 
 
index 72a7e2b65a2db8e8b74b37f8f376d6a64943318e..9de29d3988a4d5fa06ccf9d65349adecf3356922 100644 (file)
@@ -6,11 +6,11 @@ require_once('HTML/QuickForm/element.php');
 //  * locking
 //  * freezing
 //  * ajax format conversion
-//  * better area files handling
 
 class MoodleQuickForm_editor extends HTML_QuickForm_element {
     protected $_helpbutton = '';
-    protected $_options    = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>0, 'changeformat'=>0);
+    protected $_options    = array('subdirs'=>0, 'maxbytes'=>0, 'maxfiles'=>0, 'changeformat'=>0,
+                                   'context'=>null, 'noclean'=>0, 'trusttext'=>0);
     protected $_values     = array('text'=>null, 'format'=>null, 'itemid'=>null);
 
     function MoodleQuickForm_editor($elementName=null, $elementLabel=null, $attributes=null, $options=null) {
@@ -25,6 +25,9 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
         if (!empty($options['maxbytes'])) {
             $this->_options['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $options['maxbytes']);
         }
+        if (!$this->_options['context']) {
+            $this->_options['context'] = get_context_instance(CONTEXT_SYSTEM);
+        }
         parent::HTML_QuickForm_element($elementName, $elementLabel, $attributes);
     }
 
@@ -136,10 +139,10 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
         }
 
     /// print text area - TODO: add on-the-fly switching, size configuration, etc.
-        $editorclass = $editor->get_editor_element_class();
-        $editor->use_editor($id);
+        $editor->use_editor($id, $this->_options);
+        $ctx = $this->_options['context'];
 
-        $str .= '<div><textarea class="'.$editorclass.'" id="'.$id.'" name="'.$elname.'[text]" rows="15" cols="80">';
+        $str .= '<div><textarea id="'.$id.'" name="'.$elname.'[text]" rows="15" cols="80">';
         $str .= s($text);
         $str .= '</textarea></div>';
 
@@ -160,12 +163,6 @@ class MoodleQuickForm_editor extends HTML_QuickForm_element {
                 $draftitemid = $this->_values['itemid'];
             }
             $str .= '<div><input type="hidden" name="'.$elname.'[itemid]" value="'.$draftitemid.'" /></div>';
-
-            if (empty($COURSE->context)) {
-                $ctx = get_context_instance(CONTEXT_SYSTEM);
-            } else {
-                $ctx = $COURSE->context;
-            }
         /// embedded image files - TODO: hide on the fly when switching editors
             $str .= '<div id="'.$id.'_filemanager">';
             $editorurl = "$CFG->wwwroot/repository/filepicker.php?action=embedded&amp;itemid=$draftitemid&amp;subdirs=$subdirs&amp;maxbytes=$maxbytes&amp;ctx_id=".$ctx->id;
index 424a0b5826e11023044cdb5dc553f9bf6f16f026..43671abff25ee3ff10da4031f34e1a68d95d71d4 100644 (file)
@@ -4962,13 +4962,12 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
 
     if ($usehtmleditor) {
         $editor = get_preferred_texteditor(FORMAT_HTML);
-        $editorclass = $editor->get_legacy_textarea_class();
-        $editor->use_editor($id);
+        $editor->use_editor($id, array('legacy'=>true));
     } else {
         $editorclass = '';
     }
 
-    $str .= "\n".'<textarea class="form-textarea '.$editorclass.'" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
+    $str .= "\n".'<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
     if ($usehtmleditor) {
         $str .= htmlspecialchars($value); // needed for editing of cleaned text!
     } else {
index c7a8d2ffee0d2cfb0e6778c394dce8083b8c6b0a..afe0945d2cd07403dc554fa96154ec7ae7b689a4 100755 (executable)
 /// Processing submitted data, i.e updating form.
     $resettemplate = false;
 
-/// html editor is by default disabled
-    $editor = isset($SESSION->data_use_editor) ? $SESSION->data_use_editor : (can_use_html_editor() ? 1 : 0);
-
     if (($mytemplate = data_submitted()) && confirm_sesskey()) {
         $newtemplate->id = $data->id;
         $newtemplate->{$mode} = $mytemplate->template;
 
-        if (!empty($mytemplate->switcheditor)) {
-            $editor = $editor ? 0 : 1;
-            $SESSION->data_use_editor = $editor;
-        } else if (!empty($mytemplate->defaultform)) {
+        if (!empty($mytemplate->defaultform)) {
             // Reset the template to default, but don't save yet.
             $resettemplate = true;
             $data->{$mode} = data_generate_default_template($data, $mode, 0, false, false);