Changeset 1722


Ignore:
Timestamp:
Jan 15, 2007, 1:09:14 AM (17 years ago)
Author:
rub
Message:

There are no filter enabled if filter configuration is empty (no icon, no functions, ...)
New system for the filter page configuration

View mode flat_recent_cat becomes flat_cat (recent period is removed because global filter is sufficient)

Recent period of global filter must be defined "after" start parameter (default value is $userrecent_period).

Location:
trunk
Files:
14 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r1719 r1722  
    175175{
    176176  // Update filtered data
    177   update_cats_with_filtered_data($categories);
     177  if (function_exists('update_cats_with_filtered_data'))
     178  {
     179    update_cats_with_filtered_data($categories);
     180  }
    178181
    179182  if ($conf['subcatify'])
  • trunk/include/common.inc.php

    r1699 r1722  
    232232}
    233233
    234 if (!defined('IN_ADMIN') or !IN_ADMIN)
     234if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
    235235{
    236236  include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
    237237  include(PHPWG_ROOT_PATH.'include/filter.inc.php');
     238}
     239else
     240{
     241  // global variable for filter
     242  $filter = array();
     243  $filter['enabled'] = false;
    238244}
    239245
  • trunk/include/config_default.inc.php

    r1715 r1722  
    569569// | Filter                                                                |
    570570// +-----------------------------------------------------------------------+
    571 // Pages where filter is enabled
    572 // Other pages cancel current filter
    573 // Array of basename without file extention
     571// $conf['filter_pages'] contains configuration for each pages
     572//   o If values are not defined for a specific page, default value are used
     573//   o Array is composed by the basename of each page without extention
     574//   o List of value names:
     575//     - used: filter function are used
     576//       (if false nothing is done [start, cancel, stop, ...]
     577//     - cancel: cancel current started filter
     578//     - add_notes: add notes about current started filter on the header
     579//   o Empty configuration in order to disable completely filter functions
     580//     No filter, No icon,...
     581//     $conf['filter_pages'] = array();
    574582$conf['filter_pages'] = array
    575583  (
    576     'about', 'action', 'admin', 'comments',
    577     'index', 'picture', 'popuphelp', 'profile',
    578     'qsearch', 'random', 'register', 'search',
    579     'search_rules', 'tags', 'upload'
     584    // Default page
     585    'default' => array(
     586      'used' => true, 'cancel' => false, 'add_notes' => false),
     587    // Real pages
     588    'index' => array('add_notes' => true),
     589    'tags' => array('add_notes' => true),
     590    'search' => array('add_notes' => true),
     591    'comments' => array('add_notes' => true),
     592    'admin' => array('used' => false),
     593    'feed' => array('used' => false),
     594    'notification' => array('used' => false),
     595    'nbm' => array('used' => false),
     596    'popuphelp' => array('used' => false),
     597    'profile' => array('used' => false),
     598    'web_service' => array('used' => false),
     599    'ws' => array('used' => false),
     600    'identification' => array('cancel' => true),
     601    'install' => array('cancel' => true),
     602    'password' => array('cancel' => true),
     603    'register' => array('cancel' => true),
     604    'upgrade_feed' => array('cancel' => true),
    580605  );
    581606
  • trunk/include/filter.inc.php

    r1715 r1722  
    2929
    3030// $filter['enabled']: Filter is enabled
     31// $filter['check_key']: Check key to valitade computed filter data
     32// $filter['recent_period']: Recent period used to computed filter data
    3133// $filter['categories']: Computed data of filtered categories
    32 // $filter['visible_categories']: List of visible categories (count(visible) < count(forbidden) more often)
     34// $filter['visible_categories']:
     35//  List of visible categories (count(visible) < count(forbidden) more often)
    3336// $filter['visible_images']: List of visible images
    3437
    35 if (in_array(script_basename(), $conf['filter_pages']))
     38if (!get_filter_page_value('cancel'))
    3639{
    3740  if (isset($_GET['filter']))
    3841  {
    39     $filter['enabled'] = ($_GET['filter'] == 'start');
     42    $filter['matches'] = array();
     43    $filter['enabled'] =
     44      preg_match('/^start-(\d+)/', $_GET['filter'], $filter['matches']) === 1;
    4045  }
    4146  else
     
    5156if ($filter['enabled'])
    5257{
     58  if (isset($filter['matches']))
     59  {
     60    $filter['recent_period'] = $filter['matches'][1];
     61  }
     62  else
     63  {
     64    $filter['recent_period'] = pwg_get_session_var('filter_recent_period', $user['recent_period']);
     65  }
     66
    5367  if (
    5468      // New filter
     
    6276    // Need to compute dats
    6377    $filter['check_key'] = get_filter_check_key();
    64     $filter['categories'] = get_computed_categories($user['id'], $user['forbidden_categories'], true, $user['recent_period']);
     78    $filter['categories'] = get_computed_categories($user['id'], $user['forbidden_categories'], true, $filter['recent_period']);
    6579
    6680    $filter['visible_categories'] = implode(',', array_keys($filter['categories']));
     
    8498  $query.= '
    8599    date_available  > SUBDATE(
    86       CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     100      CURRENT_DATE,INTERVAL '.$filter['recent_period'].' DAY)';
    87101
    88102    $filter['visible_images'] = implode(',', array_from_query($query, 'image_id'));
     
    97111    pwg_set_session_var('filter_enabled', $filter['enabled']);
    98112    pwg_set_session_var('filter_check_key', $filter['check_key']);
     113    pwg_set_session_var('filter_recent_period', $filter['recent_period']);
    99114    pwg_set_session_var('filter_categories', serialize($filter['categories']));
    100115    pwg_set_session_var('filter_visible_categories', $filter['visible_categories']);
     
    111126  }
    112127
    113   $header_notes[] = l10n_dec('note_filter_day', 'note_filter_days', $user['recent_period']);
     128  if (get_filter_page_value('add_notes'))
     129  {
     130    $header_notes[] = l10n_dec('note_filter_day', 'note_filter_days', $filter['recent_period']);
     131  }
    114132}
    115133else
     
    119137    pwg_unset_session_var('filter_enabled');
    120138    pwg_unset_session_var('filter_check_key');
     139    pwg_unset_session_var('filter_recent_period');
    121140    pwg_unset_session_var('filter_categories');
    122141    pwg_unset_session_var('filter_visible_categories');
  • trunk/include/functions.inc.php

    r1717 r1722  
    11051105}
    11061106
     1107/**
     1108 * Return value for the current page define on $conf['filter_pages']
     1109 * Îf value is not defined, default value are returned
     1110 *
     1111 * @param value name
     1112 *
     1113 * @return filter page value
     1114 */
     1115function get_filter_page_value($value_name)
     1116{
     1117  global $conf;
     1118
     1119  $page_name = script_basename();
     1120
     1121  if (isset($conf['filter_pages'][$page_name][$value_name]))
     1122  {
     1123    return $conf['filter_pages'][$page_name][$value_name];
     1124  }
     1125  else if (isset($conf['filter_pages']['default'][$value_name]))
     1126  {
     1127    return $conf['filter_pages']['default'][$value_name];
     1128  }
     1129  else
     1130  {
     1131    return null;
     1132  }
     1133}
     1134
    11071135?>
  • trunk/include/functions_category.inc.php

    r1677 r1722  
    108108
    109109  // Update filtered data
    110   update_cats_with_filtered_data($cats);
     110  if (function_exists('update_cats_with_filtered_data'))
     111  {
     112    update_cats_with_filtered_data($cats);
     113  }
    111114
    112115  return get_html_menu_category($cats);
  • trunk/include/functions_filter.inc.php

    r1677 r1722  
    3535function get_filter_check_key()
    3636{
    37   global $user;
    38  
    39   return $user['id'].$user['recent_period'].date('Ymd');
     37  global $user, $filter;
     38
     39  return $user['id'].$filter['recent_period'].date('Ymd');
    4040}
    4141
  • trunk/include/functions_url.inc.php

    r1678 r1722  
    265265  }
    266266
    267   if (isset($params['flat_recent_cat']) and $params['flat_recent_cat'] > 0)
    268   {
    269     $url.= '/flat_recent_cat-'.$params['flat_recent_cat'];
     267  if (isset($params['flat_cat']))
     268  {
     269    $url.= '/flat_cat';
    270270  }
    271271
  • trunk/include/menubar.inc.php

    r1703 r1722  
    6666
    6767//------------------------------------------------------------------------ filter
    68 if ($filter['enabled'])
    69 {
    70   $template->assign_block_vars(
    71     'stop_filter',
    72     array(
    73       'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
    74       )
    75     );
    76 }
    77 else
    78 {
    79   $template->assign_block_vars(
    80     'start_filter',
    81     array(
    82       'URL' => add_url_params(make_index_url(array()), array('filter' => 'start'))
    83       )
    84     );
    85 }
    86 
     68if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
     69{
     70  if ($filter['enabled'])
     71  {
     72    $template->assign_block_vars(
     73      'stop_filter',
     74      array(
     75        'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
     76        )
     77      );
     78  }
     79  else
     80  {
     81    $template->assign_block_vars(
     82      'start_filter',
     83      array(
     84        'URL' => add_url_params(make_index_url(array()), array('filter' => 'start-'.$user['recent_period']))
     85        )
     86      );
     87  }
     88}
    8789
    8890//------------------------------------------------------------------------ tags
  • trunk/include/section_init.inc.php

    r1711 r1722  
    279279  }
    280280
    281   if ('categories'==$page['section'] and
    282       preg_match('/^flat_recent_cat-(\d+)/', $tokens[$i], $matches))
     281  if ('categories' == $page['section'] and
     282      'flat_cat' == $tokens[$i])
    283283  {
    284284    // indicate a special list of images
    285     $page['flat_recent_cat'] = $matches[1];
     285    $page['flat_cat'] = true;
    286286  }
    287287
     
    365365          get_cat_display_name($result['name'], '', false),
    366366        'thumbnails_include' =>
    367           (($result['nb_images'] > 0) or (isset($page['flat_recent_cat'])))
     367          (($result['nb_images'] > 0) or (isset($page['flat_cat'])))
    368368          ? 'include/category_default.inc.php'
    369369          : 'include/category_cats.inc.php'
     
    375375    $page['title'] = $lang['no_category'];
    376376    $page['thumbnails_include'] =
    377       (isset($page['flat_recent_cat']))
     377      (isset($page['flat_cat']))
    378378          ? 'include/category_default.inc.php'
    379379          : 'include/category_cats.inc.php';
    380380  }
    381381
    382   if (isset($page['flat_recent_cat']))
     382  if (isset($page['flat_cat']))
    383383  {
    384384    $page['title'] = $lang['recent_pics_cat'].' : '.$page['title'] ;
     
    390390      (
    391391        (isset($page['category'])) or
    392         (isset($page['flat_recent_cat']))
     392        (isset($page['flat_cat']))
    393393      )
    394394    )
     
    399399    }
    400400
    401     if (isset($page['flat_recent_cat']))
     401    if (isset($page['flat_cat']))
    402402    {
    403403      // flat recent categories mode
     
    409409       INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
    410410WHERE
    411   date_available  > SUBDATE(
    412       CURRENT_DATE,INTERVAL '.$page['flat_recent_cat'].' DAY)'.
    413   (isset($page['category']) ? '
    414   AND uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '' ).'
     411  '.(isset($page['category']) ? '
     412  uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '1=1' ).'
    415413'.$forbidden.'
    416414;';
     
    713711// add meta robots noindex, nofollow to avoid unnecesary robot crawls
    714712$page['meta_robots']=array();
    715 if ( isset($page['chronology_field']) or isset($page['flat_recent_cat'])
     713if ( isset($page['chronology_field']) or isset($page['flat_cat'])
    716714      or 'list'==$page['section'] or 'recent_pics'==$page['section'] )
    717715{
  • trunk/index.php

    r1711 r1722  
    107107}
    108108
    109 if (isset($page['flat_recent_cat']) or isset($page['chronology_field']))
     109if (isset($page['flat_cat']) or isset($page['chronology_field']))
    110110{
    111111  $template->assign_block_vars(
    112112    'mode_normal',
    113113    array(
    114       'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat_recent_cat') )
    115       )
    116     );
    117 }
    118 
    119 if (!isset($page['flat_recent_cat']) and 'categories'==$page['section'])
    120 {
    121   $template->assign_block_vars(
    122     'flat_recent_cat',
    123     array(
    124       'URL' => duplicate_index_url(array('flat_recent_cat' => $user['recent_period']), array('start', 'chronology_field'))
     114      'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat_cat') )
     115      )
     116    );
     117}
     118
     119if (!isset($page['flat_cat']) and 'categories' == $page['section'])
     120{
     121  $template->assign_block_vars(
     122    'flat_cat',
     123    array(
     124      'URL' => duplicate_index_url(array('flat_cat' => ''), array('start', 'chronology_field'))
    125125      )
    126126    );
     
    138138    'mode_created',
    139139    array(
    140       'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_recent_cat') )
     140      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_cat') )
    141141      )
    142142    );
     
    146146    'mode_posted',
    147147    array(
    148       'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_recent_cat') )
     148      'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_cat') )
    149149      )
    150150    );
     
    162162  $url = duplicate_index_url(
    163163            array('chronology_field'=>$chronology_field ),
    164             array('chronology_date', 'start', 'flat_recent_cat')
     164            array('chronology_date', 'start', 'flat_cat')
    165165          );
    166166  $template->assign_block_vars(
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r1678 r1722  
    491491$lang['maxwidth'] = 'Maximum width of the pictures';
    492492$lang['maxwidth_error'] = 'Maximum width must be a number superior to 50';
    493 $lang['flat_recent_cat_hint'] = 'display recent elements of categories and sub-categories';
     493$lang['flat_cat_hint'] = 'flat display elements of categories and sub-categories';
    494494$lang['start_filter_hint'] = 'displays only recent elements';
    495495$lang['stop_filter_hint'] = 'return to display all elements';
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r1677 r1722  
    491491$lang['maxwidth'] = 'Largeur maximum des images';
    492492$lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50';
    493 $lang['flat_recent_cat_hint'] = 'affiche les éléments récents des catégories et des sous-catégories';
     493$lang['flat_cat_hint'] = 'affiche à plat les éléments des catégories et des sous-catégories';
    494494$lang['start_filter_hint'] = 'afficher que les éléments récents';
    495495$lang['stop_filter_hint'] = 'retourner à l\'affichage de tous les éléments';
  • trunk/template/yoga/index.tpl

    r1703 r1722  
    3232      <!-- END mode_normal -->
    3333
    34       <!-- BEGIN flat_recent_cat -->
    35       <li><a href="{flat_recent_cat.URL}" title="{lang:flat_recent_cat_hint}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/flat_recent_cat.png" class="button" alt="{lang:flat_recent_cat_hint}"></a></li>
    36       <!-- END flat_recent_cat -->
     34      <!-- BEGIN flat_cat -->
     35      <li><a href="{flat_cat.URL}" title="{lang:flat_cat_hint}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/flat_cat.png" class="button" alt="{lang:flat_cat_hint}"></a></li>
     36      <!-- END flat_cat -->
    3737
    3838      <!-- BEGIN mode_posted -->
Note: See TracChangeset for help on using the changeset viewer.