|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00003 // This file is part of Moodle - http://moodle.org/ 00004 // 00005 // Moodle is free software: you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation, either version 3 of the License, or 00008 // (at your option) any later version. 00009 // 00010 // Moodle is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00017 00027 define('NO_MOODLE_COOKIES', true); 00028 define('NO_UPGRADE_CHECK', true); 00029 00030 require_once('../../../../config.php'); 00031 00032 $lang = optional_param('elanguage', 'en', PARAM_SAFEDIR); 00033 $theme = optional_param('etheme', 'advanced', PARAM_SAFEDIR); 00034 00035 if (!get_string_manager()->translation_exists($lang, false)) { 00036 $lang = 'en'; 00037 } 00038 00039 $string = get_string_manager()->load_component_strings('editor_tinymce', $lang); 00040 00041 //process the $strings to match expected tinymce lang array structure 00042 $result = array(); 00043 00044 foreach ($string as $key=>$value) { 00045 $parts = explode(':', $key); 00046 if (count($parts) != 2) { 00047 // incorrect string - ignore 00048 continue; 00049 } 00050 00051 $result[$parts[0]][$parts[1]] = $value; 00052 } 00053 00054 $output = 'tinyMCE.addI18n({'.$lang.':'.json_encode($result).'});'; 00055 00056 $lifetime = '10'; // TODO: increase later 00057 @header('Content-type: text/javascript; charset=utf-8'); 00058 @header('Content-length: '.strlen($output)); 00059 @header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT'); 00060 @header('Cache-control: max-age='.$lifetime); 00061 @header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .'GMT'); 00062 @header('Pragma: '); 00063 00064 echo $output;