summaryrefslogtreecommitdiff
path: root/inc/template.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2014-03-16 21:23:50 +0100
committerAndreas Gohr <andi@splitbrain.org>2014-03-16 21:23:50 +0100
commite9ac0877f6c7eb3536f8f2b6b2a431c00de8fe4f (patch)
treef712964318d38d2935f2afe909326c6b1d1e4caa /inc/template.php
parentf10dcc4dcaefb086f27df5535c619073e0665b2e (diff)
parent5c19269483d61ba921eaf572252d976c15152924 (diff)
downloadrpg-e9ac0877f6c7eb3536f8f2b6b2a431c00de8fe4f.tar.gz
rpg-e9ac0877f6c7eb3536f8f2b6b2a431c00de8fe4f.tar.bz2
Merge pull request #573 from splitbrain/FS#2437detailphprefactor
refactor detail.php to template.php
Diffstat (limited to 'inc/template.php')
-rw-r--r--inc/template.php98
1 files changed, 92 insertions, 6 deletions
diff --git a/inc/template.php b/inc/template.php
index 1bf6b45b2..4b1188c95 100644
--- a/inc/template.php
+++ b/inc/template.php
@@ -550,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) {
@@ -558,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.'" ';
@@ -613,11 +617,12 @@ function tpl_get_action($type) {
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
@@ -674,6 +679,11 @@ function tpl_get_action($type) {
$params = array('do' => '');
$accesskey = 'b';
break;
+ case 'img_backto':
+ $params = array();
+ $accesskey = 'b';
+ $replacement = $ID;
+ break;
case 'login':
$params['sectok'] = getSecurityToken();
if($INPUT->server->has('REMOTE_USER')) {
@@ -721,11 +731,26 @@ function tpl_get_action($type) {
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');
}
/**
@@ -1024,6 +1049,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