2022-10-22 11:24:48 +00:00
|
|
|
<?php
|
2022-11-10 00:16:48 +00:00
|
|
|
requirePHPLib('form');
|
|
|
|
requirePHPLib('judger');
|
|
|
|
requirePHPLib('data');
|
|
|
|
|
|
|
|
Auth::check() || redirectToLogin();
|
2022-11-11 23:10:34 +00:00
|
|
|
UOJUser::checkPermission(Auth::user(), 'lists.view') || UOJResponse::page403();
|
2022-11-10 00:16:48 +00:00
|
|
|
|
2022-11-11 23:10:34 +00:00
|
|
|
if (UOJList::userCanCreateList(Auth::user())) {
|
2023-01-14 00:51:00 +00:00
|
|
|
$new_list_form = new UOJForm('new_list');
|
2022-11-10 00:16:48 +00:00
|
|
|
$new_list_form->handle = function () {
|
2023-01-14 00:51:00 +00:00
|
|
|
DB::insert([
|
|
|
|
"insert into lists",
|
|
|
|
DB::bracketed_fields(['title', 'is_hidden']),
|
|
|
|
"values",
|
|
|
|
DB::tuple(['未命名题单', 1]),
|
|
|
|
]);
|
|
|
|
$list_id = DB::insert_id();
|
|
|
|
DB::insert([
|
|
|
|
"insert into lists_contents",
|
|
|
|
DB::bracketed_fields(['id', 'content', 'content_md']),
|
|
|
|
"values",
|
|
|
|
DB::tuple([$list_id, '', '']),
|
|
|
|
]);
|
|
|
|
redirectTo("/list/{$list_id}");
|
|
|
|
die();
|
2022-11-10 00:16:48 +00:00
|
|
|
};
|
2023-01-14 00:51:00 +00:00
|
|
|
$new_list_form->config['submit_container']['class'] = 'text-end';
|
|
|
|
$new_list_form->config['submit_button']['class'] = 'btn btn-primary';
|
|
|
|
$new_list_form->config['submit_button']['text'] = UOJLocale::get('problems::add new list');
|
|
|
|
$new_list_form->config['confirm']['smart'] = true;
|
2022-11-10 00:16:48 +00:00
|
|
|
$new_list_form->runAtServer();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getListTR($info) {
|
|
|
|
$list = new UOJList($info);
|
|
|
|
$problems = $list->getProblemIDs();
|
2022-11-11 00:20:33 +00:00
|
|
|
if (Auth::check() && !empty($problems)) {
|
|
|
|
$accepted = DB::selectCount([
|
|
|
|
"select count(*)",
|
|
|
|
"from best_ac_submissions",
|
|
|
|
"where", [
|
|
|
|
"submitter" => Auth::id(),
|
|
|
|
["problem_id", "in", DB::rawtuple($problems)],
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
} else {
|
|
|
|
$accepted = -1;
|
|
|
|
}
|
2022-11-10 00:16:48 +00:00
|
|
|
|
|
|
|
$html = HTML::tag_begin('tr', ['class' => 'text-center']);
|
|
|
|
$html .= HTML::tag('td', ['class' => $accepted == count($problems) ? 'table-success' : ''], "#{$list->info['id']}");
|
|
|
|
$html .= HTML::tag_begin('td', ['class' => 'text-start']);
|
2022-11-11 00:20:33 +00:00
|
|
|
$html .= $list->getLink();
|
2022-11-10 00:16:48 +00:00
|
|
|
if ($list->info['is_hidden']) {
|
|
|
|
$html .= ' <span class="badge text-bg-danger"><i class="bi bi-eye-slash-fill"></i> ' . UOJLocale::get('hidden') . '</span> ';
|
|
|
|
}
|
2022-12-03 06:58:06 +00:00
|
|
|
if (isset($_COOKIE['show_tags_mode'])) {
|
|
|
|
foreach ($list->queryTags() as $tag) {
|
|
|
|
$html .= ' <a class="uoj-list-tag"><span class="badge text-bg-secondary">' . HTML::escape($tag) . '</span></a> ';
|
|
|
|
}
|
2022-10-22 11:24:48 +00:00
|
|
|
}
|
2022-11-11 00:20:33 +00:00
|
|
|
$html .= HTML::tag('td', [], max(0, $accepted));
|
2022-11-10 00:16:48 +00:00
|
|
|
$html .= HTML::tag('td', [], count($problems));
|
|
|
|
$html .= HTML::tag_end('td');
|
|
|
|
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
$cond = [];
|
|
|
|
$search_tag = UOJRequest::get('tag', 'is_string', null);
|
|
|
|
if (is_string($search_tag)) {
|
|
|
|
$cond[] = [
|
|
|
|
DB::rawvalue($search_tag), "in", DB::rawbracket([
|
|
|
|
"select tag from lists_tags",
|
|
|
|
"where", ["lists_tags.list_id" => DB::raw("lists.id")]
|
|
|
|
])
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($cond)) {
|
|
|
|
$cond = '1';
|
|
|
|
}
|
|
|
|
|
|
|
|
$header = HTML::tag('tr', [], [
|
|
|
|
HTML::tag('th', ['class' => 'text-center', 'style' => 'width:5em'], 'ID'),
|
|
|
|
HTML::tag('th', [], UOJLocale::get('problems::problem list')),
|
|
|
|
HTML::tag('th', ['class' => 'text-center', 'style' => 'width:5em'], UOJLocale::get('problems::ac')),
|
|
|
|
HTML::tag('th', ['class' => 'text-center', 'style' => 'width:5em'], UOJLocale::get('problems::total')),
|
|
|
|
]);
|
|
|
|
|
|
|
|
$pag = new Paginator([
|
|
|
|
'col_names' => ['*'],
|
|
|
|
'table_name' => 'lists',
|
|
|
|
'cond' => $cond,
|
|
|
|
'tail' => "order by id desc",
|
2023-02-17 13:50:04 +00:00
|
|
|
'page_len' => 50,
|
2022-11-10 00:16:48 +00:00
|
|
|
'post_filter' => function ($info) {
|
|
|
|
return (new UOJList($info))->userCanView(Auth::user());
|
2022-10-22 11:24:48 +00:00
|
|
|
}
|
2022-11-10 00:16:48 +00:00
|
|
|
]);
|
|
|
|
?>
|
2022-10-22 11:24:48 +00:00
|
|
|
|
|
|
|
<?php echoUOJPageHeader(UOJLocale::get('problems lists')) ?>
|
|
|
|
|
|
|
|
<div class="row">
|
2022-11-10 00:16:48 +00:00
|
|
|
<!-- left col -->
|
|
|
|
<div class="col-lg-9">
|
|
|
|
<!-- title container -->
|
|
|
|
<div class="d-flex justify-content-between">
|
|
|
|
<h1>
|
|
|
|
<?= UOJLocale::get('problems lists') ?>
|
|
|
|
</h1>
|
2022-11-11 23:10:34 +00:00
|
|
|
|
2022-11-10 00:16:48 +00:00
|
|
|
<?php if (isset($new_list_form)) : ?>
|
2022-11-11 23:10:34 +00:00
|
|
|
<div class="text-end">
|
2022-11-10 00:16:48 +00:00
|
|
|
<?php $new_list_form->printHTML(); ?>
|
|
|
|
</div>
|
|
|
|
<?php endif ?>
|
|
|
|
</div>
|
|
|
|
<!-- end title container -->
|
|
|
|
|
|
|
|
<div class="text-end">
|
|
|
|
<div class="form-check d-inline-block me-2">
|
|
|
|
<input type="checkbox" id="input-show_tags_mode" class="form-check-input" <?= isset($_COOKIE['show_tags_mode']) ? 'checked="checked" ' : '' ?> />
|
|
|
|
<label class="form-check-label" for="input-show_tags_mode">
|
|
|
|
<?= UOJLocale::get('problems::show tags') ?>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
$('#input-show_tags_mode').click(function() {
|
|
|
|
if (this.checked) {
|
|
|
|
$.cookie('show_tags_mode', '', {
|
2022-12-03 06:58:06 +00:00
|
|
|
path: '/lists',
|
|
|
|
expires: 365,
|
2022-11-10 00:16:48 +00:00
|
|
|
});
|
2022-10-22 11:24:48 +00:00
|
|
|
} else {
|
2022-11-10 00:16:48 +00:00
|
|
|
$.removeCookie('show_tags_mode', {
|
2022-12-03 06:58:06 +00:00
|
|
|
path: '/lists',
|
2022-11-10 00:16:48 +00:00
|
|
|
});
|
2022-10-22 11:24:48 +00:00
|
|
|
}
|
2022-11-10 00:16:48 +00:00
|
|
|
location.reload();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<?= $pag->pagination() ?>
|
|
|
|
|
|
|
|
<div class="card my-3">
|
|
|
|
<?=
|
|
|
|
HTML::responsive_table($header, $pag->get(), [
|
|
|
|
'table_attr' => [
|
|
|
|
'class' => ['table', 'uoj-table', 'mb-0'],
|
|
|
|
],
|
|
|
|
'tr' => function ($row, $idx) {
|
|
|
|
return getListTR($row);
|
2022-10-22 11:24:48 +00:00
|
|
|
}
|
2022-11-10 00:16:48 +00:00
|
|
|
]);
|
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<?= $pag->pagination() ?>
|
|
|
|
</div>
|
|
|
|
<!-- end left col -->
|
|
|
|
|
|
|
|
<!-- right col -->
|
|
|
|
<aside class="col-lg-3 mt-3 mt-lg-0">
|
|
|
|
<?php uojIncludeView('sidebar') ?>
|
|
|
|
</aside>
|
|
|
|
<!-- end right col -->
|
2022-10-22 11:24:48 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<?php echoUOJPageFooter() ?>
|