From e8ec13b9a448dc4c0be4aa459d1586165aed6044 Mon Sep 17 00:00:00 2001 From: Klap-in Date: Fri, 2 Aug 2013 13:38:31 +0200 Subject: localized texts for templates --- inc/template.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index bb5f2cd53..33b886927 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1192,6 +1192,39 @@ function tpl_getLang($id) { return $lang[$id]; } +/** + * locale_xhtml($id) + * + * retrieve a language dependent file and pass to xhtml renderer for display + * template equivalent of p_locale_xhtml() + * + * @param string $id id of language dependent wiki page + * @return string parsed contents of the wiki page in xhtml format + */ +function tpl_locale_xhtml($id) { + return p_cached_output(tpl_localFN($id)); +} + +/** + * localFN($id) + * + * prepends appropriate path for a language dependent filename + * template equivalent of localFN() + */ +function tpl_localFN($id) { + $path = tpl_incdir().'lang/'; + global $conf; + $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)){ + //fall back to english + $file = $path.'en/'.$id.'.txt'; + } + } + return $file; +} + /** * prints the "main content" in the mediamanger popup * -- cgit v1.2.3 From d317fb5d70f8903dc518943c731202869d450d68 Mon Sep 17 00:00:00 2001 From: Anika Henke Date: Fri, 2 Aug 2013 14:04:04 +0100 Subject: fixed some bi-directionality issues Fixed some issues which occur whenever RTL and LTR languages could potentially be mixed, using the HTML5 `` element. This element is currently only supported by Chrome and Firefox. The old and only partially working fix for tpl_breadcrumbs() was removed in favour of this solution. --- inc/template.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index bb5f2cd53..d03d3561b 100644 --- a/inc/template.php +++ b/inc/template.php @@ -468,7 +468,7 @@ function tpl_link($url, $name, $more = '', $return = false) { * @author Andreas Gohr */ function tpl_pagelink($id, $name = null) { - print html_wikilink($id, $name); + print ''.html_wikilink($id, $name).''; return true; } @@ -800,13 +800,7 @@ function tpl_breadcrumbs($sep = '•') { $crumbs = breadcrumbs(); //setup crumb trace - //reverse crumborder in right-to-left mode, add RLM character to fix heb/eng display mixups - if($lang['direction'] == 'rtl') { - $crumbs = array_reverse($crumbs, true); - $crumbs_sep = ' ‏'.$sep.'‏ '; - } else { - $crumbs_sep = ' '.$sep.' '; - } + $crumbs_sep = ' '.$sep.' '; //render crumbs, highlight the last one print ''.$lang['breadcrumb'].':'; @@ -816,7 +810,9 @@ function tpl_breadcrumbs($sep = '•') { $i++; echo $crumbs_sep; if($i == $last) print ''; + print ''; tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="'.$id.'"'); + print ''; if($i == $last) print ''; } return true; @@ -889,7 +885,7 @@ function tpl_userinfo() { global $lang; global $INFO; if(isset($_SERVER['REMOTE_USER'])) { - print $lang['loggedinas'].': '.hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')'; + print $lang['loggedinas'].': '.hsc($INFO['userinfo']['name']).' ('.hsc($_SERVER['REMOTE_USER']).')'; return true; } return false; @@ -928,14 +924,14 @@ function tpl_pageinfo($ret = false) { // print it if($INFO['exists']) { $out = ''; - $out .= $fn; + $out .= ''.$fn.''; $out .= ' · '; $out .= $lang['lastmod']; $out .= ': '; $out .= $date; if($INFO['editor']) { $out .= ' '.$lang['by'].' '; - $out .= editorinfo($INFO['editor']); + $out .= ''.editorinfo($INFO['editor']).''; } else { $out .= ' ('.$lang['external_edit'].')'; } @@ -943,7 +939,7 @@ function tpl_pageinfo($ret = false) { $out .= ' · '; $out .= $lang['lockedby']; $out .= ': '; - $out .= editorinfo($INFO['locked']); + $out .= ''.editorinfo($INFO['locked']).''; } if($ret) { return $out; @@ -1469,8 +1465,8 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = } if(!$imgonly) { $out .= $lang['license'].' '; - $out .= ''; + $out .= ''; } if($wrap) $out .= ''; -- cgit v1.2.3 From c5c17fdaa1af326a3f0c68695cb93575a3af2e5e Mon Sep 17 00:00:00 2001 From: Klap-in Date: Fri, 2 Aug 2013 19:06:29 +0200 Subject: improve method name and phpdocs --- inc/template.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 33b886927..6af0535c9 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1193,25 +1193,20 @@ function tpl_getLang($id) { } /** - * locale_xhtml($id) - * - * retrieve a language dependent file and pass to xhtml renderer for display + * Retrieve a language dependent file and pass to xhtml renderer for display * template equivalent of p_locale_xhtml() * * @param string $id id of language dependent wiki page * @return string parsed contents of the wiki page in xhtml format */ function tpl_locale_xhtml($id) { - return p_cached_output(tpl_localFN($id)); + return p_cached_output(tpl_localeFN($id)); } /** - * localFN($id) - * - * prepends appropriate path for a language dependent filename - * template equivalent of localFN() + * Prepends appropriate path for a language dependent filename */ -function tpl_localFN($id) { +function tpl_localeFN($id) { $path = tpl_incdir().'lang/'; global $conf; $file = DOKU_CONF.'/template_lang/'.$conf['template'].'/'.$conf['lang'].'/'.$id.'.txt'; -- cgit v1.2.3 From afb2c08218345dc3604024c829a5c408e3f39277 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Aug 2013 14:42:05 +0200 Subject: allow for a style.ini in conf//style.ini This is another go at what pull request #227 tried to do. This removes support for a style.local.ini in the template file in preference of a style.ini in the conf folder --- inc/template.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index ca1c8d9d5..f6eb488f5 100644 --- a/inc/template.php +++ b/inc/template.php @@ -33,11 +33,13 @@ function template($file) { * This replaces the deprecated DOKU_TPLINC constant * * @author Andreas Gohr + * @param string $tpl The template to use, default to current one * @return string */ -function tpl_incdir() { +function tpl_incdir($tpl='') { global $conf; - return DOKU_INC.'lib/tpl/'.$conf['template'].'/'; + if(!$tpl) $tpl = $conf['template']; + return DOKU_INC.'lib/tpl/'.$tpl.'/'; } /** @@ -46,10 +48,12 @@ function tpl_incdir() { * This replaces the deprecated DOKU_TPL constant * * @author Andreas Gohr + * @param string $tpl The template to use, default to current one * @return string */ -function tpl_basedir() { +function tpl_basedir($tpl) { global $conf; + if(!$tpl) $tpl = $conf['template']; return DOKU_BASE.'lib/tpl/'.$conf['template'].'/'; } -- cgit v1.2.3 From 99dca51357b98d8450d43d66b5596504722809c0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 3 Aug 2013 23:34:20 +0200 Subject: added missing default --- inc/template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index f6eb488f5..ea73b01b6 100644 --- a/inc/template.php +++ b/inc/template.php @@ -51,7 +51,7 @@ function tpl_incdir($tpl='') { * @param string $tpl The template to use, default to current one * @return string */ -function tpl_basedir($tpl) { +function tpl_basedir($tpl='') { global $conf; if(!$tpl) $tpl = $conf['template']; return DOKU_BASE.'lib/tpl/'.$conf['template'].'/'; -- cgit v1.2.3