diff options
Diffstat (limited to 'inc/template.php')
-rw-r--r-- | inc/template.php | 94 |
1 files changed, 74 insertions, 20 deletions
diff --git a/inc/template.php b/inc/template.php index b8129f914..ea73b01b6 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 <andi@splitbrain.org> + * @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 <andi@splitbrain.org> + * @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'].'/'; } @@ -468,7 +472,7 @@ function tpl_link($url, $name, $more = '', $return = false) { * @author Andreas Gohr <andi@splitbrain.org> */ function tpl_pagelink($id, $name = null) { - print html_wikilink($id, $name); + print '<bdi>'.html_wikilink($id, $name).'</bdi>'; return true; } @@ -541,6 +545,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals * @var string $accesskey * @var string $id * @var string $method + * @var bool $nofollow * @var array $params */ extract($data); @@ -555,10 +560,11 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals $akey = 'accesskey="'.$accesskey.'" '; $addTitle = ' ['.strtoupper($accesskey).']'; } + $rel = $nofollow ? 'rel="nofollow" ' : ''; $out = tpl_link( $linktarget, $pre.(($inner) ? $inner : $caption).$suf, 'class="action '.$type.'" '. - $akey.'rel="nofollow" '. + $akey.$rel. 'title="'.hsc($caption).$addTitle.'"', 1 ); } @@ -595,6 +601,7 @@ function tpl_get_action($type) { global $INFO; global $REV; global $ACT; + global $conf; // check disabled actions and fix the badly named ones if($type == 'history') $type = 'revisions'; @@ -604,6 +611,7 @@ function tpl_get_action($type) { $id = $ID; $method = 'get'; $params = array('do' => $type); + $nofollow = true; switch($type) { case 'edit': // most complicated type - we need to decide on current action @@ -641,6 +649,10 @@ function tpl_get_action($type) { break; case 'index': $accesskey = 'x'; + // allow searchbots to get to the sitemap from the homepage (when dokuwiki isn't providing a sitemap.xml) + if ($conf['start'] == $ID && !$conf['sitemap']) { + $nofollow = false; + } break; case 'top': $accesskey = 't'; @@ -711,7 +723,7 @@ function tpl_get_action($type) { return '[unknown %s type]'; break; } - return compact('accesskey', 'type', 'id', 'method', 'params'); + return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow'); } /** @@ -764,7 +776,7 @@ function tpl_searchform($ajax = true, $autocomplete = true) { // don't print the search form if search action has been disabled if(!actionOK('search')) return false; - print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search" method="get"><div class="no">'; + print '<form action="'.wl().'" accept-charset="utf-8" class="search" id="dw__search" method="get" role="search"><div class="no">'; print '<input type="hidden" name="do" value="search" />'; print '<input type="text" '; if($ACT == 'search') print 'value="'.htmlspecialchars($QUERY).'" '; @@ -792,13 +804,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 = ' ‏<span class="bcsep">'.$sep.'</span>‏ '; - } else { - $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; - } + $crumbs_sep = ' <span class="bcsep">'.$sep.'</span> '; //render crumbs, highlight the last one print '<span class="bchead">'.$lang['breadcrumb'].':</span>'; @@ -808,7 +814,9 @@ function tpl_breadcrumbs($sep = '•') { $i++; echo $crumbs_sep; if($i == $last) print '<span class="curid">'; + print '<bdi>'; tpl_link(wl($id), hsc($name), 'class="breadcrumbs" title="'.$id.'"'); + print '</bdi>'; if($i == $last) print '</span>'; } return true; @@ -881,7 +889,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'].': <bdi>'.hsc($INFO['userinfo']['name']).'</bdi> (<bdi>'.hsc($_SERVER['REMOTE_USER']).'</bdi>)'; return true; } return false; @@ -920,14 +928,14 @@ function tpl_pageinfo($ret = false) { // print it if($INFO['exists']) { $out = ''; - $out .= $fn; + $out .= '<bdi>'.$fn.'</bdi>'; $out .= ' · '; $out .= $lang['lastmod']; $out .= ': '; $out .= $date; if($INFO['editor']) { $out .= ' '.$lang['by'].' '; - $out .= editorinfo($INFO['editor']); + $out .= '<bdi>'.editorinfo($INFO['editor']).'</bdi>'; } else { $out .= ' ('.$lang['external_edit'].')'; } @@ -935,7 +943,7 @@ function tpl_pageinfo($ret = false) { $out .= ' · '; $out .= $lang['lockedby']; $out .= ': '; - $out .= editorinfo($INFO['locked']); + $out .= '<bdi>'.editorinfo($INFO['locked']).'</bdi>'; } if($ret) { return $out; @@ -1185,6 +1193,34 @@ function tpl_getLang($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_localeFN($id)); +} + +/** + * Prepends appropriate path for a language dependent filename + */ +function tpl_localeFN($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 * * Depending on the user's actions this may be a list of @@ -1461,8 +1497,8 @@ function tpl_license($img = 'badge', $imgonly = false, $return = false, $wrap = } if(!$imgonly) { $out .= $lang['license'].' '; - $out .= '<a href="'.$lic['url'].'" rel="license" class="urlextern"'.$target; - $out .= '>'.$lic['name'].'</a>'; + $out .= '<bdi><a href="'.$lic['url'].'" rel="license" class="urlextern"'.$target; + $out .= '>'.$lic['name'].'</a></bdi>'; } if($wrap) $out .= '</div>'; @@ -1746,5 +1782,23 @@ function tpl_media() { echo '</div>'.NL; } +/** + * Return useful layout classes + * + * @author Anika Henke <anika@selfthinker.org> + */ +function tpl_classes() { + global $ACT, $conf, $ID, $INFO; + $classes = array( + 'dokuwiki', + 'mode_'.$ACT, + 'tpl_'.$conf['template'], + $_SERVER['REMOTE_USER'] ? 'loggedIn' : '', + $INFO['exists'] ? '' : 'notFound', + ($ID == $conf['start']) ? 'home' : '', + ); + return join(' ', $classes); +} + //Setup VIM: ex: et ts=4 : |