]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14741: Simplifies the activation of the htmleditor. This is a work-in-progress...
authorscyrma <scyrma>
Wed, 11 Jun 2008 08:37:26 +0000 (08:37 +0000)
committerscyrma <scyrma>
Wed, 11 Jun 2008 08:37:26 +0000 (08:37 +0000)
lib/adminlib.php
lib/form/htmleditor.php
lib/weblib.php

index ba6c92ab6fc38e25ad867b6768c1d594f70aa1bd..6c4d2f7ba3489d41b2e7b664c28ff623f16037c9 100644 (file)
@@ -1768,7 +1768,7 @@ class admin_setting_configtextarea extends admin_setting_configtext {
         } 
 
         return format_admin_setting($this, $this->visiblename,
-                '<div class="form-textarea" ><textarea rows="'.$this->rows.'" cols="'.$this->cols.'" id="'.$this->get_id().'" name="'.$this->get_full_name().'">'.s($data).'</textarea></div>',
+                '<div class="form-textarea form-textarea-advanced" ><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);
     }
 }
@@ -2633,11 +2633,7 @@ class admin_setting_special_frontpagedesc extends admin_setting {
         global $CFG, $htmlEditorObject;
 
         $CFG->adminusehtmleditor = can_use_html_editor();
-        $return = '<div class="form-htmlarea">'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary');
-        if ($CFG->adminusehtmleditor && !is_null($htmlEditorObject)) {
-            $return .= $htmlEditorObject->activateEditor($this->get_full_name, 'summary');
-        }
-        $return .= '</div>';
+        $return = '<div class="form-htmlarea">'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary') .'</div>';
 
         return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query);
     }
index 8eb68debdc00b02e5d4cb689f64e20b246982927..a0b5b6f4c2b6ccc2bc6f52ac00eb72aeff25f9f7 100644 (file)
@@ -60,12 +60,13 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
     }
 
     function toHtml(){
-        if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
-            global $htmlEditorObject;
-            $script = $htmlEditorObject->activateEditor($this->getName(), $this->getAttribute('id'));
-        } else {
-            $script='';
-        }
+        //if ($this->_canUseHtmlEditor && !$this->_flagFrozen){
+            //global $htmlEditorObject;
+            //$script = $htmlEditorObject->activateEditor($this->getName(), $this->getAttribute('id'));
+        //    $script = '';
+        //} else {
+        //    $script='';
+        //}
         if ($this->_flagFrozen) {
             return $this->getFrozenHtml();
         } else {
@@ -79,7 +80,7 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{
                                     preg_replace("/(\r\n|\n|\r)/", '&#010;',$this->getValue()),
                                     $this->_options['course'],
                                     true,
-                                    $this->getAttribute('id')).$script;
+                                    $this->getAttribute('id'));//.$script;
         }
     } //end func toHtml
 
index e8a1cab486ce1d930dc70fce65eda20f61d28808..e54e0f0e43b1e0bfcc07bf77c7b16f2f5e5f6979 100644 (file)
@@ -4746,23 +4746,27 @@ function print_recent_activity_note($time, $user, $text, $link, $return=false, $
 /**
  * Prints a basic textarea field.
  *
+ * When using this function, you should 
+ *
  * @uses $CFG
- * @param boolean $usehtmleditor ?
- * @param int $rows ?
- * @param int $cols ?
- * @param null $width <b>Legacy field no longer used!</b>  Set to zero to get control over mincols
- * @param null $height <b>Legacy field no longer used!</b>  Set to zero to get control over minrows
- * @param string $name ?
- * @param string $value ?
- * @param int $courseid ?
- * @todo Finish documenting this function
- */
-function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='') {
+ * @param bool $usehtmleditor Enables the use of the htmleditor for this field.
+ * @param int $rows Number of rows to display  (minimum of 10 when $height is non-null)
+ * @param int $cols Number of columns to display (minimum of 65 when $width is non-null)
+ * @param null $width (Deprecated) Width of the element; if a value is passed, the minimum value for $cols will be 65. Value is otherwise ignored.
+ * @param null $height (Deprecated) Height of the element; if a value is passe, the minimum value for $rows will be 10. Value is otherwise ignored.
+ * @param string $name Name to use for the textarea element.
+ * @param string $value Initial content to display in the textarea.
+ * @param int $courseid Course ID to pass to the file manager (defaults to global $COURSE->id).
+ * @param bool $return If false, will output string. If true, will return string value.
+ * @param string $id CSS ID to add to the textarea element.
+ * @param string $class CSS classes to add to the textarea element. Use 'form-textarea-simple' to get a basic editor. Defaults to 'form-textarea-advanced' (complete editor).
+ */
+function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $value='', $courseid=0, $return=false, $id='', $class='form-textarea-advanced') {
 /// $width and height are legacy fields and no longer used as pixels like they used to be.
 /// However, you can set them to zero to override the mincols and minrows values below.
 
     global $CFG, $COURSE, $HTTPSPAGEREQUIRED;
-    static $scriptcount = 0; // For loading the htmlarea script only once.
+    //static $scriptcount = 0; // For loading the htmlarea script only once.
 
     $mincols = 65;
     $minrows = 10;
@@ -4806,7 +4810,7 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
             }
         }
     }
-    $str .= '<textarea class="form-textarea" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">';
+    $str .= "\n".'<textarea class="form-textarea '. $class .'" id="'. $id .'" name="'. $name .'" rows="'. $rows .'" cols="'. $cols .'">'."\n";
     if ($usehtmleditor) {
         $str .= htmlspecialchars($value); // needed for editing of cleaned text!
     } else {
@@ -4816,6 +4820,8 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v
 
     if ($usehtmleditor) {
         // Show shortcuts button if HTML editor is in use, but only if JavaScript is enabled (MDL-9556)
+        $str .= '';
+        $str .= '<a href="javascript:toggleEditor(\''. $id .'\');"><img width="50" height="17" src="'. $CFG->httpswwwroot .'/lib/editor/tinymce/images/toggle.gif" alt="'. get_string('editortoggle') .'" title="'. get_string('editortoggle') .'" /></a>';
         $str .= '<script type="text/javascript">
 //<![CDATA[
 document.write(\''.addslashes_js(editorshortcutshelpbutton()).'\');
@@ -5899,6 +5905,13 @@ function emoticonhelpbutton($form, $field, $return = false) {
     }
 }
 
+/**
+ * Print a button to toggle the html editor.
+ */
+function editortogglebutton($id) {
+    
+}
+
 /**
  * Print a help button.
  *