name = 'list'; $list_editor->blog_url = null; $list_editor->cur_data = array( 'title' => $list['title'], 'tags' => $list_tags, 'is_hidden' => $list['is_hidden'] ); $list_editor->label_text = array_merge($list_editor->label_text, array( 'view blog' => '保存题单信息', 'blog visibility' => '题单可见性' )); $list_editor->show_editor = false; $list_editor->save = function($data) { global $list_id, $list; DB::update("update lists set title = '" . DB::escape($data['title']) . "' where id = {$list_id}"); if ($data['tags'] !== $list_tags) { DB::delete("delete from lists_tags where list_id = {$list_id}"); foreach ($data['tags'] as $tag) { DB::insert("insert into lists_tags (list_id, tag) values ({$list_id}, '" . DB::escape($tag) . "')"); } } if ($data['is_hidden'] != $list['is_hidden'] ) { DB::update("update lists set is_hidden = {$data['is_hidden']} where id = {$list_id}"); } }; $list_editor->runAtServer(); } function removeFromProblemListForm($problem_id) { $res_form = new UOJForm("remove_problem_{$problem_id}"); $input_name = "problem_id_delete_{$problem_id}"; $res_form->addHidden($input_name, $problem_id, function($problem_id) { global $myUser; if (!isSuperUser($myUser)) { return '只有超级用户可以编辑题单'; } }, null); $res_form->handle = function() use ($input_name) { global $list_id; $problem_id = $_POST[$input_name]; DB::query("delete from lists_problems where problem_id={$problem_id} and list_id={$list_id}"); }; $res_form->submit_button_config['class_str'] = 'btn btn-danger'; $res_form->submit_button_config['text'] = '删除'; $res_form->submit_button_config['align'] = 'inline'; return $res_form; } $removeProblemForms = array(); if (isSuperUser($myUser)) { $problem_ids = DB::query("select problem_id from lists_problems where list_id = {$list_id}"); while ($row = DB::fetch($problem_ids)) { $problem_id = $row['problem_id']; $removeForm = removeFromProblemListForm($problem_id); $removeForm->runAtServer(); $removeProblemForms[$problem_id] = $removeForm; } } if (isSuperUser($myUser)) { $add_new_problem_form = new UOJForm('add_new_problem'); $add_new_problem_form->addInput('problem_id', 'text', '题目 ID', '', function ($x) { global $myUser, $list_id; if (!isSuperUser($myUser)) { return '只有超级用户可以编辑题单'; } if (!validateUInt($x)) { return 'ID 不合法'; } $problem = queryProblemBrief($x); if (!$problem) { return '题目不存在'; } if (queryProblemInList($list_id, $x)) { return '该题目已经在题单中'; } return ''; }, null ); $add_new_problem_form->submit_button_config['align'] = 'compressed'; $add_new_problem_form->submit_button_config['text'] = '添加到题单'; $add_new_problem_form->handle = function() { global $list_id, $myUser; $problem_id = $_POST['problem_id']; DB::insert("insert into lists_problems (list_id, problem_id) values ({$list_id}, {$problem_id})"); }; $add_new_problem_form->runAtServer(); } function echoProblem($problem) { global $myUser, $removeProblemForms; if (isProblemVisibleToUser($problem, $myUser)) { echo ''; if ($problem['submission_id']) { echo ''; } else { echo ''; } echo '#', $problem['id'], ''; echo ''; if (isSuperUser($myUser)) { $form = $removeProblemForms[$problem['id']]; $form->printHTML(); } if ($problem['is_hidden']) { echo ' [隐藏] '; } if ($problem['uploader'] == $myUser['username']) { echo ' [我的题目] '; } echo '', $problem['title'], ''; if (isset($_COOKIE['show_tags_mode'])) { echo ' ' . $problem["uploader"] . ' '; foreach (queryProblemTags($problem['id']) as $tag) { echo '', '', HTML::escape($tag), '', ''; } } echo ''; if (isset($_COOKIE['show_submit_mode'])) { $perc = $problem['submit_num'] > 0 ? round(100 * $problem['ac_num'] / $problem['submit_num']) : 0; echo <<×{$problem['ac_num']} ×{$problem['submit_num']}
{$perc}%
EOD; } if (isset($_COOKIE['show_difficulty'])) { $extra_config = getProblemExtraConfig($problem); if ($extra_config['difficulty'] == 0) { echo ""; } else { echo "{$extra_config['difficulty']}"; } } echo '', getClickZanBlock('P', $problem['id'], $problem['zan']), ''; echo ''; } } $header = ''; $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').''; } if (isset($_COOKIE['show_difficulty'])) { $header .= ''.UOJLocale::get('problems::difficulty').''; } $header .= ''.UOJLocale::get('appraisal').''; $header .= ''; $pag_config = array('page_len' => 40); $pag_config['col_names'] = array('best_ac_submissions.submission_id as submission_id', 'problems.id as id', 'problems.is_hidden as is_hidden', 'problems.title as title', 'problems.submit_num as submit_num', 'problems.ac_num as ac_num', 'problems.zan as zan', 'problems.extra_config as extra_config', 'problems.uploader as uploader'); $pag_config['table_name'] = "problems left join best_ac_submissions on best_ac_submissions.submitter = '{$myUser['username']}' and problems.id = best_ac_submissions.problem_id inner join lists_problems lp on lp.list_id = {$list_id} and lp.problem_id = problems.id"; $pag_config['cond'] = '1'; $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'); ?> 编辑题单信息'; echo '
'; $list_editor->printHTML(); echo '
'; echo '
添加题目到题单
'; $add_new_problem_form->printHTML(); } ?>
"" 中的题目:

(题单 ID: #)

pagination(); ?>
'; echo ''; echo ''; echo $header; echo ''; echo ''; foreach ($pag->get() as $idx => $row) { echoProblem($row); echo "\n"; } if ($pag->isEmpty()) { echo ''; } echo ''; echo '
'.UOJLocale::get('none').'
'; echo ''; echo $pag->pagination(); ?>