diff options
Diffstat (limited to 'inc/template.php')
-rw-r--r-- | inc/template.php | 161 |
1 files changed, 92 insertions, 69 deletions
diff --git a/inc/template.php b/inc/template.php index 595c5fc03..f7c104cdb 100644 --- a/inc/template.php +++ b/inc/template.php @@ -793,75 +793,75 @@ function tpl_userinfo(){ global $INFO; if(isset($_SERVER['REMOTE_USER'])){ print $lang['loggedinas'].': '.$INFO['userinfo']['name'].' ('.$_SERVER['REMOTE_USER'].')'; - return true; - } - return false; - } + return true; + } + return false; +} - /** - * Print some info about the current page - * - * @author Andreas Gohr <andi@splitbrain.org> - */ - function tpl_pageinfo($ret=false){ - global $conf; - global $lang; - global $INFO; - global $ID; - - // return if we are not allowed to view the page - if (!auth_quickaclcheck($ID)) { return false; } - - // prepare date and path - $fn = $INFO['filepath']; - if(!$conf['fullpath']){ - if($INFO['rev']){ - $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); - }else{ - $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); - } - } - $fn = utf8_decodeFN($fn); - $date = dformat($INFO['lastmod']); - - // print it - if($INFO['exists']){ - $out = ''; - $out .= $fn; - $out .= ' · '; - $out .= $lang['lastmod']; - $out .= ': '; - $out .= $date; - if($INFO['editor']){ - $out .= ' '.$lang['by'].' '; - $out .= editorinfo($INFO['editor']); - }else{ - $out .= ' ('.$lang['external_edit'].')'; - } - if($INFO['locked']){ - $out .= ' · '; - $out .= $lang['lockedby']; - $out .= ': '; - $out .= editorinfo($INFO['locked']); - } - if($ret){ - return $out; - }else{ - echo $out; - return true; - } - } - return false; - } - - /** - * Prints or returns the name of the given page (current one if none given). - * - * If useheading is enabled this will use the first headline else - * the given ID is used. - * - * @author Andreas Gohr <andi@splitbrain.org> - */ +/** + * Print some info about the current page + * + * @author Andreas Gohr <andi@splitbrain.org> + */ +function tpl_pageinfo($ret=false){ + global $conf; + global $lang; + global $INFO; + global $ID; + + // return if we are not allowed to view the page + if (!auth_quickaclcheck($ID)) { return false; } + + // prepare date and path + $fn = $INFO['filepath']; + if(!$conf['fullpath']){ + if($INFO['rev']){ + $fn = str_replace(fullpath($conf['olddir']).'/','',$fn); + }else{ + $fn = str_replace(fullpath($conf['datadir']).'/','',$fn); + } + } + $fn = utf8_decodeFN($fn); + $date = dformat($INFO['lastmod']); + + // print it + if($INFO['exists']){ + $out = ''; + $out .= $fn; + $out .= ' · '; + $out .= $lang['lastmod']; + $out .= ': '; + $out .= $date; + if($INFO['editor']){ + $out .= ' '.$lang['by'].' '; + $out .= editorinfo($INFO['editor']); + }else{ + $out .= ' ('.$lang['external_edit'].')'; + } + if($INFO['locked']){ + $out .= ' · '; + $out .= $lang['lockedby']; + $out .= ': '; + $out .= editorinfo($INFO['locked']); + } + if($ret){ + return $out; + }else{ + echo $out; + return true; + } + } + return false; +} + +/** + * Prints or returns the name of the given page (current one if none given). + * + * If useheading is enabled this will use the first headline else + * the given ID is used. + * + * @author Andreas Gohr <andi@splitbrain.org> + */ function tpl_pagetitle($id=null, $ret=false){ global $conf; if(is_null($id)){ @@ -1017,7 +1017,7 @@ function tpl_indexerWebBug(){ */ function tpl_getConf($id){ global $conf; - global $tpl_configloaded; + static $tpl_configloaded = false; $tpl = $conf['template']; @@ -1053,6 +1053,29 @@ function tpl_loadConfig(){ return $conf; } +// language methods +/** + * tpl_getLang($id) + * + * use this function to access template language variables + */ +function tpl_getLang($id){ + static $lang = array(); + + if (count($lang) === 0){ + $path = DOKU_TPLINC.'lang/'; + + $lang = array(); + + global $conf; // definitely don't invoke "global $lang" + // don't include once + @include($path.'en/lang.php'); + if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); + } + + return $lang[$id]; +} + /** * prints the "main content" in the mediamanger popup * |