aboutsummaryrefslogtreecommitdiffstats
path: root/include/category_cats.inc.php
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2012-10-04 15:03:55 +0000
committermistic100 <mistic@piwigo.org>2012-10-04 15:03:55 +0000
commitb1cec7bf86b84296acc97ffed090bf1686964420 (patch)
tree9525c06648ec2cc90a401efc06974a0b24198294 /include/category_cats.inc.php
parentb5f020ee66b13bce8275a4d64faf8710c362a6d1 (diff)
feature:2614 pagination on albums
return to old fashioned way (one query in category_cats), restoring recent_cats feature and "menubar optimization", rename "starta" into "startcat" git-svn-id: http://piwigo.org/svn/trunk@18462 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/category_cats.inc.php')
-rw-r--r--include/category_cats.inc.php58
1 files changed, 47 insertions, 11 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index b09f4eaec..a3cc2468b 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -27,13 +27,6 @@
*
*/
-$selection = array_slice(
- $page['categories'],
- $page['starta'],
- $conf['nb_categories_page']
- );
-
-$selection = trigger_event('loc_index_categories_selection', $selection);
// $user['forbidden_categories'] including with USER_CACHE_CATEGORIES_TABLE
$query = '
@@ -48,8 +41,24 @@ SELECT
FROM '.CATEGORIES_TABLE.' c
INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ucc
ON id = cat_id
- AND user_id = '.$user['id'].'
- WHERE c.id IN('.implode(',', $selection).')';
+ AND user_id = '.$user['id'];
+
+if ('recent_cats' == $page['section'])
+{
+ $query.= '
+ WHERE date_last >= '.pwg_db_get_recent_period_expression($user['recent_period']);
+}
+else
+{
+ $query.= '
+ WHERE id_uppercat '.(!isset($page['category']) ? 'is NULL' : '= '.$page['category']['id']);
+}
+
+$query.= '
+ '.get_sql_condition_FandF(
+ array('visible_categories' => 'id'),
+ 'AND'
+ );
if ('recent_cats' != $page['section'])
{
@@ -60,13 +69,24 @@ if ('recent_cats' != $page['section'])
$query.= '
;';
-$result = pwg_query($query);
+$categories_sql = hash_from_query($query, 'id');
+
+$page['total_categories'] = count($categories_sql);
+
+$categories_sql = array_slice(
+ array_values($categories_sql),
+ $page['startcat'],
+ $conf['nb_categories_page']
+ );
+
+$categories_sql = trigger_event('loc_index_categories_selection', $categories_sql);
+
$categories = array();
$category_ids = array();
$image_ids = array();
$user_representative_updates_for = array();
-while ($row = pwg_db_fetch_assoc($result))
+foreach ($categories_sql as $row)
{
$row['is_child_date_last'] = @$row['max_date_last']>@$row['date_last'];
@@ -374,6 +394,22 @@ if (count($categories) > 0)
) );
$template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails');
+
+ // navigation bar
+ $page['cats_navigation_bar'] = array();
+ if ($page['total_categories'] > $conf['nb_categories_page'])
+ {
+ $page['cats_navigation_bar'] = create_navigation_bar(
+ duplicate_index_url(array(), array('startcat')),
+ $page['total_categories'],
+ $page['startcat'],
+ $conf['nb_categories_page'],
+ true, 'startcat'
+ );
+ }
+
+ $template->assign('cats_navbar', $page['cats_navigation_bar'] );
}
+
pwg_debug('end include/category_cats.inc.php');
?> \ No newline at end of file