Rev 355 | Rev 362 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 355 | Rev 360 | ||
---|---|---|---|
Line 45... | Line 45... | ||
45 | foreach ($manifest->getJSFiles() as $js_file) { |
45 | foreach ($manifest->getJSFiles() as $js_file) { |
46 | $files[] = $js_file; |
46 | $files[] = $js_file; |
47 | } |
47 | } |
48 | } |
48 | } |
49 | 49 | ||
- | 50 | $translation_array = array(); |
|
50 | foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) { |
51 | foreach (OIDplus::getAllPluginManifests('language') as $pluginManifest) { |
51 | $xmldata = $pluginManifest->getRawXml(); |
52 | $xmldata = $pluginManifest->getRawXml(); |
52 | $lang = $xmldata->language->code->__toString(); |
53 | $lang = $xmldata->language->code->__toString(); |
- | 54 | $translation_array[$lang] = array(); |
|
53 | if (strpos($lang,'/') !== false) return $str; // prevent attack (but actually, the sanitization above should work) |
55 | if (strpos($lang,'/') !== false) return $str; // prevent attack (but actually, the sanitization above should work) |
54 | if (strpos($lang,'\\') !== false) return $str; // prevent attack (but actually, the sanitization above should work) |
56 | if (strpos($lang,'\\') !== false) return $str; // prevent attack (but actually, the sanitization above should work) |
55 | if (strpos($lang,'..') !== false) return $str; // prevent attack (but actually, the sanitization above should work) |
57 | if (strpos($lang,'..') !== false) return $str; // prevent attack (but actually, the sanitization above should work) |
56 | $translation_file = __DIR__.'/plugins/language/'.$lang.'/messages.xml'; |
58 | $translation_file = __DIR__.'/plugins/language/'.$lang.'/messages.xml'; |
57 | if (!file_exists($translation_file)) continue; |
59 | if (!file_exists($translation_file)) continue; |
58 | $xml = simplexml_load_string(file_get_contents($translation_file)); |
60 | $xml = @simplexml_load_string(file_get_contents($translation_file)); |
- | 61 | if (!$xml) continue; // if there is an UTF-8 or parsing error, don't output any errors, otherwise the JavaScript is corrupt and the page won't render correctly |
|
59 | foreach ($xml->message as $msg) { |
62 | foreach ($xml->message as $msg) { |
60 | $src = $msg->source->__toString(); |
63 | $src = trim($msg->source->__toString()); |
61 | $dst = $msg->target->__toString(); |
64 | $dst = trim($msg->target->__toString()); |
62 | $translation_array[$lang][$src] = $dst; |
65 | $translation_array[$lang][$src] = $dst; |
63 | } |
66 | } |
64 | - | ||
65 | $files[]= 'var language_messages = '.json_encode($translation_array).';'; |
- | |
66 | } |
67 | } |
- | 68 | $files[] = 'var language_messages = '.json_encode($translation_array).';'; |
|
- | 69 | ||
- | 70 | //$tbl_prefix = OIDplus::baseConfig()->getValue('OIDPLUS_TABLENAME_PREFIX',''); |
|
- | 71 | //$files[] = 'var language_tblprefix = '.json_encode($tbl_prefix).';'; |
|
- | 72 | $files[] = 'var language_tblprefix = "<tableprefix>";'; // hide OIDPLUS_TABLENAME_PREFIX from the client |
|
67 | 73 | ||
68 | # --- |
74 | # --- |
69 | 75 | ||
70 | $minifier = null; |
76 | $minifier = null; |
71 | $out = ''; |
77 | $out = ''; |