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