Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feature 1729: rewrite function get_thumbnail_title to provide a compl…
…ete 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
  • Loading branch information
plegall committed Aug 26, 2011
1 parent cba3e53 commit 5861549
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 12 deletions.
9 changes: 7 additions & 2 deletions include/category_default.inc.php
Expand Up @@ -104,6 +104,11 @@
array('start')
);

if (isset($nb_comments_of) )
{
$row['nb_comments'] = (int)@$nb_comments_of[$row['id']];
}

$tpl_var =
array(
'ID' => $row['id'],
Expand Down Expand Up @@ -166,9 +171,9 @@

$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;
Expand Down
54 changes: 44 additions & 10 deletions include/functions.inc.php
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -847,6 +869,18 @@ function get_name_from_file($filename)
return str_replace('_',' ',get_filename_wo_extension($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
Expand Down

0 comments on commit 5861549

Please sign in to comment.