Index: /extensions/SmartAlbums/include/count_images.php
===================================================================
--- /extensions/SmartAlbums/include/count_images.php	(revision 11333)
+++ /extensions/SmartAlbums/include/count_images.php	(revision 11334)
@@ -13,5 +13,7 @@
 {
   $filters = array();
+  $page['errors'] = array();
   $limit_is_set = false;
+  
   foreach ($_POST['filters'] as $filter)
   {
Index: /extensions/SmartAlbums/include/functions.inc.php
===================================================================
--- /extensions/SmartAlbums/include/functions.inc.php	(revision 11333)
+++ /extensions/SmartAlbums/include/functions.inc.php	(revision 11334)
@@ -28,6 +28,7 @@
       $datas
       );
-    set_random_representant(array($cat_id));
-  }
+  }
+  
+  set_random_representant(array($cat_id));
   
   return $images;
Index: /extensions/SmartAlbums/include/init_cat_list.php
===================================================================
--- /extensions/SmartAlbums/include/init_cat_list.php	(revision 11334)
+++ /extensions/SmartAlbums/include/init_cat_list.php	(revision 11334)
@@ -0,0 +1,118 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+/**
+ * Add a link into categories list to regenerate associations
+ */
+$smart_count = 0;
+
+function smart_cat_list()
+{
+  global $template, $page, $smart_count;
+  include_once(SMART_PATH.'include/functions.inc.php');
+  $self_url = get_root_url().'admin.php?page=cat_list'.(isset($_GET['parent_id']) ? '&amp;parent_id='.$_GET['parent_id'] : null);
+  
+  /* get categories with smart filters */
+  $query = '
+SELECT DISTINCT id, name 
+  FROM '.CATEGORIES_TABLE.' AS c
+    INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf
+      ON c.id = cf.category_id';
+  if (!isset($_GET['parent_id']))
+  {
+    // $query.= '
+    // WHERE id_uppercat IS NULL';
+  }
+  else
+  {
+    $query .= '
+  WHERE uppercats LIKE \'%'.$_GET['parent_id'].'%\'';
+  }
+  $query .= '
+;';
+  
+  $result = pwg_query($query);
+  $smart_cats = array();
+  while ($cat = pwg_db_fetch_assoc($result))
+  {
+    $smart_cats[$cat['id']] = trigger_event('render_category_name', $cat['name']);
+  }
+  
+  $smart_count = count($smart_cats);
+  
+  if (isset($_GET['smart_generate']))
+  {
+    /* regenerate photo list | all (sub) categories */
+    if ($_GET['smart_generate'] == 'all')
+    {
+      foreach ($smart_cats as $cat => $name)
+      {
+        $associated_images = smart_make_associations($cat);
+        array_push(
+          $page['infos'], 
+          l10n_args(get_l10n_args(
+            '%d photos associated to album &laquo;%s&raquo;', 
+            array(count($associated_images), $name)
+            ))
+          );
+      }
+    }
+    /* regenerate photo list | one category */
+    else
+    {
+      $associated_images = smart_make_associations($_GET['smart_generate']);    
+      array_push(
+        $page['infos'], 
+        l10n_args(get_l10n_args(
+          '%d photos associated to album &laquo;%s&raquo;', 
+          array(count($associated_images), $smart_cats[$_GET['smart_generate']])
+          ))
+        );
+    }
+    
+    invalidate_user_cache(true);
+  }
+  
+  // create regenerate link
+  $tpl_cat = array();
+  foreach ($smart_cats as $cat => $name)
+  {
+    $tpl_cat[$cat] = $self_url.'&amp;smart_generate='.$cat;
+  }
+  $tpl_cat['all'] = $self_url.'&amp;smart_generate=all';
+  
+  $template->assign(array(
+    'SMART_URL' => $tpl_cat,
+    'SMART_PATH' => SMART_PATH,
+  ));
+  
+  $template->set_prefilter('categories', 'smart_cat_list_prefilter');
+}
+
+
+function smart_cat_list_prefilter($content, &$smarty)
+{
+  global $smart_count;
+  
+  $search[0] = '{if isset($category.U_SYNC) }';
+  $replacement[0] = '
+{if isset($SMART_URL[$category.ID])}
+        <li><a href="{$SMART_URL[$category.ID]}" title="{\'Regenerate photos list of this SmartAlbum\'|@translate}"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/synchronize.png" class="button" alt="{\'regenerate photos list\'|@translate}"></a></li>
+{/if}'
+.$search[0];
+
+  if ($smart_count > 0)
+  {
+    $search[1] = '</ul>
+</form>
+{/if}';
+    $replacement[1] = $search[1].'
+<form method="post" action="{$SMART_URL.all}">
+  <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
+  <p><input class="submit" type="submit" value="{\'Regenerate photos list of all SmartAlbums\'|@translate}"></p>
+</form>';
+  }
+
+  return str_replace($search, $replacement, $content);
+}
+
+?>
Index: /extensions/SmartAlbums/include/init_cat_modify.php
===================================================================
--- /extensions/SmartAlbums/include/init_cat_modify.php	(revision 11334)
+++ /extensions/SmartAlbums/include/init_cat_modify.php	(revision 11334)
@@ -0,0 +1,144 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+/**
+ * Add the SmartAlbums configuration tool to virtual cats' configuration page
+ */
+ 
+function smart_cat_modify()
+{
+  global $template, $page;
+  include_once(SMART_PATH.'include/functions.inc.php');
+  
+  $cat_id = $_GET['cat_id'];
+  list($cat_dir) = pwg_db_fetch_row(pwg_query('SELECT dir FROM '.CATEGORIES_TABLE.' WHERE id = '.$cat_id.';'));
+  
+  // category must be virtual
+  if ($cat_dir != NULL)
+  {
+    return;
+  }
+  
+  /* SAVE FILTERS */
+  if (isset($_POST['submitFilters']))
+  {
+    // test if it was a Smart Album
+    $result = pwg_query('SELECT DISTINCT category_id FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';');
+    $was_smart = pwg_db_num_rows($result);
+    
+    /* this album is no longer a SmartAlbum */
+    if ($was_smart AND !isset($_POST['is_smart']))
+    {
+      pwg_query('DELETE FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;');
+      pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';');
+      set_random_representant(array($cat_id));
+    }
+    /* no filter selected */
+    else if (isset($_POST['is_smart']) AND !isset($_POST['filters']))
+    {
+      array_push($page['errors'], l10n('No filter selected'));
+    }
+    /* everything is fine */
+    else if (isset($_POST['is_smart']) AND count($_POST['filters']) > 0)
+    {
+      pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';');
+      
+      $limit_is_set = false;
+      foreach ($_POST['filters'] as $filter)
+      {
+        if (($filter = smart_check_filter($filter)) != false)
+        {
+          $query = '
+INSERT INTO '.CATEGORY_FILTERS_TABLE.' 
+  VALUES(
+    '.$cat_id.', 
+    "'.$filter['type'].'", 
+    "'.$filter['cond'].'", 
+    "'.$filter['value'].'"
+  )
+;';
+        pwg_query($query);
+        }
+      }
+      
+      $associated_images = smart_make_associations($cat_id);
+      invalidate_user_cache(true);
+      $template->assign('IMAGE_COUNT', l10n_dec('%d photo', '%d photos', count($associated_images)));
+    }
+  }
+      
+  /* select options, for html_options */
+  $template->assign(
+    'options', 
+    array(
+      'tags' => array(
+        'all' => l10n('All these tags'),
+        'one' => l10n('One of these tags'),
+        'none' => l10n('None of these tags'),
+        'only' => l10n('Only these tags'),
+        ),
+      'date' => array(
+        'the' => l10n('Added the'),
+        'before' => l10n('Added before the'),
+        'after' => l10n('Added after the'),
+        ),
+      'limit' => array('limit' => 'limit'), // second filter not used
+      )
+    );
+  
+  /* get filters for this album */
+  $filters = pwg_query('SELECT * FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.' ORDER BY type ASC, cond ASC;');
+  while ($filter = pwg_db_fetch_assoc($filters))
+  {
+    // get tags name and id
+    if ($filter['type'] == 'tags')
+    {
+      $query = '
+SELECT
+    id AS tag_id,
+    name AS tag_name
+  FROM '.TAGS_TABLE.'
+  WHERE id IN('.$filter['value'].')
+';
+      $filter['value'] = get_taglist($query); 
+    }
+    
+    $template->append('filters', array(
+      'TYPE' => $filter['type'],
+      'COND' => $filter['cond'],
+      'VALUE' => $filter['value'],
+    ));
+  }
+  
+  /* all tags */
+  $query = '
+SELECT
+    id AS tag_id,
+    name AS tag_name
+  FROM '.TAGS_TABLE.'
+;';
+  $tags = get_taglist($query);
+  
+  /* get image number */
+  if ($template->get_template_vars('IMAGE_COUNT') == null)
+  {
+    list($image_num) = pwg_db_fetch_row(pwg_query('SELECT count(*) FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;'));
+    $template->assign('IMAGE_COUNT', l10n_dec('%d photo', '%d photos', $image_num));
+  }
+  
+  $template->assign(array(
+    'SMART_PATH' => SMART_PATH,
+    'COUNT_SCRIPT_URL' => SMART_PATH.'include/count_images.php',
+    'tags' => $tags,
+  )); 
+  $template->set_prefilter('categories', 'smart_cat_modify_prefilter');
+}
+
+
+function smart_cat_modify_prefilter($content, &$smarty)
+{
+  $search = '<form action="{$F_ACTION}" method="POST" id="links">';
+  $replacement = file_get_contents(SMART_PATH.'template/cat_modify.tpl')."\n".$search;
+  return str_replace($search, $replacement, $content);
+}
+
+?>
Index: /extensions/SmartAlbums/include/init_page_items.php
===================================================================
--- /extensions/SmartAlbums/include/init_page_items.php	(revision 11334)
+++ /extensions/SmartAlbums/include/init_page_items.php	(revision 11334)
@@ -0,0 +1,97 @@
+<?php
+if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+/**
+ * Remove form $page['items'] picture that musn't be displayed
+ *
+ * here we get all pictures that current user could see 
+ * if SmartAlbums doesn't exist, and make intersect with pictures
+ * actually displayed
+ */
+function smart_init_page_items()
+{
+  global $user, $page, $conf;
+
+  if (
+    ('categories' == $page['section']) and
+    (!isset($page['chronology_field'])) and
+    (
+      (isset($page['category'])) or
+      (isset($page['flat']))
+    )
+  ) {
+  
+    $query = '
+SELECT DISTINCT(cat.id) AS id
+  FROM '.CATEGORIES_TABLE.' AS cat
+    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS img
+    ON img.category_id = cat.id
+  WHERE img.smart = "true"
+;';
+    $smart_albums = array_from_query($query, 'id');
+      
+    if (count($smart_albums) > 0 and !is_admin())
+    {
+      // add SmartAlbums to forbidden categories
+      $user['forbidden_categories_old'] = $user['forbidden_categories'];
+      $user['forbidden_categories'] = explode(',', $user['forbidden_categories']);
+      $user['forbidden_categories'] = array_unique(array_merge($user['forbidden_categories'], $smart_albums));
+      $user['forbidden_categories'] = implode(',', $user['forbidden_categories']);
+    
+      if ( isset($page['category']) )
+      {
+        $query = '
+SELECT id
+  FROM '.CATEGORIES_TABLE.'
+  WHERE
+    '.get_sql_condition_FandF(
+      array(
+        'forbidden_categories' => 'id',
+        'visible_categories' => 'id',
+        )
+      );
+        $subcat_ids = array_from_query($query, 'id');
+        $subcat_ids[] = 0;
+        $where_sql = 'category_id IN ('.implode(',',$subcat_ids).')';
+        // remove categories from forbidden because just checked above
+        $forbidden = get_sql_condition_FandF(
+          array( 
+            'visible_images' => 'id'
+            ),
+          'AND'
+          );
+      }
+      else
+      {
+        $where_sql = '1=1';
+        $forbidden = get_sql_condition_FandF(
+          array(
+            'forbidden_categories' => 'category_id',
+            'visible_categories' => 'category_id',
+            'visible_images' => 'id'
+            ),
+          'AND'
+          );
+      }
+
+      // Main query
+      $query = '
+SELECT DISTINCT(image_id)
+  FROM '.IMAGE_CATEGORY_TABLE.'
+    INNER JOIN '.IMAGES_TABLE.' ON id = image_id
+  WHERE
+    '.$where_sql.'
+'.$forbidden.'
+  '.$conf['order_by'].'
+;';
+
+      $page['items_wo_sa'] = array_from_query($query, 'image_id');
+      $page['items'] = array_intersect($page['items'], $page['items_wo_sa']);
+      
+      // restore forbidden categories
+      $user['forbidden_categories'] = $user['forbidden_categories_old'];
+    }
+  }
+}
+
+?>
Index: tensions/SmartAlbums/init_cat_list.php
===================================================================
--- /extensions/SmartAlbums/init_cat_list.php	(revision 11333)
+++ 	(revision )
@@ -1,117 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-/**
- * Add a link into categories list to regenerate associations
- */
-$smart_count = 0;
-
-function smart_cat_list()
-{
-  global $template, $page, $smart_count;
-  include_once(SMART_PATH.'include/functions.inc.php');
-  $self_url = get_root_url().'admin.php?page=cat_list'.(isset($_GET['parent_id']) ? '&amp;parent_id='.$_GET['parent_id'] : null);
-  
-  /* get categories with smart filters */
-  $query = '
-SELECT DISTINCT id, name 
-  FROM '.CATEGORIES_TABLE.' AS c
-    INNER JOIN '.CATEGORY_FILTERS_TABLE.' AS cf
-      ON c.id = cf.category_id';
-  if (!isset($_GET['parent_id']))
-  {
-    // $query.= '
-    // WHERE id_uppercat IS NULL';
-  }
-  else
-  {
-    $query .= '
-  WHERE uppercats LIKE \'%'.$_GET['parent_id'].'%\'';
-  }
-  $query .= '
-;';
-  
-  $result = pwg_query($query);
-  $smart_cats = array();
-  while ($cat = pwg_db_fetch_assoc($result))
-  {
-    $smart_cats[$cat['id']] = trigger_event('render_category_name', $cat['name']);
-  }
-  
-  $smart_count = count($smart_cats);
-  
-  if (isset($_GET['smart_generate']))
-  {
-    /* regenerate photo list | all (sub) categories */
-    if ($_GET['smart_generate'] == 'all')
-    {
-      foreach ($smart_cats as $cat => $name)
-      {
-        $associated_images = smart_make_associations($cat);
-        array_push(
-          $page['infos'], 
-          l10n_args(get_l10n_args(
-            '%d photos associated to album &laquo;%s&raquo;', 
-            array(count($associated_images), $name)
-            ))
-          );
-      }
-    }
-    /* regenerate photo list | one category */
-    else
-    {
-      $associated_images = smart_make_associations($_GET['smart_generate']);    
-      array_push(
-        $page['infos'], 
-        l10n_args(get_l10n_args(
-          '%d photos associated to album &laquo;%s&raquo;', 
-          array(count($associated_images), $smart_cats[$_GET['smart_generate']])
-          ))
-        );
-    }
-    
-    invalidate_user_cache(true);
-  }
-  
-  // create regenerate link
-  $tpl_cat = array();
-  foreach ($smart_cats as $cat => $name)
-  {
-    $tpl_cat[$cat] = $self_url.'&amp;smart_generate='.$cat;
-  }
-  $tpl_cat['all'] = $self_url.'&amp;smart_generate=all';
-  
-  $template->assign(array(
-    'SMART_URL' => $tpl_cat,
-    'SMART_PATH' => SMART_PATH,
-  ));
-  
-  $template->set_prefilter('categories', 'smart_cat_list_prefilter');
-}
-
-
-function smart_cat_list_prefilter($content, &$smarty)
-{
-  global $smart_count;
-  
-  $search[0] = '<ul class="categoryActions">';
-  $replacement[0] = $search[0].'
-{if isset($SMART_URL[$category.ID])}
-        <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>
-{/if}';
-
-  if ($smart_count > 0)
-  {
-    $search[1] = '</ul>
-</form>
-{/if}';
-    $replacement[1] = $search[1].'
-<form method="post" action="{$SMART_URL.all}">
-  <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
-  <p><input class="submit" type="submit" value="{\'regenerate photos list of all SmartAlbums\'|@translate}"></p>
-</form>';
-  }
-
-  return str_replace($search, $replacement, $content);
-}
-
-?>
Index: tensions/SmartAlbums/init_cat_modify.php
===================================================================
--- /extensions/SmartAlbums/init_cat_modify.php	(revision 11333)
+++ 	(revision )
@@ -1,143 +1,0 @@
-<?php
-if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
-/**
- * Add the SmartAlbums configuration tool to virtual cats' configuration page
- */
- 
-function smart_cat_modify()
-{
-  global $template;
-  include_once(SMART_PATH.'include/functions.inc.php');
-  
-  $cat_id = $_GET['cat_id'];
-  list($cat_dir) = pwg_db_fetch_row(pwg_query('SELECT dir FROM '.CATEGORIES_TABLE.' WHERE id = '.$cat_id.';'));
-  
-  // category must be virtual
-  if ($cat_dir != NULL)
-  {
-    return;
-  }
-  
-  /* SAVE FILTERS */
-  if (isset($_POST['submitFilters']))
-  {
-    // test if it was a Smart Album
-    $result = pwg_query('SELECT DISTINCT category_id FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';');
-    $was_smart = pwg_db_num_rows($result);
-    
-    /* this album is no longer a SmartAlbum */
-    if ($was_smart AND !isset($_POST['is_smart']))
-    {
-      pwg_query('DELETE FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;');
-      pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';');
-    }
-    /* no filter selected */
-    else if (isset($_POST['is_smart']) AND !isset($_POST['filters']))
-    {
-      array_push($page['errors'], l10n('No filter selected'));
-    }
-    /* everything is fine */
-    else if (isset($_POST['is_smart']) AND count($_POST['filters']) > 0)
-    {
-      pwg_query('DELETE FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.';');
-      
-      $limit_is_set = false;
-      foreach ($_POST['filters'] as $filter)
-      {
-        if (($filter = smart_check_filter($filter)) != false)
-        {
-          $query = '
-INSERT INTO '.CATEGORY_FILTERS_TABLE.' 
-  VALUES(
-    '.$cat_id.', 
-    "'.$filter['type'].'", 
-    "'.$filter['cond'].'", 
-    "'.$filter['value'].'"
-  )
-;';
-        pwg_query($query);
-        }
-      }
-      
-      $associated_images = smart_make_associations($cat_id);
-      invalidate_user_cache(true);
-      $template->assign('IMAGE_COUNT', l10n_dec('%d photo', '%d photos', count($associated_images)));
-    }
-  }
-      
-  /* select options, for html_options */
-  $template->assign(
-    'options', 
-    array(
-      'tags' => array(
-        'all' => l10n('All these tags'),
-        'one' => l10n('One of these tags'),
-        'none' => l10n('None of these tags'),
-        'only' => l10n('Only these tags'),
-        ),
-      'date' => array(
-        'the' => l10n('Added the'),
-        'before' => l10n('Added before the'),
-        'after' => l10n('Added after the'),
-        ),
-      'limit' => array('limit' => 'limit'), // second filter not used
-      )
-    );
-  
-  /* get filters for this album */
-  $filters = pwg_query('SELECT * FROM '.CATEGORY_FILTERS_TABLE.' WHERE category_id = '.$cat_id.' ORDER BY type ASC, cond ASC;');
-  while ($filter = pwg_db_fetch_assoc($filters))
-  {
-    // get tags name and id
-    if ($filter['type'] == 'tags')
-    {
-      $query = '
-SELECT
-    id AS tag_id,
-    name AS tag_name
-  FROM '.TAGS_TABLE.'
-  WHERE id IN('.$filter['value'].')
-';
-      $filter['value'] = get_taglist($query); 
-    }
-    
-    $template->append('filters', array(
-      'TYPE' => $filter['type'],
-      'COND' => $filter['cond'],
-      'VALUE' => $filter['value'],
-    ));
-  }
-  
-  /* all tags */
-  $query = '
-SELECT
-    id AS tag_id,
-    name AS tag_name
-  FROM '.TAGS_TABLE.'
-;';
-  $tags = get_taglist($query);
-  
-  /* get image number */
-  if ($template->get_template_vars('IMAGE_COUNT') == null)
-  {
-    list($image_num) = pwg_db_fetch_row(pwg_query('SELECT count(*) FROM '.IMAGE_CATEGORY_TABLE.' WHERE category_id = '.$cat_id.' AND smart = true;'));
-    $template->assign('IMAGE_COUNT', l10n_dec('%d photo', '%d photos', $image_num));
-  }
-  
-  $template->assign(array(
-    'SMART_PATH' => SMART_PATH,
-    'COUNT_SCRIPT_URL' => SMART_PATH.'include/count_images.php',
-    'tags' => $tags,
-  )); 
-  $template->set_prefilter('categories', 'smart_cat_modify_prefilter');
-}
-
-
-function smart_cat_modify_prefilter($content, &$smarty)
-{
-  $search = '<form action="{$F_ACTION}" method="POST" id="links">';
-  $replacement = file_get_contents(SMART_PATH.'template/cat_modify.tpl')."\n".$search;
-  return str_replace($search, $replacement, $content);
-}
-
-?>
Index: /extensions/SmartAlbums/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/SmartAlbums/language/en_UK/plugin.lang.php	(revision 11333)
+++ /extensions/SmartAlbums/language/en_UK/plugin.lang.php	(revision 11334)
@@ -21,4 +21,6 @@
 $lang['This album is a SmartAlbum'] = 'This album is a SmartAlbum';
 $lang['Count'] = 'Count';
+$lang['Regenerate photos list of this SmartAlbum'] = 'Regenerate photos list of this SmartAlbum';
+$lang['Regenerate photos list of all SmartAlbums'] = 'Regenerate photos list of all SmartAlbums';
 
 ?>
Index: /extensions/SmartAlbums/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/SmartAlbums/language/fr_FR/plugin.lang.php	(revision 11333)
+++ /extensions/SmartAlbums/language/fr_FR/plugin.lang.php	(revision 11334)
@@ -1,5 +1,5 @@
 <?php
 
-$lang['%d photos associated to album &laquo;%s&raquo;'] = '%d photos associées à album &laquo;%s&raquo;';
+$lang['%d photos associated to album &laquo;%s&raquo;'] = '%d photos associées à l\'album &laquo;%s&raquo;';
 $lang['No filter selected'] = 'Aucun filter sélectionné';
 $lang['No tag selected'] = 'Aucun tag sélectionné';
@@ -21,4 +21,6 @@
 $lang['This album is a SmartAlbum'] = 'Cet album est un SmartAlbum';
 $lang['Count'] = 'Compter';
+$lang['Regenerate photos list of this SmartAlbum'] = 'Régénérer les photos de ce SmartAlbum';
+$lang['Regenerate photos list of all SmartAlbums'] = 'Régénérer les photos de tous les SmartAlbums';
 
 ?>
Index: /extensions/SmartAlbums/main.inc.php
===================================================================
--- /extensions/SmartAlbums/main.inc.php	(revision 11333)
+++ /extensions/SmartAlbums/main.inc.php	(revision 11334)
@@ -16,21 +16,18 @@
 define('CATEGORY_FILTERS_TABLE', $prefixeTable.'category_filters');
 
-if (script_basename() == 'admin')
+if (script_basename() == 'index')
+{
+  add_event_handler('loc_end_section_init', 'smart_init_page_items');
+  include_once(SMART_PATH.'include/init_page_items.php');
+}
+else if (script_basename() == 'admin')
 {
   load_language('plugin.lang', SMART_PATH);
   
-  add_event_handler('loc_begin_cat_modify', 'smart_init_cat_modify'); 
-  function smart_init_cat_modify()
-  {
-    include_once(SMART_PATH.'init_cat_modify.php');
-    smart_cat_modify();
-  }
+  add_event_handler('loc_begin_cat_modify', 'smart_cat_modify'); 
+  include_once(SMART_PATH.'include/init_cat_modify.php');
   
-  add_event_handler('loc_begin_cat_list', 'smart_init_cat_list');
-  function smart_init_cat_list()
-  {
-    include_once(SMART_PATH.'init_cat_list.php');
-    smart_cat_list();
-  }
+  add_event_handler('loc_begin_cat_list', 'smart_cat_list');
+  include_once(SMART_PATH.'include/init_cat_list.php');
 }
 
Index: /extensions/SmartAlbums/template/cat_modify.tpl
===================================================================
--- /extensions/SmartAlbums/template/cat_modify.tpl	(revision 11333)
+++ /extensions/SmartAlbums/template/cat_modify.tpl	(revision 11334)
@@ -35,4 +35,5 @@
     $('#SmartAlbum_options').toggle();
     $('input[name="countImages"]').toggle();
+    $('.count_images_display').toggle();
   });
   
