forked from Public/pics
65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
/*****************************************************************************
|
|
* Pagination.php
|
|
* Contains the pagination template.
|
|
*
|
|
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
|
|
*****************************************************************************/
|
|
|
|
class Pagination extends SubTemplate
|
|
{
|
|
private $index;
|
|
private static $unique_index_count = 0;
|
|
private string $class;
|
|
|
|
public function __construct(PageIndex $index)
|
|
{
|
|
$this->index = $index;
|
|
$this->class = $index->getPageIndexClass();
|
|
}
|
|
|
|
protected function html_content()
|
|
{
|
|
$index = $this->index->getPageIndex();
|
|
|
|
echo '
|
|
<div class="table_pagination', !empty($this->class) ? ' ' . $this->class : '', '">
|
|
<ul>
|
|
<li class="first"><', !empty($index['previous']) ? 'a href="' . $index['previous']['href'] . '"' : 'span', '>« previous</', !empty($index['previous']) ? 'a' : 'span', '></li>';
|
|
|
|
$num_wildcards = 0;
|
|
foreach ($index as $key => $page)
|
|
{
|
|
if (!is_numeric($key))
|
|
continue;
|
|
|
|
if (!is_array($page))
|
|
{
|
|
$num_wildcards++;
|
|
echo '
|
|
<li class="page-padding" onclick="javascript:promptGoToPage(', self::$unique_index_count, ')"><span>...</span></li>';
|
|
}
|
|
else
|
|
echo '
|
|
<li class="page-number', $page['is_selected'] ? ' active' : '', '"><a href="', $page['href'], '">', $page['index'], '</a></li>';
|
|
}
|
|
|
|
echo '
|
|
<li class="last"><', !empty($index['next']) ? 'a href="' . $index['next']['href'] . '"' : 'span', '>next »</', !empty($index['next']) ? 'a' : 'span', '></li>
|
|
</ul>
|
|
</div>';
|
|
|
|
if ($num_wildcards)
|
|
{
|
|
echo '
|
|
<script type="text/javascript">
|
|
var page_index_', self::$unique_index_count++, ' = {
|
|
wildcard_url: "', $this->index->getLink("%d"), '",
|
|
num_pages: ', $this->index->getNumberOfPages(), ',
|
|
per_page: ', $this->index->getItemsPerPage(), '
|
|
};
|
|
</script>';
|
|
}
|
|
}
|
|
}
|