]> git.mjollnir.org Git - moodle.git/commitdiff
Textarea field now uses functions use_html_editor() and print_editor_config()
authorvyshane <vyshane>
Wed, 15 Mar 2006 03:11:25 +0000 (03:11 +0000)
committervyshane <vyshane>
Wed, 15 Mar 2006 03:11:25 +0000 (03:11 +0000)
form /lib/weblib.php. It's been decided that the minimum requirements for the
database module will be 1.5.3+ stable. Will commit updates to the above two
functions to 1.5.3+ stable once they have been tested on stable.

mod/data/field/textarea/field.class.php

index 70ff0e0fe7fd69b3bce769ed44c9adab24629885..114daf31ee961f9694e52367a4275f65ba1f6668 100755 (executable)
@@ -128,7 +128,7 @@ class data_field_textarea extends data_field_base {
             $scriptcount++;
         }
 
-        $output .= '<textarea id="' . $name .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
+        $output .= '<textarea id="edit-' . $name .'" name="edit-'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
         
         if ($usehtmleditor) {
             $output .= htmlspecialchars(stripslashes_safe($value)); // needed for editing of cleaned text!
@@ -144,106 +144,16 @@ class data_field_textarea extends data_field_base {
     
     function print_after_form() {
         if (can_use_richtext_editor()) {
-            $this->use_html_editor('field_' . $this->id);
+            use_html_editor('field_' . $this->id);
         }
     }
     
     
-    /**
-     * Sets up the HTML editor on textareas in the current page.
-     * If a field name is provided, then it will only be
-     * applied to that field - otherwise it will be used
-     * on every textarea in the page.
-     *
-     * For Moodle 1.6, this is nearly exactly the same as
-     * use_html_editor() in /lib/weblib.php. For Moodle 1.5, this
-     * function is different to that in /lib/weblib.php. The
-     * reason is because we need the database module to be
-     * compatible with 1.5.
-     *
-     * @param string $name Form element to replace with HTMl editor by name
-     */
-    function use_html_editor($name='', $editorhidebuttons='') {
-        echo '<script language="javascript" type="text/javascript" defer="defer">'."\n";
-        echo "editor = new HTMLArea('$name');\n";
-
-        echo $this->print_editor_config($editorhidebuttons);
-
-        if (empty($name)) {
-            echo "\n".'HTMLArea.replaceAll(editor.config);'."\n";
-        } else {
-            echo "\neditor.generate();\n";
-        }
-        echo '</script>'."\n";
-    }
-    
-    
-    /**
-     * Versioning issue same as above.
-     */
-     function print_editor_config($editorhidebuttons='', $return=false) {
-         global $CFG;
-
-         $str = "var config = editor.config;\n";
-         $str .= "config.pageStyle = \"body {";
-
-         if (!(empty($CFG->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($usehtmleditor=true, true);
-         }
-
-         if ($return) {
-             return $str;
-         }
-         echo $str;
-     }
-    
-    
-
     function display_edit_field($id, $mode=0) {
         parent::display_edit_field($id, $mode);
     }
         
-
+    
     function update($fieldobject) {
         $fieldobject->param1 = trim($fieldobject->param1);
         $fieldobject->param2 = trim($fieldobject->param2);