2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* ViewTimeline.php
|
|
|
|
* Contains the photo timeline index controller
|
|
|
|
*
|
|
|
|
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class ViewTimeline extends HTMLController
|
|
|
|
{
|
|
|
|
protected $iterator;
|
|
|
|
protected $total_count;
|
|
|
|
protected $base_url;
|
|
|
|
|
|
|
|
const PER_PAGE = 24;
|
|
|
|
|
|
|
|
public function __construct($title = 'Photos - ' . SITE_TITLE)
|
|
|
|
{
|
2016-09-02 11:16:01 +02:00
|
|
|
// Ensure we're logged in at this point.
|
|
|
|
if (!Registry::get('user')->isLoggedIn())
|
|
|
|
throw new NotAllowedException();
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
// What page are we at?
|
|
|
|
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
|
|
|
|
|
|
|
parent::__construct('Timeline - Page ' . $page . ' - ' . SITE_TITLE);
|
|
|
|
|
|
|
|
// Load a photo mosaic.
|
|
|
|
list($this->iterator, $total_count) = AssetIterator::getByOptions([
|
|
|
|
'order' => 'date_captured',
|
|
|
|
'direction' => 'desc',
|
|
|
|
'limit' => self::PER_PAGE,
|
|
|
|
'page' => $page,
|
|
|
|
], true);
|
|
|
|
|
|
|
|
$mosaic = $total_count > 0 ? new PhotoMosaic($this->iterator) : null;
|
|
|
|
if (isset($mosaic))
|
|
|
|
$this->page->adopt(new PhotosIndex($mosaic, Registry::get('user')->isAdmin()));
|
|
|
|
|
|
|
|
// Make a page index as needed, while we're at it.
|
|
|
|
if ($total_count > self::PER_PAGE)
|
|
|
|
{
|
|
|
|
$index = new PageIndex([
|
|
|
|
'recordCount' => $total_count,
|
|
|
|
'items_per_page' => self::PER_PAGE,
|
|
|
|
'start' => (isset($_GET['page']) ? $_GET['page'] - 1 : 0) * self::PER_PAGE,
|
|
|
|
'base_url' => BASEURL . '/timeline/',
|
|
|
|
'page_slug' => 'page/%PAGE%/',
|
2023-12-02 01:38:07 +01:00
|
|
|
'index_class' => 'pagination-lg justify-content-around justify-content-lg-center',
|
2016-09-01 23:13:23 +02:00
|
|
|
]);
|
2023-03-11 13:20:59 +01:00
|
|
|
$this->page->adopt(new PageIndexWidget($index));
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the canonical url.
|
|
|
|
$this->page->setCanonicalUrl(BASEURL . '/timeline/');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function __destruct()
|
|
|
|
{
|
|
|
|
if (isset($this->iterator))
|
|
|
|
$this->iterator->clean();
|
|
|
|
}
|
|
|
|
}
|