summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorGerrit Uitslag <klapinklapin@gmail.com>2013-11-19 21:26:50 +0100
committerGerrit Uitslag <klapinklapin@gmail.com>2013-11-19 21:26:50 +0100
commit703aeaef1a43b07dc5497dba72c98151466396cc (patch)
tree1e18a6b3fc3c28156c2e56f8a3d515b8dd6a9cf9 /inc/template.php
parent33c3b3817b00aa9384760813643fac0e33daaaff (diff)
parent14b3007921f7b66fc9e3621b861a3c83e7e9093c (diff)
downloadrpg-703aeaef1a43b07dc5497dba72c98151466396cc.tar.gz
rpg-703aeaef1a43b07dc5497dba72c98151466396cc.tar.bz2
Merge remote-tracking branch 'origin/master' into diff_navigation
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php148
1 files changed, 93 insertions, 55 deletions
diff --git a/inc/template.php b/inc/template.php
index a87650b84..60e178d1a 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,11 +48,13 @@ 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;
- return DOKU_BASE.'lib/tpl/'.$conf['template'].'/';
+ if(!$tpl) $tpl = $conf['template'];
+ return DOKU_BASE.'lib/tpl/'.$tpl.'/';
}
/**
@@ -219,7 +223,7 @@ function tpl_toc($return = false) {
if(in_array($class, $pluginlist)) {
// attempt to load the plugin
/** @var $plugin DokuWiki_Admin_Plugin */
- $plugin =& plugin_load('admin', $class);
+ $plugin = plugin_load('admin', $class);
}
}
if( ($plugin !== null) && (!$plugin->forAdminOnly() || $INFO['isadmin']) ) {
@@ -253,7 +257,7 @@ function tpl_admin() {
if(in_array($class, $pluginlist)) {
// attempt to load the plugin
/** @var $plugin DokuWiki_Admin_Plugin */
- $plugin =& plugin_load('admin', $class);
+ $plugin = plugin_load('admin', $class);
}
}
@@ -286,17 +290,16 @@ function tpl_metaheaders($alt = true) {
global $QUERY;
global $lang;
global $conf;
+ global $updateVersion;
// prepare the head array
$head = array();
// prepare seed for js and css
- $tseed = 0;
+ $tseed = $updateVersion;
$depends = getConfigFiles('main');
- foreach($depends as $f) {
- $time = @filemtime($f);
- if($time > $tseed) $tseed = $time;
- }
+ foreach($depends as $f) $tseed .= @filemtime($f);
+ $tseed = md5($tseed);
// the usual stuff
$head['meta'][] = array('name'=> 'generator', 'content'=> 'DokuWiki');
@@ -315,11 +318,11 @@ function tpl_metaheaders($alt = true) {
if($alt) {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
- 'title'=> 'Recent Changes', 'href'=> DOKU_BASE.'feed.php'
+ 'title'=> $lang['btn_recent'], 'href'=> DOKU_BASE.'feed.php'
);
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
- 'title'=> 'Current Namespace',
+ 'title'=> $lang['currentns'],
'href' => DOKU_BASE.'feed.php?mode=list&ns='.$INFO['namespace']
);
if(($ACT == 'show' || $ACT == 'search') && $INFO['writable']) {
@@ -333,21 +336,21 @@ function tpl_metaheaders($alt = true) {
if($ACT == 'search') {
$head['link'][] = array(
'rel' => 'alternate', 'type'=> 'application/rss+xml',
- 'title'=> 'Search Result',
+ 'title'=> $lang['searchresult'],
'href' => DOKU_BASE.'feed.php?mode=search&q='.$QUERY
);
}
if(actionOK('export_xhtml')) {
$head['link'][] = array(
- 'rel' => 'alternate', 'type'=> 'text/html', 'title'=> 'Plain HTML',
+ 'rel' => 'alternate', 'type'=> 'text/html', 'title'=> $lang['plainhtml'],
'href'=> exportlink($ID, 'xhtml', '', false, '&')
);
}
if(actionOK('export_raw')) {
$head['link'][] = array(
- 'rel' => 'alternate', 'type'=> 'text/plain', 'title'=> 'Wiki Markup',
+ 'rel' => 'alternate', 'type'=> 'text/plain', 'title'=> $lang['wikimarkup'],
'href'=> exportlink($ID, 'raw', '', false, '&')
);
}
@@ -398,7 +401,7 @@ function tpl_metaheaders($alt = true) {
// make $INFO and other vars available to JavaScripts
$json = new JSON();
$script = "var NS='".$INFO['namespace']."';";
- if($conf['useacl'] && $_SERVER['REMOTE_USER']) {
+ if($conf['useacl'] && !empty($_SERVER['REMOTE_USER'])) {
$script .= "var SIG='".toolbar_signature()."';";
}
$script .= 'var JSINFO = '.$json->encode($JSINFO).';';
@@ -470,7 +473,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;
}
@@ -543,6 +546,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);
@@ -557,10 +561,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
);
}
@@ -597,15 +602,18 @@ 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';
+ if ($type == 'subscription') $type = 'subscribe';
if(!actionOK($type)) return false;
$accesskey = null;
$id = $ID;
$method = 'get';
$params = array('do' => $type);
+ $nofollow = true;
switch($type) {
case 'edit':
// most complicated type - we need to decide on current action
@@ -643,6 +651,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';
@@ -669,12 +681,12 @@ function tpl_get_action($type) {
}
break;
case 'register':
- if($_SERVER['REMOTE_USER']) {
+ if(!empty($_SERVER['REMOTE_USER'])) {
return false;
}
break;
case 'resendpwd':
- if($_SERVER['REMOTE_USER']) {
+ if(!empty($_SERVER['REMOTE_USER'])) {
return false;
}
break;
@@ -690,10 +702,6 @@ function tpl_get_action($type) {
$params['rev'] = $REV;
$params['sectok'] = getSecurityToken();
break;
- /** @noinspection PhpMissingBreakStatementInspection */
- case 'subscription':
- $type = 'subscribe';
- $params['do'] = 'subscribe';
case 'subscribe':
if(!$_SERVER['REMOTE_USER']) {
return false;
@@ -713,7 +721,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');
}
/**
@@ -766,7 +774,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).'" ';
@@ -794,13 +802,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 = ' &#8207;<span class="bcsep">'.$sep.'</span>&#8207; ';
- } 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>';
@@ -810,7 +812,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;
@@ -883,7 +887,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;
@@ -922,14 +926,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'].')';
}
@@ -937,7 +941,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;
@@ -1187,6 +1191,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
@@ -1199,7 +1231,7 @@ function tpl_getLang($id) {
* @param bool $fromajax - set true when calling this function via ajax
* @author Andreas Gohr <andi@splitbrain.org>
*/
-function tpl_mediaContent($fromajax = false) {
+function tpl_mediaContent($fromajax = false, $sort='natural') {
global $IMG;
global $AUTH;
global $INUSE;
@@ -1229,7 +1261,7 @@ function tpl_mediaContent($fromajax = false) {
if($do == 'filesinuse') {
media_filesinuse($INUSE, $IMG);
} elseif($do == 'filelist') {
- media_filelist($NS, $AUTH, $JUMPTO);
+ media_filelist($NS, $AUTH, $JUMPTO,false,$sort);
} elseif($do == 'searchlist') {
media_searchlist($INPUT->str('q'), $NS, $AUTH);
} else {
@@ -1377,7 +1409,7 @@ function tpl_actiondropdown($empty = '', $button = '&gt;') {
echo '<div class="no">';
echo '<input type="hidden" name="id" value="'.$ID.'" />';
if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />';
- if ($_SERVER['REMOTE_USER']) {
+ if (!empty($_SERVER['REMOTE_USER'])) {
echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />';
}
@@ -1463,8 +1495,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>';
@@ -1662,18 +1694,6 @@ function tpl_includeFile($file) {
}
/**
- * Returns icon from data/media root directory if it exists, otherwise
- * the one in the template's image directory.
- *
- * @deprecated Use tpl_getMediaFile() instead
- * @author Anika Henke <anika@selfthinker.org>
- */
-function tpl_getFavicon($abs = false, $fileName = 'favicon.ico') {
- $look = array(":wiki:$fileName", ":$fileName", "images/$fileName");
- return tpl_getMediaFile($look, $abs);
-}
-
-/**
* Returns <link> tag for various icon types (favicon|mobile|generic)
*
* @author Anika Henke <anika@selfthinker.org>
@@ -1748,5 +1768,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'],
+ !empty($_SERVER['REMOTE_USER']) ? 'loggedIn' : '',
+ $INFO['exists'] ? '' : 'notFound',
+ ($ID == $conf['start']) ? 'home' : '',
+ );
+ return join(' ', $classes);
+}
+
//Setup VIM: ex: et ts=4 :