mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-28 04:09:56 +03: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:
parent
b6789d4de9
commit
b3151e0129
9 changed files with 589 additions and 92 deletions
|
@ -859,14 +859,70 @@ function ws_images_filteredSearch_create($params, $service)
|
|||
$search['fields']['added_by'] = $params['added_by'];
|
||||
}
|
||||
|
||||
if (isset($params['date_posted']))
|
||||
if (isset($params['date_posted_preset']))
|
||||
{
|
||||
if (!preg_match('/^(24h|7d|30d|3m|6m|y\d+|)$/', $params['date_posted']))
|
||||
if (!preg_match('/^(24h|7d|30d|3m|6m|custom|)$/', $params['date_posted_preset']))
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid parameter date_posted');
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid parameter date_posted_preset');
|
||||
}
|
||||
|
||||
$search['fields']['date_posted'] = $params['date_posted'];
|
||||
@$search['fields']['date_posted']['preset'] = $params['date_posted_preset'];
|
||||
|
||||
if ('custom' == $search['fields']['date_posted']['preset'] and empty($params['date_posted_custom']))
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'date_posted_custom is missing');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['date_posted_custom']))
|
||||
{
|
||||
if (!isset($search['fields']['date_posted']['preset']) or $search['fields']['date_posted']['preset'] != 'custom')
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'date_posted_custom provided date_posted_preset is not custom');
|
||||
}
|
||||
|
||||
foreach ($params['date_posted_custom'] as $date)
|
||||
{
|
||||
$correct_format = false;
|
||||
|
||||
$ymd = substr($date, 0, 1);
|
||||
if ('y' == $ymd)
|
||||
{
|
||||
if (preg_match('/^y(\d{4})$/', $date, $matches))
|
||||
{
|
||||
$correct_format = true;
|
||||
}
|
||||
}
|
||||
elseif ('m' == $ymd)
|
||||
{
|
||||
if (preg_match('/^m(\d{4}-\d{2})$/', $date, $matches))
|
||||
{
|
||||
list($year, $month) = explode('-', $matches[1]);
|
||||
if ($month >= 1 and $month <= 12)
|
||||
{
|
||||
$correct_format = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ('d' == $ymd)
|
||||
{
|
||||
if (preg_match('/^d(\d{4}-\d{2}-\d{2})$/', $date, $matches))
|
||||
{
|
||||
list($year, $month, $day) = explode('-', $matches[1]);
|
||||
if ($month >= 1 and $month <= 12 and $day >= 1 and $day <= cal_days_in_month(CAL_GREGORIAN, (int)$month, (int)$year))
|
||||
{
|
||||
$correct_format = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$correct_format)
|
||||
{
|
||||
return new PwgError(WS_ERR_INVALID_PARAM, 'date_posted_custom, invalid option '.$date);
|
||||
}
|
||||
|
||||
@$search['fields']['date_posted']['custom'][] = $date;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['ratios']))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue