From 7ee809bd564cb1b95197aa8bb9dbf4496a78952a Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sat, 24 Sep 2022 13:24:48 +0800 Subject: [PATCH] refactor: problem_lists with bs5 --- web/app/controllers/problem_lists.php | 67 ++++++++++++++++++++------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/web/app/controllers/problem_lists.php b/web/app/controllers/problem_lists.php index 3fef911..f385b1b 100644 --- a/web/app/controllers/problem_lists.php +++ b/web/app/controllers/problem_lists.php @@ -3,6 +3,10 @@ become403Page(UOJLocale::get('need login')); } + if (!isset($_COOKIE['bootstrap4'])) { + $REQUIRE_LIB['bootstrap5'] = ''; + } + requirePHPLib('form'); requirePHPLib('judger'); requirePHPLib('data'); @@ -21,7 +25,7 @@ } function echoList($list) { - global $myUser; + global $myUser, $REQUIRE_LIB; echo ''; if ($list['problem_count'] == $list['accepted'] && $list['problem_count'] > 0) { @@ -31,13 +35,30 @@ } echo '#', $list['list_id'], ''; - echo ''; + if (isset($REQUIRE_LIB['bootstrap5'])) { + echo ''; + } else { + echo ''; + } + if ($list['is_hidden']) { echo ' [隐藏] '; } - echo '', $list['title'], ''; + echo '', $list['title'], ''; foreach (queryProblemListTags($list['list_id']) as $tag) { - echo '', '', HTML::escape($tag), '', ''; + if (isset($REQUIRE_LIB['bootstrap5'])) { + echo ''; + echo ''; + } else { + echo ''; + echo ''; + } + + echo HTML::escape($tag), '', ''; } echo ''; @@ -50,13 +71,18 @@ -printHTML(); - } + + +
+ + printHTML(); ?> + +
+ + - $problem_list_caption = UOJLocale::get('problems::problem list'); + 40, + 'table_classes' => array('table', 'table-bordered', 'table-hover', 'table-striped'), + 'head_pagination' => true, + 'pagination_table' => 'lists' + ); + + if (isset($REQUIRE_LIB['bootstrap5'])) { + $table_config['div_classes'] = array('card', 'mb-3'); + $table_config['table_classes'] = array('table', 'uoj-table', 'mb-0'); + } + echoLongTable( array('a.id as list_id', 'a.title as title', 'a.is_hidden as is_hidden', 'count(b.problem_id) as problem_count', 'count(c.submitter) as accepted'), $from, $cond, 'group by a.id order by a.id desc', $header, 'echoList', - array('page_len' => 40, - 'table_classes' => array('table', 'table-bordered', 'table-hover', 'table-striped'), - 'print_after_table' => function() { - global $myUser; - }, - 'head_pagination' => true, - 'pagination_table' => 'lists' - ) + $table_config, ); ?>