Add a bootstrap-compatible paginator

This commit is contained in:
Kazhnuz 2025-07-27 15:59:13 +02:00
parent c35330fa4d
commit 70b64f7c90

View file

@ -190,6 +190,63 @@ class Paginator {
return $html;
}
public static function bootstrap_numberedPageHTML($class = '') {
global $L;
$maxDistance = 2;
if (self::get('numberOfPages') <= 1) {
return "";
}
$html = '<nav id="paginator">';
$html .= '<ul class="pagination '.$class.'">';
if(self::get('showPrev'))
{
$html .= '<li class="page-item">';
$html .= '<a class="page-link" aria-label="'.$L->g('Previous page').'" href="'.self::previousPageUrl().'">←</a>';
$html .= '</li>';
} else {
$html .= '<li class="page-item disabled">';
$html .= '<span class="page-link" aria-label="'.$L->g('Previous page').'">←</span>';
$html .= '</li>';
}
for ($i=1; $i <= self::get('numberOfPages'); $i++) {
if ($i <= 1 || $i >= self::get('numberOfPages') || abs($i - self::currentPage()) < $maxDistance) {
if ($i == self::currentPage()) {
$html .= '<li class="page-item active">';
$html .= '<span class="page-link">'.($i).'</span>';
$html .= '</li>';
} else {
$html .= '<li class="page-item">';
$html .= '<a class="page-link" href="'.self::numberUrl($i).'">'.($i).'</a>';
$html .= '</li>';
}
} elseif (abs($i - self::currentPage()) == $maxDistance) {
$html .= '<li class="page-item">';
$html .= '<span class="page-link">…</span>';
$html .= '</li>';
}
}
if(self::get('showNext'))
{
$html .= '<li class="page-item">';
$html .= '<a class="page-link" aria-label="'.$L->g('Next page').'" href="'.self::nextPageUrl().'">→</a>';
$html .= '</li>';
} else {
$html .= '<li class="page-item disabled">';
$html .= '<span class="page-link" aria-label="'.$L->g('Next page').'">→</span>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</nav>';
return $html;
}
/*
* Bootstrap Pagination
*/