From: scyrma Date: Thu, 5 Jun 2008 09:36:55 +0000 (+0000) Subject: MDL-14741: use the default html editor, as chosen in the admin settings X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=b26be9a9cd1161841eb84d3ff70b7eb77eb0ae08;p=moodle.git MDL-14741: use the default html editor, as chosen in the admin settings --- diff --git a/lib/form/htmleditor.php b/lib/form/htmleditor.php index 20d1109a88..8eb68debdc 100644 --- a/lib/form/htmleditor.php +++ b/lib/form/htmleditor.php @@ -61,9 +61,8 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{ function toHtml(){ if ($this->_canUseHtmlEditor && !$this->_flagFrozen){ - ob_start(); - use_html_editor($this->getName(), '', $this->getAttribute('id')); - $script=ob_get_clean(); + global $htmlEditorObject; + $script = $htmlEditorObject->activateEditor($this->getName(), $this->getAttribute('id')); } else { $script=''; } @@ -96,4 +95,4 @@ class MoodleQuickForm_htmleditor extends MoodleQuickForm_textarea{ return $html . $this->_getPersistantData(); } //end func getFrozenHtml } -?> \ No newline at end of file +?> diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 12f551258c..6d0e8c9146 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6131,6 +6131,33 @@ function ini_get_bool($ini_get_arg) { return false; } + /** + * Get the list of available HTML editors + */ +function get_available_html_editors() { + global $CFG; + static $editors = null; + + if ($editors != null) { + return $editors; + } + + $editors = array(); + + $dir = opendir($CFG->libdir .'/editor'); + while (($file = readdir($dir)) !== false) { + if ($file != '.' and $file != '..') { + $path_file = $CFG->libdir ."/editor/{$file}"; + if (is_dir($path_file) and file_exists($path_file .'.js.php')) { + $editors[] = $file; + } + } + } + closedir($dir); + + return $editors; +} + /** * Determines if the HTML editor is enabled. * diff --git a/lib/weblib.php b/lib/weblib.php index af9fe88812..616878b356 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2557,11 +2557,18 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $bodytags .= ' class="'.$pageclass.'" id="'.$pageid.'"'; + require_once($CFG->libdir .'/editor/htmlEditor.class.php'); + global $htmlEditorObject; + $htmlEditorObject = new htmlEditor(); + $htmlEditor = $htmlEditorObject->configure(); + ob_start(); include($CFG->header); $output = ob_get_contents(); ob_end_clean(); + $output = str_replace('', "\n\n$htmlEditor\n\n", $output); + // container debugging info $THEME->open_header_containers = open_containers();