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', [ 'options' => UOJProblem::$difficulty, 'default_value' => UOJProblem::info('difficulty'), ]); $difficulty_form->handle = function () { DB::update([ "update problems", "set", [ "difficulty" => $_POST['difficulty'], ], "where", [ "id" => UOJProblem::info('id'), ], ]); }; $difficulty_form->runAtServer(); ?>