aboutsummaryrefslogtreecommitdiffstats
path: root/admin/cat_list.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2014-01-02 11:51:58 +0000
committerplegall <plg@piwigo.org>2014-01-02 11:51:58 +0000
commit5fb0ce9063564955bd7e46033528ad678cc30321 (patch)
treed1c4ac761932ac9181bd9646dc5881422c6c18d8 /admin/cat_list.php
parentdd73213674aefd202200c4f144e12b9dafdfb744 (diff)
bug 3015 fixed: remove "manage album photos" from cat_list to avoid
misunderstanding with "photos sort order". Add infos on album manager: number of photos and sub-albums git-svn-id: http://piwigo.org/svn/trunk@26399 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/cat_list.php57
1 files changed, 47 insertions, 10 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index f728e8f73..0ca366e84 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -251,13 +251,53 @@ $categories = hash_from_query($query, 'id');
// get the categories containing images directly
$categories_with_images = array();
-if ( count($categories) )
+if (count($categories))
{
$query = '
-SELECT DISTINCT category_id
+SELECT
+ category_id,
+ COUNT(*) AS nb_photos
FROM '.IMAGE_CATEGORY_TABLE.'
- WHERE category_id IN ('.implode(',', array_keys($categories)).')';
- $categories_with_images = array_flip( array_from_query($query, 'category_id') );
+ GROUP BY category_id
+;';
+ // WHERE category_id IN ('.implode(',', array_keys($categories)).')
+
+ $nb_photos_in = query2array($query, 'category_id', 'nb_photos');
+
+ $query = '
+SELECT
+ id,
+ uppercats
+ FROM '.CATEGORIES_TABLE.'
+;';
+ $all_categories = query2array($query, 'id', 'uppercats');
+ $subcats_of = array();
+
+ foreach (array_keys($categories) as $cat_id)
+ {
+ foreach ($all_categories as $id => $uppercats)
+ {
+ if (preg_match('/(^|,)'.$cat_id.',/', $uppercats))
+ {
+ @$subcats_of[$cat_id][] = $id;
+ }
+ }
+ }
+
+ $nb_sub_photos = array();
+ foreach ($subcats_of as $cat_id => $subcat_ids)
+ {
+ $nb_photos = 0;
+ foreach ($subcat_ids as $id)
+ {
+ if (isset($nb_photos_in[$id]))
+ {
+ $nb_photos+= $nb_photos_in[$id];
+ }
+ }
+
+ $nb_sub_photos[$cat_id] = $nb_photos;
+ }
}
$template->assign('categories', array());
@@ -289,6 +329,9 @@ foreach ($categories as $category)
$category['name'],
'admin_cat_list'
),
+ 'NB_PHOTOS' => isset($nb_photos_in[$category['id']]) ? $nb_photos_in[$category['id']] : 0,
+ 'NB_SUB_PHOTOS' => isset($nb_sub_photos[$category['id']]) ? $nb_sub_photos[$category['id']] : 0,
+ 'NB_SUB_ALBUMS' => isset($subcats_of[$category['id']]) ? count($subcats_of[$category['id']]) : 0,
'ID' => $category['id'],
'RANK' => $category['rank']*10,
@@ -317,12 +360,6 @@ foreach ($categories as $category)
}
}
- if ( array_key_exists($category['id'], $categories_with_images) )
- {
- $tpl_cat['U_MANAGE_ELEMENTS']=
- $base_url.'batch_manager&amp;filter=album-'.$category['id'];
- }
-
$template->append('categories', $tpl_cat);
}