From 7ab64c1ba3dd566decac014e7f4c982ea27a5847 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 26 Sep 2022 07:58:58 +0800 Subject: [PATCH] refactor: problem_list with bs5 --- web/app/controllers/problem_list.php | 137 +++++++++++++++++++++++---- 1 file changed, 121 insertions(+), 16 deletions(-) diff --git a/web/app/controllers/problem_list.php b/web/app/controllers/problem_list.php index 61807b7..7176138 100644 --- a/web/app/controllers/problem_list.php +++ b/web/app/controllers/problem_list.php @@ -13,8 +13,12 @@ become404Page(); } + if (!isset($_COOKIE['bootstrap4'])) { + $REQUIRE_LIB['bootstrap5'] = ''; + } + function echoProblem($problem) { - global $myUser, $removeProblemForms; + global $myUser, $removeProblemForms, $REQUIRE_LIB; if (isProblemVisibleToUser($problem, $myUser)) { echo ''; @@ -24,20 +28,37 @@ echo ''; } echo '#', $problem['id'], ''; - echo ''; + if (isset($REQUIRE_LIB['bootstrap5'])) { + echo ''; + } else { + echo ''; + } if ($problem['is_hidden']) { echo ' [隐藏] '; } if ($problem['uploader'] == $myUser['username']) { echo ' [我的题目] '; } - echo '', $problem['title'], ''; + echo '', $problem['title'], ''; if (isset($_COOKIE['show_tags_mode'])) { echo ' ' . $problem["uploader"] . ' '; foreach (queryProblemTags($problem['id']) as $tag) { - echo '', '', HTML::escape($tag), '', ''; + + if (isset($REQUIRE_LIB['bootstrap5'])) { + echo ''; + echo ''; + } else { + echo ''; + echo ''; + } + echo HTML::escape($tag), ''; + echo ' '; } } echo ''; @@ -62,11 +83,11 @@ EOD; $header .= 'ID'; $header .= ''.UOJLocale::get('problems::problem').''; if (isset($_COOKIE['show_submit_mode'])) { - $header .= ''.UOJLocale::get('problems::ac').''; - $header .= ''.UOJLocale::get('problems::submit').''; - $header .= ''.UOJLocale::get('problems::ac ratio').''; + $header .= ''.UOJLocale::get('problems::ac').''; + $header .= ''.UOJLocale::get('problems::submit').''; + $header .= ''.UOJLocale::get('problems::ac ratio').''; } - $header .= ''.UOJLocale::get('appraisal').''; + $header .= ''.UOJLocale::get('appraisal').''; $header .= ''; $pag_config = array('page_len' => 40); @@ -78,32 +99,107 @@ EOD; $pag_config['tail'] = "order by id asc"; $pag = new Paginator($pag_config); - $div_classes = array('table-responsive'); - $table_classes = array('table', 'table-bordered', 'table-hover', 'table-striped'); + $div_classes = isset($REQUIRE_LIB['bootstrap5']) + ? array('card', 'my-3', 'overflow-auto') + : array('table-responsive'); + $table_classes = isset($REQUIRE_LIB['bootstrap5']) + ? array('table', 'uoj-table', 'mb-0') + : array('table', 'table-bordered', 'table-hover', 'table-striped'); ?> + +
+
+
+

+ (ID: #)

+ +
+ + + +
+ + + + +
+
-
- - +
+ +
+ +
+ + + +
+ +
+
-
+
pagination(); ?>
+ +
+ +