diff --git a/lib/editor/htmlEditor.class.php b/lib/editor/htmlEditor.class.php
index fe40d6ecd80..ac1cb26dd77 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;
+ $configuration[] = $CFG->httpswwwroot ."/lib/editor/fckeditor/fckeditor.js";
+ $configuration[] = $CFG->httpswwwroot ."/lib/editor/fckeditor.js.php?course=". $courseid;
+ $configured['fckeditor'] = true;
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;
+// 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 cee21428e70..72c63fd9712 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 c88d830b398..57e1f22e84b 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();