From 5c2eed9a193e9341fbfee63d4a973898acdc5ee5 Mon Sep 17 00:00:00 2001 From: lisps Date: Thu, 21 Nov 2013 15:50:52 +0100 Subject: add parameter at($DATE_AT) and mind revisions --- 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 60e178d1a..ac85059a8 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1031,6 +1031,7 @@ function tpl_img_getTag($tags, $alt = '', $src = null) { function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { global $IMG; global $INPUT; + global $REV; $w = tpl_img_getTag('File.Width'); $h = tpl_img_getTag('File.Height'); @@ -1055,8 +1056,8 @@ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { } //prepare URLs - $url = ml($IMG, array('cache'=> $INPUT->str('cache')), true, '&'); - $src = ml($IMG, array('cache'=> $INPUT->str('cache'), 'w'=> $w, 'h'=> $h), true, '&'); + $url = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV), true, '&'); + $src = ml($IMG, array('cache'=> $INPUT->str('cache'),'rev'=>$REV, 'w'=> $w, 'h'=> $h), true, '&'); //prepare attributes $alt = tpl_img_getTag('Simple.Title'); -- cgit v1.2.3 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 From e0c26282a603881e8d2f839d94c28dbbfc57d71b Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 03:34:17 +0200 Subject: scrutinizer documentations issues --- inc/template.php | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 7f3c68534..667e3db1c 100644 --- a/inc/template.php +++ b/inc/template.php @@ -204,7 +204,7 @@ function tpl_toc($return = false) { $toc = $TOC; } elseif(($ACT == 'show' || substr($ACT, 0, 6) == 'export') && !$REV && $INFO['exists']) { // get TOC from metadata, render if neccessary - $meta = p_get_metadata($ID, false, METADATA_RENDER_USING_CACHE); + $meta = p_get_metadata($ID, '', METADATA_RENDER_USING_CACHE); if(isset($meta['internal']['toc'])) { $tocok = $meta['internal']['toc']; } else { @@ -503,6 +503,10 @@ function tpl_getparent($id) { * * @author Adrian Lang * @see tpl_get_action + * + * @param string $type + * @param bool $return + * @return bool|string html, or false if no data, true if printed */ function tpl_button($type, $return = false) { $data = tpl_get_action($type); @@ -534,6 +538,13 @@ function tpl_button($type, $return = false) { * * @author Adrian Lang * @see tpl_get_action + * + * @param string $type + * @param string $pre prefix of link + * @param string $suf suffix of link + * @param string $inner innerHML of link + * @param bool $return + * @return bool|string html or false if no data, true if printed */ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = false) { global $lang; @@ -571,7 +582,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; @@ -599,6 +610,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals * @author Andreas Gohr * @author Matthias Grimm * @author Adrian Lang + * * @param string $type * @return array|bool|string */ @@ -757,20 +769,20 @@ function tpl_get_action($type) { * * @author Anika Henke * @param - * @param bool $link link or form button? - * @param bool $wrapper HTML element wrapper - * @param bool $return return or print - * @param string $pre prefix for links - * @param string $suf suffix for links - * @param string $inner inner HTML for links + * @param bool $link link or form button? + * @param string|bool $wrapper HTML element wrapper + * @param bool $return return or print + * @param string $pre prefix for links + * @param string $suf suffix for links + * @param string $inner inner HTML for links * @return bool|string */ 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"; @@ -1029,7 +1041,7 @@ function tpl_pagetitle($id = null, $ret = false) { * @author Andreas Gohr * @param array $tags 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 + * @param null|string $src the image src, uses global $SRC if not given * @return string */ function tpl_img_getTag($tags, $alt = '', $src = null) { @@ -1613,6 +1625,11 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = * * This function is useful to populate sidebars or similar features in a * template + * + * @param string $pageid + * @param bool $print + * @param bool $propagate + * @return bool|null|string */ function tpl_include_page($pageid, $print = true, $propagate = false) { if (!$pageid) return false; -- cgit v1.2.3 From 59bc3b48fdffb76ee65a4b630be3ffa1f6c20c80 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Mon, 29 Sep 2014 21:45:27 +0200 Subject: more scrutinizer issue improvements --- inc/template.php | 1 - 1 file changed, 1 deletion(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 667e3db1c..49f6986fd 100644 --- a/inc/template.php +++ b/inc/template.php @@ -759,7 +759,6 @@ function tpl_get_action($type) { break; default: return '[unknown %s type]'; - break; } return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement'); } -- cgit v1.2.3 From 42ea7f447f39fbc2f79eaaec31f8c10ede59c5d0 Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 1 Oct 2014 11:30:27 +0200 Subject: Many PHPDocs, some unused and dyn declared vars many PHPDocs some unused variables some dynamically declared variables declared --- inc/template.php | 59 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 49f6986fd..98ea9df82 100644 --- a/inc/template.php +++ b/inc/template.php @@ -68,6 +68,7 @@ function tpl_basedir($tpl='') { * handled by this function. ACL stuff is not done here either. * * @author Andreas Gohr + * * @triggers TPL_ACT_RENDER * @triggers TPL_CONTENT_DISPLAY * @param bool $prependTOC should the TOC be displayed here? @@ -186,6 +187,7 @@ function tpl_content_core() { * a false argument * * @author Andreas Gohr + * * @param bool $return Should the TOC be returned instead to be printed? * @return string */ @@ -243,6 +245,8 @@ function tpl_toc($return = false) { * Handle the admin page contents * * @author Andreas Gohr + * + * @return bool */ function tpl_admin() { global $INFO; @@ -277,6 +281,7 @@ function tpl_admin() { * This has to go into the head section of your template. * * @author Andreas Gohr + * * @triggers TPL_METAHEADER_OUTPUT * @param bool $alt Should feeds and alternative format links be added? * @return bool @@ -426,10 +431,12 @@ function tpl_metaheaders($alt = true) { * instances. Attributes are given as key value pairs. Values will be HTML * encoded automatically so they should be provided as is in the $data array. * - * For tags having a body attribute specify the the body data in the special + * For tags having a body attribute specify the body data in the special * attribute '_data'. This field will NOT BE ESCAPED automatically. * * @author Andreas Gohr + * + * @param array $data */ function _tpl_metaheaders_action($data) { foreach($data as $tag => $inst) { @@ -456,6 +463,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 return html + * @return bool|string html or true */ function tpl_link($url, $name, $more = '', $return = false) { $out = ' + * + * @param string $id page id + * @param string|null $name the name of the link + * @return bool */ function tpl_pagelink($id, $name = null) { print ''.html_wikilink($id, $name).''; @@ -485,6 +502,9 @@ function tpl_pagelink($id, $name = null) { * returns false if none is available * * @author Andreas Gohr + * + * @param string $id page id + * @return false|string */ function tpl_getparent($id) { $parent = getNS($id).':'; @@ -539,7 +559,7 @@ function tpl_button($type, $return = false) { * @author Adrian Lang * @see tpl_get_action * - * @param string $type + * @param string $type action command * @param string $pre prefix of link * @param string $suf suffix of link * @param string $inner innerHML of link @@ -767,7 +787,8 @@ function tpl_get_action($type) { * Wrapper around tpl_button() and tpl_actionlink() * * @author Anika Henke - * @param + * + * @param string $type action command * @param bool $link link or form button? * @param string|bool $wrapper HTML element wrapper * @param bool $return return or print @@ -801,6 +822,7 @@ function tpl_action($type, $link = false, $wrapper = false, $return = false, $pr * autocompletion feature (MSIE and Firefox) * * @author Andreas Gohr + * * @param bool $ajax * @param bool $autocomplete * @return bool @@ -829,6 +851,7 @@ function tpl_searchform($ajax = true, $autocomplete = true) { * Print the breadcrumbs trace * * @author Andreas Gohr + * * @param string $sep Separator between entries * @return bool */ @@ -870,6 +893,7 @@ function tpl_breadcrumbs($sep = '•') { * @author Sean Coates * @author * @todo May behave strangely in RTL languages + * * @param string $sep Separator between entries * @return bool */ @@ -920,6 +944,7 @@ function tpl_youarehere($sep = ' » ') { * Could be enhanced with a profile link in future? * * @author Andreas Gohr + * * @return bool */ function tpl_userinfo() { @@ -938,6 +963,7 @@ function tpl_userinfo() { * Print some info about the current page * * @author Andreas Gohr + * * @param bool $ret return content instead of printing it * @return bool|string */ @@ -1001,6 +1027,7 @@ function tpl_pageinfo($ret = false) { * the given ID is used. * * @author Andreas Gohr + * * @param string $id page id * @param bool $ret return content instead of printing * @return bool|string @@ -1038,6 +1065,7 @@ function tpl_pagetitle($id = null, $ret = false) { * Only allowed in: detail.php * * @author Andreas Gohr + * * @param array $tags tags to try * @param string $alt alternative output if no data was found * @param null|string $src the image src, uses global $SRC if not given @@ -1128,7 +1156,7 @@ function tpl_get_img_meta() { * @param $maxheight int - maximal height of the image * @param $link bool - link to the orginal size? * @param $params array - additional image attributes - * @return mixed Result of TPL_IMG_DISPLAY + * @return bool Result of TPL_IMG_DISPLAY */ function tpl_img($maxwidth = 0, $maxheight = 0, $link = true, $params = null) { global $IMG; @@ -1280,6 +1308,9 @@ function tpl_loadConfig() { * tpl_getLang($id) * * use this function to access template language variables + * + * @param string $id key of language string + * @return string */ function tpl_getLang($id) { static $lang = array(); @@ -1311,6 +1342,9 @@ function tpl_locale_xhtml($id) { /** * Prepends appropriate path for a language dependent filename + * + * @param string $id id of localized text + * @return string wiki text */ function tpl_localeFN($id) { $path = tpl_incdir().'lang/'; @@ -1337,6 +1371,8 @@ 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') { @@ -1511,6 +1547,9 @@ function tpl_mediaTree() { * Note: this will not use any pretty URLs * * @author Andreas Gohr + * + * @param string $empty empty option label + * @param string $button submit button label */ function tpl_actiondropdown($empty = '', $button = '>') { global $ID; @@ -1737,10 +1776,11 @@ function tpl_flush() { * If a given location starts with a colon it is assumed to be a media * file, otherwise it is assumed to be relative to the current template * - * @param array $search locations to look at - * @param bool $abs if to use absolute URL - * @param array &$imginfo filled with getimagesize() + * @param string[] $search locations to look at + * @param bool $abs if to use absolute URL + * @param array &$imginfo filled with getimagesize() * @return string + * * @author Andreas Gohr */ function tpl_getMediaFile($search, $abs = false, &$imginfo = null) { @@ -1791,6 +1831,8 @@ function tpl_getMediaFile($search, $abs = false, &$imginfo = null) { * * @author Anika Henke * @author Andreas Gohr + * + * @param string $file */ function tpl_includeFile($file) { global $config_cascade; @@ -1816,6 +1858,7 @@ function tpl_includeFile($file) { * Returns tag for various icon types (favicon|mobile|generic) * * @author Anika Henke + * * @param array $types - list of icon types to display (favicon|mobile|generic) * @return string */ @@ -1891,6 +1934,8 @@ function tpl_media() { * Return useful layout classes * * @author Anika Henke + * + * @return string */ function tpl_classes() { global $ACT, $conf, $ID, $INFO; -- cgit v1.2.3 From 7e8500eea1e53b1de0e0f70400664afa442cd08d Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Thu, 2 Oct 2014 14:55:24 +0200 Subject: PHPDocs and some improvements --- inc/template.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 98ea9df82..6bb6275f3 100644 --- a/inc/template.php +++ b/inc/template.php @@ -1066,8 +1066,8 @@ function tpl_pagetitle($id = null, $ret = false) { * * @author Andreas Gohr * - * @param array $tags tags to try - * @param string $alt alternative output if no data was found + * @param array|string $tags tags to try + * @param string $alt alternative output if no data was found * @param null|string $src the image src, uses global $SRC if not given * @return string */ -- cgit v1.2.3 From a85f63dedee1c8ddf15757e204a170bf000d89dc Mon Sep 17 00:00:00 2001 From: Gerrit Uitslag Date: Wed, 3 Dec 2014 00:09:04 +0100 Subject: code reformatting tpl_content_core() --- inc/template.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inc/template.php') diff --git a/inc/template.php b/inc/template.php index 31a65ce61..eb88732c4 100644 --- a/inc/template.php +++ b/inc/template.php @@ -170,8 +170,9 @@ function tpl_content_core() { break; default: $evt = new Doku_Event('TPL_ACT_UNKNOWN', $ACT); - if($evt->advise_before()) + if($evt->advise_before()) { msg("Failed to handle command: ".hsc($ACT), -1); + } $evt->advise_after(); unset($evt); return false; -- cgit v1.2.3