forked from Public/pics
PageIndexWidget: restore wildcard functionality
This commit is contained in:
parent
2ec565242e
commit
230c65478f
@ -75,6 +75,9 @@ a:hover {
|
|||||||
.pagination .page-item {
|
.pagination .page-item {
|
||||||
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
|
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.3);
|
||||||
}
|
}
|
||||||
|
.pagination .wildcard {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 767px) {
|
@media (max-width: 767px) {
|
||||||
.pagination {
|
.pagination {
|
||||||
|
@ -11,6 +11,8 @@ class PageIndexWidget extends Template
|
|||||||
private $index;
|
private $index;
|
||||||
private string $class;
|
private string $class;
|
||||||
|
|
||||||
|
private static $unique_index_count = 0;
|
||||||
|
|
||||||
public function __construct(PageIndex $index)
|
public function __construct(PageIndex $index)
|
||||||
{
|
{
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
@ -37,14 +39,18 @@ class PageIndexWidget extends Template
|
|||||||
'<a class="page-link"', !empty($page_index['previous']) ? ' href="' . $page_index['previous']['href'] . '"' : '', '>',
|
'<a class="page-link"', !empty($page_index['previous']) ? ' href="' . $page_index['previous']['href'] . '"' : '', '>',
|
||||||
'« previous</a></li>';
|
'« previous</a></li>';
|
||||||
|
|
||||||
|
$num_wildcards = 0;
|
||||||
foreach ($page_index as $key => $page)
|
foreach ($page_index as $key => $page)
|
||||||
{
|
{
|
||||||
if (!is_numeric($key))
|
if (!is_numeric($key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!is_array($page))
|
if (!is_array($page))
|
||||||
|
{
|
||||||
|
$num_wildcards++;
|
||||||
echo '
|
echo '
|
||||||
<li class="page-item page-padding disabled"><a class="page-link">...</a></li>';
|
<li class="page-item page-padding wildcard" onclick="javascript:promptGoToPage(', self::$unique_index_count, ')"><a class="page-link">...</a></li>';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
echo '
|
echo '
|
||||||
<li class="page-item page-number', $page['is_selected'] ? ' active" aria-current="page' : '', '">',
|
<li class="page-item page-number', $page['is_selected'] ? ' active" aria-current="page' : '', '">',
|
||||||
@ -56,5 +62,17 @@ class PageIndexWidget extends Template
|
|||||||
'<a class="page-link"', !empty($page_index['next']) ? ' href="' . $page_index['next']['href'] . '"' : '', '>',
|
'<a class="page-link"', !empty($page_index['next']) ? ' href="' . $page_index['next']['href'] . '"' : '', '>',
|
||||||
'next »</a></li>
|
'next »</a></li>
|
||||||
</ul>';
|
</ul>';
|
||||||
|
|
||||||
|
if ($num_wildcards)
|
||||||
|
{
|
||||||
|
echo '
|
||||||
|
<script type="text/javascript">
|
||||||
|
var page_index_', self::$unique_index_count++, ' = {
|
||||||
|
wildcard_url: "', $index->getLink("%d"), '",
|
||||||
|
num_pages: ', $index->getNumberOfPages(), ',
|
||||||
|
per_page: ', $index->getItemsPerPage(), '
|
||||||
|
};
|
||||||
|
</script>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user