Ignore:
Timestamp:
Feb 12, 2006, 10:52:16 PM (18 years ago)
Author:
plg
Message:

improvement: $pagewhere string replaced by $pageitems.
$pagewhere was an SQL clause used to retrieve pictures in #images
table. $pageitems is the list of picture ids of the current section.

improvement: function initialize_category replaced by dedicated included PHP
script include/section_init.inc.php. Code was refactored to improve
readibility and maintenability. $pagenavigation_bar is now build in
category.php instead of initialize_category function. Function check_cat_id
was also replaced by a piece of code in the new file. The file to include to
display thumbnails from category.php is now set in section_init.inc.php
instead of calculated in category.php.

bug fix: the test for rel="up" link for standard HTML navigation links in
category menu was not working with non numeric categories, such as
"favorites".

improvement: function check_login_authorization removed because useless but
in profile.php.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_default.inc.php

    r1014 r1036  
    3232 */
    3333
    34 /**
    35  * $array_cat_directories is a cache hash associating category id with their
    36  * complete directory
    37  */
    38 $array_cat_directories = array();
    39  
    40 $query = '
    41 SELECT DISTINCT(id),path,file,date_available
    42        ,tn_ext,name,filesize,storage_category_id,average_rate,hit
    43   FROM '.IMAGES_TABLE.' AS i
    44     INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id
    45   '.$page['where'].'
    46   '.$conf['order_by'].'
    47   LIMIT '.$page['start'].','.$page['nb_image_page'].'
     34$page['rank_of'] = array_flip($page['items']);
     35
     36$pictures = array();
     37
     38$selection = array_slice(
     39  $page['items'],
     40  $page['start'],
     41  $page['nb_image_page']
     42  );
     43
     44if (count($selection) > 0)
     45{
     46  $query = '
     47SELECT *
     48  FROM '.IMAGES_TABLE.'
     49  WHERE id IN ('.implode(',', $selection).')
    4850;';
    49 //echo '<pre>'.$query.'</pre>';
    50 $result = pwg_query($query);
     51  $result = pwg_query($query);
     52  while ($row = mysql_fetch_array($result))
     53  {
     54    $row['rank'] = $page['rank_of'][ $row['id'] ];
     55   
     56    array_push($pictures, $row);
     57  }
     58
     59  usort($pictures, 'rank_compare');
     60}
    5161
    5262// template thumbnail initialization
    53 if ( mysql_num_rows($result) > 0 )
     63if (count($pictures) > 0)
    5464{
    5565  $template->assign_block_vars('thumbnails', array());
     
    6070}
    6171
    62 while ($row = mysql_fetch_array($result))
     72foreach ($pictures as $row)
    6373{
    6474  $thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
     
    151161  }
    152162}
     163
     164pwg_debug('end include/category_default.inc.php');
    153165?>
Note: See TracChangeset for help on using the changeset viewer.