From ee6169f621cec3673cdfc0edcea98030f52d2489 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 22 Oct 2022 09:29:51 +0800 Subject: [PATCH] fix(web/group): group rank list pagination --- web/app/controllers/group.php | 1 + web/app/libs/uoj-html-lib.php | 4 +++- web/app/models/Paginator.php | 4 +++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web/app/controllers/group.php b/web/app/controllers/group.php index 2988ffb..bc62b39 100644 --- a/web/app/controllers/group.php +++ b/web/app/controllers/group.php @@ -143,6 +143,7 @@ EOD, 'page_len' => 50, 'group_id' => $group_id, 'by_accepted' => true, + 'div_classes' => ['table-responsive', 'mb-3'], 'table_classes' => ['table', 'text-center', 'mb-0'], ]) ?> diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index 72152e4..6e8e85f 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -1389,10 +1389,13 @@ function echoRanklist($config = array()) { $col_names = array('b.username as username', 'count(*) as ac_num', 'b.motto as motto'); $cond = '1'; $tail = 'group by username order by ac_num desc, username asc'; + $config['pagination_table'] = 'user_info'; if (isset($config['group_id'])) { $group_id = $config['group_id']; $from = "best_ac_submissions a inner join user_info b on a.submitter = b.username inner join groups_users c on (a.submitter = c.username and c.group_id = {$group_id})"; + $config['pagination_table'] = 'groups_users'; + $config['pagination_cond'] = "group_id = {$group_id}"; } if (isset($config['top10'])) { @@ -1400,6 +1403,5 @@ function echoRanklist($config = array()) { } $config['get_row_index'] = ''; - $config['pagination_table'] = 'user_info'; echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config); } diff --git a/web/app/models/Paginator.php b/web/app/models/Paginator.php index e82802d..6f39ef9 100644 --- a/web/app/models/Paginator.php +++ b/web/app/models/Paginator.php @@ -17,10 +17,12 @@ class Paginator { $this->table = $config['data']; } elseif (!isset($config['echo_full'])) { $table = $config['table_name']; + $cond = isset($config['cond']) ? $config['cond'] : '1'; if (isset($config['pagination_table'])) { $table = $config['pagination_table']; + $cond = isset($config['pagination_cond']) ? $config['pagination_cond'] : $cond; } - $this->n_rows = DB::selectCount("select count(*) from {$table} where {$config['cond']}"); + $this->n_rows = DB::selectCount("select count(*) from {$table} where {$cond}"); $this->page_len = isset($config['page_len']) ? $config['page_len'] : 10;