3 ///////////////////////////////////////////////////////////////////////////
5 // NOTICE OF COPYRIGHT //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.org //
10 // Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
12 // This program is free software; you can redistribute it and/or modify //
13 // it under the terms of the GNU General Public License as published by //
14 // the Free Software Foundation; either version 2 of the License, or //
15 // (at your option) any later version. //
17 // This program is distributed in the hope that it will be useful, //
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20 // GNU General Public License for more details: //
22 // http://www.gnu.org/copyleft/gpl.html //
24 ///////////////////////////////////////////////////////////////////////////
26 define('NO_MOODLE_COOKIES', true);
27 define('NO_UPGRADE_CHECK', true);
29 require_once('../../../../config.php');
31 $lang = optional_param('elanguage', 'en_utf8', PARAM_SAFEDIR);
32 $theme = optional_param('etheme', 'standard', PARAM_SAFEDIR);
33 $usehttps = optional_param('eusehttps', 0, PARAM_BOOL);
35 if (file_exists("$CFG->dataroot/lang/$lang") or file_exists("$CFG->dirroot/lang/$lang")) {
36 $SESSION->lang = $lang;
37 } else if (file_exists("$CFG->dataroot/lang/{$lang}_utf8") or file_exists("$CFG->dirroot/lang/{$lang}_utf8")) {
38 $SESSION->lang = $lang.'_utf8';
41 $xmlruleset = file_get_contents('xhtml_ruleset.txt');
43 $directionality = get_string('thisdirection');
45 $strtime = get_string('strftimetime');
46 $strdate = get_string('strftimedaydate');
48 $lang = str_replace('_utf8', '', $lang); // use more standard language codes
51 $wwwbase = str_replace('http:', 'https:', $CFG->wwwroot);
53 $wwwbase = $CFG->wwwroot;
56 // $contentcss should be customizable
57 $contentcss = "$CFG->themewww/$theme/styles.php";
59 //TODO: reimplement spellchecker support - the TinyMCE one is hardcoded for linux, has encoding problems, etc.
62 function mc_init_editors() {
66 editor_selector: "form-tinymce-legacy",
67 document_base_url: "$wwwbase",
68 content_css: "$contentcss",
70 directionality: "$directionality",
71 plugin_insertdate_dateFormat : "$strdate",
72 plugin_insertdate_timeFormat : "$strtime",
75 skin_variant: "silver",
76 apply_source_formatting: true,
77 remove_script_host: false,
78 entity_encoding: "raw",
79 plugins: "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,media,searchreplace,paste,directionality,fullscreen,moodlenolink,dragmath,nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
80 theme_advanced_font_sizes: "1,2,3,4,5,6,7",
81 theme_advanced_layout_manager: "SimpleLayout",
82 theme_advanced_toolbar_align : "left",
83 theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,styleselect",
84 theme_advanced_buttons1_add: "|,undo,redo,|,search,replace,|,fullscreen",
85 theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym",
86 theme_advanced_buttons2_add: "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
87 theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,advhr,nonbreaking,charmap",
88 theme_advanced_buttons3_add: "|,table,insertlayer,styleprops,visualchars,|,code,preview",
89 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",
90 theme_advanced_resize_horizontal: true,
91 theme_advanced_resizing: true,
92 theme_advanced_toolbar_location : "top",
93 theme_advanced_statusbar_location : "bottom",
100 editor_selector: "form-tinymce-advanced",
101 document_base_url: "$wwwbase",
102 content_css: "$contentcss",
104 directionality: "$directionality",
105 plugin_insertdate_dateFormat : "$strdate",
106 plugin_insertdate_timeFormat : "$strtime",
109 skin_variant: "silver",
110 apply_source_formatting: true,
111 remove_script_host: false,
112 entity_encoding: "raw",
113 plugins: "safari,table,style,layer,advhr,advimage,advlink,emotions,inlinepopups,media,searchreplace,paste,directionality,fullscreen,moodlenolink,dragmath,nonbreaking,contextmenu,insertdatetime,save,iespell,preview,print,noneditable,visualchars,xhtmlxtras,template,pagebreak",
114 theme_advanced_font_sizes: "1,2,3,4,5,6,7",
115 theme_advanced_layout_manager: "SimpleLayout",
116 theme_advanced_toolbar_align : "left",
117 theme_advanced_buttons1: "fontselect,fontsizeselect,formatselect,styleselect",
118 theme_advanced_buttons1_add: "|,undo,redo,|,search,replace,|,fullscreen",
119 theme_advanced_buttons2: "bold,italic,underline,strikethrough,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,cite,abbr,acronym",
120 theme_advanced_buttons2_add: "|,selectall,cleanup,removeformat,pastetext,pasteword,|,forecolor,backcolor,|,ltr,rtl",
121 theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,media,dragmath,advhr,nonbreaking,charmap",
122 theme_advanced_buttons3_add: "|,table,insertlayer,styleprops,visualchars,|,code,preview",
123 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",
124 theme_advanced_resize_horizontal: true,
125 theme_advanced_resizing: true,
126 theme_advanced_toolbar_location : "top",
127 theme_advanced_statusbar_location : "bottom",
128 file_browser_callback : "mce_moodlefilemanager",
133 function mce_toggleEditor(id) {
134 tinyMCE.execCommand('mceToggleEditor',false,id);
137 function mce_saveOnSubmit(id) {
138 var prevOnSubmit = document.getElementById(id).form.onsubmit;
139 document.getElementById(id).form.onsubmit = function() {
140 tinyMCE.triggerSave();
142 if (prevOnSubmit != undefined) {
143 if (prevOnSubmit()) {
154 function mce_moodlefilemanager(field_name, url, type, win) {
155 var client_id = id2clientid[tinyMCE.selectedInstance.editorId];
156 document.body.className += ' yui-skin-sam';
157 var picker = document.createElement('DIV');
158 picker.className = "file-picker";
159 picker.id = 'file-picker-'+client_id;
160 document.body.appendChild(picker);
161 var el = win.document.getElementById(field_name);
162 eval('open_filepicker(client_id, {"env":"editor","target":el,"filetype":type})');
165 // finally init editors
171 $lifetime = '10'; // TODO: increase later
172 header('Content-type: text/javascript; charset=utf-8');
173 header('Content-length: '.strlen($output));
174 header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
175 header('Cache-control: max-age='.$lifetime);
176 header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .'GMT');