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.
This commit is contained in:
@@ -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
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/tinymce.js.php"></script>
|
||||
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
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/fckeditor/fckeditor.js"></script>
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/fckeditor.js.php"></script>
|
||||
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 = <<<EOF
|
||||
<script type="text/javascript">
|
||||
_editor_url = "{$CFG->wwwroot}/lib/editor/xinha/"
|
||||
_editor_lang = "en";
|
||||
_editor_skin = "blue-look";
|
||||
</script>
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/xinha/XinhaCore.js"></script>
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/xinha.js.php"></script>
|
||||
EOF;
|
||||
break;
|
||||
|
||||
case 'yuirte':
|
||||
$configuration = <<<EOF
|
||||
<!-- Skin CSS file -->
|
||||
<link rel="stylesheet" type="text/css" href="{$CFG->wwwroot}/lib/editor/yui/build/assets/skins/sam/skin.css">
|
||||
|
||||
<!-- Utility Dependencies -->
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yui/build/element/element-beta-min.js"></script>
|
||||
|
||||
<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
|
||||
<script src="{$CFG->wwwroot}/lib/editor/yui/build/container/container_core-min.js"></script>
|
||||
<script src="{$CFG->wwwroot}/lib/editor/yui/build/menu/menu-min.js"></script>
|
||||
<script src="{$CFG->wwwroot}/lib/editor/yui/build/button/button-min.js"></script>
|
||||
|
||||
<!-- Source file for Rich Text Editor-->
|
||||
<script src="{$CFG->wwwroot}/lib/editor/yui/build/editor/editor-beta-min.js"></script>
|
||||
|
||||
<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yuirte.js.php"></script>
|
||||
EOF;
|
||||
break;
|
||||
// case 'xinha':
|
||||
// $configuration = <<<EOF
|
||||
//<script type="text/javascript">
|
||||
// _editor_url = "{$CFG->wwwroot}/lib/editor/xinha/"
|
||||
// _editor_lang = "en";
|
||||
// _editor_skin = "blue-look";
|
||||
//</script>
|
||||
//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/xinha/XinhaCore.js"></script>
|
||||
//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/xinha.js.php"></script>
|
||||
//EOF;
|
||||
// break;
|
||||
//
|
||||
// case 'yuirte':
|
||||
// $configuration = <<<EOF
|
||||
//<!-- Skin CSS file -->
|
||||
//<link rel="stylesheet" type="text/css" href="{$CFG->wwwroot}/lib/editor/yui/build/assets/skins/sam/skin.css">
|
||||
//
|
||||
//<!-- Utility Dependencies -->
|
||||
//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yui/build/element/element-beta-min.js"></script>
|
||||
//
|
||||
//<!-- Needed for Menus, Buttons and Overlays used in the Toolbar -->
|
||||
//<script src="{$CFG->wwwroot}/lib/editor/yui/build/container/container_core-min.js"></script>
|
||||
//<script src="{$CFG->wwwroot}/lib/editor/yui/build/menu/menu-min.js"></script>
|
||||
//<script src="{$CFG->wwwroot}/lib/editor/yui/build/button/button-min.js"></script>
|
||||
//
|
||||
//<!-- Source file for Rich Text Editor-->
|
||||
//<script src="{$CFG->wwwroot}/lib/editor/yui/build/editor/editor-beta-min.js"></script>
|
||||
//
|
||||
//<script type="text/javascript" src="{$CFG->wwwroot}/lib/editor/yuirte.js.php"></script>
|
||||
//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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
require_once('../../config.php');
|
||||
|
||||
$course = optional_param('course', 0, PARAM_INT);
|
||||
|
||||
/*
|
||||
*
|
||||
* ********************************************************************************************************
|
||||
@@ -175,7 +177,7 @@ echo <<<EOF
|
||||
theme_advanced_buttons3: "media,advhr,emoticons,dragmath,spellchecker,search,code,fullscreen,bullist,numlist,outdent,indent,forecolor,backcolor,link,unlink,anchor,image,charmap,insertlayer,table",
|
||||
theme_advanced_buttons3_add: "media,emoticons,charmap,dragmath,search,code,fullscreen",
|
||||
theme_advanced_fonts: "Trebuchet=Trebuchet MS,Verdana,Arial,Helvetica,sans-serif;Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;Wingdings=wingdings",
|
||||
moodleimage_course_id: $COURSE->id,
|
||||
moodleimage_course_id: $course,
|
||||
theme_advanced_resize_horizontal: true,
|
||||
theme_advanced_resizing: true,
|
||||
theme_advanced_toolbar_location : "top",
|
||||
@@ -196,7 +198,7 @@ echo <<<EOF
|
||||
}
|
||||
function moodlefilemanager(field_name, url, type, win) {
|
||||
tinyMCE.activeEditor.windowManager.open({
|
||||
file: "{$CFG->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",
|
||||
|
||||
+1
-6
@@ -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('</head>', "\n\n$htmlEditor\n\n</head>", $output);
|
||||
|
||||
// container debugging info
|
||||
$THEME->open_header_containers = open_containers();
|
||||
|
||||
Reference in New Issue
Block a user