+
+
+
+ = UOJLocale::get('problems lists') ?>
+
+
+
+ printHTML(); ?>
+
+
+
+
-
- = UOJLocale::get('problems lists') ?>
-
+
+
+ />
+
+
+
-
-
- printHTML(); ?>
-
-
-
-
-
-EOD;
-
- $cond = [];
- $search_tag = null;
-
- if (isset($_GET['tag'])) {
- $search_tag = $_GET['tag'];
- }
-
- if ($search_tag) {
- $cond[] = "'" . DB::escape($search_tag) . "' in (select tag from lists_tags where lists_tags.list_id = a.id)";
- }
-
- if ($cond) {
- $cond = join($cond, ' and ');
- } else {
- $cond = '1';
- }
-
- 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'),
- "lists a left join lists_problems b on a.id = b.list_id left join best_ac_submissions c on (b.problem_id = c.problem_id and c.submitter = '{$myUser['username']}')",
- $cond,
- 'group by a.id order by a.id desc',
- $header,
- function($list) use ($myUser) {
- if (isListVisibleToUser($list, $myUser)) {
- echo '
';
- if ($list['problem_count'] == $list['accepted'] && $list['problem_count'] > 0) {
- echo '';
+
-
+ = $pag->pagination() ?>
+
+ =
+ HTML::responsive_table($header, $pag->get(), [
+ 'table_attr' => [
+ 'class' => ['table', 'uoj-table', 'mb-0'],
+ ],
+ 'tr' => function ($row, $idx) {
+ return getListTR($row);
+ }
+ ]);
+ ?>
+
+
+ = $pag->pagination() ?>
+
+
+
+
+
+
diff --git a/web/app/controllers/problem_set.php b/web/app/controllers/problem_set.php
index d0ad81d..7729fae 100644
--- a/web/app/controllers/problem_set.php
+++ b/web/app/controllers/problem_set.php
@@ -288,11 +288,11 @@ $pag = new Paginator([
$('#input-show_tags_mode').click(function() {
if (this.checked) {
$.cookie('show_tags_mode', '', {
- path: '/problems'
+ path: '/'
});
} else {
$.removeCookie('show_tags_mode', {
- path: '/problems'
+ path: '/'
});
}
location.reload();
@@ -300,11 +300,11 @@ $pag = new Paginator([
$('#input-show_submit_mode').click(function() {
if (this.checked) {
$.cookie('show_submit_mode', '', {
- path: '/problems'
+ path: '/'
});
} else {
$.removeCookie('show_submit_mode', {
- path: '/problems'
+ path: '/'
});
}
location.reload();
@@ -382,4 +382,4 @@ $pag = new Paginator([
-
\ No newline at end of file
+
diff --git a/web/app/libs/uoj-query-lib.php b/web/app/libs/uoj-query-lib.php
index 0d0760e..3741f47 100644
--- a/web/app/libs/uoj-query-lib.php
+++ b/web/app/libs/uoj-query-lib.php
@@ -37,33 +37,6 @@ function queryProblemBrief($id) {
return DB::selectFirst("select * from problems where id = $id", MYSQLI_ASSOC);
}
-function queryProblemTags($id) {
- $tags = array();
- $result = DB::query("select tag from problems_tags where problem_id = $id order by id");
- while ($row = DB::fetch($result, MYSQLI_NUM)) {
- $tags[] = $row[0];
- }
- return $tags;
-}
-
-function queryProblemList($id) {
- return DB::selectFirst("select * from lists where id = $id", MYSQLI_ASSOC);
-}
-function queryProblemListTags($id) {
- $tags = array();
- $result = DB::query("select tag from lists_tags where list_id = $id order by id");
- if (!$result) {
- return $tags;
- }
- while ($row = DB::fetch($result, MYSQLI_NUM)) {
- $tags[] = $row[0];
- }
- return $tags;
-}
-function queryProblemInList($list_id, $problem_id) {
- return DB::selectFirst("SELECT * FROM lists_problems WHERE list_id = '$list_id' AND problem_id = '$problem_id'", MYSQLI_ASSOC);
-}
-
function querySolution($problem_id, $blog_id) {
return DB::selectFirst("select * from problems_solutions where blog_id='$blog_id' and problem_id='$problem_id'", MYSQLI_ASSOC);
}
diff --git a/web/app/models/HTML.php b/web/app/models/HTML.php
index 1dc727e..63410df 100644
--- a/web/app/models/HTML.php
+++ b/web/app/models/HTML.php
@@ -60,7 +60,7 @@ class HTML {
return '' . $name . '>';
}
public static function tag(string $name, array $attr, $content) {
- return HTML::tag_begin($name, $attr) . $content . HTML::tag_end($name);
+ return HTML::tag_begin($name, $attr) . (is_array($content) ? implode('', $content) : $content) . HTML::tag_end($name);
}
public static function empty_tag(string $name, array $attr) {
return '<' . $name . HTML::attr($attr) . ' />';
diff --git a/web/app/models/UOJList.php b/web/app/models/UOJList.php
new file mode 100644
index 0000000..9255516
--- /dev/null
+++ b/web/app/models/UOJList.php
@@ -0,0 +1,61 @@
+ $id]
+ ]);
+ if (!$info) {
+ return null;
+ }
+ return new UOJList($info);
+ }
+
+ public function __construct($info) {
+ $this->info = $info;
+ }
+
+ public function getProblemIDs() {
+ return array_map(fn ($x) => $x['problem_id'], DB::selectAll([
+ DB::lc(), "select problem_id from lists_problems",
+ "where", ['list_id' => $this->info['id']],
+ "order by problem_id"
+ ]));
+ }
+
+ public function hasProblem(UOJProblem $problem) {
+ return DB::selectFirst([
+ DB::lc(), "select 1 from lists_problems",
+ "where", [
+ 'list_id' => $this->info['id'],
+ 'problem_id' => $problem->info['id']
+ ]
+ ]) != null;
+ }
+
+ public function userCanManage(array $user = null) {
+ return isSuperUser($user);
+ }
+
+ public function userCanView(array $user = null, array $cfg = []) {
+ $cfg += ['ensure' => false];
+ if ($this->info['is_hidden'] && !$this->userCanManage($user)) {
+ $cfg['ensure'] && UOJResponse::page404();
+ return false;
+ }
+ return true;
+ }
+}
+
+UOJList::$table_for_content = 'lists_contents';
+UOJList::$key_for_content = 'id';
+UOJList::$fields_for_content = ['*'];
+UOJList::$table_for_tags = 'lists_tags';
+UOJList::$key_for_tags = 'list_id';
diff --git a/web/app/models/UOJRequest.php b/web/app/models/UOJRequest.php
index 709d58c..57ca237 100644
--- a/web/app/models/UOJRequest.php
+++ b/web/app/models/UOJRequest.php
@@ -4,7 +4,7 @@ class UOJRequest {
const GET = 'get';
const POST = 'post';
- public static function get($name, $val=null, $default=null) {
+ public static function get($name, $val = null, $default = null) {
if (!isset($_GET[$name])) {
return $default;
}
@@ -14,7 +14,7 @@ class UOJRequest {
return $_GET[$name];
}
- public static function post($name, $val=null, $default=null) {
+ public static function post($name, $val = null, $default = null) {
if (!isset($_POST[$name])) {
return $default;
}
@@ -24,7 +24,7 @@ class UOJRequest {
return $_POST[$name];
}
- public static function data(string $method, string $name, callable $val=null, $default=null) {
+ public static function data(string $method, string $name, callable $val = null, $default = null) {
if ($method == self::GET) {
return self::get($name, $val, $default);
} elseif ($method == self::POST) {
diff --git a/web/app/route.php b/web/app/route.php
index 53963ed..3422d02 100644
--- a/web/app/route.php
+++ b/web/app/route.php
@@ -28,7 +28,7 @@ Route::group(
Route::any('/lists', '/lists.php');
Route::any('/list/{id}', '/list.php');
- Route::any('/list/{id}/edit(?:/{tab})?', '/list_edit.php');
+ Route::any('/list/{id}/manage(?:/{tab})?', '/list_manage.php');
Route::any('/contests', '/contests.php');
Route::any('/contest/new', '/add_contest.php');
diff --git a/web/app/upgrade/16_list_v3/up.sql b/web/app/upgrade/16_list_v3/up.sql
new file mode 100644
index 0000000..3451e43
--- /dev/null
+++ b/web/app/upgrade/16_list_v3/up.sql
@@ -0,0 +1,6 @@
+CREATE TABLE `lists_contents` (
+ `id` int NOT NULL,
+ `content` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
+ `content_md` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
+ PRIMARY KEY (`id`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
diff --git a/web/app/upgrade/16_list_v3/upgrade.php b/web/app/upgrade/16_list_v3/upgrade.php
new file mode 100644
index 0000000..3bc245d
--- /dev/null
+++ b/web/app/upgrade/16_list_v3/upgrade.php
@@ -0,0 +1,28 @@
+purify($parsedown->text($info['description'])),
+ $info['description'],
+ ]),
+ ]);
+ }
+
+ DB::query("alter table lists drop column description");
+ }
+};
|