From 38fb1fc7a9bbb1e70f0f24352891601b2e0856d6 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Tue, 13 May 2014 21:57:50 +0200 Subject: extend lang file cascade, so users can override some lang strings Fixes #692 --- inc/template.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 35b54b4c3..f8ec637b3 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1285,8 +1285,8 @@ function tpl_getLang($id) { // don't include once @include($path.'en/lang.php'); if($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php'); + @include(DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/lang.php'); } - return $lang[$id]; } @@ -1307,7 +1307,7 @@ function tpl_locale_xhtml($id) { function tpl_localeFN($id) { $path = tpl_incdir().'lang/'; global $conf; - $file = DOKU_CONF.'/template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; + $file = DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; if (!@file_exists($file)){ $file = $path.$conf['lang'].'/'.$id.'.txt'; if(!@file_exists($file)){ @@ -1329,6 +1329,7 @@ function tpl_localeFN($id) { * * @triggers MEDIAMANAGER_CONTENT_OUTPUT * @param bool $fromajax - set true when calling this function via ajax + * @param string $sort * @author Andreas Gohr */ function tpl_mediaContent($fromajax = false, $sort='natural') { -- cgit v1.2.3 From dd7a6159c4224a6a3dda22a1f35f5fb13b06ec2e Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 28 Sep 2014 13:27:05 +0200 Subject: use config cascade for loading of localizations --- inc/template.php | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index f8ec637b3..15854282e 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1277,15 +1277,28 @@ function tpl_getLang($id) { static $lang = array(); if(count($lang) === 0) { - $path = tpl_incdir().'lang/'; + global $conf, $config_cascade; // definitely don't invoke "global $lang" + + $path = tpl_incdir() . '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'); - @include(DOKU_CONF.'template_lang/'.$conf['template'].'/'.$conf['lang'].'/lang.php'); + @include($path . 'en/lang.php'); + foreach($config_cascade['lang']['template'] as $config_file) { + if(@file_exists($config_file . $conf['template'] . '/en/lang.php')) { + include($config_file . $conf['template'] . '/en/lang.php'); + } + } + + if($conf['lang'] != 'en') { + @include($path . $conf['lang'] . '/lang.php'); + foreach($config_cascade['lang']['template'] as $config_file) { + if(@file_exists($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php')) { + include($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php'); + } + } + } } return $lang[$id]; } -- cgit v1.2.3 From 21d806cd5466991b4790c5e6b37a40ae35f1eecb Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Sun, 28 Sep 2014 14:44:17 +0200 Subject: improve some scrutinizer issues different types unused vars PHPDocs --- inc/template.php | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index d4357cf0e..3730495c8 100644 --- a/inc/template.php +++ b/inc/template.php @@ -456,6 +456,12 @@ function _tpl_metaheaders_action($data) { * Just builds a link. * * @author Andreas Gohr + * + * @param string $url + * @param string $name + * @param string $more + * @param bool $return if true return the link html, otherwise print + * @return bool|string html of the link, or true if printed */ function tpl_link($url, $name, $more = '', $return = false) { $out = ' + * + * @param string $id page id + * @param string|null $name link name + * @return bool true */ function tpl_pagelink($id, $name = null) { print ''.html_wikilink($id, $name).''; @@ -534,6 +544,13 @@ function tpl_button($type, $return = false) { * * @author Adrian Lang * @see tpl_get_action + * + * @param string $type action name + * @param string $pre prefix of link + * @param string $suf suffix of link + * @param string $inner inner HTML for link + * @param bool $return if true it returns html, otherwise prints + * @return bool|string html of action link or false if nothing, or true if printed */ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false) { global $lang; @@ -571,7 +588,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals $linktarget, $pre.(($inner) ? $inner : $caption).$suf, 'class="action '.$type.'" '. $akey.$rel. - 'title="'.hsc($caption).$addTitle.'"', 1 + 'title="'.hsc($caption).$addTitle.'"', true ); } if($return) return $out; @@ -747,7 +764,6 @@ function tpl_get_action($type) { break; default: return '[unknown %s type]'; - break; } return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement'); } @@ -768,9 +784,9 @@ function tpl_get_action($type) { function tpl_action($type, $link = false, $wrapper = false, $return = false, $pre = '', $suf = '', $inner = '') { $out = ''; if($link) { - $out .= tpl_actionlink($type, $pre, $suf, $inner, 1); + $out .= tpl_actionlink($type, $pre, $suf, $inner, true); } else { - $out .= tpl_button($type, 1); + $out .= tpl_button($type, true); } if($out && $wrapper) $out = "<$wrapper>$out"; @@ -1027,7 +1043,7 @@ function tpl_pagetitle($id = null, $ret = false) { * Only allowed in: detail.php * * @author Andreas Gohr - * @param array $tags tags to try + * @param array|string $tags tag or array of tags to try * @param string $alt alternative output if no data was found * @param null $src the image src, uses global $SRC if not given * @return string -- cgit v1.2.3