diff options
Diffstat (limited to 'inc')
-rw-r--r-- | inc/lang/en/lang.php | 4 | ||||
-rw-r--r-- | inc/template.php | 98 |
2 files changed, 94 insertions, 8 deletions
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index cbdef8661..e945341d7 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -52,6 +52,8 @@ $lang['btn_register'] = 'Register'; $lang['btn_apply'] = 'Apply'; $lang['btn_media'] = 'Media Manager'; $lang['btn_deleteuser'] = 'Remove My Account'; +$lang['btn_img_backto'] = 'Back to %s'; +$lang['btn_mediaManager'] = 'View in media manager'; $lang['loggedinas'] = 'Logged in as'; $lang['user'] = 'Username'; @@ -253,7 +255,6 @@ $lang['admin_register'] = 'Add new user'; $lang['metaedit'] = 'Edit Metadata'; $lang['metasaveerr'] = 'Writing metadata failed'; $lang['metasaveok'] = 'Metadata saved'; -$lang['img_backto'] = 'Back to'; $lang['img_title'] = 'Title'; $lang['img_caption'] = 'Caption'; $lang['img_date'] = 'Date'; @@ -266,7 +267,6 @@ $lang['img_camera'] = 'Camera'; $lang['img_keywords'] = 'Keywords'; $lang['img_width'] = 'Width'; $lang['img_height'] = 'Height'; -$lang['img_manager'] = 'View in media manager'; $lang['subscr_subscribe_success'] = 'Added %s to subscription list for %s'; $lang['subscr_subscribe_error'] = 'Error adding %s to subscription list for %s'; diff --git a/inc/template.php b/inc/template.php index 0a6a9e4aa..aa3c658a8 100644 --- a/inc/template.php +++ b/inc/template.php @@ -548,6 +548,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 +557,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.'" '; @@ -609,11 +613,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 @@ -670,6 +675,11 @@ function tpl_get_action($type) { $params = array(); $accesskey = 'b'; break; + case 'img_backto': + $params = array(); + $accesskey = 'b'; + $replacement = $ID; + break; case 'login': $params['sectok'] = getSecurityToken(); if(isset($_SERVER['REMOTE_USER'])) { @@ -717,11 +727,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'); } /** @@ -1017,6 +1042,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 |