rosehill/libraries/Blossom/blocks/html/pageNavigation.inc

47 lines
1.3 KiB
PHP
Raw Normal View History

<?php
/**
2014-08-18 19:53:40 +00:00
* Displays page navigation for any list that has pagination turned on
*
* @copyright 2007-2013 City of Bloomington, Indiana
* @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt
* @author Cliff Ingham <inghamn@bloomington.in.gov>
2014-08-18 19:53:40 +00:00
* @param Zend\Paginator $this->paginator
*/
2014-08-18 19:53:40 +00:00
use Blossom\Classes\Url;
if ($this->paginator->count() > 1) {
$pages = $this->paginator->getPages();
$url = new Url($_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']);
$url->purgeEmptyParameters();
echo '<ul class="pageNavigation">';
// Show the Back button
2014-08-18 19:53:40 +00:00
if (isset($pages->previous)) {
$url->page = $pages->first;
echo "<li><a href=\"$url\" class=\"first\">First</a></li>";
2014-08-18 19:53:40 +00:00
$url->page = $pages->previous;
echo "<li><a href=\"$url\" class=\"previous\">Back</a></li>";
}
// Show the page number links
// Show only $maxNumLinks pages at a time
2014-08-18 19:53:40 +00:00
foreach ($pages->pagesInRange as $page) {
$url->page = $page;
2014-08-18 19:53:40 +00:00
$class = ($page == $pages->current) ? 'class="current"' : '';
echo "<li><a href=\"$url\" $class>$page</a></li>";
}
// Show the Next button
2014-08-18 19:53:40 +00:00
if (isset($pages->next)) {
$url->page = $pages->next;
echo "<li><a href=\"$url\" class=\"next\">Next</a></li>";
2014-08-18 19:53:40 +00:00
$url->page = $pages->last;
echo "<li><a href=\"$url\" class=\"last\">Last</a></li>";
}
echo '</ul>';
}