MDL-19211 spellchecker TODOs
[moodle.git] / lib / editor / tinymce / extra / tinymce.js.php
CommitLineData
5ca3c838 1<?php
2
3///////////////////////////////////////////////////////////////////////////
4// //
5// NOTICE OF COPYRIGHT //
6// //
7// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8// http://moodle.org //
9// //
10// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
11// //
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. //
16// //
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: //
21// //
22// http://www.gnu.org/copyleft/gpl.html //
23// //
24///////////////////////////////////////////////////////////////////////////
25
26define('NO_MOODLE_COOKIES', true);
27define('NO_UPGRADE_CHECK', true);
28
29require_once('../../../../config.php');
30
31$lang = optional_param('elanguage', 'en_utf8', PARAM_SAFEDIR);
58aa4c08 32$theme = optional_param('etheme', 'standard', PARAM_SAFEDIR);
5ca3c838 33$usehttps = optional_param('eusehttps', 0, PARAM_BOOL);
34
35if (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';
39}
40
5ca3c838 41$xmlruleset = file_get_contents('xhtml_ruleset.txt');
42
43$directionality = get_string('thisdirection');
44
45$strtime = get_string('strftimetime');
46$strdate = get_string('strftimedaydate');
47
48$lang = str_replace('_utf8', '', $lang); // use more standard language codes
49
50if ($usehttps) {
51 $wwwbase = str_replace('http:', 'https:', $CFG->wwwroot);
52} else {
53 $wwwbase = $CFG->wwwroot;
54}
55
58aa4c08 56// $contentcss should be customizable
57$contentcss = "$CFG->themewww/$theme/styles.php";
5ca3c838 58
a07ca51f 59//TODO: reimplement spellchecker support - the TinyMCE one is hardcoded for linux, has encoding problems, etc.
60
5ca3c838 61$output = <<<EOF
62function mc_init_editors() {
63 tinyMCE.init({
64 mode: "textareas",
65 relative_urls: false,
66 editor_selector: "form-tinymce-legacy",
67 document_base_url: "$wwwbase",
68 content_css: "$contentcss",
69 language: "$lang",
70 directionality: "$directionality",
71 plugin_insertdate_dateFormat : "$strdate",
72 plugin_insertdate_timeFormat : "$strtime",
73 theme: "advanced",
74 skin: "o2k7",
75 skin_variant: "silver",
76 apply_source_formatting: true,
77 remove_script_host: false,
78 entity_encoding: "raw",
a07ca51f 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",
5ca3c838 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",
a07ca51f 84 theme_advanced_buttons1_add: "|,undo,redo,|,search,replace,|,fullscreen",
5ca3c838 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",
1b24d749 87 theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,advhr,nonbreaking,charmap",
5ca3c838 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",
94 $xmlruleset
95 });
96
97 tinyMCE.init({
98 mode: "textareas",
99 relative_urls: false,
100 editor_selector: "form-tinymce-advanced",
101 document_base_url: "$wwwbase",
102 content_css: "$contentcss",
103 language: "$lang",
104 directionality: "$directionality",
105 plugin_insertdate_dateFormat : "$strdate",
106 plugin_insertdate_timeFormat : "$strtime",
107 theme: "advanced",
108 skin: "o2k7",
109 skin_variant: "silver",
110 apply_source_formatting: true,
111 remove_script_host: false,
112 entity_encoding: "raw",
a07ca51f 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",
5ca3c838 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",
a07ca51f 118 theme_advanced_buttons1_add: "|,undo,redo,|,search,replace,|,fullscreen",
5ca3c838 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",
1b24d749 121 theme_advanced_buttons3: "bullist,numlist,outdent,indent,|,link,unlink,moodlenolink,anchor,|,insertdate,inserttime,|,emotions,image,media,dragmath,advhr,nonbreaking,charmap",
5ca3c838 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",
129 $xmlruleset
130 });
131}
132
133function mce_toggleEditor(id) {
134 tinyMCE.execCommand('mceToggleEditor',false,id);
135}
136
137function mce_saveOnSubmit(id) {
138 var prevOnSubmit = document.getElementById(id).form.onsubmit;
139 document.getElementById(id).form.onsubmit = function() {
140 tinyMCE.triggerSave();
141 var ret = true;
142 if (prevOnSubmit != undefined) {
143 if (prevOnSubmit()) {
144 ret = true;
145 prevOnSubmit = null;
146 } else {
147 ret = false;
148 }
149 }
150 return ret;
151 };
152}
153
154function 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})');
163}
164
165// finally init editors
166mc_init_editors();
167
168EOF;
169
170
171$lifetime = '10'; // TODO: increase later
172header('Content-type: text/javascript; charset=utf-8');
173header('Content-length: '.strlen($output));
174header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
175header('Cache-control: max-age='.$lifetime);
176header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .'GMT');
177header('Pragma: ');
178
179echo $output;