ViewPhoto: take filter into account for prev/next links
This commit is contained in:
@@ -697,7 +697,7 @@ class Asset
|
||||
$params);
|
||||
}
|
||||
|
||||
protected function getUrlForAdjacentInSet($prevNext, ?Tag $tag)
|
||||
protected function getUrlForAdjacentInSet($prevNext, ?Tag $tag, $activeFilter)
|
||||
{
|
||||
$next = $prevNext === 'next';
|
||||
$previous = !$next;
|
||||
@@ -722,6 +722,14 @@ class Asset
|
||||
$params['order_dir'] = $previous ? 'ASC' : 'DESC';
|
||||
}
|
||||
|
||||
// Take active filter into account as well
|
||||
if (!empty($activeFilter))
|
||||
{
|
||||
$user = Member::fromSlug($activeFilter);
|
||||
$where[] = 'id_user_uploaded = {int:id_user_uploaded}';
|
||||
$params['id_user_uploaded'] = $user->getUserId();
|
||||
}
|
||||
|
||||
// Use complete ordering when sorting the set
|
||||
$where[] = '(a.date_captured, a.id_asset) {raw:where_op} ' .
|
||||
'({datetime:date_captured}, {int:id_asset})';
|
||||
@@ -740,22 +748,29 @@ class Asset
|
||||
LIMIT 1',
|
||||
$params);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$obj = self::byRow($row, 'object');
|
||||
return $obj->getPageUrl() . ($tag ? '?in=' . $tag->id_tag : '');
|
||||
}
|
||||
else
|
||||
if (!$row)
|
||||
return false;
|
||||
|
||||
$obj = self::byRow($row, 'object');
|
||||
|
||||
$urlParams = [];
|
||||
if (isset($tag))
|
||||
$urlParams['in'] = $tag->id_tag;
|
||||
if (!empty($activeFilter))
|
||||
$urlParams['by'] = $activeFilter;
|
||||
|
||||
$queryString = !empty($urlParams) ? '?' . http_build_query($urlParams) : '';
|
||||
|
||||
return $obj->getPageUrl() . $queryString;
|
||||
}
|
||||
|
||||
public function getUrlForPreviousInSet(?Tag $tag)
|
||||
public function getUrlForPreviousInSet(?Tag $tag, $activeFilter)
|
||||
{
|
||||
return $this->getUrlForAdjacentInSet('previous', $tag);
|
||||
return $this->getUrlForAdjacentInSet('previous', $tag, $activeFilter);
|
||||
}
|
||||
|
||||
public function getUrlForNextInSet(?Tag $tag)
|
||||
public function getUrlForNextInSet(?Tag $tag, $activeFilter)
|
||||
{
|
||||
return $this->getUrlForAdjacentInSet('next', $tag);
|
||||
return $this->getUrlForAdjacentInSet('next', $tag, $activeFilter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user