Changeset 11290


Ignore:
Timestamp:
Jun 10, 2011, 11:02:04 AM (9 years ago)
Author:
mistic100
Message:
 
Location:
extensions/SmartAlbums
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/include/count_images.php

    r10980 r11290  
    1010include_once(SMART_PATH.'include/functions.inc.php');
    1111
    12 $filters = array();
    13 $limit_is_set = false;
    14 foreach ($_POST['filters'] as $filter)
     12if (isset($_POST['filters']))
    1513{
    16   if (($filter = smart_check_filter($filter)) != false)
     14  $filters = array();
     15  $limit_is_set = false;
     16  foreach ($_POST['filters'] as $filter)
    1717  {
    18     array_push($filters, $filter);
     18    if (($filter = smart_check_filter($filter)) != false)
     19    {
     20      array_push($filters, $filter);
     21    }
    1922  }
     23
     24  $associated_images = smart_get_pictures($_POST['cat_id'], $filters);
     25}
     26else
     27{
     28  $associated_images = array();
    2029}
    2130
    22 $associated_images = smart_get_pictures($_POST['cat_id'], $filters);
    2331echo l10n_dec('%d photo', '%d photos', count($associated_images));
    2432
  • extensions/SmartAlbums/init_cat_list.php

    r10980 r11290  
    44 * Add a link into categories list to regenerate associations
    55 */
    6  
     6$smart_count = 0;
     7
    78function smart_cat_list()
    89{
    9   global $template, $page;
     10  global $template, $page, $smart_count;
    1011  include_once(SMART_PATH.'include/functions.inc.php');
    1112  $self_url = get_root_url().'admin.php?page=cat_list'.(isset($_GET['parent_id']) ? '&parent_id='.$_GET['parent_id'] : null);
     
    2829 
    2930  $result = pwg_query($query);
    30   $categories = array();
     31  $smart_cats = array();
    3132  while ($cat = pwg_db_fetch_assoc($result))
    3233  {
    33     $categories[$cat['id']] = trigger_event('render_category_name', $cat['name']);
     34    $smart_cats[$cat['id']] = trigger_event('render_category_name', $cat['name']);
    3435  }
     36 
     37  $smart_count = count($smart_cats);
    3538 
    3639  if (isset($_GET['smart_generate']))
     
    3942    if ($_GET['smart_generate'] == 'all')
    4043    {
    41       foreach ($categories as $cat => $name)
     44      foreach ($smart_cats as $cat => $name)
    4245      {
    4346        $associated_images = smart_make_associations($cat);
     
    5457      array_push($page['infos'], l10n_args(get_l10n_args(
    5558        '%d photos associated to album «%s»',
    56         array(count($associated_images), $categories[$_GET['smart_generate']])
     59        array(count($associated_images), $smart_cats[$_GET['smart_generate']])
    5760      )));
    5861    }
     
    6366  // create regenerate link
    6467  $tpl_cat = array();
    65   foreach ($categories as $cat => $name)
     68  foreach ($smart_cats as $cat => $name)
    6669  {
    6770    $tpl_cat[$cat] = $self_url.'&smart_generate='.$cat;
     
    8083function smart_cat_list_prefilter($content, &$smarty)
    8184{
    82 $search[0] = '<ul class="categoryActions">';
    83 $replacement[0] = $search[0].'
     85  global $smart_count;
     86 
     87  $search[0] = '<ul class="categoryActions">';
     88  $replacement[0] = $search[0].'
    8489{if isset($SMART_URL[$category.ID])}
    8590        <li><a href="{$SMART_URL[$category.ID]}" title="{\'regenerate photos list\'|@translate}"><img src="{$SMART_PATH}template/refresh.png" class="button" alt="{\'regenerate photos list\'|@translate}"></a></li>
    8691{/if}';
    8792
    88 $search[1] = '</ul>
     93  if ($smart_count > 0)
     94  {
     95    $search[1] = '</ul>
    8996</form>
    9097{/if}';
    91 $replacement[1] = $search[1].'
     98    $replacement[1] = $search[1].'
    9299<form method="post" action="{$SMART_URL.all}">
    93100  <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
    94101  <p><input class="submit" type="submit" value="{\'regenerate photos list of all SmartAlbums\'|@translate}"></p>
    95102</form>';
     103  }
    96104
    97105  return str_replace($search, $replacement, $content);
  • extensions/SmartAlbums/main.inc.php

    r10980 r11290  
    1818if (script_basename() == 'admin')
    1919{
     20  load_language('plugin.lang', SMART_PATH);
     21 
    2022  add_event_handler('loc_begin_cat_modify', 'smart_init_cat_modify');
    2123  function smart_init_cat_modify()
     
    3335}
    3436
    35 
    3637?>
Note: See TracChangeset for help on using the changeset viewer.