fix pagination when pagination is diabled (entries per page = 0)

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2023-01-08 18:52:58 +01:00
parent 452df60866
commit 3b9c60e985

View File

@@ -63,7 +63,9 @@ class Pagination
$this->perPage = $perPage; $this->perPage = $perPage;
$this->pageno = 1; $this->pageno = 1;
// add default limitation by settings // add default limitation by settings
$this->addLimit(Settings::Get('panel.paging')); if (Settings::Get('panel.paging') > 0) {
$this->addLimit(Settings::Get('panel.paging'));
}
// check search request // check search request
$this->searchtext = ''; $this->searchtext = '';
if (count($fields) > 0) { if (count($fields) > 0) {
@@ -201,7 +203,7 @@ class Pagination
public function getApiResponseParams(): array public function getApiResponseParams(): array
{ {
return [ return [
'pagination' => [ 'pagination' => (Settings::Get('panel.paging') > 0) ? [
"total" => $this->entries, "total" => $this->entries,
"per_page" => $this->perPage, "per_page" => $this->perPage,
"current_page" => $this->pageno, "current_page" => $this->pageno,
@@ -209,7 +211,7 @@ class Pagination
"from" => $this->data['sql_offset'] ?? null, "from" => $this->data['sql_offset'] ?? null,
"to" => min($this->data['sql_offset'] + $this->perPage, $this->entries), "to" => min($this->data['sql_offset'] + $this->perPage, $this->entries),
'sortfields' => array_keys($this->fields), 'sortfields' => array_keys($this->fields),
] ] : []
]; ];
} }