From d074c20e4914ebe5ba9ded050b4ae1a5dbff69b8 Mon Sep 17 00:00:00 2001 From: scyrma Date: Thu, 3 Jul 2008 05:32:34 +0000 Subject: [PATCH] MDL-14741: Using a better way to include javascript files (removed use of output buffering) and corrected parameters so that the file manager is linked to the right course again. --- lib/editor/htmlEditor.class.php | 104 +++++++++++++++++--------------- lib/editor/tinymce.js.php | 6 +- lib/weblib.php | 7 +-- 3 files changed, 62 insertions(+), 55 deletions(-) diff --git a/lib/editor/htmlEditor.class.php b/lib/editor/htmlEditor.class.php index fe40d6ecd8..ac1cb26dd7 100644 --- a/lib/editor/htmlEditor.class.php +++ b/lib/editor/htmlEditor.class.php @@ -14,7 +14,13 @@ class htmlEditor { public function __construct() { } - public function configure($editor = NULL) { + /** + * Does initial configuration for a given html editor. + * @param string editor the name of desired html editor, system default will be used if none is passed + * @param int courseid the courseid uploaded files should be linked to + * @return bool true if an editor was configured, false otherwise. + */ + public function configure($editor = NULL, $courseid = NULL) { global $CFG; static $configured = Array(); @@ -27,68 +33,72 @@ class htmlEditor { $editor = (isset($CFG->defaulthtmleditor) ? $CFG->defaulthtmleditor : ''); } - $configuration = ''; + if (isset($configured[$editor])) { + return $configured[$editor]; + } + + $configuration = array(); switch ($editor) { case 'tinymce': - if (!isset($configured['tinymce'])) { - $configuration = << - -EOF; - $configured['tinymce'] = true; - } + $configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"; + $configuration[] = $CFG->httpswwwroot ."/lib/editor/tinymce.js.php?course=". $courseid; + $configured['tinymce'] = true; break; case 'fckeditor': - $configuration = << - -EOF; - break; - - - case 'xinha': - $configuration = << - _editor_url = "{$CFG->wwwroot}/lib/editor/xinha/" - _editor_lang = "en"; - _editor_skin = "blue-look"; - - - -EOF; + $configuration[] = $CFG->httpswwwroot ."/lib/editor/fckeditor/fckeditor.js"; + $configuration[] = $CFG->httpswwwroot ."/lib/editor/fckeditor.js.php?course=". $courseid; + $configured['fckeditor'] = true; break; - case 'yuirte': - $configuration = << - - - - - - - - - - - - - - - -EOF; - break; +// case 'xinha': +// $configuration = << +// _editor_url = "{$CFG->wwwroot}/lib/editor/xinha/" +// _editor_lang = "en"; +// _editor_skin = "blue-look"; +// +// +// +//EOF; +// break; +// +// case 'yuirte': +// $configuration = << +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +//EOF; +// break; default: + $configured[$editor] = false; break; } - return $configuration; + if (is_array($CFG->editorsrc)) { + $CFG->editorsrc = $configuration + $CFG->editorsrc; + } else { + $CFG->editorsrc = $configuration; + } + return $configured[$editor]; } } diff --git a/lib/editor/tinymce.js.php b/lib/editor/tinymce.js.php index cee21428e7..72c63fd971 100644 --- a/lib/editor/tinymce.js.php +++ b/lib/editor/tinymce.js.php @@ -2,6 +2,8 @@ require_once('../../config.php'); +$course = optional_param('course', 0, PARAM_INT); + /* * * ******************************************************************************************************** @@ -175,7 +177,7 @@ echo <<id, + moodleimage_course_id: $course, theme_advanced_resize_horizontal: true, theme_advanced_resizing: true, theme_advanced_toolbar_location : "top", @@ -196,7 +198,7 @@ echo <<httpswwwroot}/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id={$COURSE->id}", + file: "{$CFG->httpswwwroot}/lib/editor/tinymce/jscripts/tiny_mce/plugins/moodlelink/link.php?id={$course}", width: 480, height: 380, resizable: "yes", diff --git a/lib/weblib.php b/lib/weblib.php index c88d830b39..57e1f22e84 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2524,14 +2524,9 @@ function print_header ($title='', $heading='', $navigation='', $focus='', require_once($CFG->libdir .'/editor/htmlEditor.class.php'); global $htmlEditorObject; $htmlEditorObject = new htmlEditor(); - $htmlEditor = $htmlEditorObject->configure(); + $htmlEditor = $htmlEditorObject->configure(NULL, $COURSE->id); - 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(); -- 2.39.5