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%/', ]); $this->page->adopt(new Pagination($index)); } // Set the canonical url. $this->page->setCanonicalUrl(BASEURL . '/timeline/'); } public function __destruct() { if (isset($this->iterator)) $this->iterator->clean(); } }