Changeset 11996


Ignore:
Timestamp:
08/26/11 13:02:11 (8 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.

Location:
trunk/include
Files:
2 edited

Legend:

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

    r11981 r11996  
    105105      ); 
    106106 
     107  if (isset($nb_comments_of) ) 
     108  { 
     109    $row['nb_comments'] = (int)@$nb_comments_of[$row['id']]; 
     110  } 
     111 
    107112  $tpl_var = 
    108113    array( 
     
    167172  $tpl_var['NAME'] = $name; 
    168173 
    169   if ( isset($nb_comments_of) ) 
     174  if (isset($row['nb_comments'])) 
    170175  { 
    171     $tpl_var['NB_COMMENTS'] = (int)@$nb_comments_of[$row['id']]; 
     176    $tpl_var['NB_COMMENTS'] = $row['nb_comments']; 
    172177  } 
    173178 
  • 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.