diff options
Diffstat (limited to 'include/filter.inc.php')
-rw-r--r-- | include/filter.inc.php | 31 |
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'); |