diff options
author | Michael Große <grosse@cosmocode.de> | 2018-03-29 16:27:10 +0200 |
---|---|---|
committer | Michael Große <grosse@cosmocode.de> | 2018-03-29 16:29:23 +0200 |
commit | 10cf78c4ce248cccc029815ed2ced19d64b9920c (patch) | |
tree | 32f4f844b438bf261b4bd0c0d7e9ec3fe914991a | |
parent | 034db8853cc3f0d01180743036aa58194a562533 (diff) | |
download | dokuwiki-10cf78c4ce248cccc029815ed2ced19d64b9920c.tar.gz dokuwiki-10cf78c4ce248cccc029815ed2ced19d64b9920c.zip |
refactor: extract $JSINFO initialization into tpl_ function
-rw-r--r-- | doku.php | 4 | ||||
-rw-r--r-- | inc/template.php | 18 |
2 files changed, 15 insertions, 7 deletions
@@ -90,10 +90,6 @@ if($DATE_AT) { //make infos about the selected page available $INFO = pageinfo(); -//export minimal info to JS, plugins can add more -$JSINFO['id'] = $ID; -$JSINFO['namespace'] = (string) $INFO['namespace']; - // handle debugging if($conf['allowdebug'] && $ACT == 'debug') { html_debug(); diff --git a/inc/template.php b/inc/template.php index 7eef41aad..720513b0f 100644 --- a/inc/template.php +++ b/inc/template.php @@ -330,9 +330,7 @@ function tpl_metaheaders($alt = true) { if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { $script .= "var SIG='".toolbar_signature()."';"; } - $JSINFO['ACT'] = act_clean($ACT); - $JSINFO['DOKU_UHN'] = (int) useHeading('navigation'); - $JSINFO['DOKU_UHC'] = (int) useHeading('content'); + _tpl_ensureJSINFO(); $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; $head['script'][] = array('type'=> 'text/javascript', '_data'=> $script); @@ -355,6 +353,20 @@ function tpl_metaheaders($alt = true) { return true; } +function _tpl_ensureJSINFO() { + global $JSINFO, $ID, $INFO; + + if (!is_array($JSINFO)) { + $JSINFO = []; + } + //export minimal info to JS, plugins can add more + $JSINFO['id'] = $ID; + $JSINFO['namespace'] = (string) $INFO['namespace']; + $JSINFO['ACT'] = act_clean($ACT); + $JSINFO['DOKU_UHN'] = (int) useHeading('navigation'); + $JSINFO['DOKU_UHC'] = (int) useHeading('content'); +} + /** * prints the array build by tpl_metaheaders * |