From d77dc5f1e0b0fe43bcbda0a6657bcdf5f0c4a1e2 Mon Sep 17 00:00:00 2001
From: Floorb <132411956+Neetpone@users.noreply.github.com>
Date: Tue, 29 Aug 2023 03:42:29 -0400
Subject: [PATCH] fix(admin): fix paginator
---
includes/functions.php | 6 +++---
public/admin/dashboard.php | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/includes/functions.php b/includes/functions.php
index c6d795d..3c45582 100644
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -249,7 +249,7 @@ function escapeLikeQuery(string $query) : string {
return str_replace(['\\', '_', '%'], ['\\\\', '\\_', '\\%'], $query);
}
-function paginate(int $current_page, int $per_page, int $total_records) : string {
+function paginate(int $current_page, int $per_page, int $total_records, $prefix = '') : string {
$first_page = 0;
$last_page = floor($total_records / $per_page);
$window = 2;
@@ -258,11 +258,11 @@ function paginate(int $current_page, int $per_page, int $total_records) : string
// Do something?
}
- $_page_button = function(int $page, string $text, bool $disabled = false) use ($current_page) : string {
+ $_page_button = function(int $page, string $text, bool $disabled = false) use ($current_page, $prefix) : string {
/* We need to update the 'page' parameter in the request URI, or add it if it doesn't exist. */
$request_uri = parse_url($_SERVER['REQUEST_URI']);
parse_str((string) @$request_uri['query'], $parsed_query);
- $parsed_query['page'] = (string) $page;
+ $parsed_query[$prefix . 'page'] = (string) $page;
$page_uri = ((string) @$request_uri['path']) . '?' . http_build_query($parsed_query);
$selected_class = $current_page == $page ? ' paginator__button--selected' : '';
diff --git a/public/admin/dashboard.php b/public/admin/dashboard.php
index a628fdc..df17009 100644
--- a/public/admin/dashboard.php
+++ b/public/admin/dashboard.php
@@ -55,7 +55,7 @@ foreach (PageView::orderBy('id', 'desc')->take(7)->get() as $row) {
$tvisit[] = $row['tvisit'];
}
-[$mm_per_page, $mm_current_page] = pp_setup_pagination('mm', 10);
+[$mm_per_page, $mm_current_page] = pp_setup_pagination('mm_', 10);
$admin_histories = AdminLog::with('user')
->orderBy('id', 'desc')
@@ -303,7 +303,7 @@ $is_admin = $current_user->role >= User::ROLE_ADMIN;
- = paginate($mm_current_page, $mm_per_page, ModMessage::count()) ?>
+ = paginate($mm_current_page, $mm_per_page, ModMessage::count(), 'mm_') ?>