Implement navigation for photo pages.
This commit is contained in:
@@ -500,4 +500,70 @@ class Asset
|
||||
WHERE id_asset = {int:id_asset}',
|
||||
$params);
|
||||
}
|
||||
|
||||
public function getUrlForPreviousInSet($id_tag = null)
|
||||
{
|
||||
$row = Registry::get('db')->queryAssoc('
|
||||
SELECT a.*
|
||||
' . (isset($id_tag) ? '
|
||||
FROM assets_tags AS t
|
||||
INNER JOIN assets AS a ON a.id_asset = t.id_asset
|
||||
WHERE t.id_tag = {int:id_tag} AND
|
||||
a.date_captured <= {datetime:date_captured} AND
|
||||
a.id_asset != {int:id_asset}
|
||||
ORDER BY a.date_captured DESC'
|
||||
: '
|
||||
FROM assets AS a
|
||||
WHERE date_captured >= {datetime:date_captured} AND
|
||||
a.id_asset != {int:id_asset}
|
||||
ORDER BY date_captured ASC')
|
||||
. '
|
||||
LIMIT 1',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
'id_tag' => $id_tag,
|
||||
'date_captured' => $this->date_captured,
|
||||
]);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$obj = self::byRow($row, 'object');
|
||||
return $obj->getPageUrl() . ($id_tag ? '?in=' . $id_tag : '');
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getUrlForNextInSet($id_tag = null)
|
||||
{
|
||||
$row = Registry::get('db')->queryAssoc('
|
||||
SELECT a.*
|
||||
' . (isset($id_tag) ? '
|
||||
FROM assets_tags AS t
|
||||
INNER JOIN assets AS a ON a.id_asset = t.id_asset
|
||||
WHERE t.id_tag = {int:id_tag} AND
|
||||
a.date_captured >= {datetime:date_captured} AND
|
||||
a.id_asset != {int:id_asset}
|
||||
ORDER BY a.date_captured ASC'
|
||||
: '
|
||||
FROM assets AS a
|
||||
WHERE date_captured <= {datetime:date_captured} AND
|
||||
a.id_asset != {int:id_asset}
|
||||
ORDER BY date_captured DESC')
|
||||
. '
|
||||
LIMIT 1',
|
||||
[
|
||||
'id_asset' => $this->id_asset,
|
||||
'id_tag' => $id_tag,
|
||||
'date_captured' => $this->date_captured,
|
||||
]);
|
||||
|
||||
if ($row)
|
||||
{
|
||||
$obj = self::byRow($row, 'object');
|
||||
return $obj->getPageUrl() . ($id_tag ? '?in=' . $id_tag : '');
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user