mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-07 02:11:26 +02:00
fixes #2211 integrate new redesign for date posted filter
filter on date_posted custom values (specific years, months or days) along side last 7, 30 days, 3 and 6 months following redesign by alice
This commit is contained in:
@@ -341,20 +341,6 @@ SELECT
|
||||
);
|
||||
}
|
||||
|
||||
$pre_counters_keys = array_keys($pre_counters);
|
||||
rsort($pre_counters_keys); // we want y2023 to come before y2022 in the list
|
||||
|
||||
foreach ($pre_counters_keys as $key)
|
||||
{
|
||||
if (preg_match('/^y(\d+)$/', $key, $matches))
|
||||
{
|
||||
$counters[$key] = array(
|
||||
'label' => l10n('year %d', $matches[1]),
|
||||
'counter' => count(array_keys($pre_counters[$key]))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($counters as $key => $counter)
|
||||
{
|
||||
if (0 == $counter['counter'])
|
||||
@@ -364,6 +350,49 @@ SELECT
|
||||
}
|
||||
|
||||
$template->assign('DATE_POSTED', $counters);
|
||||
|
||||
|
||||
// Custom date
|
||||
$query = '
|
||||
SELECT
|
||||
DISTINCT id,
|
||||
date_available as date
|
||||
FROM '.IMAGES_TABLE.' AS i
|
||||
JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON ic.image_id = i.id
|
||||
WHERE '.$filter_clause.'
|
||||
;';
|
||||
|
||||
$list_of_dates = array();
|
||||
|
||||
$result = pwg_query($query);
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
list($date_without_time) = explode(' ', $row['date']);
|
||||
list($y, $m) = explode('-', $date_without_time);
|
||||
|
||||
@$list_of_dates[$y]['months'][$y.'-'.$m]['days'][$date_without_time]['count']++;
|
||||
@$list_of_dates[$y]['months'][$y.'-'.$m]['count']++;
|
||||
@$list_of_dates[$y]['count']++;
|
||||
|
||||
// Benchmark if better to put the label in another array rather than keep in this array
|
||||
|
||||
if (!isset($list_of_dates[$y]['months'][$y.'-'.$m]['days'][$date_without_time]['label']))
|
||||
{
|
||||
$list_of_dates[$y]['months'][$y.'-'.$m]['days'][$date_without_time]['label'] = format_date($row['date']);
|
||||
}
|
||||
|
||||
if (!isset($list_of_dates[$y]['months'][$m]['label']))
|
||||
{
|
||||
$list_of_dates[$y]['months'][$y.'-'.$m]['label'] = $lang['month'][(int)$m].' '.$y;
|
||||
}
|
||||
|
||||
if (!isset($list_of_dates[$y]['label']))
|
||||
{
|
||||
$list_of_dates[$y]['label'] = l10n('year %d', $y);
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('LIST_DATE_POSTED', $list_of_dates);
|
||||
}
|
||||
|
||||
if (isset($my_search['fields']['added_by']))
|
||||
|
||||
Reference in New Issue
Block a user