[30100] | 1 | <?php |
---|
[27645] | 2 | |
---|
[30234] | 3 | class Thumbnail_Tooltip_IMG { |
---|
| 4 | var $plugin_name, $plugin_path, $plugin_url; |
---|
[30100] | 5 | var $my_config; |
---|
[27645] | 6 | |
---|
[30234] | 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 | } |
---|
| 13 | |
---|
[30234] | 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 | } |
---|
| 18 | |
---|
[30234] | 19 | function thumbnail_tooltip_affich($tpl_var) { |
---|
[30100] | 20 | global $user; |
---|
| 21 | |
---|
[30234] | 22 | $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip"'; |
---|
[30100] | 23 | $row = pwg_db_fetch_assoc( pwg_query($query) ); |
---|
| 24 | |
---|
[30234] | 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 | ); |
---|
| 36 | |
---|
| 37 | |
---|
[31176] | 38 | foreach($tpl_var as $cle=>$valeur) { |
---|
| 39 | if ($params['display_name']==true) { |
---|
[30234] | 40 | $query = " |
---|
| 41 | SELECT name, hit, comment, author, rating_score, CONCAT(width, 'x', height) AS dimensions, filesize FROM ".IMAGES_TABLE." |
---|
| 42 | WHERE id = ".(int)$tpl_var[$cle]['id']." |
---|
[30100] | 43 | ;"; |
---|
| 44 | $row = pwg_db_fetch_assoc( pwg_query($query) ); |
---|
| 45 | |
---|
| 46 | $details = array(); |
---|
| 47 | $details_param = array(); |
---|
| 48 | |
---|
[30271] | 49 | $details['tn_type1'] = str_replace('"', '\"', strip_tags($row['name'])); |
---|
[30100] | 50 | |
---|
| 51 | if (!empty($row['hit'])) { |
---|
| 52 | $details['tn_type2'] = $row['hit'].' '.strtolower(l10n('Visits')); |
---|
| 53 | $details['tn_type3'] = '('.$row['hit'].' '.strtolower(l10n('Visits')).')'; |
---|
| 54 | if (!empty($row['rating_score'])) { $type8 = ', '.strtolower(l10n('Rating score')).' '.$row['rating_score']; } else { $type8 = ''; } |
---|
| 55 | $details['tn_type8'] = '('.$row['hit'].' '.strtolower(l10n('Visits')).$type8.')'; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | if (!empty($row['comment'])) { |
---|
[30271] | 59 | $details['tn_type4'] = str_replace('"', '\"', strip_tags($row['comment'])); |
---|
[30100] | 60 | } |
---|
| 61 | |
---|
| 62 | if (!empty($row['author'])) { |
---|
| 63 | $details['tn_type5'] = $row['author']; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | if (!empty($row['author'])) { |
---|
| 67 | $details['tn_type6'] = (preg_match('#(,|\/)#i', $row['author'])) ? str_replace(array('(',')'), '', ucfirst(l10n('author(s) : %s', $row['author']))) : l10n('Author').' : '.$row['author']; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | if (!empty($row['rating_score'])) { |
---|
| 71 | $details['tn_type7'] = strtolower(l10n('Rating score')).' '.$row['rating_score']; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | if (!empty($row['dimensions'])) { |
---|
| 75 | $details['tn_type9'] = l10n('Dimensions').' : '.$row['dimensions']; |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | if (!empty($row['filesize'])) { |
---|
| 79 | 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'] = ' '; } |
---|
| 80 | $details['tn_type9'].= l10n('Filesize').' : '.l10n('%d Kb', $row['filesize']); |
---|
| 81 | } |
---|
[30234] | 82 | |
---|
| 83 | if ((!empty($details[$values['value1']])) && ($details[$values['value1']]!='none')) { $details_param[] = $details[$values['value1']]; } |
---|
| 84 | if ((!empty($details[$values['value2']])) && ($details[$values['value2']]!='none')) { $details_param[] = $details[$values['value2']]; } |
---|
| 85 | if ((!empty($details[$values['value3']])) && ($details[$values['value3']]!='none')) { $details_param[] = $details[$values['value3']]; } |
---|
| 86 | if ((!empty($details[$values['value4']])) && ($details[$values['value4']]!='none')) { $details_param[] = $details[$values['value4']]; } |
---|
| 87 | if ((!empty($details[$values['value5']])) && ($details[$values['value5']]!='none')) { $details_param[] = $details[$values['value5']]; } |
---|
| 88 | if ((!empty($details[$values['value6']])) && ($details[$values['value6']]!='none')) { $details_param[] = $details[$values['value6']]; } |
---|
[30100] | 89 | |
---|
| 90 | if ($params['separator']=='1') { $title = implode(' - ', $details_param); } else { $title = implode(' ', $details_param); } |
---|
| 91 | |
---|
[30234] | 92 | $tpl_var[$cle]['TN_TITLE'] = $title; |
---|
| 93 | } |
---|
[31176] | 94 | else |
---|
| 95 | { |
---|
| 96 | $tpl_var[$cle]['TN_TITLE'] = null; |
---|
| 97 | } |
---|
[30234] | 98 | } |
---|
| 99 | return $tpl_var; |
---|
[30100] | 100 | } |
---|
[30234] | 101 | |
---|
[30100] | 102 | |
---|
[30234] | 103 | function Author_Description_affich($tpl_var) { |
---|
[30100] | 104 | global $user, $lang; |
---|
| 105 | |
---|
[30234] | 106 | $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip";'; |
---|
[30100] | 107 | $row = pwg_db_fetch_assoc( pwg_query($query) ); |
---|
| 108 | |
---|
[30234] | 109 | $params = unserialize($row['value']); |
---|
[30100] | 110 | $values = array('DISPLAY_AUTHOR_CAT' => $params['display_author_cat']); |
---|
| 111 | |
---|
[30234] | 112 | if ($params['display_author_cat']==true) { |
---|
| 113 | foreach($tpl_var as $cle=>$valeur) { |
---|
| 114 | $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"; |
---|
| 115 | $result = pwg_query($query); |
---|
| 116 | $row = pwg_db_fetch_assoc($result); |
---|
[30100] | 117 | |
---|
| 118 | $auteur = ''; |
---|
| 119 | |
---|
[30234] | 120 | if (!empty($row['author'])) { |
---|
| 121 | do { |
---|
| 122 | $auteur .= $row['author'].', '; |
---|
[30100] | 123 | } while ($row = pwg_db_fetch_assoc($result)); |
---|
| 124 | |
---|
[30234] | 125 | $auteur = substr($auteur, 0, -2); |
---|
| 126 | if (preg_match('#(,|\/)#i', $auteur )) { $auteur = str_replace(array('(',')'), '', ucfirst(sprintf($lang['author(s) : %s'], $auteur))); } else { $auteur = $lang['Author'].' : '.$auteur ; } |
---|
| 127 | if (!empty($tpl_var[$cle]['DESCRIPTION'])) { $tpl_var[$cle]['DESCRIPTION'] = $tpl_var[$cle]['DESCRIPTION'].'<br/>'.$auteur; } else { $tpl_var[$cle]['DESCRIPTION'] = $auteur; } |
---|
| 128 | } |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | return $tpl_var; |
---|
| 132 | } |
---|
[30100] | 133 | } |
---|
| 134 | |
---|
[31176] | 135 | ?> |
---|