Changeset 30234


Ignore:
Timestamp:
Oct 20, 2014, 2:08:13 PM (10 years ago)
Author:
sarybe
Message:

[Thumbnail_Tooltip] Bug fix for html and double quotes in name (title)

Location:
extensions/ThumbnailTooltip
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/ThumbnailTooltip/admin/config_default.inc.php

    r30100 r30234  
    11<?php
    2 
    32$config_default = array(
    4 
    53  'display_name'        => true,
    6 
    74  'value1'              => 'tn_type1',
    8 
    95  'value2'              => 'tn_type8',
    10 
    116  'value3'              => 'tn_type4',
    12 
    137  'value4'              => 'none',
    14 
    158  'value5'              => 'none',
    16 
    179  'value6'              => 'none',
    18 
    1910  'separator'           => '1',
    20 
    2111  'display_author_cat'  => '1'
    22 
    2312);
    24 
    2513?>
  • extensions/ThumbnailTooltip/admin/functions.inc.php

    r30100 r30234  
    11<?php
    2 
    32add_event_handler('get_admin_plugin_menu_links', 'thumbnail_tooltip_admin_menu');
    43
    5 
    6 
    74function thumbnail_tooltip_admin_menu($menu)
    8 
    95{
    10 
    116  array_push($menu, array(
    12 
    137    'NAME' => 'Thumbnail Tooltip',
    14 
    158    'URL' => get_admin_plugin_menu_link(dirname(__FILE__).'/admin.php')));
    16 
    179  return $menu;
    18 
    1910}
    20 
    2111?>
  • extensions/ThumbnailTooltip/include/class.inc.php

    r30100 r30234  
    11<?php
    22
    3 
    4 
    53class Thumbnail_Tooltip_IMG {
    6 
    74  var $plugin_name, $plugin_path, $plugin_url;
    8 
    95  var $my_config;
    106
     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  }
    1113
     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);
     17  }
    1218
    13   function Thumbnail_Tooltip_IMG ($plugin_name, $plugin_path, $plugin_url) {
     19  function thumbnail_tooltip_affich($tpl_var) {
     20    global $user;
    1421
    15     $this->plugin_name = $plugin_name;
     22        $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip"';
     23        $row = pwg_db_fetch_assoc( pwg_query($query) );
    1624
    17     $this->plugin_path = $plugin_path;
     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']
     35        );
     36       
    1837
    19     $this->plugin_url = $plugin_url;
     38        if ($params['display_name']==true) {
     39      foreach($tpl_var as $cle=>$valeur) {
     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']."
     43                ;";
     44            $row = pwg_db_fetch_assoc( pwg_query($query) );
    2045
    21     $this->initialize_event_handler($plugin_name, $plugin_path, $plugin_url);
     46        $details = array();
     47        $details_param = array();
    2248
     49        $details['tn_type1'] = addslashes(strip_tags($row['name']));
     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'])) {
     59                  $details['tn_type4'] = addslashes(strip_tags($row['comment']));
     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                }
     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']]; } 
     89
     90        if ($params['separator']=='1') { $title = implode(' - ', $details_param); } else { $title = implode(' ', $details_param); }
     91
     92        $tpl_var[$cle]['TN_TITLE'] = $title;
     93      }
     94    }
     95    return $tpl_var;
    2396  }
    2497
    2598
     99  function Author_Description_affich($tpl_var) {
     100    global $user, $lang;
    26101
    27   function initialize_event_handler() {
    28 
    29     add_event_handler('loc_end_index_thumbnails', array($this, 'thumbnail_tooltip_affich'), 50, 2);
    30 
    31     add_event_handler('loc_end_index_category_thumbnails', array($this, 'Author_Description_affich'), 50, 2);
    32 
    33   }
    34 
    35 
    36 
    37   function thumbnail_tooltip_affich($tpl_var) {
    38 
    39     global $user;
    40 
    41      
    42 
    43         $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip"';
    44 
     102        $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip";';
    45103        $row = pwg_db_fetch_assoc( pwg_query($query) );
    46104
    47  
    48 
    49         $params = unserialize($row['value']);
    50 
    51         $values = array(
    52 
    53                   'DISPLAY_NAME'         => $params['display_name'],
    54 
    55                   'value1'               => $params['value1'],
    56 
    57                   'value2'               => $params['value2'],
    58 
    59                   'value3'               => $params['value3'],
    60 
    61                   'value4'               => $params['value4'],
    62 
    63                   'value5'               => $params['value5'],
    64 
    65                   'value6'               => $params['value6'],
    66 
    67                   'separator'            => $params['separator']
    68 
    69         );
    70 
    71        
    72 
    73         if ($params['display_name']==true) {
    74 
    75       foreach($tpl_var as $cle=>$valeur) {
    76 
    77         $query = "
    78 
    79                   SELECT name, hit, comment, author, rating_score, CONCAT(width, 'x', height) AS dimensions, filesize FROM ".IMAGES_TABLE."
    80 
    81                   WHERE id = ".(int)$tpl_var[$cle]['id']."
    82 
    83                 ;";
    84 
    85             $row = pwg_db_fetch_assoc( pwg_query($query) );
    86 
    87 
    88 
    89         $details = array();
    90 
    91         $details_param = array();
    92 
    93          
    94 
    95         $details['tn_type1'] = $row['name'];
    96 
    97 
    98 
    99         if (!empty($row['hit'])) {
    100 
    101                   $details['tn_type2'] = $row['hit'].' '.strtolower(l10n('Visits'));
    102 
    103                   $details['tn_type3'] = '('.$row['hit'].' '.strtolower(l10n('Visits')).')';
    104 
    105               if (!empty($row['rating_score'])) { $type8 = ', '.strtolower(l10n('Rating score')).' '.$row['rating_score']; } else { $type8 = ''; }
    106 
    107                   $details['tn_type8'] = '('.$row['hit'].' '.strtolower(l10n('Visits')).$type8.')';
    108 
    109         }
    110 
    111         if (!empty($row['comment'])) {
    112 
    113                   $details['tn_type4'] = addslashes(strip_tags($row['comment']));
    114 
    115         }
    116 
    117         if (!empty($row['author'])) {
    118 
    119                   $details['tn_type5'] = $row['author'];
    120 
    121         }
    122 
    123         if (!empty($row['author'])) {
    124 
    125                   $details['tn_type6'] = (preg_match('#(,|\/)#i', $row['author'])) ? str_replace(array('(',')'), '', ucfirst(l10n('author(s) : %s', $row['author']))) : l10n('Author').' : '.$row['author'];
    126 
    127         }
    128 
    129         if (!empty($row['rating_score'])) {
    130 
    131                   $details['tn_type7'] = strtolower(l10n('Rating score')).' '.$row['rating_score'];
    132 
    133         }
    134 
    135         if (!empty($row['dimensions'])) {
    136 
    137                   $details['tn_type9'] = l10n('Dimensions').' : '.$row['dimensions'];
    138 
    139         }
    140 
    141                 if (!empty($row['filesize'])) {
    142 
    143                   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'] = ' '; }
    144 
    145                   $details['tn_type9'].= l10n('Filesize').' : '.l10n('%d Kb', $row['filesize']);
    146 
    147                 }
    148 
    149                  
    150 
    151         if ((!empty($details[$values['value1']])) && ($details[$values['value1']]!='none')) { $details_param[] = $details[$values['value1']]; }
    152 
    153         if ((!empty($details[$values['value2']])) && ($details[$values['value2']]!='none')) { $details_param[] = $details[$values['value2']]; }
    154 
    155         if ((!empty($details[$values['value3']])) && ($details[$values['value3']]!='none')) { $details_param[] = $details[$values['value3']]; }
    156 
    157         if ((!empty($details[$values['value4']])) && ($details[$values['value4']]!='none')) { $details_param[] = $details[$values['value4']]; }
    158 
    159         if ((!empty($details[$values['value5']])) && ($details[$values['value5']]!='none')) { $details_param[] = $details[$values['value5']]; }
    160 
    161         if ((!empty($details[$values['value6']])) && ($details[$values['value6']]!='none')) { $details_param[] = $details[$values['value6']]; }
    162 
    163          
    164 
    165         if ($params['separator']=='1') { $title = implode(' - ', $details_param); } else { $title = implode(' ', $details_param); }
    166 
    167          
    168 
    169         $tpl_var[$cle]['TN_TITLE'] = $title;
    170 
    171       }
    172 
    173     }
    174 
    175     return $tpl_var;
    176 
    177   }
    178 
    179  
    180 
    181  
    182 
    183   function Author_Description_affich($tpl_var) {
    184 
    185     global $user, $lang;
    186 
    187 
    188 
    189         $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip";';
    190 
    191         $row = pwg_db_fetch_assoc( pwg_query($query) );
    192 
    193  
    194 
    195105    $params = unserialize($row['value']);
    196 
    197106        $values = array('DISPLAY_AUTHOR_CAT' => $params['display_author_cat']);
    198107
    199        
    200 
    201108        if ($params['display_author_cat']==true) {
    202 
    203109      foreach($tpl_var as $cle=>$valeur) {
    204 
    205110        $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";
    206 
    207111            $result = pwg_query($query);
    208 
    209             $row = pwg_db_fetch_assoc($result);
    210 
    211                
     112            $row = pwg_db_fetch_assoc($result);
    212113
    213114                $auteur = '';
    214115
    215116            if (!empty($row['author'])) {
    216 
    217117                  do {
    218 
    219118                    $auteur .= $row['author'].', ';
    220 
    221119                  } while ($row = pwg_db_fetch_assoc($result));
    222120
    223121                  $auteur = substr($auteur, 0, -2);
    224 
    225122              if (preg_match('#(,|\/)#i', $auteur )) { $auteur = str_replace(array('(',')'), '', ucfirst(sprintf($lang['author(s) : %s'], $auteur))); } else { $auteur = $lang['Author'].' : '.$auteur ; }
    226 
    227123              if (!empty($tpl_var[$cle]['DESCRIPTION'])) { $tpl_var[$cle]['DESCRIPTION'] = $tpl_var[$cle]['DESCRIPTION'].'<br/>'.$auteur; } else { $tpl_var[$cle]['DESCRIPTION'] = $auteur; }
    228 
    229124            }
    230 
    231125      }
    232 
    233126    }
    234 
    235127    return $tpl_var;
    236 
    237128  }
    238 
    239129}
    240130
  • extensions/ThumbnailTooltip/main.inc.php

    r30100 r30234  
    55Plugin Name: Thumbnail Tooltip
    66
    7 Version: 1.4.8
     7Version: 1.4.8.1
    88Description: Permet de changer l'infobulle sur les images dans les albums.
    99
Note: See TracChangeset for help on using the changeset viewer.