Changeset 26399 for trunk/admin/cat_list.php
- Timestamp:
- Jan 2, 2014, 12:51:58 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/cat_list.php
r25975 r26399 252 252 // get the categories containing images directly 253 253 $categories_with_images = array(); 254 if ( count($categories))254 if (count($categories)) 255 255 { 256 256 $query = ' 257 SELECT DISTINCT category_id 257 SELECT 258 category_id, 259 COUNT(*) AS nb_photos 258 260 FROM '.IMAGE_CATEGORY_TABLE.' 259 WHERE category_id IN ('.implode(',', array_keys($categories)).')'; 260 $categories_with_images = array_flip( array_from_query($query, 'category_id') ); 261 GROUP BY category_id 262 ;'; 263 // WHERE category_id IN ('.implode(',', array_keys($categories)).') 264 265 $nb_photos_in = query2array($query, 'category_id', 'nb_photos'); 266 267 $query = ' 268 SELECT 269 id, 270 uppercats 271 FROM '.CATEGORIES_TABLE.' 272 ;'; 273 $all_categories = query2array($query, 'id', 'uppercats'); 274 $subcats_of = array(); 275 276 foreach (array_keys($categories) as $cat_id) 277 { 278 foreach ($all_categories as $id => $uppercats) 279 { 280 if (preg_match('/(^|,)'.$cat_id.',/', $uppercats)) 281 { 282 @$subcats_of[$cat_id][] = $id; 283 } 284 } 285 } 286 287 $nb_sub_photos = array(); 288 foreach ($subcats_of as $cat_id => $subcat_ids) 289 { 290 $nb_photos = 0; 291 foreach ($subcat_ids as $id) 292 { 293 if (isset($nb_photos_in[$id])) 294 { 295 $nb_photos+= $nb_photos_in[$id]; 296 } 297 } 298 299 $nb_sub_photos[$cat_id] = $nb_photos; 300 } 261 301 } 262 302 … … 290 330 'admin_cat_list' 291 331 ), 332 'NB_PHOTOS' => isset($nb_photos_in[$category['id']]) ? $nb_photos_in[$category['id']] : 0, 333 'NB_SUB_PHOTOS' => isset($nb_sub_photos[$category['id']]) ? $nb_sub_photos[$category['id']] : 0, 334 'NB_SUB_ALBUMS' => isset($subcats_of[$category['id']]) ? count($subcats_of[$category['id']]) : 0, 292 335 'ID' => $category['id'], 293 336 'RANK' => $category['rank']*10, … … 318 361 } 319 362 320 if ( array_key_exists($category['id'], $categories_with_images) )321 {322 $tpl_cat['U_MANAGE_ELEMENTS']=323 $base_url.'batch_manager&filter=album-'.$category['id'];324 }325 326 363 $template->append('categories', $tpl_cat); 327 364 }
Note: See TracChangeset
for help on using the changeset viewer.