diff --git a/web/app/controllers/group.php b/web/app/controllers/group.php index 94db9e4..fba856a 100644 --- a/web/app/controllers/group.php +++ b/web/app/controllers/group.php @@ -118,6 +118,13 @@ +
+
+
+ true, 'group_id' => $group_id, 'by_accepted' => true)) ?> +
+
+
编辑小组信息
diff --git a/web/app/controllers/index.php b/web/app/controllers/index.php index 93cb398..6af9f0f 100644 --- a/web/app/controllers/index.php +++ b/web/app/controllers/index.php @@ -43,4 +43,17 @@
+ + +
+
+

+ true, 'top10' => true, 'by_accepted' => true)) ?> +
+ +
+
+
+ + diff --git a/web/app/controllers/ranklist.php b/web/app/controllers/ranklist.php index ce3b1fc..ba708ad 100644 --- a/web/app/controllers/ranklist.php +++ b/web/app/controllers/ranklist.php @@ -3,8 +3,13 @@ becomeMsgPage(UOJLocale::get('need login')); } - become404Page(); + if (isset($_GET['type']) && $_GET['type'] == 'accepted') { + $config = array('page_len' => 100, 'by_accepted' => true); + $title = UOJLocale::get('top solver'); + } else { + become404Page(); + } ?> - + diff --git a/web/app/libs/uoj-html-lib.php b/web/app/libs/uoj-html-lib.php index 8a879f9..685f24e 100644 --- a/web/app/libs/uoj-html-lib.php +++ b/web/app/libs/uoj-html-lib.php @@ -961,3 +961,54 @@ function echoUOJPageHeader($page_title, $extra_config = array()) { function echoUOJPageFooter($config = array()) { uojIncludeView('page-footer', $config); } + +function echoRanklist($config = array()) { + $header_row = ''; + $header_row .= ''; + $header_row .= '#'; + $header_row .= ''.UOJLocale::get('username').''; + $header_row .= ''.UOJLocale::get('motto').''; + $header_row .= ''.UOJLocale::get('solved').''; + $header_row .= ''; + + $users = array(); + $print_row = function($user, $now_cnt) use (&$users, $config) { + if (!$users) { + if ($now_cnt == 1) { + $rank = 1; + } else { + $rank = DB::selectCount("select count(*) from (select b.username as username, count(*) as accepted from best_ac_submissions a inner join user_info b on a.submitter = b.username group by username) as derived where accepted > {$user['ac_num']}") + 1; + } + } else { + $rank = $now_cnt; + } + + $user['rank'] = $rank; + + echo ''; + echo '' . $user['rank'] . ''; + echo '' . getUserLink($user['username']) . ''; + echo '' . HTML::escape($user['motto']) . ''; + echo '' . $user['ac_num'] . ''; + echo ''; + + $users[] = $user; + }; + + $from = 'best_ac_submissions a inner join user_info b on a.submitter = b.username'; + $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'; + + 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})"; + } + + if (isset($config['top10'])) { + $tail .= ' limit 10'; + } + + $config['get_row_index'] = ''; + echoLongTable($col_names, $from, $cond, $tail, $header_row, $print_row, $config); +} diff --git a/web/app/locale/basic/en.php b/web/app/locale/basic/en.php index 5da1d8b..2870d9a 100644 --- a/web/app/locale/basic/en.php +++ b/web/app/locale/basic/en.php @@ -19,6 +19,8 @@ return [ 'blogs' => 'Blogs', 'announcements' => 'Announcements', 'all the announcements' => 'All the Announcements……', + 'solved' => 'Solved', + 'top solver' => 'Top solver', 'help' => 'Help', 'search' => 'Search', 'news' => 'News', diff --git a/web/app/locale/basic/zh-cn.php b/web/app/locale/basic/zh-cn.php index 7b349fe..1051f2c 100644 --- a/web/app/locale/basic/zh-cn.php +++ b/web/app/locale/basic/zh-cn.php @@ -19,6 +19,8 @@ return [ 'blogs' => '博客', 'announcements' => '公告', 'all the announcements' => '所有公告……', + 'solved' => 'AC 数', + 'top solver' => 'AC 数排行榜', 'help' => '帮助', 'search' => '搜索', 'news' => '最新动态', diff --git a/web/app/route.php b/web/app/route.php index 7796d71..75d2f7f 100644 --- a/web/app/route.php +++ b/web/app/route.php @@ -51,6 +51,7 @@ Route::group([ Route::any('/announcements', '/announcements.php'); Route::any('/faq', '/faq.php'); + Route::any('/solverlist', '/ranklist.php?type=accepted'); Route::any('/captcha', '/captcha.php'); Route::any('/login', '/login.php');