diff options
author | lisps <stummp@loewen.de> | 2014-03-19 08:07:16 +0100 |
---|---|---|
committer | lisps <stummp@loewen.de> | 2014-03-19 08:07:16 +0100 |
commit | e310313d794a3336d279ee09973508e794dbf08e (patch) | |
tree | 7f90b51d344f7163c6fbb109f04ff22dea5ae129 /inc/template.php | |
parent | cdb5e9613f7c4b1be4515715652aca451493d5d5 (diff) | |
parent | 177ef92c4ddd38cb906dd7d5f0208c698048cd57 (diff) | |
download | rpg-e310313d794a3336d279ee09973508e794dbf08e.tar.gz rpg-e310313d794a3336d279ee09973508e794dbf08e.tar.bz2 |
Merge remote-tracking branch 'remotes/origin/master' into revisions_local
Diffstat (limited to 'inc/template.php')
-rw-r--r-- | inc/template.php | 148 |
1 files changed, 125 insertions, 23 deletions
diff --git a/inc/template.php b/inc/template.php index d98a66ebc..2cb6d3da8 100644 --- a/inc/template.php +++ b/inc/template.php @@ -154,7 +154,7 @@ function tpl_content_core() { html_resendpwd(); break; case 'denied': - print p_locale_xhtml('denied'); + html_denied(); break; case 'profile' : html_updateprofile(); @@ -210,7 +210,7 @@ function tpl_toc($return = false) { } else { $tocok = true; } - $toc = $meta['description']['tableofcontents']; + $toc = isset($meta['description']['tableofcontents']) ? $meta['description']['tableofcontents'] : null; if(!$tocok || !is_array($toc) || !$conf['tocminheads'] || count($toc) < $conf['tocminheads']) { $toc = array(); } @@ -291,6 +291,8 @@ function tpl_metaheaders($alt = true) { global $lang; global $conf; global $updateVersion; + /** @var Input $INPUT */ + global $INPUT; // prepare the head array $head = array(); @@ -401,7 +403,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'] && !empty($_SERVER['REMOTE_USER'])) { + if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { $script .= "var SIG='".toolbar_signature()."';"; } $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; @@ -548,6 +550,7 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals * @var string $method * @var bool $nofollow * @var array $params + * @var string $replacement */ extract($data); if(strpos($id, '#') === 0) { @@ -556,6 +559,9 @@ function tpl_actionlink($type, $pre = '', $suf = '', $inner = '', $return = fals $linktarget = wl($id, $params); } $caption = $lang['btn_'.$type]; + if(strpos($caption, '%s')){ + $caption = sprintf($caption, $replacement); + } $akey = $addTitle = ''; if($accesskey) { $akey = 'accesskey="'.$accesskey.'" '; @@ -603,17 +609,20 @@ function tpl_get_action($type) { global $REV; global $ACT; global $conf; + /** @var Input $INPUT */ + global $INPUT; // 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; + $accesskey = null; + $id = $ID; + $method = 'get'; + $params = array('do' => $type); + $nofollow = true; + $replacement = ''; switch($type) { case 'edit': // most complicated type - we need to decide on current action @@ -637,7 +646,7 @@ function tpl_get_action($type) { $accesskey = 'v'; } } else { - $params = array(); + $params = array('do' => ''); $type = 'show'; $accesskey = 'v'; } @@ -658,7 +667,7 @@ function tpl_get_action($type) { break; case 'top': $accesskey = 't'; - $params = array(); + $params = array('do' => ''); $id = '#dokuwiki__top'; break; case 'back': @@ -667,12 +676,17 @@ function tpl_get_action($type) { return false; } $id = $parent; - $params = array(); + $params = array('do' => ''); $accesskey = 'b'; break; + case 'img_backto': + $params = array(); + $accesskey = 'b'; + $replacement = $ID; + break; case 'login': $params['sectok'] = getSecurityToken(); - if(isset($_SERVER['REMOTE_USER'])) { + if($INPUT->server->has('REMOTE_USER')) { if(!actionOK('logout')) { return false; } @@ -681,12 +695,12 @@ function tpl_get_action($type) { } break; case 'register': - if(!empty($_SERVER['REMOTE_USER'])) { + if($INPUT->server->str('REMOTE_USER')) { return false; } break; case 'resendpwd': - if(!empty($_SERVER['REMOTE_USER'])) { + if($INPUT->server->str('REMOTE_USER')) { return false; } break; @@ -703,25 +717,40 @@ function tpl_get_action($type) { $params['sectok'] = getSecurityToken(); break; case 'subscribe': - if(!$_SERVER['REMOTE_USER']) { + if(!$INPUT->server->str('REMOTE_USER')) { return false; } break; case 'backlink': break; case 'profile': - if(!isset($_SERVER['REMOTE_USER'])) { + if(!$INPUT->server->has('REMOTE_USER')) { return false; } break; case 'media': $params['ns'] = getNS($ID); break; + case 'mediaManager': + // View image in media manager + global $IMG; + $imgNS = getNS($IMG); + $authNS = auth_quickaclcheck("$imgNS:*"); + if ($authNS < AUTH_UPLOAD) { + return false; + } + $params = array( + 'ns' => $imgNS, + 'image' => $IMG, + 'do' => 'media' + ); + //$type = 'media'; + break; default: return '[unknown %s type]'; break; } - return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow'); + return compact('accesskey', 'type', 'id', 'method', 'params', 'nofollow', 'replacement'); } /** @@ -885,9 +914,11 @@ function tpl_youarehere($sep = ' » ') { */ function tpl_userinfo() { global $lang; - global $INFO; - if(isset($_SERVER['REMOTE_USER'])) { - print $lang['loggedinas'].': <bdi>'.hsc($INFO['userinfo']['name']).'</bdi> (<bdi>'.hsc($_SERVER['REMOTE_USER']).'</bdi>)'; + /** @var Input $INPUT */ + global $INPUT; + + if($INPUT->server->str('REMOTE_USER')) { + print $lang['loggedinas'].': '.userlink(); return true; } return false; @@ -1017,6 +1048,67 @@ function tpl_img_getTag($tags, $alt = '', $src = null) { } /** + * Returns a description list of the metatags of the current image + * + * @return string html of description list + */ +function tpl_img_meta() { + global $lang; + + $tags = tpl_get_img_meta(); + + echo '<dl>'; + foreach($tags as $tag) { + $label = $lang[$tag['langkey']]; + if(!$label) $label = $tag['langkey']; + + echo '<dt>'.$label.':</dt><dd>'; + if ($tag['type'] == 'date') { + echo dformat($tag['value']); + } else { + echo hsc($tag['value']); + } + echo '</dd>'; + } + echo '</dl>'; +} + +/** + * Returns metadata as configured in mediameta config file, ready for creating html + * + * @return array with arrays containing the entries: + * - string langkey key to lookup in the $lang var, if not found printed as is + * - string type type of value + * - string value tag value (unescaped) + */ +function tpl_get_img_meta() { + + $config_files = getConfigFiles('mediameta'); + foreach ($config_files as $config_file) { + if(@file_exists($config_file)) { + include($config_file); + } + } + /** @var array $fields the included array with metadata */ + + $tags = array(); + foreach($fields as $tag){ + $t = array(); + if (!empty($tag[0])) { + $t = array($tag[0]); + } + if(is_array($tag[3])) { + $t = array_merge($t,$tag[3]); + } + $value = tpl_img_getTag($t); + if ($value) { + $tags[] = array('langkey' => $tag[1], 'type' => $tag[2], 'value' => $value); + } + } + return $tags; +} + +/** * Prints the image with a link to the full sized version * * Only allowed in: detail.php @@ -1030,6 +1122,7 @@ function tpl_img_getTag($tags, $alt = '', $src = null) { */ 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'); @@ -1243,6 +1336,7 @@ function tpl_mediaContent($fromajax = false, $sort='natural') { global $INUSE; global $NS; global $JUMPTO; + /** @var Input $INPUT */ global $INPUT; $do = $INPUT->extract('do')->str('do'); @@ -1292,6 +1386,7 @@ function tpl_mediaFileList() { global $NS; global $JUMPTO; global $lang; + /** @var Input $INPUT */ global $INPUT; $opened_tab = $INPUT->str('tab_files'); @@ -1332,7 +1427,9 @@ function tpl_mediaFileList() { * @author Kate Arzamastseva <pshns@ukr.net> */ function tpl_mediaFileDetails($image, $rev) { - global $AUTH, $NS, $conf, $DEL, $lang, $INPUT; + global $AUTH, $NS, $conf, $DEL, $lang; + /** @var Input $INPUT */ + global $INPUT; $removed = (!file_exists(mediaFN($image)) && file_exists(mediaMetaFN($image, '.changes')) && $conf['mediarevisions']); if(!$image || (!file_exists(mediaFN($image)) && !$removed) || $DEL) return; @@ -1410,12 +1507,14 @@ function tpl_actiondropdown($empty = '', $button = '>') { global $ID; global $REV; global $lang; + /** @var Input $INPUT */ + global $INPUT; echo '<form action="'.script().'" method="get" accept-charset="utf-8">'; echo '<div class="no">'; echo '<input type="hidden" name="id" value="'.$ID.'" />'; if($REV) echo '<input type="hidden" name="rev" value="'.$REV.'" />'; - if (!empty($_SERVER['REMOTE_USER'])) { + if ($INPUT->server->str('REMOTE_USER')) { echo '<input type="hidden" name="sectok" value="'.getSecurityToken().'" />'; } @@ -1781,11 +1880,14 @@ function tpl_media() { */ function tpl_classes() { global $ACT, $conf, $ID, $INFO; + /** @var Input $INPUT */ + global $INPUT; + $classes = array( 'dokuwiki', 'mode_'.$ACT, 'tpl_'.$conf['template'], - !empty($_SERVER['REMOTE_USER']) ? 'loggedIn' : '', + $INPUT->server->bool('REMOTE_USER') ? 'loggedIn' : '', $INFO['exists'] ? '' : 'notFound', ($ID == $conf['start']) ? 'home' : '', ); |