Ignore:
Timestamp:
Aug 26, 2011, 1:02:11 PM (13 years ago)
Author:
plg
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions.inc.php

    r11511 r11996  
    783783}
    784784
    785 /* returns the title of the thumnail */
    786 function get_thumbnail_title($element_info)
    787 {
    788   // message in title for the thumbnail
    789   if (isset($element_info['file']))
    790   {
    791     $thumbnail_title = $element_info['file'];
    792   }
    793   else
    794   {
    795     $thumbnail_title = '';
    796   }
    797 
    798   if (!empty($element_info['filesize']))
    799   {
    800     $thumbnail_title .= ' : '.sprintf(l10n('%d Kb'), $element_info['filesize']);
    801   }
    802 
    803   return $thumbnail_title;
     785/**
     786 * returns the title of the thumbnail based on photo properties
     787 */
     788function get_thumbnail_title($info)
     789{
     790  global $conf, $user;
     791
     792  $title = get_picture_title($info);
     793
     794  $details = array();
     795
     796  if ($info['hit'] != 0)
     797  {
     798    $details[] = $info['hit'].' '.strtolower(l10n('Visits'));
     799  }
     800
     801  if ($conf['rate'] and !empty($info['rating_score']))
     802  {
     803    $details[] = strtolower(l10n('Rating score')).' '.$info['rating_score'];
     804  }
     805
     806  if (isset($info['nb_comments']) and $info['nb_comments'] != 0)
     807  {
     808    $details[] = l10n_dec('%d comment', '%d comments', $info['nb_comments']);
     809  }
     810
     811  if (count($details) > 0)
     812  {
     813    $title.= ' ('.implode(', ', $details).')';
     814  }
     815
     816  if (!empty($info['comment']))
     817  {
     818    $title.= ' '.$info['comment'];
     819  }
     820
     821  $title = strip_tags($title);
     822
     823  $title = trigger_event('get_thumbnail_title', $title, $info);
     824
     825  return $title;
    804826}
    805827
     
    846868{
    847869  return str_replace('_',' ',get_filename_wo_extension($filename));
     870}
     871
     872/**
     873 */
     874function get_picture_title($info)
     875{
     876  if (isset($info['name']) and !empty($info['name']))
     877  {
     878    return $info['name'];
     879  }
     880
     881  return  get_name_from_file($info['file']);
    848882}
    849883
Note: See TracChangeset for help on using the changeset viewer.