From: scyrma Date: Wed, 11 Jun 2008 08:37:26 +0000 (+0000) Subject: MDL-14741: Simplifies the activation of the htmleditor. This is a work-in-progress... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=8c37106df2121b9c975772d9239bf66d1cc52fd4;p=moodle.git MDL-14741: Simplifies the activation of the htmleditor. This is a work-in-progress at this stage, but it's an improvement on the current state. --- diff --git a/lib/adminlib.php b/lib/adminlib.php index ba6c92ab6f..6c4d2f7ba3 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -1768,7 +1768,7 @@ class admin_setting_configtextarea extends admin_setting_configtext { } return format_admin_setting($this, $this->visiblename, - '
', + '
', $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 = '
'.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 .= '
'; + $return = '
'.print_textarea($CFG->adminusehtmleditor, 15, 60, 0, 0, $this->get_full_name(), $data, 0, true, 'summary') .'
'; return format_admin_setting($this, $this->visiblename, $return, $this->description, false, '', NULL, $query); } diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php index 8eb68debdc..a0b5b6f4c2 100644 --- a/lib/form/htmleditor.php +++ b/lib/form/htmleditor.php @@ -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)/", ' ',$this->getValue()), $this->_options['course'], true, - $this->getAttribute('id')).$script; + $this->getAttribute('id'));//.$script; } } //end func toHtml diff --git a/lib/weblib.php b/lib/weblib.php index e8a1cab486..e54e0f0e43 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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 Legacy field no longer used! Set to zero to get control over mincols - * @param null $height Legacy field no longer used! 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 .= '