source: extensions/ThumbnailTooltip/include/class.inc.php @ 31179

Last change on this file since 31179 was 31179, checked in by sarybe, 9 years ago

[ThumbnailTooltip] show/hide out of the loop

File size: 5.8 KB
RevLine 
[30100]1<?php
[31179]2
3class Thumbnail_Tooltip_IMG {
4  var $plugin_name, $plugin_path, $plugin_url;
[30100]5  var $my_config;
[31179]6 
7  function Thumbnail_Tooltip_IMG ($plugin_name, $plugin_path, $plugin_url) {
8    $this->plugin_name = $plugin_name;
9    $this->plugin_path = $plugin_path;
10    $this->plugin_url = $plugin_url;
11    $this->initialize_event_handler($plugin_name, $plugin_path, $plugin_url);
[30100]12  }
[31179]13 
14  function initialize_event_handler() {
15    add_event_handler('loc_end_index_thumbnails', array($this, 'thumbnail_tooltip_affich'), 50, 2);
16    add_event_handler('loc_end_index_category_thumbnails', array($this, 'Author_Description_affich'), 50, 2);
[30100]17  }
[31179]18 
19  function thumbnail_tooltip_affich($tpl_var) {
[30100]20    global $user;
[31179]21       
22        $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip"';
23               
[30100]24        $row = pwg_db_fetch_assoc( pwg_query($query) );
[31179]25        $params = unserialize($row['value']);
26        $values = array(
27        'DISPLAY_NAME'         => $params['display_name'],
28        'value1'               => $params['value1'],
29        'value2'               => $params['value2'],
30        'value3'               => $params['value3'],
31        'value4'               => $params['value4'],
32        'value5'               => $params['value5'],
33        'value6'               => $params['value6'],
34        'separator'            => $params['separator']
[30100]35        );
[31179]36       
37        if ($params['display_name']==true) {
38      foreach($tpl_var as $cle=>$valeur) {
39        $query = "SELECT name, hit, comment, author, rating_score, CONCAT(width, 'x', height) AS dimensions, filesize FROM ".IMAGES_TABLE."
40                  WHERE id = ".(int)$tpl_var[$cle]['id'].";";
41        $row = pwg_db_fetch_assoc( pwg_query($query) );
[30100]42        $details = array();
43        $details_param = array();
[30271]44        $details['tn_type1'] = str_replace('"', '\"', strip_tags($row['name']));
[31179]45               
[30100]46        if (!empty($row['hit'])) {
[31179]47          $details['tn_type2'] = $row['hit'].' '.strtolower(l10n('Visits'));
48          $details['tn_type3'] = '('.$row['hit'].' '.strtolower(l10n('Visits')).')';
49          if (!empty($row['rating_score'])) { $type8 = ', '.strtolower(l10n('Rating score')).' '.$row['rating_score']; } else { $type8 = ''; }
50          $details['tn_type8'] = '('.$row['hit'].' '.strtolower(l10n('Visits')).$type8.')';
[30100]51        }
52        if (!empty($row['comment'])) {
[31179]53          $details['tn_type4'] = str_replace('"', '\"', strip_tags($row['comment']));
[30100]54        }
55        if (!empty($row['author'])) {
[31179]56          $details['tn_type5'] = $row['author'];
[30100]57        }
58        if (!empty($row['author'])) {
[31179]59          $details['tn_type6'] = (preg_match('#(,|\/)#i', $row['author'])) ? str_replace(array('(',')'), '', ucfirst(l10n('author(s) : %s', $row['author']))) : l10n('Author').' : '.$row['author'];
[30100]60        }
61        if (!empty($row['rating_score'])) {
[31179]62          $details['tn_type7'] = strtolower(l10n('Rating score')).' '.$row['rating_score'];
[30100]63        }
64        if (!empty($row['dimensions'])) {
[31179]65          $details['tn_type9'] = l10n('Dimensions').' : '.$row['dimensions'];
[30100]66        }
[31179]67        if (!empty($row['filesize'])) {
68          if (($params['separator']=='1') && (!empty($details['tn_type9']))) { $details['tn_type9'].= ' - '; } elseif (($params['separator']!='1') && (!empty($details['tn_type9']))) { $details['tn_type9'].= ' '; } else { $details['tn_type9'] = ' '; } 
69          $details['tn_type9'].= l10n('Filesize').' : '.l10n('%d Kb', $row['filesize']); 
70        }
71               
72        if ((!empty($details[$values['value1']])) && ($details[$values['value1']]!='none')) { $details_param[] = $details[$values['value1']]; }
73        if ((!empty($details[$values['value2']])) && ($details[$values['value2']]!='none')) { $details_param[] = $details[$values['value2']]; }
74        if ((!empty($details[$values['value3']])) && ($details[$values['value3']]!='none')) { $details_param[] = $details[$values['value3']]; }
75        if ((!empty($details[$values['value4']])) && ($details[$values['value4']]!='none')) { $details_param[] = $details[$values['value4']]; }
76        if ((!empty($details[$values['value5']])) && ($details[$values['value5']]!='none')) { $details_param[] = $details[$values['value5']]; }
77        if ((!empty($details[$values['value6']])) && ($details[$values['value6']]!='none')) { $details_param[] = $details[$values['value6']]; } 
[30100]78        if ($params['separator']=='1') { $title = implode(' - ', $details_param); } else { $title = implode(' ', $details_param); }
[31179]79        $tpl_var[$cle]['TN_TITLE'] = $title;
80      }
81        }
82    else {
83      $tpl_var[$cle]['TN_TITLE'] = null;
84    }
85    return $tpl_var;
[30100]86  }
[31179]87 
88  function Author_Description_affich($tpl_var) {
[30100]89    global $user, $lang;
[31179]90       
91    $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip";';
92    $row = pwg_db_fetch_assoc( pwg_query($query) );
93    $params = unserialize($row['value']);
94    $values = array('DISPLAY_AUTHOR_CAT' => $params['display_author_cat']);
95               
96    if ($params['display_author_cat']==true) {
97          foreach($tpl_var as $cle=>$valeur) {
98            $query = "SELECT author FROM ".IMAGE_CATEGORY_TABLE." INNER JOIN ".IMAGES_TABLE." ON image_id = id WHERE category_id = ".(int)$tpl_var[$cle]['id']." AND author<>'' GROUP BY author";
99            $result = pwg_query($query);
100            $row = pwg_db_fetch_assoc($result); 
101            $auteur = '';
102                       
103            if (!empty($row['author'])) {
104              do {
105                $auteur .= $row['author'].', ';
106              } while ($row = pwg_db_fetch_assoc($result));
107                 
108              $auteur = substr($auteur, 0, -2);
109              if (preg_match('#(,|\/)#i', $auteur )) { $auteur = str_replace(array('(',')'), '', ucfirst(sprintf($lang['author(s) : %s'], $auteur))); } else { $auteur = $lang['Author'].' : '.$auteur ; }
110              if (!empty($tpl_var[$cle]['DESCRIPTION'])) { $tpl_var[$cle]['DESCRIPTION'] = $tpl_var[$cle]['DESCRIPTION'].'<br/>'.$auteur; } else { $tpl_var[$cle]['DESCRIPTION'] = $auteur; }
111            }
112      }
113    }
114    return $tpl_var;
115  }
[30100]116}
[31179]117?>
Note: See TracBrowser for help on using the repository browser.