summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php84
1 files changed, 56 insertions, 28 deletions
diff --git a/inc/template.php b/inc/template.php
index ae817985c..31a65ce61 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -369,7 +369,11 @@ function tpl_metaheaders($alt = true) {
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,nofollow');
}
- $head['link'][] = array('rel'=> 'canonical', 'href'=> wl($ID, '', true, '&'));
+ $canonicalUrl = wl($ID, '', true, '&');
+ if ($ID == $conf['start']) {
+ $canonicalUrl = DOKU_URL;
+ }
+ $head['link'][] = array('rel'=> 'canonical', 'href'=> $canonicalUrl);
} else {
$head['meta'][] = array('name'=> 'robots', 'content'=> 'noindex,follow');
}
@@ -381,13 +385,6 @@ function tpl_metaheaders($alt = true) {
// set metadata
if($ACT == 'show' || $ACT == 'export_xhtml') {
- // date of modification
- if($REV) {
- $head['meta'][] = array('name'=> 'date', 'content'=> date('Y-m-d\TH:i:sO', $REV));
- } else {
- $head['meta'][] = array('name'=> 'date', 'content'=> date('Y-m-d\TH:i:sO', $INFO['lastmod']));
- }
-
// keywords (explicit or implicit)
if(!empty($INFO['meta']['subject'])) {
$head['meta'][] = array('name'=> 'keywords', 'content'=> join(',', $INFO['meta']['subject']));
@@ -459,6 +456,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.'" ';
@@ -475,6 +478,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 link name
+ * @return bool true
*/
function tpl_pagelink($id, $name = null) {
print '<bdi>'.html_wikilink($id, $name).'</bdi>';
@@ -537,6 +544,13 @@ function tpl_button($type, $return = false) {
*
* @author Adrian Lang <mail@adrianlang.de>
* @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;
@@ -574,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;
@@ -750,7 +764,6 @@ function tpl_get_action($type) {
break;
default:
return '[unknown %s type]';
- break;
}
return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement');
}
@@ -771,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</$wrapper>";
@@ -836,7 +849,7 @@ function tpl_breadcrumbs($sep = '•') {
$crumbs_sep = ' <span class="bcsep">'.$sep.'</span> ';
//render crumbs, highlight the last one
- print '<span class="bchead">'.$lang['breadcrumb'].':</span>';
+ print '<span class="bchead">'.$lang['breadcrumb'].'</span>';
$last = count($crumbs);
$i = 0;
foreach($crumbs as $id => $name) {
@@ -876,7 +889,7 @@ function tpl_youarehere($sep = ' » ') {
$parts = explode(':', $ID);
$count = count($parts);
- echo '<span class="bchead">'.$lang['youarehere'].': </span>';
+ echo '<span class="bchead">'.$lang['youarehere'].' </span>';
// always print the startpage
echo '<span class="home">';
@@ -920,7 +933,7 @@ function tpl_userinfo() {
global $INPUT;
if($INPUT->server->str('REMOTE_USER')) {
- print $lang['loggedinas'].': '.userlink();
+ print $lang['loggedinas'].' '.userlink();
return true;
}
return false;
@@ -962,7 +975,7 @@ function tpl_pageinfo($ret = false) {
$out .= '<bdi>'.$fn.'</bdi>';
$out .= ' · ';
$out .= $lang['lastmod'];
- $out .= ': ';
+ $out .= ' ';
$out .= $date;
if($INFO['editor']) {
$out .= ' '.$lang['by'].' ';
@@ -973,7 +986,7 @@ function tpl_pageinfo($ret = false) {
if($INFO['locked']) {
$out .= ' · ';
$out .= $lang['lockedby'];
- $out .= ': ';
+ $out .= ' ';
$out .= '<bdi>'.editorinfo($INFO['locked']).'</bdi>';
}
if($ret) {
@@ -1030,7 +1043,7 @@ 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 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
@@ -1062,9 +1075,9 @@ function tpl_img_meta() {
echo '<dl>';
foreach($tags as $tag) {
$label = $lang[$tag['langkey']];
- if(!$label) $label = $tag['langkey'];
+ if(!$label) $label = $tag['langkey'] . ':';
- echo '<dt>'.$label.':</dt><dd>';
+ echo '<dt>'.$label.'</dt><dd>';
if ($tag['type'] == 'date') {
echo dformat($tag['value']);
} else {
@@ -1126,6 +1139,7 @@ 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');
@@ -1150,8 +1164,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');
@@ -1277,16 +1291,29 @@ 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];
}
@@ -1307,7 +1334,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 +1356,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 <andi@splitbrain.org>
*/
function tpl_mediaContent($fromajax = false, $sort='natural') {