Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions manager/actions/report/logging.static.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class="inputbox" style="width:100px"
// Load up the 2 array in order to display result
$array_paging = $p->getPagingArray();
$array_row_paging = $p->getPagingRowArray();
$current_row = evo()->input_get('int_cur_position', 0) / $int_num_result;
$current_row = (int)(evo()->input_get('int_cur_position', 0) / $int_num_result);

// Display the result as you like...
echo sprintf('<p>%s %s', lang('paging_showing'), $array_paging['lower']);
Expand All @@ -303,11 +303,11 @@ class="inputbox" style="width:100px"
$paging .= $array_paging['previous_link'] . lang('paging_prev') . (isset($array_paging['previous_link']) ? "</a> " : " ");
$pagesfound = sizeof($array_row_paging);
if ($pagesfound > 6) {
$paging .= $array_row_paging[$current_row - 2];
$paging .= $array_row_paging[$current_row - 1];
$paging .= $array_row_paging[$current_row];
$paging .= $array_row_paging[$current_row + 1];
$paging .= $array_row_paging[$current_row + 2];
$start = max(0, min($current_row - 2, $pagesfound - 5));
$end = min($pagesfound - 1, $start + 4);
for ($i = $start; $i <= $end; $i++) {
$paging .= $array_row_paging[$i];
}
} else {
for ($i = 0; $i < $pagesfound; $i++) {
$paging .= $array_row_paging[$i] . "&nbsp;";
Expand Down
2 changes: 1 addition & 1 deletion manager/includes/paginate.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getPagingRowArray()

private function getNumberOfPage()
{
return $this->int_nbr_row / $this->int_num_result;
return (int)ceil($this->int_nbr_row / $this->int_num_result);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve ratio used by getCurrentPage calculation

Changing getNumberOfPage() to ceil(...) breaks the algebra that getCurrentPage() relies on (($int_cur_position * getNumberOfPage()) / $int_nbr_row), so non-even totals can round to the wrong page index. For example with 4 rows, page size 3, and int_cur_position=3, getCurrentPage() becomes 1.5 and number_format(..., 0) returns 2, which is outside valid indexes 0..1; this leaves no page marked as current (or marks the wrong one) in pagers that consume getPagingRowArray().

Useful? React with 👍 / 👎.

}

private function getCurrentPage()
Expand Down