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

Last change on this file since 27645 was 27645, checked in by sarybe, 10 years ago
File size: 3.7 KB
RevLine 
[27645]1<?php
2
3class Thumbnail_Tooltip_IMG {
4  var $plugin_name, $plugin_path, $plugin_url;
5  var $my_config;
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);
12  }
13
14  function initialize_event_handler() {
15    add_event_handler('loc_end_index_thumbnails', array($this, 'thumbnail_tooltip_affich'), 50, 2);
16  }
17
18  function thumbnail_tooltip_affich($tpl_var) {
19    global $user;
20     
21          $query = '
22                SELECT param, value, comment
23                FROM ' . CONFIG_TABLE . '
24                WHERE param="thumbnail_tooltip"
25                ;';
26          $row = pwg_db_fetch_assoc( pwg_query($query) );
27 
28      $params = unserialize($row['value']);
29
30      $values = array(
31                  'DISPLAY_NAME'         => $params['display_name'],
32                  'value1'               => $params['value1'],
33                  'value2'               => $params['value2'],
34                  'value3'               => $params['value3'],
35                  'value4'               => $params['value4'],
36                  'value5'               => $params['value5'],
37                  'value6'               => $params['value6'],
38                  'separator'            => $params['separator']
39      );
40         
41    foreach($tpl_var as $cle=>$valeur) {
42      $query = "
43                SELECT name AS value1, hit AS value2, hit AS value3, comment AS value4, author AS value5, CONCAT('".l10n('Author').' : '."', author,'') AS value6, rating_score AS value7
44                FROM ".IMAGES_TABLE."
45                WHERE id = ".(int)$tpl_var[$cle]['id']."
46                ;";
47          $row = pwg_db_fetch_assoc( pwg_query($query) );
48
49      $details = array();
50      $details_param = array();
51         
52      $details['tn_type1'] = $row['value1'];
53
54      if (!empty($row['value2']))
55      {
56                $details['tn_type2'] = $row['value2'].' '.strtolower(l10n('Visits'));
57      }
58          if (!empty($row['value3']))
59      {
60                $details['tn_type3'] = '('.$row['value3'].' '.strtolower(l10n('Visits')).')';
61            if (!empty($row['value7'])) { $type8 = ', '.strtolower(l10n('Rating score')).' '.$row['value7']; } else { $type8 = ''; }
62                $details['tn_type8'] = '('.$row['value3'].' '.strtolower(l10n('Visits')).$type8.')';
63          }
64      if (!empty($row['value4']))
65      {
66                $details['tn_type4'] = $row['value4'];
67      }
68      if (!empty($row['value5']))
69      {
70                $details['tn_type5'] = $row['value5'];
71      }
72      if (!empty($row['value6']))
73      {
74                $details['tn_type6'] = $row['value6'];
75      }
76      if (!empty($row['value7']))
77      {
78                $details['tn_type7'] = strtolower(l10n('Rating score')).' '.$row['value7'];
79      }
80                 
81          if ((!empty($details[$values['value1']])) && ($details[$values['value1']]!='none')) { $details_param[] = $details[$values['value1']]; }
82          if ((!empty($details[$values['value2']])) && ($details[$values['value2']]!='none')) { $details_param[] = $details[$values['value2']]; }
83          if ((!empty($details[$values['value3']])) && ($details[$values['value3']]!='none')) { $details_param[] = $details[$values['value3']]; }
84          if ((!empty($details[$values['value4']])) && ($details[$values['value4']]!='none')) { $details_param[] = $details[$values['value4']]; }
85          if ((!empty($details[$values['value5']])) && ($details[$values['value5']]!='none')) { $details_param[] = $details[$values['value5']]; }
86          if ((!empty($details[$values['value6']])) && ($details[$values['value6']]!='none')) { $details_param[] = $details[$values['value6']]; }
87         
88          if ($params['separator']=='1') { $title = implode(' - ', $details_param); } else { $title = implode(' ', $details_param); }
89         
90          if ($params['display_name']==true) { $tpl_var[$cle]['TN_TITLE'] = $title; } else { $tpl_var[$cle]['TN_TITLE']=''; }
91    }
92    return $tpl_var;
93  }
94}
95?>
Note: See TracBrowser for help on using the repository browser.