userCanManage(Auth::user()) || UOJResponse::page403(); $cur_tab = UOJRequest::get('tab', 'is_string', 'profile'); $tabs_info = [ 'profile' => [ 'name' => '基本信息', 'url' => '/list/' . UOJList::info('id') . '/manage/profile', ], 'problems' => [ 'name' => '题目管理', 'url' => '/list/' . UOJList::info('id') . '/manage/problems', ], ]; if (!isset($tabs_info[$cur_tab])) { become404Page(); } if ($cur_tab == 'profile') { $update_profile_form = new UOJBs4Form('update_profile'); $update_profile_form->addVInput( 'name', 'text', '标题', UOJList::info('title'), function ($title, &$vdata) { if ($title == '') { return '标题不能为空'; } if (strlen($title) > 100) { return '标题过长'; } $title = HTML::escape($title); if ($title === '') { return '无效编码'; } $vdata['title'] = $title; return ''; }, null ); $update_profile_form->addVCheckboxes('is_hidden', [ '0' => '公开', '1' => '隐藏', ], '可见性', UOJList::info('is_hidden')); $update_profile_form->addVInput( 'tags', 'text', '标签(多个标签用逗号隔开)', implode(', ', UOJList::cur()->queryTags()), function ($tags_str, &$vdata) { $tags_raw = explode(',', str_replace(',', ',', $tags_str)); $tags = []; if (count($tags_raw) > 10) { return '不能存在超过 10 个标签'; } foreach ($tags_raw as $tag) { $tag = HTML::escape(trim($tag)); if (strlen($tag) == 0) { continue; } if (strlen($tag) > 30) { return '标签 “' . $tag . '” 太长'; } if (in_array($tag, $tags, true)) { return '标签 “' . $tag . '” 重复出现'; } $tags[] = $tag; } $vdata['tags'] = $tags; return ''; }, null ); $update_profile_form->addVTextArea( 'content_md', '描述', UOJList::cur()->queryContent()['content_md'], function ($content_md, &$vdata) { if (strlen($content_md) > 3000) { return '描述过长'; } $vdata['content_md'] = $content_md; return ''; }, null ); $update_profile_form->handle = function ($vdata) { DB::update([ "update lists", "set", [ "title" => $vdata['title'], "is_hidden" => $_POST['is_hidden'], ], "where", [ "id" => UOJList::info('id'), ] ]); DB::update([ "update lists_contents", "set", [ "content" => HTML::purifier()->purify(HTML::parsedown()->text($vdata['content_md'])), "content_md" => $vdata['content_md'], ], "where", [ "id" => UOJList::info('id'), ], ]); UOJList::cur()->updateTags($vdata['tags']); dieWithJsonData(['status' => 'success', 'message' => '修改成功']); }; $update_profile_form->setAjaxSubmit(<<submit_button_config['class_str'] = 'btn btn-secondary mt-3'; $update_profile_form->submit_button_config['text'] = '更新'; $update_profile_form->runAtServer(); } elseif ($cur_tab == 'problems') { if (isset($_POST['submit-remove_problem']) && $_POST['submit-remove_problem'] == 'remove_problem') { crsf_defend(); $problem = UOJProblem::query(UOJRequest::post('problem_id', 'validateUInt')); if (!$problem) { dieWithAlert('题目不存在'); } if (!UOJList::cur()->hasProblem($problem)) { dieWithAlert('题目不在题单中'); } DB::delete([ "delete from lists_problems", "where", [ "problem_id" => $problem->info['id'], "list_id" => UOJList::info('id'), ], ]); dieWithAlert('移除成功!'); } $n_problems = DB::selectCount([ "select count(*)", "from lists_problems", "where", [ "list_id" => UOJList::info('id'), ], ]); $add_new_problem_form = new UOJBs4Form('add_new_problem'); $add_new_problem_form->addVInput( 'problem_id', 'text', '题目 ID', '', function ($problem_id, &$vdata) { $problem = UOJProblem::query($problem_id); if (!$problem || !$problem->userCanView(Auth::user())) { return '题目不存在'; } if (UOJList::cur()->hasProblem($problem)) { return '该题目已经在题单中'; } $vdata['problem'] = $problem; return ''; }, null ); $add_new_problem_form->submit_button_config['class_str'] = 'btn btn-secondary mt-3'; $add_new_problem_form->submit_button_config['text'] = '添加'; $add_new_problem_form->handle = function ($vdata) { DB::insert([ "insert into lists_problems", DB::bracketed_fields(["list_id", "problem_id"]), "values", DB::tuple([UOJList::info('id'), $vdata['problem']->info['id']]), ]); dieWithJsonData(['status' => 'success', 'message' => '已将题目 #' . $vdata['problem']->info['id'] . ' 添加到题单 #' . UOJList::info('id') . ' 中']); }; $add_new_problem_form->setAjaxSubmit(<<runAtServer(); } ?>

(ID: #) 管理

printHTML() ?>
注意事项
  • 隐藏的题单无法被普通用户查看。
  • 题单描述支持 Markdown 语法。
UOJList::info('id'), "lists_problems.problem_id" => DB::raw("problems.id") ] ], "1", "order by id asc", << ID 标题 操作 EOD, function ($row) { echo HTML::tag_begin('tr'); echo HTML::tag('td', ['class' => 'text-center'], $row['id']); echo HTML::tag_begin('td'); echo getProblemLink($row); if ($row['is_hidden']) { echo ' ', UOJLocale::get('hidden'), ' '; } echo HTML::tag_end('td'); echo HTML::tag_begin('td'); echo '
'; echo ''; echo ''; echo ''; echo '
'; echo HTML::tag_end('td'); echo HTML::tag_end('tr'); }, [ 'page_len' => 20, 'div_classes' => ['table-responsive'], 'table_classes' => ['table', 'align-middle'], 'print_after_table' => function () use ($n_problems) { echo '
共 ', $n_problems, ' 道题目
'; }, ] ); ?>
printHTML() ?>
注意事项
  • 隐藏的题目添加进题单后无法被普通用户查看。
  • 如当前题单已经被设置为某个小组的作业,则作业也会一并更新。