From a3e9ed23ceb23395bec18cf9812ca138a72c58f9 Mon Sep 17 00:00:00 2001 From: plegall Date: Fri, 20 Sep 2024 14:21:28 +0200 Subject: [PATCH] issue #2227 like for date_posted, display all presets for date_created --- include/functions_search.inc.php | 2 +- include/search_filters.inc.php | 17 +++++++---------- include/ws_functions/pwg.images.php | 2 +- language/en_UK/common.lang.php | 2 +- language/fr_FR/common.lang.php | 2 ++ themes/default/css/clear-search.css | 1 + themes/default/css/dark-search.css | 1 + .../template/include/search_filters.inc.tpl | 6 +++--- ws.php | 2 +- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index 8183b9e85..366c7b183 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -485,11 +485,11 @@ SELECT $has_filters_filled = true; $options = array( - '24h' => '24 HOUR', '7d' => '7 DAY', '30d' => '30 DAY', '3m' => '3 MONTH', '6m' => '6 MONTH', + '12m' => '12 MONTH', ); if (isset($options[ $search['fields']['date_created']['preset'] ]) and 'custom' != $search['fields']['date_created']['preset']) diff --git a/include/search_filters.inc.php b/include/search_filters.inc.php index e019e5ce2..e020b771a 100644 --- a/include/search_filters.inc.php +++ b/include/search_filters.inc.php @@ -229,11 +229,11 @@ SELECT { $query = ' SELECT - SUBDATE(NOW(), INTERVAL 24 HOUR) AS 24h, SUBDATE(NOW(), INTERVAL 7 DAY) AS 7d, SUBDATE(NOW(), INTERVAL 30 DAY) AS 30d, SUBDATE(NOW(), INTERVAL 3 MONTH) AS 3m, - SUBDATE(NOW(), INTERVAL 6 MONTH) AS 6m + SUBDATE(NOW(), INTERVAL 6 MONTH) AS 6m, + SUBDATE(NOW(), INTERVAL 12 MONTH) AS 12m ;'; $thresholds = query2array($query)[0]; @@ -285,23 +285,20 @@ SELECT } $label_for_threshold = array( - '24h' => l10n('last 24 hours'), '7d' => l10n('last 7 days'), '30d' => l10n('last 30 days'), '3m' => l10n('last 3 months'), '6m' => l10n('last 6 months'), + '12m' => l10n('last 12 months'), ); $counters = array(); foreach (array_keys($label_for_threshold) as $threshold) { - if (isset($date_created['pre_counters'][$threshold])) - { - $counters[$threshold] = array( - 'label' => $label_for_threshold[$threshold], - 'counter' => $date_created['pre_counters'][$threshold], - ); - } + $counters[$threshold] = array( + 'label' => $label_for_threshold[$threshold], + 'counter' => $date_created['pre_counters'][$threshold] ?? 0, + ); } foreach (array_keys($date_created['list_of_dates']) as $y) diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index 0ba20fae6..72473bcbf 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -927,7 +927,7 @@ function ws_images_filteredSearch_create($params, $service) if (isset($params['date_created_preset'])) { - if (!preg_match('/^(24h|7d|30d|3m|6m|custom|)$/', $params['date_created_preset'])) + if (!preg_match('/^(7d|30d|3m|6m|12m|custom|)$/', $params['date_created_preset'])) { return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid parameter date_created_preset'); } diff --git a/language/en_UK/common.lang.php b/language/en_UK/common.lang.php index 9bddb0bce..1929d18c2 100644 --- a/language/en_UK/common.lang.php +++ b/language/en_UK/common.lang.php @@ -449,5 +449,5 @@ $lang['Only the first %d albums are displayed, out of %d.'] = 'Only the first %d $lang['Pages'] = "Pages"; $lang['The PDF you requested is too large to display on this page.']= 'The PDF you requested is too large to display on this page.'; $lang['Click here to display it']= 'Click here to display it'; - +$lang['last 12 months'] = 'Last 12 months'; ?> diff --git a/language/fr_FR/common.lang.php b/language/fr_FR/common.lang.php index 93f7c05db..dd1501747 100644 --- a/language/fr_FR/common.lang.php +++ b/language/fr_FR/common.lang.php @@ -454,3 +454,5 @@ $lang['Album already selected'] = 'Album déjà sélectionné'; $lang['Pages'] = "Pages"; $lang['The PDF you requested is too large to display on this page.']= 'Le PDF que vous avez demandé est trop volumineux pour être affiché sur cette page.'; $lang['Click here to display it']= 'Cliquez ici pour le voir'; +$lang['last 12 months'] = '12 derniers mois'; + diff --git a/themes/default/css/clear-search.css b/themes/default/css/clear-search.css index a02a6d48b..624d0b1b0 100644 --- a/themes/default/css/clear-search.css +++ b/themes/default/css/clear-search.css @@ -174,6 +174,7 @@ .ratios-option.disabled label .ratio-name, .filetypes-option.disabled label .ext-name, .date_posted-option.disabled label .date-period, +.date_created-option.disabled label .date-period, .ratings-option.disabled label .ratings-name{ color:#888 } diff --git a/themes/default/css/dark-search.css b/themes/default/css/dark-search.css index 14ff5fadb..207bef721 100644 --- a/themes/default/css/dark-search.css +++ b/themes/default/css/dark-search.css @@ -151,6 +151,7 @@ .ratios-option.disabled label .ratio-name, .filetypes-option.disabled label .ext-name, .date_posted-option.disabled label .date-period, +.date_created-option.disabled label .date-period, .ratings-option.disabled label .ratings-name{ color:#888 } diff --git a/themes/default/template/include/search_filters.inc.tpl b/themes/default/template/include/search_filters.inc.tpl index f48776ddf..4cc475b94 100644 --- a/themes/default/template/include/search_filters.inc.tpl +++ b/themes/default/template/include/search_filters.inc.tpl @@ -381,12 +381,12 @@ const prefix_icon = 'gallery-icon-';
{foreach from=$DATE_CREATED item=date_created key=k} -
- +
+ {if 0 != $date_created.counter}{/if}
{/foreach} diff --git a/ws.php b/ws.php index fc9f8d63b..9416f6325 100644 --- a/ws.php +++ b/ws.php @@ -1464,7 +1464,7 @@ enabled_high, registration_date, registration_date_string, registration_date_sin ), 'date_created_preset' => array( 'flags' => WS_PARAM_OPTIONAL, - 'info' => 'files created within 24 hours, 7 days, 30 days, 3 months, 6 months or custom. Value among 24h|7d|30d|3m|6m|custom.', + 'info' => 'files created within 7 days, 30 days, 3 months, 6 months, 12 months or custom. Value among 7d|30d|3m|6m|12m|custom.', ), 'date_created_custom' => array( 'flags' => WS_PARAM_OPTIONAL|WS_PARAM_FORCE_ARRAY,