aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2005-01-15 11:16:46 +0000
committerplegall <plg@piwigo.org>2005-01-15 11:16:46 +0000
commitcc5ba30bd061d00be17bb26061962016e4112b9d (patch)
treeed4710bd435466dcba3d5d828797a90c62cda3ca
parent46dcfba37dc27dd51f14eccddabc803686712d01 (diff)
- bug fixed : count the exact number of elements that can be displayed in
most_visited category because it can be less than $conf['top_number'] git-svn-id: http://piwigo.org/svn/trunk@694 68402e56-0260-453c-a942-63ccdbb3a9ee
-rw-r--r--include/functions_category.inc.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 67be45b0e..2e7ce2903 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -592,7 +592,26 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images
}
$conf['order_by'] = ' ORDER BY hit DESC, file ASC';
- $page['cat_nb_images'] = $conf['top_number'];
+
+ // $page['cat_nb_images'] equals $conf['top_number'] unless there
+ // are less visited items
+ $query ='
+SELECT COUNT(DISTINCT(id)) AS count
+ FROM '.IMAGES_TABLE.'
+ INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
+ '.$page['where'].'
+;';
+ $row = mysql_fetch_array(pwg_query($query));
+ if ($row['count'] < $conf['top_number'])
+ {
+ $page['cat_nb_images'] = $row['count'];
+ }
+ else
+ {
+ $page['cat_nb_images'] = $conf['top_number'];
+ }
+ unset($query);
+
if ( isset( $page['start'] )
and ($page['start']+$user['nb_image_page']>=$conf['top_number']))
{