Allow jumping to random pages through pagination fillers.

This commit is contained in:
2016-09-02 14:19:47 +02:00
parent 29030eade6
commit df7655e00b
8 changed files with 67 additions and 11 deletions

View File

@@ -32,6 +32,7 @@ class MainTemplate extends Template
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">', !empty($this->css) ? '
<style type="text/css">' . $this->css . '
</style>' : '', $this->header_html, '
<script type="text/javascript" src="', BASEURL, '/js/main.js"></script>
</head>
<body', !empty($this->classes) ? ' class="' . implode(' ', $this->classes) . '"' : '', '>
<header>

View File

@@ -3,42 +3,61 @@
* Pagination.php
* Contains the pagination template.
*
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
*****************************************************************************/
class Pagination extends SubTemplate
{
private $index;
private static $unique_index_count = 0;
public function __construct(PageIndex $index)
{
$this->index = $index->getPageIndex();
$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($this->index['previous']) ? 'a href="' . $this->index['previous']['href'] . '"' : 'span', '>&laquo; previous</', !empty($this->index['previous']) ? 'a' : 'span', '></li>';
<li class="first"><', !empty($index['previous']) ? 'a href="' . $index['previous']['href'] . '"' : 'span', '>&laquo; previous</', !empty($index['previous']) ? 'a' : 'span', '></li>';
foreach ($this->index as $key => $page)
$num_wildcards = 0;
foreach ($index as $key => $page)
{
if (!is_numeric($key))
continue;
if (!is_array($page))
{
$num_wildcards++;
echo '
<li class="page-padding"><span>...</span></li>';
<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($this->index['next']) ? 'a href="' . $this->index['next']['href'] . '"' : 'span', '>next &raquo;</', !empty($this->index['next']) ? 'a' : 'span', '></li>
<li class="last"><', !empty($index['next']) ? 'a href="' . $index['next']['href'] . '"' : 'span', '>next &raquo;</', !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>';
}
}
}