mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-21 09:03:38 +02:00
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
This commit is contained in:
+25
-6
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user