From fca55624d146dce2dd45e1a0f4dc493d8f36b32f Mon Sep 17 00:00:00 2001 From: scyrma Date: Thu, 31 Jul 2008 08:52:54 +0000 Subject: [PATCH] MDL-15688: Script that build TinyMCE's language files --- lib/editor/tinymce/strings.php | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 lib/editor/tinymce/strings.php diff --git a/lib/editor/tinymce/strings.php b/lib/editor/tinymce/strings.php new file mode 100644 index 0000000000..b45005ad4c --- /dev/null +++ b/lib/editor/tinymce/strings.php @@ -0,0 +1,71 @@ +dirroot .'/lang/en_utf8/tinymce.php'); +$keys = array_keys($string); + +if (!is_null($contexturl)) { + $context = array_pop(explode('/tinymce/jscripts/tiny_mce/', $contexturl)); + $contexts = explode('/', $context); + $moduletype = $contexts[0]; + $modulename = $contexts[1]; + + $dialogpostfix = ''; + if ($modulename && $isdialog) { + $dialogpostfix = '_dlg'; + } + + $selectedkeys = preg_grep('/^'. $moduletype .'\/'. $modulename . $dialogpostfix .':/', $keys); + + $output = "tinyMCE.addI18n('$lang". ($modulename ? '.'.$modulename:'') ."$dialogpostfix',{\n"; + foreach($selectedkeys as $key) { + $output .= substr($key, strpos($key, ':')+1) .':"'. addslashes_js(get_string($key, 'tinymce')) ."\",\n"; + } + $output .= "});"; + +} else { + $output = "tinyMCE.addI18n({". $lang .":{"; + $selectedkeys = preg_grep('/^main\//', $keys); + $currentsection = ''; + $firstiteration = true; + foreach($selectedkeys as $key) { + $subkey = explode(':', array_pop(explode('/', $key))); + $section = $subkey[0]; + $string = $subkey[1]; + if ($section != $currentsection) { + if ($firstiteration) { + $firstiteration = false; + $output .= "\n"; + } else { + $output .= "},\n"; + } + $currentsection = $section; + $output .= $currentsection .":{\n"; + } + $output .= $string .':"'. addslashes_js(get_string($key, 'tinymce')) ."\",\n"; + } + $output .= "}}});"; +} + +$lifetime = '86400'; +@header('Content-type: text/javascript; charset=utf-8'); +@header('Content-length: '.strlen($output)); +@header('Last-Modified: '. gmdate('D, d M Y H:i:s', time()) .' GMT'); +@header('Cache-control: max-age='.$lifetime); +@header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .'GMT'); +@header('Pragma: '); + +echo $output; + +?> -- 2.39.5