aboutsummaryrefslogtreecommitdiffstats
path: root/include/category_default.inc.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2006-02-12 21:52:16 +0000
committerplegall <plg@piwigo.org>2006-02-12 21:52:16 +0000
commitdac7decfb5d01ff27797ba3ba39ea8af3766b89e (patch)
tree2191078267800600bc7c195f3626ee3436572990 /include/category_default.inc.php
parent2dc2eb8630a286ac291605901d7384840a0202a9 (diff)
improvement: $page['where'] string replaced by $page['items'].
$page['where'] was an SQL clause used to retrieve pictures in #images table. $page['items'] 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. $page['navigation_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. git-svn-id: http://piwigo.org/svn/trunk@1036 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/category_default.inc.php')
-rw-r--r--include/category_default.inc.php48
1 files changed, 30 insertions, 18 deletions
diff --git a/include/category_default.inc.php b/include/category_default.inc.php
index fd04181e9..009d9ef14 100644
--- a/include/category_default.inc.php
+++ b/include/category_default.inc.php
@@ -31,26 +31,36 @@
*
*/
-/**
- * $array_cat_directories is a cache hash associating category id with their
- * complete directory
- */
-$array_cat_directories = array();
-
-$query = '
-SELECT DISTINCT(id),path,file,date_available
- ,tn_ext,name,filesize,storage_category_id,average_rate,hit
- FROM '.IMAGES_TABLE.' AS i
- INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id=ic.image_id
- '.$page['where'].'
- '.$conf['order_by'].'
- LIMIT '.$page['start'].','.$page['nb_image_page'].'
+$page['rank_of'] = array_flip($page['items']);
+
+$pictures = array();
+
+$selection = array_slice(
+ $page['items'],
+ $page['start'],
+ $page['nb_image_page']
+ );
+
+if (count($selection) > 0)
+{
+ $query = '
+SELECT *
+ FROM '.IMAGES_TABLE.'
+ WHERE id IN ('.implode(',', $selection).')
;';
-//echo '<pre>'.$query.'</pre>';
-$result = pwg_query($query);
+ $result = pwg_query($query);
+ while ($row = mysql_fetch_array($result))
+ {
+ $row['rank'] = $page['rank_of'][ $row['id'] ];
+
+ array_push($pictures, $row);
+ }
+
+ usort($pictures, 'rank_compare');
+}
// template thumbnail initialization
-if ( mysql_num_rows($result) > 0 )
+if (count($pictures) > 0)
{
$template->assign_block_vars('thumbnails', array());
// first line
@@ -59,7 +69,7 @@ if ( mysql_num_rows($result) > 0 )
$row_number = 0;
}
-while ($row = mysql_fetch_array($result))
+foreach ($pictures as $row)
{
$thumbnail_url = get_thumbnail_src($row['path'], @$row['tn_ext']);
@@ -150,4 +160,6 @@ SELECT COUNT(*) AS nb_comments
$row_number = 0;
}
}
+
+pwg_debug('end include/category_default.inc.php');
?> \ No newline at end of file