Ignore:
Timestamp:
Jan 4, 2014, 4:13:08 PM (10 years ago)
Author:
mistic100
Message:

update for Piwigo 2.6

File:
1 moved

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/include/events_admin.inc.php

    r24342 r26442  
    11<?php
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
     2defined('SMART_PATH') or die('Hacking attempt!');
     3
     4/**
     5 * new tab on album properties page
     6 */
     7function smart_tab($sheets, $id)
     8{
     9  if ($id == 'album')
     10  {
     11    global $category;
     12
     13    if ($category['dir'] == null)
     14    {
     15      $sheets['smartalbum'] = array(
     16        'caption' => 'SmartAlbum',
     17        'url' => SMART_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'],
     18        );
     19    }
     20  }
     21
     22  return $sheets;
     23}
     24
     25/**
     26 * admin plugins menu link
     27 */
     28function smart_admin_menu($menu)
     29{
     30  $menu[] = array(
     31    'NAME' => 'SmartAlbums',
     32    'URL' => SMART_ADMIN,
     33    );
     34  return $menu;
     35}
     36
    337/**
    438 * Add a link into categories list to regenerate associations
    539 */
    6 $smart_count = 0;
    7 
    840function smart_cat_list()
    941{
    10   global $template, $page, $smart_count;
     42  global $template, $page;
     43
     44  if (!isset($smart_count))
     45  {
     46    $smart_count = 0;
     47  }
    1148
    1249  $self_url = get_root_url().'admin.php?page=cat_list'.(isset($_GET['parent_id']) ? '&amp;parent_id='.$_GET['parent_id'] : null);
    13  
     50
    1451  /* get categories with smart filters */
    1552  $query = '
    16 SELECT DISTINCT id, name 
     53SELECT DISTINCT id, name
    1754  FROM '.CATEGORIES_TABLE.' AS c
    1855    INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf
    19       ON c.id = cf.category_id';
     56    ON c.id = cf.category_id';
    2057  if (!isset($_GET['parent_id']))
    2158  {
     
    3067  $query .= '
    3168;';
    32  
    33   $smart_cats = hash_from_query($query, 'id');
    34   $smart_count = count($smart_cats);
    35  
     69
     70  $smart_cats = query2array($query, 'id');
     71
    3672  if (isset($_GET['smart_generate']))
    3773  {
     
    4278      {
    4379        $associated_images = smart_make_associations($category['id']);
    44         array_push($page['infos'],
    45           sprintf(l10n('%d photos associated to album %s'),
    46             count($associated_images),
    47             '&laquo;'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'&raquo;'
    48             )
     80
     81        $page['infos'][] = l10n(
     82          '%d photos associated to album %s',
     83          count($associated_images),
     84          '&laquo;'.trigger_event('render_category_name', $category['name'], 'admin_cat_list').'&raquo;'
    4985          );
    5086      }
     
    5389    else
    5490    {
    55       $associated_images = smart_make_associations($_GET['smart_generate']);   
    56       array_push($page['infos'],
    57         sprintf(l10n('%d photos associated to album %s'),
    58           count($associated_images),
    59           '&laquo;'.trigger_event('render_category_name', $smart_cats[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'&raquo;'
    60           )
     91      $associated_images = smart_make_associations($_GET['smart_generate']);
     92
     93      $page['infos'][] = l10n(
     94        '%d photos associated to album %s',
     95        count($associated_images),
     96        '&laquo;'.trigger_event('render_category_name', $smart_cats[ $_GET['smart_generate'] ]['name'], 'admin_cat_list').'&raquo;'
    6197        );
    6298    }
    63    
     99
    64100    define('SMART_NOT_UPDATE', 1);
    65101    invalidate_user_cache();
    66102  }
    67  
     103
    68104  // create regenerate link
    69105  $tpl_cat = array();
     
    72108    $tpl_cat[$cat] = $self_url.'&amp;smart_generate='.$cat;
    73109  }
    74   $tpl_cat['all'] = $self_url.'&amp;smart_generate=all';
    75  
     110  if (count($smart_cats))
     111  {
     112    $tpl_cat['all'] = $self_url.'&amp;smart_generate=all';
     113  }
     114
    76115  $template->assign(array(
    77116    'SMART_URL' => $tpl_cat,
    78117    'SMART_PATH' => SMART_PATH,
    79118  ));
    80  
     119
    81120  $template->set_prefilter('categories', 'smart_cat_list_prefilter');
    82121}
    83122
    84123
    85 function smart_cat_list_prefilter($content, &$smarty)
     124function smart_cat_list_prefilter($content)
    86125{
    87   global $smart_count;
    88  
    89126  $search[0] = '{if isset($category.U_MANAGE_ELEMENTS) }';
    90127  $replacement[0] = $search[0].'
     
    93130{/if}';
    94131
    95   if ($smart_count > 0)
    96   {
    97     $search[1] = '<a href="#" id="autoOrderOpen">{\'apply automatic sort order\'|@translate}</a>';
    98     $replacement[1] = $search[1].'
    99 | <a href="{$SMART_URL.all}">{\'Regenerate photos list of all SmartAlbums\'|@translate}</a>';
    100   }
    101  
     132  $search[1] = '<a href="#" id="autoOrderOpen">{\'apply automatic sort order\'|@translate}</a>';
     133  $replacement[1] = $search[1].'
     134{if isset($SMART_URL.all)}| <a href="{$SMART_URL.all}">{\'Regenerate photos list of all SmartAlbums\'|@translate}</a>{/if}';
     135
    102136  $search[2] = '{$category.NAME}</a></strong>';
    103137  $replacement[2] = $search[2].'
     
    108142  return str_replace($search, $replacement, $content);
    109143}
    110 
    111 ?>
Note: See TracChangeset for help on using the changeset viewer.