Changeset 26399


Ignore:
Timestamp:
Jan 2, 2014, 12:51:58 PM (7 years ago)
Author:
plg
Message:

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

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_list.php

    r25975 r26399  
    252252// get the categories containing images directly
    253253$categories_with_images = array();
    254 if ( count($categories) )
     254if (count($categories))
    255255{
    256256  $query = '
    257 SELECT DISTINCT category_id
     257SELECT
     258    category_id,
     259    COUNT(*) AS nb_photos
    258260  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 = '
     268SELECT
     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  }
    261301}
    262302
     
    290330          'admin_cat_list'
    291331          ),
     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,
    292335      'ID'         => $category['id'],
    293336      'RANK'       => $category['rank']*10,
     
    318361  }
    319362
    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 
    326363  $template->append('categories', $tpl_cat);
    327364}
  • trunk/admin/themes/default/template/cat_list.tpl

    r24985 r26399  
    117117        <img src="{$themeconf.admin_icon_dir}/cat_move.png" class="drag_button" style="display:none;" alt="{'Drag to re-order'|@translate}" title="{'Drag to re-order'|@translate}">
    118118        <strong><a href="{$category.U_CHILDREN}" title="{'manage sub-albums'|@translate}">{$category.NAME}</a></strong>
     119        <span class="albumInfos"><span class="userSeparator">&middot;</span> {$category.NB_PHOTOS|translate_dec:'%d photo':'%d photos'} <span class="userSeparator">&middot;</span> {$category.NB_SUB_PHOTOS|translate_dec:'%d photo':'%d photos'} {$category.NB_SUB_ALBUMS|translate_dec:'in %d sub-album':'in %d sub-albums'}</span>
    119120      </p>
    120121
     
    123124      <p class="albumActions">
    124125        <a href="{$category.U_EDIT}"><span class="icon-pencil"></span>{'Edit'|@translate}</a>
    125         {if isset($category.U_MANAGE_ELEMENTS) }
    126         | <a href="{$category.U_MANAGE_ELEMENTS}"><span class="icon-picture"></span>{'manage album photos'|@translate}</a>
    127         {/if}
    128126        | <a href="{$category.U_CHILDREN}"><span class="icon-sitemap"></span>{'manage sub-albums'|@translate}</a>
    129127        {if isset($category.U_SYNC) }
  • trunk/admin/themes/default/theme.css

    r26230 r26399  
    10651065
    10661066FORM#categoryOrdering p.albumTitle {margin:0;}
    1067 FORM#categoryOrdering p.albumActions {visibility:hidden; margin:0}
    1068 FORM#categoryOrdering .categoryLi:hover p.albumActions {visibility:visible;}
     1067FORM#categoryOrdering p.albumActions, FORM#categoryOrdering span.albumInfos {visibility:hidden; margin:0}
     1068FORM#categoryOrdering .categoryLi:hover p.albumActions, FORM#categoryOrdering .categoryLi:hover span.albumInfos {visibility:visible;}
    10691069
    10701070.showCreateAlbum {text-align:left; margin:0 1em 1em 1em;line-height:22px;}
Note: See TracChangeset for help on using the changeset viewer.