From: skodak Date: Sun, 14 Jun 2009 21:35:07 +0000 (+0000) Subject: MDL-19500 improved editor embedding X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=13a220cfb80d3c637bb4d852787190c95a23c553;p=moodle.git MDL-19500 improved editor embedding --- diff --git a/lib/adminlib.php b/lib/adminlib.php index 5c21b668c1..ebec3dfeeb 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -1634,6 +1634,7 @@ 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()); return format_admin_setting($this, $this->visiblename, '
', diff --git a/lib/editor/textarea/lib.php b/lib/editor/textarea/lib.php index 82552ff102..d6400e92ef 100644 --- a/lib/editor/textarea/lib.php +++ b/lib/editor/textarea/lib.php @@ -53,8 +53,8 @@ class textarea_texteditor extends texteditor { return 'form-textarea-legacy'; } - public function header_js() { - return ''; + public function use_editor($elementid=null) { + return; } } diff --git a/lib/editor/tinymce/lib.php b/lib/editor/tinymce/lib.php index fbeec676cc..3e2ef835b9 100644 --- a/lib/editor/tinymce/lib.php +++ b/lib/editor/tinymce/lib.php @@ -59,14 +59,14 @@ class tinymce_texteditor extends texteditor { return 'form-tinymce-legacy'; } - public function header_js() { - global $CFG; - + public function use_editor($elementid=null) { + global $CFG, $PAGE; $usehttps = (int)($CFG->httpswwwroot !== $CFG->wwwroot); //hmm, is there a better test? - - $js = ''."\n". - ''."\n"; - return $js; + + //TODO: requirements manager does not support parameters :-( + + $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().'&etheme='.current_theme().'&eusehttps='.$usehttps, true); } } \ No newline at end of file diff --git a/lib/editorlib.php b/lib/editorlib.php index b86ddc0996..f68292d737 100644 --- a/lib/editorlib.php +++ b/lib/editorlib.php @@ -156,10 +156,10 @@ abstract class texteditor { public abstract function get_legacy_textarea_class(); /** - * Returns js script statements needed in html head. - * @return string + * Add required JS needed for editor + * @return void */ - public abstract function header_js(); + public abstract function use_editor($elementid=null); } diff --git a/lib/form/editor.php b/lib/form/editor.php index 6f2e35c59a..26718e8169 100644 --- a/lib/form/editor.php +++ b/lib/form/editor.php @@ -137,6 +137,7 @@ 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); $str .= '