userCanManage(Auth::user()) || UOJResponse::page403(); $problem_content = UOJProblem::cur()->queryContent(); $problem_editor = new UOJBlogEditor(); $problem_editor->name = 'problem'; $problem_editor->blog_url = '/problem/' . UOJProblem::info('id'); $problem_editor->cur_data = [ 'title' => UOJProblem::info('title'), 'content_md' => $problem_content['statement_md'], 'content' => $problem_content['statement'], 'tags' => UOJProblem::cur()->queryTags(), 'is_hidden' => UOJProblem::info('is_hidden') ]; $problem_editor->label_text = array_merge($problem_editor->label_text, [ 'view blog' => '查看题目', 'blog visibility' => '题目可见性' ]); $problem_editor->save = function ($data) { DB::update([ "update problems", "set", ["title" => $data['title']], "where", ["id" => UOJProblem::info('id')] ]); DB::update([ "update problems_contents", "set", [ "statement" => $data['content'], "statement_md" => $data['content_md'] ], "where", ["id" => UOJProblem::info('id')] ]); UOJProblem::cur()->updateTags($data['tags']); if ($data['is_hidden'] != UOJProblem::info('is_hidden')) { DB::update([ "update problems", "set", ["is_hidden" => $data['is_hidden']], "where", ["id" => UOJProblem::info('id')] ]); DB::update([ "update submissions", "set", ["is_hidden" => $data['is_hidden']], "where", ["problem_id" => UOJProblem::info('id')] ]); DB::update([ "update hacks", "set", ["is_hidden" => $data['is_hidden']], "where", ["problem_id" => UOJProblem::info('id')] ]); } }; $problem_editor->runAtServer(); $difficulty_form = new UOJForm('difficulty'); $difficulty_form->addSelect('difficulty', [ 'div_class' => 'flex-grow-1', 'options' => [-1 => '暂无评定'] + array_combine(UOJProblem::$difficulty, UOJProblem::$difficulty), 'default_value' => UOJProblem::info('difficulty'), ]); $difficulty_form->config['form']['class'] = 'd-flex'; $difficulty_form->config['submit_container']['class'] = 'ms-2'; $difficulty_form->handle = function () { DB::update([ "update problems", "set", [ "difficulty" => $_POST['difficulty'], ], "where", [ "id" => UOJProblem::info('id'), ], ]); }; $difficulty_form->runAtServer(); $view_type_form = new UOJForm('view_type'); $view_type_form->addSelect('view_content_type', [ 'div_class' => 'row align-items-center g-0', 'label_class' => 'form-label col-auto m-0 flex-grow-1', 'select_class' => 'col-auto form-select w-auto', 'label' => '查看提交文件', 'options' => [ 'NONE' => '禁止', 'ALL_AFTER_AC' => 'AC 后', 'ALL' => '所有人', ], 'default_value' => UOJProblem::cur()->getExtraConfig('view_content_type'), ]); $view_type_form->addSelect('view_all_details_type', [ 'div_class' => 'row align-items-center g-0 mt-3', 'label_class' => 'form-label col-auto m-0 flex-grow-1', 'select_class' => 'col-auto form-select w-auto', 'label' => '查看全部详细信息', 'options' => [ 'NONE' => '禁止', 'SELF' => '仅自己', 'ALL_AFTER_AC' => 'AC 后', 'ALL' => '所有人' ], 'default_value' => UOJProblem::cur()->getExtraConfig('view_all_details_type'), ]); $view_type_form->addSelect('view_details_type', [ 'div_class' => 'row align-items-center g-0 mt-3', 'label_class' => 'form-label col-auto m-0 flex-grow-1', 'select_class' => 'col-auto form-select w-auto', 'label' => '查看测试点详细信息', 'options' => [ 'NONE' => '禁止', 'SELF' => '仅自己', 'ALL_AFTER_AC' => 'AC 后', 'ALL' => '所有人', ], 'default_value' => UOJProblem::cur()->getExtraConfig('view_details_type'), ]); $view_type_form->handle = function () { $config = UOJProblem::cur()->getExtraConfig(); $config['view_content_type'] = $_POST['view_content_type']; $config['view_all_details_type'] = $_POST['view_all_details_type']; $config['view_details_type'] = $_POST['view_details_type']; $esc_config = json_encode($config); DB::update([ "update problems", "set", ["extra_config" => $esc_config], "where", ["id" => UOJProblem::info('id')] ]); }; $view_type_form->runAtServer(); $solution_view_type_form = new UOJForm('solution_view_type'); $solution_view_type_form->addSelect('view_solution_type', [ 'div_class' => 'row align-items-center g-0', 'label_class' => 'form-label col-auto m-0 flex-grow-1', 'select_class' => 'col-auto form-select w-auto', 'label' => '查看题解', 'options' => [ 'NONE' => '禁止', 'ALL_AFTER_AC' => 'AC 后', 'ALL' => '所有人', ], 'default_value' => UOJProblem::cur()->getExtraConfig('view_solution_type'), ]); $solution_view_type_form->addSelect('submit_solution_type', [ 'div_class' => 'row align-items-center g-0 mt-3', 'label_class' => 'form-label col-auto m-0 flex-grow-1', 'select_class' => 'col-auto form-select w-auto', 'label' => '提交题解', 'options' => [ 'NONE' => '禁止', 'ALL_AFTER_AC' => 'AC 后', 'ALL' => '所有人', ], 'default_value' => UOJProblem::cur()->getExtraConfig('submit_solution_type'), ]); $solution_view_type_form->handle = function () { $config = UOJProblem::cur()->getExtraConfig(); $config['view_solution_type'] = $_POST['view_solution_type']; $config['submit_solution_type'] = $_POST['submit_solution_type']; $esc_config = json_encode($config); DB::update([ "update problems", "set", ["extra_config" => $esc_config], "where", ["id" => UOJProblem::info('id')] ]); }; $solution_view_type_form->runAtServer(); ?>