aboutsummaryrefslogtreecommitdiffstats
path: root/include/filter.inc.php
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2007-01-15 00:09:14 +0000
committerrub <rub@piwigo.org>2007-01-15 00:09:14 +0000
commit9362801a48c6e88fcc9bd56e69ba044f718c6b74 (patch)
tree5c05741cb7262fc51d6c6ad6b6b2bd8c44e0353f /include/filter.inc.php
parent3cef1e6895ed3daeb398980b22cab1c1edefa3c3 (diff)
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 $user['recent_period']). git-svn-id: http://piwigo.org/svn/trunk@1722 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/filter.inc.php')
-rw-r--r--include/filter.inc.php31
1 files changed, 25 insertions, 6 deletions
diff --git a/include/filter.inc.php b/include/filter.inc.php
index f67a63386..2dbd37a9d 100644
--- a/include/filter.inc.php
+++ b/include/filter.inc.php
@@ -28,15 +28,20 @@
$filter = array();
// $filter['enabled']: Filter is enabled
+// $filter['check_key']: Check key to valitade computed filter data
+// $filter['recent_period']: Recent period used to computed filter data
// $filter['categories']: Computed data of filtered categories
-// $filter['visible_categories']: List of visible categories (count(visible) < count(forbidden) more often)
+// $filter['visible_categories']:
+// List of visible categories (count(visible) < count(forbidden) more often)
// $filter['visible_images']: List of visible images
-if (in_array(script_basename(), $conf['filter_pages']))
+if (!get_filter_page_value('cancel'))
{
if (isset($_GET['filter']))
{
- $filter['enabled'] = ($_GET['filter'] == 'start');
+ $filter['matches'] = array();
+ $filter['enabled'] =
+ preg_match('/^start-(\d+)/', $_GET['filter'], $filter['matches']) === 1;
}
else
{
@@ -50,6 +55,15 @@ else
if ($filter['enabled'])
{
+ if (isset($filter['matches']))
+ {
+ $filter['recent_period'] = $filter['matches'][1];
+ }
+ else
+ {
+ $filter['recent_period'] = pwg_get_session_var('filter_recent_period', $user['recent_period']);
+ }
+
if (
// New filter
!pwg_get_session_var('filter_enabled', false) or
@@ -61,7 +75,7 @@ if ($filter['enabled'])
{
// Need to compute dats
$filter['check_key'] = get_filter_check_key();
- $filter['categories'] = get_computed_categories($user['id'], $user['forbidden_categories'], true, $user['recent_period']);
+ $filter['categories'] = get_computed_categories($user['id'], $user['forbidden_categories'], true, $filter['recent_period']);
$filter['visible_categories'] = implode(',', array_keys($filter['categories']));
if (empty($filter['visible_categories']))
@@ -83,7 +97,7 @@ WHERE ';
}
$query.= '
date_available > SUBDATE(
- CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
+ CURRENT_DATE,INTERVAL '.$filter['recent_period'].' DAY)';
$filter['visible_images'] = implode(',', array_from_query($query, 'image_id'));
@@ -96,6 +110,7 @@ WHERE ';
// Save filter data on session
pwg_set_session_var('filter_enabled', $filter['enabled']);
pwg_set_session_var('filter_check_key', $filter['check_key']);
+ pwg_set_session_var('filter_recent_period', $filter['recent_period']);
pwg_set_session_var('filter_categories', serialize($filter['categories']));
pwg_set_session_var('filter_visible_categories', $filter['visible_categories']);
pwg_set_session_var('filter_visible_images', $filter['visible_images']);
@@ -110,7 +125,10 @@ WHERE ';
$filter['visible_images'] = pwg_get_session_var('filter_visible_images', '');
}
- $header_notes[] = l10n_dec('note_filter_day', 'note_filter_days', $user['recent_period']);
+ if (get_filter_page_value('add_notes'))
+ {
+ $header_notes[] = l10n_dec('note_filter_day', 'note_filter_days', $filter['recent_period']);
+ }
}
else
{
@@ -118,6 +136,7 @@ else
{
pwg_unset_session_var('filter_enabled');
pwg_unset_session_var('filter_check_key');
+ pwg_unset_session_var('filter_recent_period');
pwg_unset_session_var('filter_categories');
pwg_unset_session_var('filter_visible_categories');
pwg_unset_session_var('filter_visible_images');