summaryrefslogtreecommitdiff
path: root/lib/exe/js.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-10-28 20:22:05 +0100
committerAndreas Gohr <andi@splitbrain.org>2013-10-28 20:22:05 +0100
commit23a363f01514464eb2238ac09ec7723d03d57ecb (patch)
tree42c7dcff8c5b0e506a25d08ee5583ed2a24e8602 /lib/exe/js.php
parent25e48e54df60b3df6efa365daceb3a8966c8f427 (diff)
parent75cf672f10a71f7dee6d50eb70b742689838bc36 (diff)
downloadrpg-23a363f01514464eb2238ac09ec7723d03d57ecb.tar.gz
rpg-23a363f01514464eb2238ac09ec7723d03d57ecb.tar.bz2
Merge branch 'master' into stable
* master: (413 commits) release preparation fixed strict violation in ACL plugin Fix issues from teams:i18n:translation-check in localizations ensure locale is set back to the original value skip FS#2867 test if \s doesn't match \xA0 after attempting to change the locale unittests for auth_loadACL translation update allow charset for SSO to be configured FS#2148 Mailer: avoid overlong headers in content ids FS#2868 translation update translation update replace \s, \S with [ \t], [^ \t] in regexs used with acls translation update translation update translation update translation update Fix handling of the legacy subscription action name remove obsolete opera handling and session closing remove no longer used ajax.php fix proxy CONNECT where HTTP 1.1 answer is given ...
Diffstat (limited to 'lib/exe/js.php')
-rw-r--r--lib/exe/js.php32
1 files changed, 29 insertions, 3 deletions
diff --git a/lib/exe/js.php b/lib/exe/js.php
index 4ff48133e..040b8874d 100644
--- a/lib/exe/js.php
+++ b/lib/exe/js.php
@@ -86,16 +86,25 @@ function js_out(){
// start output buffering and build the script
ob_start();
+ $json = new JSON();
// add some global variables
print "var DOKU_BASE = '".DOKU_BASE."';";
print "var DOKU_TPL = '".tpl_basedir()."';";
+ print "var DOKU_COOKIE_PARAM = " . $json->encode(
+ array(
+ 'path' => empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'],
+ 'secure' => $conf['securecookie'] && is_ssl()
+ )).";";
// FIXME: Move those to JSINFO
print "var DOKU_UHN = ".((int) useHeading('navigation')).";";
print "var DOKU_UHC = ".((int) useHeading('content')).";";
// load JS specific translations
- $json = new JSON();
$lang['js']['plugins'] = js_pluginstrings();
+ $templatestrings = js_templatestrings();
+ if(!empty($templatestrings)) {
+ $lang['js']['template'] = $templatestrings;
+ }
echo 'LANG = '.$json->encode($lang['js']).";\n";
// load toolbar
@@ -104,10 +113,13 @@ function js_out(){
// load files
foreach($files as $file){
$ismin = (substr($file,-7) == '.min.js');
+ $debugjs = ($conf['allowdebug'] && strpos($file, DOKU_INC.'lib/scripts/') !== 0);
echo "\n\n/* XXXXXXXXXX begin of ".str_replace(DOKU_INC, '', $file) ." XXXXXXXXXX */\n\n";
if($ismin) echo "\n/* BEGIN NOCOMPRESS */\n";
+ if ($debugjs) echo "\ntry {\n";
js_load($file);
+ if ($debugjs) echo "\n} catch (e) {\n logError(e, '".str_replace(DOKU_INC, '', $file)."');\n}\n";
if($ismin) echo "\n/* END NOCOMPRESS */\n";
echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n";
}
@@ -187,8 +199,7 @@ function js_pluginscripts(){
*
* @author Gabriel Birke <birke@d-scribe.de>
*/
-function js_pluginstrings()
-{
+function js_pluginstrings() {
global $conf;
$pluginstrings = array();
$plugins = plugin_list();
@@ -207,6 +218,21 @@ function js_pluginstrings()
return $pluginstrings;
}
+function js_templatestrings() {
+ global $conf;
+ $templatestrings = array();
+ if (@file_exists(tpl_incdir()."lang/en/lang.php")) {
+ include tpl_incdir()."lang/en/lang.php";
+ }
+ if (isset($conf['lang']) && $conf['lang']!='en' && @file_exists(tpl_incdir()."lang/".$conf['lang']."/lang.php")) {
+ include tpl_incdir()."lang/".$conf['lang']."/lang.php";
+ }
+ if (isset($lang['js'])) {
+ $templatestrings[$conf['template']] = $lang['js'];
+ }
+ return $templatestrings;
+}
+
/**
* Escapes a String to be embedded in a JavaScript call, keeps \n
* as newline