Changeset 31180


Ignore:
Timestamp:
May 27, 2015, 3:28:08 PM (9 years ago)
Author:
sarybe
Message:

[ThumbnailTooltip] Canceling changes. Back to 31176 Version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ThumbnailTooltip/include/class.inc.php

    r31179 r31180  
    44  var $plugin_name, $plugin_path, $plugin_url;
    55  var $my_config;
    6  
     6
    77  function Thumbnail_Tooltip_IMG ($plugin_name, $plugin_path, $plugin_url) {
    88    $this->plugin_name = $plugin_name;
     
    1111    $this->initialize_event_handler($plugin_name, $plugin_path, $plugin_url);
    1212  }
    13  
     13
    1414  function initialize_event_handler() {
    1515    add_event_handler('loc_end_index_thumbnails', array($this, 'thumbnail_tooltip_affich'), 50, 2);
    1616    add_event_handler('loc_end_index_category_thumbnails', array($this, 'Author_Description_affich'), 50, 2);
    1717  }
    18  
     18
    1919  function thumbnail_tooltip_affich($tpl_var) {
    2020    global $user;
    21        
     21
    2222        $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip"';
    23                
    2423        $row = pwg_db_fetch_assoc( pwg_query($query) );
     24
    2525        $params = unserialize($row['value']);
    2626        $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']
     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']
    3535        );
    36        
     36       
     37
    3738        if ($params['display_name']==true) {
    3839      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) );
     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) );
     45
    4246        $details = array();
    4347        $details_param = array();
     48
    4449        $details['tn_type1'] = str_replace('"', '\"', strip_tags($row['name']));
    45                
     50
    4651        if (!empty($row['hit'])) {
    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.')';
     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.')';
    5156        }
     57
    5258        if (!empty($row['comment'])) {
    53           $details['tn_type4'] = str_replace('"', '\"', strip_tags($row['comment']));
     59                  $details['tn_type4'] = str_replace('"', '\"', strip_tags($row['comment']));
    5460        }
     61
    5562        if (!empty($row['author'])) {
    56           $details['tn_type5'] = $row['author'];
     63                  $details['tn_type5'] = $row['author'];
    5764        }
     65
    5866        if (!empty($row['author'])) {
    59           $details['tn_type6'] = (preg_match('#(,|\/)#i', $row['author'])) ? str_replace(array('(',')'), '', ucfirst(l10n('author(s) : %s', $row['author']))) : l10n('Author').' : '.$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'];
    6068        }
     69
    6170        if (!empty($row['rating_score'])) {
    62           $details['tn_type7'] = strtolower(l10n('Rating score')).' '.$row['rating_score'];
     71                  $details['tn_type7'] = strtolower(l10n('Rating score')).' '.$row['rating_score'];
    6372        }
     73
    6474        if (!empty($row['dimensions'])) {
    65           $details['tn_type9'] = l10n('Dimensions').' : '.$row['dimensions'];
     75                  $details['tn_type9'] = l10n('Dimensions').' : '.$row['dimensions'];
    6676        }
    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                
     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
    7283        if ((!empty($details[$values['value1']])) && ($details[$values['value1']]!='none')) { $details_param[] = $details[$values['value1']]; }
    7384        if ((!empty($details[$values['value2']])) && ($details[$values['value2']]!='none')) { $details_param[] = $details[$values['value2']]; }
     
    7586        if ((!empty($details[$values['value4']])) && ($details[$values['value4']]!='none')) { $details_param[] = $details[$values['value4']]; }
    7687        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']]; }
     88        if ((!empty($details[$values['value6']])) && ($details[$values['value6']]!='none')) { $details_param[] = $details[$values['value6']]; } 
     89
    7890        if ($params['separator']=='1') { $title = implode(' - ', $details_param); } else { $title = implode(' ', $details_param); }
     91
    7992        $tpl_var[$cle]['TN_TITLE'] = $title;
    8093      }
    81         }
    82     else {
    83       $tpl_var[$cle]['TN_TITLE'] = null;
    8494    }
    8595    return $tpl_var;
    8696  }
    87  
     97
     98
    8899  function Author_Description_affich($tpl_var) {
    89100    global $user, $lang;
    90        
    91     $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip";';
    92     $row = pwg_db_fetch_assoc( pwg_query($query) );
     101
     102        $query = 'SELECT param, value, comment FROM ' . CONFIG_TABLE . ' WHERE param="thumbnail_tooltip";';
     103        $row = pwg_db_fetch_assoc( pwg_query($query) );
     104
    93105    $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";
     106        $values = array('DISPLAY_AUTHOR_CAT' => $params['display_author_cat']);
     107
     108        if ($params['display_author_cat']==true) {
     109      foreach($tpl_var as $cle=>$valeur) {
     110        $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";
    99111            $result = pwg_query($query);
    100             $row = pwg_db_fetch_assoc($result);
    101             $auteur = '';
    102                        
     112            $row = pwg_db_fetch_assoc($result);
     113
     114                $auteur = '';
     115
    103116            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);
     117                  do {
     118                    $auteur .= $row['author'].', ';
     119                  } while ($row = pwg_db_fetch_assoc($result));
     120
     121                  $auteur = substr($auteur, 0, -2);
    109122              if (preg_match('#(,|\/)#i', $auteur )) { $auteur = str_replace(array('(',')'), '', ucfirst(sprintf($lang['author(s) : %s'], $auteur))); } else { $auteur = $lang['Author'].' : '.$auteur ; }
    110123              if (!empty($tpl_var[$cle]['DESCRIPTION'])) { $tpl_var[$cle]['DESCRIPTION'] = $tpl_var[$cle]['DESCRIPTION'].'<br/>'.$auteur; } else { $tpl_var[$cle]['DESCRIPTION'] = $auteur; }
     
    115128  }
    116129}
     130
    117131?>
Note: See TracChangeset for help on using the changeset viewer.