diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2009-10-26 12:40:46 +0100 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2009-10-26 12:40:46 +0100 |
commit | 83a482b68691087fcfd636e6b093fd41f52b759a (patch) | |
tree | 6497c497ad36d8ef466c36507345e58f975859ab /inc/template.php | |
parent | 7285682975d50129e7b6650a14e09510b9850fd6 (diff) | |
download | rpg-83a482b68691087fcfd636e6b093fd41f52b759a.tar.gz rpg-83a482b68691087fcfd636e6b093fd41f52b759a.tar.bz2 |
make $INFO available to JavaScripts
Ignore-this: 372ed5dafd33b16d910edc164dc69fb9
$INFO is now exported as JavaScript variable INFO in the HTML
meta headers. This makes it easier for plugin authors to access
important info about the current page and user from JavaScript.
darcs-hash:20091026114046-6e07b-340f009428322105a5dda72933a66a3719de544d.gz
Diffstat (limited to 'inc/template.php')
-rw-r--r-- | inc/template.php | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/inc/template.php b/inc/template.php index e26c5202a..837b06eb4 100644 --- a/inc/template.php +++ b/inc/template.php @@ -352,6 +352,14 @@ function tpl_metaheaders($alt=true){ $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=>'', 'src'=>DOKU_BASE.'lib/exe/js.php?edit='.$js_edit.'&write='.$js_write); + // make $INFO available to JavaScripts + require_once(DOKU_INC.'inc/JSON.php'); + $json = new JSON(); + $infocpy = $INFO; + $infocpy['userinfo']['pass'] = ''; + $head['script'][] = array( 'type'=>'text/javascript', 'charset'=>'utf-8', '_data'=> 'var INFO = '.$json->encode($infocpy).';'); + + // trigger event here trigger_event('TPL_METAHEADER_OUTPUT',$head,'_tpl_metaheaders_action',true); return true; |