dbms_primeidc_init...1
This commit is contained in:
parent
d86b67f6de
commit
9ac695ad88
@ -8,6 +8,7 @@ class Pagination
|
||||
public int $perPage;
|
||||
public int $totalItems;
|
||||
public int $totalPages;
|
||||
public int $groupSize = 10;
|
||||
public int $start;
|
||||
public int $end;
|
||||
|
||||
@ -17,9 +18,9 @@ class Pagination
|
||||
$this->perPage = $perPage;
|
||||
$this->currentPage = max(1, $currentPage);
|
||||
$this->totalPages = (int)ceil($totalItems / $perPage);
|
||||
|
||||
$this->start = ($this->currentPage - 1) * $perPage;
|
||||
$this->end = min($this->start + $perPage, $totalItems);
|
||||
$this->groupSize = $_ENV['VIEW_LIST_PAGINATION_GROUPSIZE'] ?? $_SERVER['VIEW_LIST_PAGINATION_GROUPSIZE'] ?? 10;
|
||||
}
|
||||
|
||||
public function hasPrevious(): bool
|
||||
@ -71,20 +72,24 @@ class Pagination
|
||||
public function render(string $baseUrl = '', array $query = []): string
|
||||
{
|
||||
if ($this->totalPages <= 1) {
|
||||
return ''; // 페이지가 1개 이하면 렌더링 생략
|
||||
return '';
|
||||
}
|
||||
|
||||
$html = '<nav><ul class="pagination">';
|
||||
$currentGroup = (int)floor(($this->currentPage - 1) / $this->groupSize);
|
||||
$startPage = $currentGroup * $this->groupSize + 1;
|
||||
$endPage = min($startPage + $this->groupSize - 1, $this->totalPages);
|
||||
|
||||
// 이전 버튼
|
||||
if ($this->hasPrevious()) {
|
||||
$html .= $this->pageLink($this->previousPage(), '«', $baseUrl, $query);
|
||||
// << 그룹 이전
|
||||
if ($startPage > 1) {
|
||||
$prevGroupPage = max(1, $startPage - 1);
|
||||
$html .= $this->pageLink($prevGroupPage, '«', $baseUrl, $query);
|
||||
} else {
|
||||
$html .= '<li class="page-item disabled"><span class="page-link">«</span></li>';
|
||||
}
|
||||
|
||||
// 페이지 번호 링크 (간단히 1 ~ totalPages 모두 표시, 필요시 range 조절 가능)
|
||||
for ($i = 1; $i <= $this->totalPages; $i++) {
|
||||
// 페이지 번호들
|
||||
for ($i = $startPage; $i <= $endPage; $i++) {
|
||||
if ($i === $this->currentPage) {
|
||||
$html .= '<li class="page-item active"><span class="page-link">' . $i . '</span></li>';
|
||||
} else {
|
||||
@ -92,9 +97,10 @@ class Pagination
|
||||
}
|
||||
}
|
||||
|
||||
// 다음 버튼
|
||||
if ($this->hasNext()) {
|
||||
$html .= $this->pageLink($this->nextPage(), '»', $baseUrl, $query);
|
||||
// >> 그룹 다음
|
||||
if ($endPage < $this->totalPages) {
|
||||
$nextGroupPage = $endPage + 1;
|
||||
$html .= $this->pageLink($nextGroupPage, '»', $baseUrl, $query);
|
||||
} else {
|
||||
$html .= '<li class="page-item disabled"><span class="page-link">»</span></li>';
|
||||
}
|
||||
@ -102,7 +108,6 @@ class Pagination
|
||||
$html .= '</ul></nav>';
|
||||
return $html;
|
||||
}
|
||||
|
||||
private function pageLink(int $page, string $label, string $baseUrl, array $query): string
|
||||
{
|
||||
$query['page'] = $page;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user