aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2011-08-26 11:02:11 +0000
committerplegall <plg@piwigo.org>2011-08-26 11:02:11 +0000
commit5861549e51d5cbe9ef7b0f504d0ede06c8fcc676 (patch)
tree3a8ede6028a31d75fdbf891c467a6727a59fa91f /include
parentcba3e53a0405a9aeaa4301ce636e4cf333750c40 (diff)
feature 1729: rewrite function get_thumbnail_title to provide a complete tooltip
to the template file. It include the name of the photo, details such as number of visits, number of comments, rating score, and the description. git-svn-id: http://piwigo.org/svn/trunk@11996 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/category_default.inc.php9
-rw-r--r--include/functions.inc.php54
2 files changed, 51 insertions, 12 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index 40e5b6814..1133c2b00 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -104,6 +104,11 @@ foreach ($pictures as $row)
array('start')
);
+ if (isset($nb_comments_of) )
+ {
+ $row['nb_comments'] = (int)@$nb_comments_of[$row['id']];
+ }
+
$tpl_var =
array(
'ID' => $row['id'],
@@ -166,9 +171,9 @@ foreach ($pictures as $row)
$tpl_var['NAME'] = $name;
- if ( isset($nb_comments_of) )
+ if (isset($row['nb_comments']))
{
- $tpl_var['NB_COMMENTS'] = (int)@$nb_comments_of[$row['id']];
+ $tpl_var['NB_COMMENTS'] = $row['nb_comments'];
}
$tpl_thumbnails_var[] = $tpl_var;
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 09ac3b668..ae29267d7 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -782,25 +782,47 @@ function get_thumbnail_location($element_info)
return $path;
}
-/* returns the title of the thumnail */
-function get_thumbnail_title($element_info)
+/**
+ * returns the title of the thumbnail based on photo properties
+ */
+function get_thumbnail_title($info)
{
- // message in title for the thumbnail
- if (isset($element_info['file']))
+ global $conf, $user;
+
+ $title = get_picture_title($info);
+
+ $details = array();
+
+ if ($info['hit'] != 0)
{
- $thumbnail_title = $element_info['file'];
+ $details[] = $info['hit'].' '.strtolower(l10n('Visits'));
}
- else
+
+ if ($conf['rate'] and !empty($info['rating_score']))
+ {
+ $details[] = strtolower(l10n('Rating score')).' '.$info['rating_score'];
+ }
+
+ if (isset($info['nb_comments']) and $info['nb_comments'] != 0)
{
- $thumbnail_title = '';
+ $details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']);
}
- if (!empty($element_info['filesize']))
+ if (count($details) > 0)
{
- $thumbnail_title .= ' : '.sprintf(l10n('%d Kb'), $element_info['filesize']);
+ $title.= ' ('.implode(', ', $details).')';
}
- return $thumbnail_title;
+ if (!empty($info['comment']))
+ {
+ $title.= ' '.$info['comment'];
+ }
+
+ $title = strip_tags($title);
+
+ $title = trigger_event('get_thumbnail_title', $title, $info);
+
+ return $title;
}
/**
@@ -848,6 +870,18 @@ function get_name_from_file($filename)
}
/**
+ */
+function get_picture_title($info)
+{
+ if (isset($info['name']) and !empty($info['name']))
+ {
+ return $info['name'];
+ }
+
+ return get_name_from_file($info['file']);
+}
+
+/**
* returns the corresponding value from $lang if existing. Else, the key is
* returned
*