Changeset 3650


Ignore:
Timestamp:
Jul 21, 2009, 1:00:03 AM (15 years ago)
Author:
tiico
Message:

Correct request on tag page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/piclens/generate_rss.php

    r3649 r3650  
    177177                {
    178178//                      $row = get_image_ids_for_tags($page['tags_id']);
     179          $tag_images = array();
     180
     181              foreach ($page['tag_ids'] as $tag_id)
     182              {
     183                $query = '
     184                SELECT image_id
     185                  FROM '.IMAGE_TAG_TABLE.'
     186                  WHERE tag_id = '.$tag_id.'
     187                ;';
     188                $tag_images[$tag_id] = array_from_query($query, 'image_id');
     189              }
     190
     191              // then we calculate the intersection, the images that are associated to
     192              // every tags
     193              $items = array_shift($tag_images);
     194              foreach ($tag_images as $images)
     195              {
     196                $items = array_intersect($items, $images);
     197              }
     198
    179199                        // $cat need to bo not null...
    180200                        array_push($cat, "1");
    181                         $query = 'SELECT DISTINCT(tag.image_id) , img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
     201                        $query = 'SELECT img.id, img.file, img.date_available, img.date_creation, img.tn_ext, img.name,
    182202                                          img.comment, img.author, img.hit ,img.filesize, img.average_rate, img.has_high, img.path,
    183203                                          img.level , ic.category_id, cat.name AS catname, cat.comment AS catcomment, cat.rank, cat.status,
    184204                                          cat.visible, cat.uppercats, cat.permalink, cat.dir '
    185                                         .' FROM '.IMAGE_TAG_TABLE.' AS tag '."\n"
    186                                         .' INNER JOIN '.IMAGES_TABLE.' AS img ON tag.image_id = img.id'
     205                                        .' FROM '.IMAGES_TABLE.' AS img '
    187206                                        .' INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON img.id = ic.image_id'
    188                                         .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id'                   
    189                                         .' WHERE tag.tag_id IN ('.implode(',', $page['tag_ids']).') '
    190                                     .$forbidden
     207                                        .' INNER JOIN '.CATEGORIES_TABLE.' AS cat ON ic.category_id = cat.id '
     208                                        .' WHERE img.id IN ('.implode(',', $items).') '
     209                    .$forbidden
    191210                                        .' '.$conf['order_by'].';';
    192211                }
Note: See TracChangeset for help on using the changeset viewer.