Ignore:
Timestamp:
Oct 15, 2012, 3:38:31 PM (11 years ago)
Author:
plg
Message:

compatibility with Piwigo 2.4

fix bug with icon in RSS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/piclens/generate_rss.php

    r12542 r18642  
    6262                $cat = array();
    6363                $pictures = array();
     64
     65    $basic_fields = array(
     66      'DISTINCT(img.id)',
     67      'img.file',
     68      'img.date_available',
     69      'img.date_creation',
     70      'img.name',
     71      'img.comment',
     72      'img.author',
     73      'img.hit',
     74      'img.filesize',
     75      'img.rating_score',
     76      'img.path',
     77      'img.level',
     78      );
    6479
    6580                $forbidden = get_sql_condition_FandF(
     
    87102                        array_push($cat, "1");
    88103
    89                         $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    90                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    91                                           img.level '
    92                                         .' FROM ' . IMAGES_TABLE.' AS img'
    93                                         .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    94                                         .' WHERE
    95                                                 img.date_available >= SUBDATE(
    96                                                 CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY) '
    97                     .get_sql_condition_FandF
    98                                                 (
    99                                                         array('visible_images' => 'id'),
    100                                                         'AND'
    101                                                 )
    102                                         .' '.$conf['order_by'].';';
     104                        $query = '
     105SELECT '.implode(',', $basic_fields).'
     106  FROM ' . IMAGES_TABLE.' AS img
     107    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     108  WHERE img.date_available >= SUBDATE(CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)
     109    '.get_sql_condition_FandF(array('visible_images' => 'id'), 'AND').'
     110  '.$conf['order_by'].'
     111;';
    103112                }
    104113                // Plus vues
     
    108117                        array_push($cat, "1");
    109118
    110                         $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    111                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    112                                           img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
    113                                           cat.visible, cat.uppercats, cat.permalink, cat.dir '
    114                                         .' FROM ' . IMAGES_TABLE.' AS img'
    115                                         .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    116                                         .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'                   
    117                                         .' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON cat.id = cat_id and user_id = '.$user['id']
    118                                         .' WHERE date_last >= SUBDATE(
    119                                                 CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY
    120                                                 )
    121                     '.$forbidden
    122                     .';';
     119                        $query = '
     120SELECT
     121    '.implode(',', $basic_fields).',
     122    ic.category_id,
     123    cat.name AS catname,
     124    cat.comment AS catcomment,
     125    cat.rank,
     126    cat.status,
     127    cat.visible,
     128    cat.uppercats,
     129    cat.permalink,
     130    cat.dir
     131  FROM '.IMAGES_TABLE.' AS img
     132    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     133    INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id
     134    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON cat.id = cat_id and user_id = '.$user['id'].'
     135  WHERE date_last >= SUBDATE(CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)
     136    '.$forbidden.'
     137;';
    123138                }
    124139               
     
    128143                        // $cat need to bo not null...
    129144                        array_push($cat, "1");
    130                         $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    131                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    132                                           img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
    133                                           cat.visible, cat.uppercats, cat.permalink, cat.dir '
    134                                         .' FROM ' . IMAGES_TABLE.' AS img'
    135                                         .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    136                                         .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'                   
    137                                         .' WHERE img.hit > 0 '
    138                                     .$forbidden
    139                                         .' ORDER BY hit DESC, file ASC'
    140                                         .' LIMIT 0, '.$conf['top_number'].';';
    141                
     145                        $query = '
     146SELECT
     147    '.implode(',', $basic_fields).',
     148    ic.category_id,
     149    cat.name AS catname,
     150    cat.comment AS catcomment,
     151    cat.rank,
     152    cat.status,
     153    cat.visible,
     154    cat.uppercats,
     155    cat.permalink,
     156    cat.dir
     157  FROM '.IMAGES_TABLE.' AS img
     158    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     159    INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id
     160  WHERE img.hit > 0
     161    '.$forbidden.'
     162  ORDER BY hit DESC, file ASC
     163  LIMIT 0, '.$conf['top_number'].'
     164;';
    142165                }
    143166                // mieux notees
     
    147170                        array_push($cat, "1");
    148171
    149                         $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    150                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    151                                           img.level '
    152                                         .' FROM ' . IMAGES_TABLE.' AS img'
    153                                         .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    154                                         .' WHERE img.rating_score IS NOT NULL '
    155                                         .get_sql_condition_FandF
    156                                                 (
    157                                                         array('visible_images' => 'id'),
    158                                                         'AND'
    159                                                 )
    160                                         .' ORDER BY rating_score DESC, id ASC'
    161                                         .' LIMIT 0, '.$conf['top_number'].';';
     172                        $query = '
     173SELECT '.implode(',', $basic_fields).'
     174  FROM ' . IMAGES_TABLE.' AS img
     175    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     176  WHERE img.rating_score IS NOT NULL
     177    '.get_sql_condition_FandF(array('visible_images' => 'id'), 'AND').'
     178  ORDER BY rating_score DESC, id ASC
     179  LIMIT 0, '.$conf['top_number'].'
     180;';
    162181                }
    163182                elseif ($page['section'] == 'favorites')
     
    167186                        array_push($cat, "1");
    168187
    169                         $query = 'SELECT img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    170                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    171                                           img.level  '
    172                                         .' FROM '.FAVORITES_TABLE.' AS fav '
    173                                         .' INNER JOIN '.IMAGES_TABLE.' AS img ON fav.image_id = img.id'
    174                                         .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    175                                         .' WHERE user_id = '.$user['id']
    176                                         .' '.get_sql_condition_FandF
    177                                                 (
    178                                                         array('visible_images' => 'id'),
    179                                                         'AND'
    180                                                 )
    181                                         .' '.$conf['order_by'].';';
     188                        $query = '
     189SELECT '.implode(',', $basic_fields).'
     190  FROM '.FAVORITES_TABLE.' AS fav
     191    INNER JOIN '.IMAGES_TABLE.' AS img ON fav.image_id = img.id
     192    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     193  WHERE user_id = '.$user['id'].'
     194  '.get_sql_condition_FandF(array('visible_images' => 'id'), 'AND').'
     195  '.$conf['order_by'].'
     196;';
    182197                }
    183198
     
    210225                        // $cat need to bo not null...
    211226                        array_push($cat, "1");
    212                         $query = 'SELECT distinct(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    213                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    214                                           img.level  '
    215                                         .' FROM '.IMAGES_TABLE.' AS img '
    216                                         .' WHERE img.id IN ('.implode(',', $items).') '
    217 
    218                                         .' '.get_sql_condition_FandF
    219                                                 (
    220                                                         array('visible_images' => 'id'),
    221                                                         'AND'
    222                                                 )
    223                                         .' '.$conf['order_by'].';';
     227                        $query = '
     228SELECT '.implode(',', $basic_fields).'
     229  FROM '.IMAGES_TABLE.' AS img
     230  WHERE img.id IN ('.implode(',', $items).')
     231  '.get_sql_condition_FandF(array('visible_images' => 'id'), 'AND').'
     232  '.$conf['order_by'].'
     233;';
    224234                }
    225235               
     
    274284                                        }
    275285
    276                                         $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    277                                                           img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    278                                                           img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
    279                                                           cat.visible, cat.uppercats, cat.permalink, cat.dir '
    280                                         .' FROM ' . IMAGES_TABLE.' AS img'
    281                                         .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    282                                         .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
    283                                         .' WHERE ic.category_id IN ('.implode(',', $cat).')'
    284                                         .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '')
    285                                         .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : ''))
    286                                         // Verif droits (niveaux) de l'utilisateur sur les images
    287                                         .' AND img.level <='.$user['level'].' '
    288                                         // Choix du critere de tri d'affichage
    289                                         .$order_list[ $obj->my_config['piclens_order'] ]
    290                                         .$order_sort[ $obj->my_config['piclens_sort'] ];
    291                                        
    292                                        
     286                                        $query = '
     287SELECT
     288    '.implode(',', $basic_fields).',
     289    ic.category_id,
     290    cat.name AS catname,
     291    cat.comment AS catcomment,
     292    cat.rank,
     293    cat.status,
     294    cat.visible,
     295    cat.uppercats,
     296    cat.permalink,
     297    cat.dir
     298  FROM '.IMAGES_TABLE.' AS img
     299    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     300    INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id
     301  WHERE ic.category_id IN ('.implode(',', $cat).')
     302    AND img.level <='.$user['level'].'
     303  '.$order_list[ $obj->my_config['piclens_order'] ].'
     304  '.$order_sort[ $obj->my_config['piclens_sort'] ].'
     305;';
    293306                                }
    294307                        }
     
    342355                                }
    343356                                       
    344                                 $query = 'SELECT DISTINCT(img.id), img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    345                                                   img.comment, img.author, img.hit ,img.filesize, img.rating_score, img.has_high, img.path,
    346                                                   img.level, ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
    347                                                   cat.visible, cat.uppercats, cat.permalink, cat.dir '
    348                                 .' FROM ' . IMAGES_TABLE.' AS img'
    349                                 .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    350                                 .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'
    351                                 .' WHERE ic.category_id IN ('.implode(',', $cat).')'
    352                                 .(sizeof($obj->my_config['included_file_types']) ? ' AND (img.tn_ext IN ('.implode(',', $type_ext).')' : '')
    353                                 .($tn_ext_is_null ? ' OR img.tn_ext IS NULL)' : (sizeof($obj->my_config['included_file_types']) ? ')' : ''))
    354                                 // Verif droits (niveaux) de l'utilisateur sur les images
    355                                 .' AND img.level <='.$user['level'].' '
    356                                 // Choix du critere de tri d'affichage
    357                                 .$order_list[ $obj->my_config['piclens_order_cat'] ]
    358                                 .$order_sort[ $obj->my_config['piclens_sort_cat'] ];
     357                                $query = '
     358SELECT
     359    '.implode(',', $basic_fields).',
     360    ic.category_id,
     361    cat.name AS catname,
     362    cat.comment AS catcomment,
     363    cat.rank,
     364    cat.status,
     365    cat.visible,
     366    cat.uppercats,
     367    cat.permalink,
     368    cat.dir
     369  FROM '.IMAGES_TABLE.' AS img
     370    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id
     371    INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id
     372  WHERE ic.category_id IN ('.implode(',', $cat).')
     373    AND img.level <='.$user['level'].'
     374    '.$order_list[ $obj->my_config['piclens_order_cat'] ].'
     375    '.$order_sort[ $obj->my_config['piclens_sort_cat'] ].'
     376;';
    359377
    360378                                }
     
    441459                .(strlen($obj->my_config['piclens_rss_icon'])
    442460                                    ? $obj->my_config['piclens_rss_icon']
    443                                     : $obj->root_site_piclens.'template-common/favicon.ico')
     461                                    : $obj->root_site_piclens.'plugins/piclens/icon/rss_icon.png')
    444462                .'</atom:icon>';
     463
    445464                echo "\n";
    446465
     
    451470                        // Mode de l'image parametre
    452471                        $piclens_normal = $obj->my_config['piclens_normal'];
    453 
    454                         // si parametrage high et high absente ou utilisateur non habilite, affichage version normale
    455                         if (($piclens_normal == 3) && (!($row['has_high']) || !$user['enabled_high']))
    456                                 $piclens_normal = 2; // Normal uniquement pour l'image en cours
    457472
    458473                        // Get thumbnail url
     
    469484                        {
    470485                                $link_url = $obj->root_site_piclens.$row['path'];
     486
     487                                $src_image = new SrcImage($row);
     488                                set_make_full_url();
     489                                $thumb_url = DerivativeImage::url(IMG_THUMB, $src_image);
     490                                $medium_url = DerivativeImage::url(IMG_MEDIUM, $src_image);
     491                                $high_url = DerivativeImage::url(IMG_XXLARGE, $src_image);
     492                                unset_make_full_url();
    471493                               
    472494                                if ( ($obj->my_config['piclens_thumb']) == 2)   // Normal
    473                                         $thumbnail_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
     495                                {
     496                                  $thumbnail_url = $medium_url;
     497                                }
    474498                                else
    475499                                {
    476                     $path=get_thumbnail_location($row);
    477                     $thumbnail_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
    478                                 }       
    479 
    480                                 switch ($piclens_normal)
    481                                 {
    482                                         case 1 : // miniature
    483                         $path=get_thumbnail_location($row);
    484                         $content_url = ( url_is_remote($path) ? $path : embellish_url($obj->root_site_piclens.$path) );
    485                                                 break;
    486                                         case 2 : // normal
    487                                                 $content_url = (url_is_remote($row['path']) ? $row['path']: embellish_url($obj->root_site_piclens.$row['path']));
    488                                                 break;
    489                                         case 3 :
    490                                                  $content_url =  (url_is_remote($row['path']) ? dirname($row['path']).'/pwg_high/'.basename($row['path'])
    491                                                                                                                                           : embellish_url( $obj->root_site_piclens. dirname($row['path']).'/pwg_high/'.basename($row['path']))
    492                                                                                  );
    493                                                  break;
    494                                         default : // normal
    495                                                 $content_url =  (url_is_remote($row['path']) ? $row['path'] : embellish_url($obj->root_site_piclens.$row['path']));
    496                                                 break;
     500                                  $thumbnail_url = $thumb_url;
    497501                                }
     502
     503                                if (1 == $piclens_normal)
     504                                {
     505                                  $content_url = $thumb_url;
     506                                }
     507                                elseif (3 == $piclens_normal)
     508                                {
     509                                  $content_url = $high_url;
     510                                }
     511                                else
     512                                {
     513                                  $content_url = $medium_url;
     514                                }
    498515                        }
    499516                       
Note: See TracChangeset for help on using the changeset viewer.