2016-09-01 23:13:23 +02:00
|
|
|
<?php
|
|
|
|
/*****************************************************************************
|
|
|
|
* Pagination.php
|
|
|
|
* Contains the pagination template.
|
|
|
|
*
|
2016-09-02 14:19:47 +02:00
|
|
|
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
|
2016-09-01 23:13:23 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
class Pagination extends SubTemplate
|
|
|
|
{
|
|
|
|
private $index;
|
2016-09-02 14:19:47 +02:00
|
|
|
private static $unique_index_count = 0;
|
2016-09-01 23:13:23 +02:00
|
|
|
|
|
|
|
public function __construct(PageIndex $index)
|
|
|
|
{
|
2016-09-02 14:19:47 +02:00
|
|
|
$this->index = $index;
|
2016-09-01 23:13:23 +02:00
|
|
|
$this->class = $index->getPageIndexClass();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function html_content()
|
|
|
|
{
|
2016-09-02 14:19:47 +02:00
|
|
|
$index = $this->index->getPageIndex();
|
|
|
|
|
2016-09-01 23:13:23 +02:00
|
|
|
echo '
|
|
|
|
<div class="table_pagination', !empty($this->class) ? ' ' . $this->class : '', '">
|
|
|
|
<ul>
|
2016-09-02 14:19:47 +02:00
|
|
|
<li class="first"><', !empty($index['previous']) ? 'a href="' . $index['previous']['href'] . '"' : 'span', '>« previous</', !empty($index['previous']) ? 'a' : 'span', '></li>';
|
2016-09-01 23:13:23 +02:00
|
|
|
|
2016-09-02 14:19:47 +02:00
|
|
|
$num_wildcards = 0;
|
|
|
|
foreach ($index as $key => $page)
|
2016-09-01 23:13:23 +02:00
|
|
|
{
|
|
|
|
if (!is_numeric($key))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!is_array($page))
|
2016-09-02 14:19:47 +02:00
|
|
|
{
|
|
|
|
$num_wildcards++;
|
2016-09-01 23:13:23 +02:00
|
|
|
echo '
|
2016-09-02 14:19:47 +02:00
|
|
|
<li class="page-padding" onclick="javascript:promptGoToPage(', self::$unique_index_count, ')"><span>...</span></li>';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
else
|
|
|
|
echo '
|
|
|
|
<li class="page-number', $page['is_selected'] ? ' active' : '', '"><a href="', $page['href'], '">', $page['index'], '</a></li>';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '
|
2016-09-02 14:19:47 +02:00
|
|
|
<li class="last"><', !empty($index['next']) ? 'a href="' . $index['next']['href'] . '"' : 'span', '>next »</', !empty($index['next']) ? 'a' : 'span', '></li>
|
2016-09-01 23:13:23 +02:00
|
|
|
</ul>
|
|
|
|
</div>';
|
2016-09-02 14:19:47 +02:00
|
|
|
|
|
|
|
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>';
|
|
|
|
}
|
2016-09-01 23:13:23 +02:00
|
|
|
}
|
|
|
|
}
|