aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--include/category_cats.inc.php5
-rw-r--r--include/common.inc.php8
-rw-r--r--include/config_default.inc.php39
-rw-r--r--include/filter.inc.php31
-rw-r--r--include/functions.inc.php28
-rw-r--r--include/functions_category.inc.php5
-rw-r--r--include/functions_filter.inc.php6
-rw-r--r--include/functions_url.inc.php4
-rw-r--r--include/menubar.inc.php36
-rw-r--r--include/section_init.inc.php24
-rw-r--r--index.php16
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php2
-rw-r--r--language/fr_FR.iso-8859-1/common.lang.php2
-rw-r--r--template/yoga/icon/flat_cat.png (renamed from template/yoga/icon/flat_recent_cat.png)bin754 -> 754 bytes
-rw-r--r--template/yoga/index.tpl6
15 files changed, 148 insertions, 64 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index f6f188831..8f8f3ba50 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -174,7 +174,10 @@ SELECT id, path, tn_ext
if (count($categories) > 0)
{
// Update filtered data
- update_cats_with_filtered_data($categories);
+ if (function_exists('update_cats_with_filtered_data'))
+ {
+ update_cats_with_filtered_data($categories);
+ }
if ($conf['subcatify'])
{
diff --git a/include/common.inc.php b/include/common.inc.php
index 01e6869e1..5a0a82ff9 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -231,11 +231,17 @@ if (count($header_msgs) > 0)
}
}
-if (!defined('IN_ADMIN') or !IN_ADMIN)
+if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
{
include(PHPWG_ROOT_PATH.'include/functions_filter.inc.php');
include(PHPWG_ROOT_PATH.'include/filter.inc.php');
}
+else
+{
+ // global variable for filter
+ $filter = array();
+ $filter['enabled'] = false;
+}
if (isset($conf['header_notes']))
{
diff --git a/include/config_default.inc.php b/include/config_default.inc.php
index 2f61f5584..42a7cae8e 100644
--- a/include/config_default.inc.php
+++ b/include/config_default.inc.php
@@ -568,15 +568,40 @@ $conf['enable_plugins']=true;
// +-----------------------------------------------------------------------+
// | Filter |
// +-----------------------------------------------------------------------+
-// Pages where filter is enabled
-// Other pages cancel current filter
-// Array of basename without file extention
+// $conf['filter_pages'] contains configuration for each pages
+// o If values are not defined for a specific page, default value are used
+// o Array is composed by the basename of each page without extention
+// o List of value names:
+// - used: filter function are used
+// (if false nothing is done [start, cancel, stop, ...]
+// - cancel: cancel current started filter
+// - add_notes: add notes about current started filter on the header
+// o Empty configuration in order to disable completely filter functions
+// No filter, No icon,...
+// $conf['filter_pages'] = array();
$conf['filter_pages'] = array
(
- 'about', 'action', 'admin', 'comments',
- 'index', 'picture', 'popuphelp', 'profile',
- 'qsearch', 'random', 'register', 'search',
- 'search_rules', 'tags', 'upload'
+ // Default page
+ 'default' => array(
+ 'used' => true, 'cancel' => false, 'add_notes' => false),
+ // Real pages
+ 'index' => array('add_notes' => true),
+ 'tags' => array('add_notes' => true),
+ 'search' => array('add_notes' => true),
+ 'comments' => array('add_notes' => true),
+ 'admin' => array('used' => false),
+ 'feed' => array('used' => false),
+ 'notification' => array('used' => false),
+ 'nbm' => array('used' => false),
+ 'popuphelp' => array('used' => false),
+ 'profile' => array('used' => false),
+ 'web_service' => array('used' => false),
+ 'ws' => array('used' => false),
+ 'identification' => array('cancel' => true),
+ 'install' => array('cancel' => true),
+ 'password' => array('cancel' => true),
+ 'register' => array('cancel' => true),
+ 'upgrade_feed' => array('cancel' => true),
);
?>
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');
diff --git a/include/functions.inc.php b/include/functions.inc.php
index de69a252c..177ab651c 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1104,4 +1104,32 @@ function script_basename()
return basename(strtolower($file_name), '.php');
}
+/**
+ * Return value for the current page define on $conf['filter_pages']
+ * Îf value is not defined, default value are returned
+ *
+ * @param value name
+ *
+ * @return filter page value
+ */
+function get_filter_page_value($value_name)
+{
+ global $conf;
+
+ $page_name = script_basename();
+
+ if (isset($conf['filter_pages'][$page_name][$value_name]))
+ {
+ return $conf['filter_pages'][$page_name][$value_name];
+ }
+ else if (isset($conf['filter_pages']['default'][$value_name]))
+ {
+ return $conf['filter_pages']['default'][$value_name];
+ }
+ else
+ {
+ return null;
+ }
+}
+
?>
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index bde0944e7..f7a27c0eb 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -107,7 +107,10 @@ WHERE
usort($cats, 'global_rank_compare');
// Update filtered data
- update_cats_with_filtered_data($cats);
+ if (function_exists('update_cats_with_filtered_data'))
+ {
+ update_cats_with_filtered_data($cats);
+ }
return get_html_menu_category($cats);
}
diff --git a/include/functions_filter.inc.php b/include/functions_filter.inc.php
index 4bd5a6769..12d8c051c 100644
--- a/include/functions_filter.inc.php
+++ b/include/functions_filter.inc.php
@@ -34,9 +34,9 @@
*/
function get_filter_check_key()
{
- global $user;
-
- return $user['id'].$user['recent_period'].date('Ymd');
+ global $user, $filter;
+
+ return $user['id'].$filter['recent_period'].date('Ymd');
}
/**
diff --git a/include/functions_url.inc.php b/include/functions_url.inc.php
index 53792083d..1410243da 100644
--- a/include/functions_url.inc.php
+++ b/include/functions_url.inc.php
@@ -264,9 +264,9 @@ function add_well_known_params_in_url($url, $params)
}
}
- if (isset($params['flat_recent_cat']) and $params['flat_recent_cat'] > 0)
+ if (isset($params['flat_cat']))
{
- $url.= '/flat_recent_cat-'.$params['flat_recent_cat'];
+ $url.= '/flat_cat';
}
if (isset($params['start']) and $params['start'] > 0)
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index a57db5ea7..dce77aef6 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -65,26 +65,28 @@ foreach ($conf['links'] as $url => $label)
}
//------------------------------------------------------------------------ filter
-if ($filter['enabled'])
+if (!empty($conf['filter_pages']) and get_filter_page_value('used'))
{
- $template->assign_block_vars(
- 'stop_filter',
- array(
- 'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
- )
- );
-}
-else
-{
- $template->assign_block_vars(
- 'start_filter',
- array(
- 'URL' => add_url_params(make_index_url(array()), array('filter' => 'start'))
- )
- );
+ if ($filter['enabled'])
+ {
+ $template->assign_block_vars(
+ 'stop_filter',
+ array(
+ 'URL' => add_url_params(make_index_url(array()), array('filter' => 'stop'))
+ )
+ );
+ }
+ else
+ {
+ $template->assign_block_vars(
+ 'start_filter',
+ array(
+ 'URL' => add_url_params(make_index_url(array()), array('filter' => 'start-'.$user['recent_period']))
+ )
+ );
+ }
}
-
//------------------------------------------------------------------------ tags
if ('tags' == $page['section'])
{
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index cb963f3e1..a1535668a 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -278,11 +278,11 @@ while (isset($tokens[$i]))
$page['start'] = $matches[1];
}
- if ('categories'==$page['section'] and
- preg_match('/^flat_recent_cat-(\d+)/', $tokens[$i], $matches))
+ if ('categories' == $page['section'] and
+ 'flat_cat' == $tokens[$i])
{
// indicate a special list of images
- $page['flat_recent_cat'] = $matches[1];
+ $page['flat_cat'] = true;
}
if (preg_match('/^(posted|created)/', $tokens[$i] ))
@@ -364,7 +364,7 @@ if ('categories' == $page['section'])
'title' =>
get_cat_display_name($result['name'], '', false),
'thumbnails_include' =>
- (($result['nb_images'] > 0) or (isset($page['flat_recent_cat'])))
+ (($result['nb_images'] > 0) or (isset($page['flat_cat'])))
? 'include/category_default.inc.php'
: 'include/category_cats.inc.php'
)
@@ -374,12 +374,12 @@ if ('categories' == $page['section'])
{
$page['title'] = $lang['no_category'];
$page['thumbnails_include'] =
- (isset($page['flat_recent_cat']))
+ (isset($page['flat_cat']))
? 'include/category_default.inc.php'
: 'include/category_cats.inc.php';
}
- if (isset($page['flat_recent_cat']))
+ if (isset($page['flat_cat']))
{
$page['title'] = $lang['recent_pics_cat'].' : '.$page['title'] ;
}
@@ -389,7 +389,7 @@ if ('categories' == $page['section'])
(!isset($page['chronology_field'])) and
(
(isset($page['category'])) or
- (isset($page['flat_recent_cat']))
+ (isset($page['flat_cat']))
)
)
{
@@ -398,7 +398,7 @@ if ('categories' == $page['section'])
$conf[ 'order_by' ] = ' ORDER BY '.$result['image_order'];
}
- if (isset($page['flat_recent_cat']))
+ if (isset($page['flat_cat']))
{
// flat recent categories mode
$query = '
@@ -408,10 +408,8 @@ FROM '.IMAGES_TABLE.' AS i
INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
WHERE
- date_available > SUBDATE(
- CURRENT_DATE,INTERVAL '.$page['flat_recent_cat'].' DAY)'.
- (isset($page['category']) ? '
- AND uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '' ).'
+ '.(isset($page['category']) ? '
+ uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '1=1' ).'
'.$forbidden.'
;';
@@ -712,7 +710,7 @@ SELECT id,file
// add meta robots noindex, nofollow to avoid unnecesary robot crawls
$page['meta_robots']=array();
-if ( isset($page['chronology_field']) or isset($page['flat_recent_cat'])
+if ( isset($page['chronology_field']) or isset($page['flat_cat'])
or 'list'==$page['section'] or 'recent_pics'==$page['section'] )
{
$page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
diff --git a/index.php b/index.php
index 48e309633..0352e8a88 100644
--- a/index.php
+++ b/index.php
@@ -106,22 +106,22 @@ if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
$template_title.= ' ['.$page['cat_nb_images'].']';
}
-if (isset($page['flat_recent_cat']) or isset($page['chronology_field']))
+if (isset($page['flat_cat']) or isset($page['chronology_field']))
{
$template->assign_block_vars(
'mode_normal',
array(
- 'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat_recent_cat') )
+ 'URL' => duplicate_index_url( array(), array('chronology_field', 'start', 'flat_cat') )
)
);
}
-if (!isset($page['flat_recent_cat']) and 'categories'==$page['section'])
+if (!isset($page['flat_cat']) and 'categories' == $page['section'])
{
$template->assign_block_vars(
- 'flat_recent_cat',
+ 'flat_cat',
array(
- 'URL' => duplicate_index_url(array('flat_recent_cat' => $user['recent_period']), array('start', 'chronology_field'))
+ 'URL' => duplicate_index_url(array('flat_cat' => ''), array('start', 'chronology_field'))
)
);
}
@@ -137,7 +137,7 @@ if (!isset($page['chronology_field']))
$template->assign_block_vars(
'mode_created',
array(
- 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_recent_cat') )
+ 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_cat') )
)
);
@@ -145,7 +145,7 @@ if (!isset($page['chronology_field']))
$template->assign_block_vars(
'mode_posted',
array(
- 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_recent_cat') )
+ 'URL' => duplicate_index_url( $chronology_params, array('start', 'flat_cat') )
)
);
}
@@ -161,7 +161,7 @@ else
}
$url = duplicate_index_url(
array('chronology_field'=>$chronology_field ),
- array('chronology_date', 'start', 'flat_recent_cat')
+ array('chronology_date', 'start', 'flat_cat')
);
$template->assign_block_vars(
'mode_'.$chronology_field,
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index bc60feaa5..d566d845e 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -490,7 +490,7 @@ $lang['maxheight'] = 'Maximum height of the pictures';
$lang['maxheight_error'] = 'Maximum height must be a number superior to 50';
$lang['maxwidth'] = 'Maximum width of the pictures';
$lang['maxwidth_error'] = 'Maximum width must be a number superior to 50';
-$lang['flat_recent_cat_hint'] = 'display recent elements of categories and sub-categories';
+$lang['flat_cat_hint'] = 'flat display elements of categories and sub-categories';
$lang['start_filter_hint'] = 'displays only recent elements';
$lang['stop_filter_hint'] = 'return to display all elements';
$lang['mode_created_hint'] = 'displays a calendar by creation date';
diff --git a/language/fr_FR.iso-8859-1/common.lang.php b/language/fr_FR.iso-8859-1/common.lang.php
index 04a4081d9..bcc5d75d7 100644
--- a/language/fr_FR.iso-8859-1/common.lang.php
+++ b/language/fr_FR.iso-8859-1/common.lang.php
@@ -490,7 +490,7 @@ $lang['maxheight'] = 'Hauteur maximum des images';
$lang['maxheight_error'] = 'La hauteur maximum des images doit être supérieure à 50';
$lang['maxwidth'] = 'Largeur maximum des images';
$lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50';
-$lang['flat_recent_cat_hint'] = 'affiche les éléments récents des catégories et des sous-catégories';
+$lang['flat_cat_hint'] = 'affiche à plat les éléments des catégories et des sous-catégories';
$lang['start_filter_hint'] = 'afficher que les éléments récents';
$lang['stop_filter_hint'] = 'retourner à l\'affichage de tous les éléments';
$lang['mode_created_hint'] = 'afficher un calendrier par date de création';
diff --git a/template/yoga/icon/flat_recent_cat.png b/template/yoga/icon/flat_cat.png
index 43584e825..43584e825 100644
--- a/template/yoga/icon/flat_recent_cat.png
+++ b/template/yoga/icon/flat_cat.png
Binary files differ
diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl
index 2252cf0e9..0fef1363f 100644
--- a/template/yoga/index.tpl
+++ b/template/yoga/index.tpl
@@ -31,9 +31,9 @@
<li><a href="{mode_normal.URL}" title="{lang:mode_normal_hint}"><img src="{pwg_root}{themeconf:icon_dir}/normal_mode.png" class="button" alt="{lang:mode_normal_hint}"></a></li>
<!-- END mode_normal -->
- <!-- BEGIN flat_recent_cat -->
- <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>
- <!-- END flat_recent_cat -->
+ <!-- BEGIN flat_cat -->
+ <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>
+ <!-- END flat_cat -->
<!-- BEGIN mode_posted -->
<li><a href="{mode_posted.URL}" title="{lang:mode_posted_hint}" rel="nofollow"><img src="{pwg_root}{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:mode_posted_hint}"></a></li>