Skip to content

Commit

Permalink
rex_list: refactor logic into new getRowsOnCurrentPage() method (#5827)
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed Sep 29, 2023
1 parent d4265f3 commit 7e72dfb
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions redaxo/src/core/lib/list.php
Expand Up @@ -918,6 +918,19 @@ public function getRows()
return $this->rows;
}

protected function getRowsOnCurrentPage(): int
{
$nbRows = $this->getRows();

if ($this->pager) {
$maxRows = min($this->pager->getRowsPerPage(), $nbRows - $this->pager->getCursor());
} else {
$maxRows = $nbRows;
}

return $maxRows;
}

/**
* Returns the pager for this list.
*
Expand Down Expand Up @@ -1190,7 +1203,6 @@ public function get()
$sortType = $this->getSortType();
$warning = $this->getWarning();
$message = $this->getMessage();
$nbRows = $this->getRows();

$header = $this->getHeader();
$footer = $this->getFooter();
Expand Down Expand Up @@ -1255,12 +1267,8 @@ public function get()
$s .= ' </tfoot>' . "\n";
}

if ($nbRows > 0) {
if ($this->pager) {
$maxRows = min($this->pager->getRowsPerPage(), $nbRows - $this->pager->getCursor());
} else {
$maxRows = $nbRows;
}
if ($this->getRows() > 0) {
$maxRows = $this->getRowsOnCurrentPage();

$s .= ' <tbody>' . "\n";
for ($i = 0; $i < $maxRows; ++$i) {
Expand Down

0 comments on commit 7e72dfb

Please sign in to comment.