summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php134
1 files changed, 105 insertions, 29 deletions
diff --git a/inc/template.php b/inc/template.php
index 7f3c68534..3bccb0bd8 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 <andi@splitbrain.org>
+ *
* @triggers TPL_ACT_RENDER
* @triggers TPL_CONTENT_DISPLAY
* @param bool $prependTOC should the TOC be displayed here?
@@ -170,8 +171,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;
@@ -186,6 +188,7 @@ function tpl_content_core() {
* a false argument
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param bool $return Should the TOC be returned instead to be printed?
* @return string
*/
@@ -204,7 +207,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 {
@@ -243,6 +246,8 @@ function tpl_toc($return = false) {
* Handle the admin page contents
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @return bool
*/
function tpl_admin() {
global $INFO;
@@ -277,6 +282,7 @@ function tpl_admin() {
* This has to go into the head section of your template.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @triggers TPL_METAHEADER_OUTPUT
* @param bool $alt Should feeds and alternative format links be added?
* @return bool
@@ -426,10 +432,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 <andi@splitbrain.org>
+ *
+ * @param array $data
*/
function _tpl_metaheaders_action($data) {
foreach($data as $tag => $inst) {
@@ -456,6 +464,12 @@ function _tpl_metaheaders_action($data) {
* Just builds a link.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @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 = '<a href="'.$url.'" ';
@@ -472,6 +486,10 @@ function tpl_link($url, $name, $more = '', $return = false) {
* Wrapper around html_wikilink
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id
+ * @param string|null $name the name of the link
+ * @return bool true
*/
function tpl_pagelink($id, $name = null) {
print '<bdi>'.html_wikilink($id, $name).'</bdi>';
@@ -485,6 +503,9 @@ function tpl_pagelink($id, $name = null) {
* returns false if none is available
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $id page id
+ * @return false|string
*/
function tpl_getparent($id) {
$parent = getNS($id).':';
@@ -503,6 +524,10 @@ function tpl_getparent($id) {
*
* @author Adrian Lang <mail@adrianlang.de>
* @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 +559,13 @@ function tpl_button($type, $return = false) {
*
* @author Adrian Lang <mail@adrianlang.de>
* @see tpl_get_action
+ *
+ * @param string $type action command
+ * @param string $pre prefix of link
+ * @param string $suf suffix of link
+ * @param string $inner innerHML of link
+ * @param bool $return if true it returns html, otherwise prints
+ * @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 +603,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 +631,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals
* @author Andreas Gohr <andi@splitbrain.org>
* @author Matthias Grimm <matthiasgrimm@users.sourceforge.net>
* @author Adrian Lang <mail@adrianlang.de>
+ *
* @param string $type
* @return array|bool|string
*/
@@ -747,7 +780,6 @@ function tpl_get_action($type) {
break;
default:
return '[unknown %s type]';
- break;
}
return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement');
}
@@ -756,21 +788,22 @@ function tpl_get_action($type) {
* Wrapper around tpl_button() and tpl_actionlink()
*
* @author Anika Henke <anika@selfthinker.org>
- * @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 string $type action command
+ * @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</$wrapper>";
@@ -790,6 +823,7 @@ function tpl_action($type, $link = false, $wrapper = false, $return = false, $pr
* autocompletion feature (MSIE and Firefox)
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param bool $ajax
* @param bool $autocomplete
* @return bool
@@ -818,6 +852,7 @@ function tpl_searchform($ajax = true, $autocomplete = true) {
* Print the breadcrumbs trace
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param string $sep Separator between entries
* @return bool
*/
@@ -859,6 +894,7 @@ function tpl_breadcrumbs($sep = '•') {
* @author Sean Coates <sean@caedmon.net>
* @author <fredrik@averpil.com>
* @todo May behave strangely in RTL languages
+ *
* @param string $sep Separator between entries
* @return bool
*/
@@ -909,6 +945,7 @@ function tpl_youarehere($sep = ' » ') {
* Could be enhanced with a profile link in future?
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @return bool
*/
function tpl_userinfo() {
@@ -927,6 +964,7 @@ function tpl_userinfo() {
* Print some info about the current page
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param bool $ret return content instead of printing it
* @return bool|string
*/
@@ -990,6 +1028,7 @@ function tpl_pageinfo($ret = false) {
* the given ID is used.
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
* @param string $id page id
* @param bool $ret return content instead of printing
* @return bool|string
@@ -1027,9 +1066,10 @@ function tpl_pagetitle($id = null, $ret = false) {
* Only allowed in: detail.php
*
* @author Andreas Gohr <andi@splitbrain.org>
- * @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 array|string $tags tag or array of 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
*/
function tpl_img_getTag($tags, $alt = '', $src = null) {
@@ -1117,12 +1157,13 @@ 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;
/** @var Input $INPUT */
global $INPUT;
+ global $REV;
$w = tpl_img_getTag('File.Width');
$h = tpl_img_getTag('File.Height');
@@ -1147,8 +1188,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');
@@ -1269,21 +1310,37 @@ 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();
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($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];
}
@@ -1300,11 +1357,14 @@ 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/';
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)){
@@ -1326,6 +1386,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 <andi@splitbrain.org>
*/
function tpl_mediaContent($fromajax = false, $sort='natural') {
@@ -1500,6 +1562,9 @@ function tpl_mediaTree() {
* Note: this will not use any pretty URLs
*
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $empty empty option label
+ * @param string $button submit button label
*/
function tpl_actiondropdown($empty = '', $button = '&gt;') {
global $ID;
@@ -1613,6 +1678,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;
@@ -1721,10 +1791,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 <andi@splitbrain.org>
*/
function tpl_getMediaFile($search, $abs = false, &$imginfo = null) {
@@ -1775,6 +1846,8 @@ function tpl_getMediaFile($search, $abs = false, &$imginfo = null) {
*
* @author Anika Henke <anika@selfthinker.org>
* @author Andreas Gohr <andi@splitbrain.org>
+ *
+ * @param string $file
*/
function tpl_includeFile($file) {
global $config_cascade;
@@ -1800,6 +1873,7 @@ function tpl_includeFile($file) {
* Returns <link> tag for various icon types (favicon|mobile|generic)
*
* @author Anika Henke <anika@selfthinker.org>
+ *
* @param array $types - list of icon types to display (favicon|mobile|generic)
* @return string
*/
@@ -1875,6 +1949,8 @@ function tpl_media() {
* Return useful layout classes
*
* @author Anika Henke <anika@selfthinker.org>
+ *
+ * @return string
*/
function tpl_classes() {
global $ACT, $conf, $ID, $INFO;