Skip to content

Commit

Permalink
Retain query parameters on pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
ecartz committed Sep 28, 2021
1 parent 9c802ea commit 4e052ad
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions admin/includes/classes/paginator.php
Expand Up @@ -34,10 +34,15 @@ public function __construct(&$table_definition) {
if ($this->current_page_number > $this->page_count) {
$this->current_page_number = $this->page_count;
}

$table_definition['page'] = $this->current_page_number;
$offset = ($this->table_definition['rows_per_page'] * ($this->current_page_number - 1));
$table_definition['sql'] .= " LIMIT " . max($offset, 0) . ", " . $this->table_definition['rows_per_page'];
$this->query = $GLOBALS['db']->query($table_definition['sql']);

if (!isset($table_definition['parameters'])) {
$table_definition['parameters'] = array_diff_key($_GET, ['page' => 0]);
}
}

public function display_count() {
Expand All @@ -59,15 +64,15 @@ public function display_table() {
include DIR_FS_ADMIN . 'includes/components/paginated_table.php';
}

public function draw_pages_form($parameters = []) {
public function draw_pages_form() {
$pages = [];
for ($i = 1; $i <= $this->page_count; $i++) {
$pages[] = ['id' => $i, 'text' => $i];
}

$form = new Form('pages', $GLOBALS['Admin']->link(), 'get');

foreach ($parameters as $key => $value) {
foreach ($this->table_definition['parameters'] ?? [] as $key => $value) {
$form->hide($key, $value);
}

Expand Down

0 comments on commit 4e052ad

Please sign in to comment.