2016-07-18 16:39:37 +00:00
< ? php
requirePHPLib ( 'form' );
2022-03-17 04:00:03 +00:00
2022-10-07 09:29:26 +00:00
if ( ! Auth :: check () && UOJConfig :: $data [ 'switch' ][ 'force-login' ]) {
2022-10-06 12:28:43 +00:00
redirectToLogin ();
2022-03-17 04:00:03 +00:00
}
2016-07-18 16:39:37 +00:00
if ( ! validateUInt ( $_GET [ 'id' ]) || ! ( $problem = queryProblemBrief ( $_GET [ 'id' ]))) {
become404Page ();
}
if ( ! hasProblemPermission ( $myUser , $problem )) {
become403Page ();
}
2022-10-02 06:25:22 +00:00
if ( ! isset ( $_COOKIE [ 'bootstrap4' ])) {
$REQUIRE_LIB [ 'bootstrap5' ] = '' ;
}
2016-07-18 16:39:37 +00:00
$problem_content = queryProblemContent ( $problem [ 'id' ]);
$problem_tags = queryProblemTags ( $problem [ 'id' ]);
$problem_editor = new UOJBlogEditor ();
$problem_editor -> name = 'problem' ;
$problem_editor -> blog_url = " /problem/ { $problem [ 'id' ] } " ;
$problem_editor -> cur_data = array (
'title' => $problem [ 'title' ],
'content_md' => $problem_content [ 'statement_md' ],
'content' => $problem_content [ 'statement' ],
'tags' => $problem_tags ,
'is_hidden' => $problem [ 'is_hidden' ]
);
$problem_editor -> label_text = array_merge ( $problem_editor -> label_text , array (
'view blog' => '查看题目' ,
'blog visibility' => '题目可见性'
));
$problem_editor -> save = function ( $data ) {
global $problem , $problem_tags ;
DB :: update ( " update problems set title = ' " . DB :: escape ( $data [ 'title' ]) . " ' where id = { $problem [ 'id' ] } " );
DB :: update ( " update problems_contents set statement = ' " . DB :: escape ( $data [ 'content' ]) . " ', statement_md = ' " . DB :: escape ( $data [ 'content_md' ]) . " ' where id = { $problem [ 'id' ] } " );
if ( $data [ 'tags' ] !== $problem_tags ) {
DB :: delete ( " delete from problems_tags where problem_id = { $problem [ 'id' ] } " );
foreach ( $data [ 'tags' ] as $tag ) {
DB :: insert ( " insert into problems_tags (problem_id, tag) values ( { $problem [ 'id' ] } , ' " . DB :: escape ( $tag ) . " ') " );
}
}
if ( $data [ 'is_hidden' ] != $problem [ 'is_hidden' ] ) {
DB :: update ( " update problems set is_hidden = { $data [ 'is_hidden' ] } where id = { $problem [ 'id' ] } " );
DB :: update ( " update submissions set is_hidden = { $data [ 'is_hidden' ] } where problem_id = { $problem [ 'id' ] } " );
DB :: update ( " update hacks set is_hidden = { $data [ 'is_hidden' ] } where problem_id = { $problem [ 'id' ] } " );
}
};
$problem_editor -> runAtServer ();
2022-09-18 04:58:35 +00:00
?>
2016-07-18 16:39:37 +00:00
< ? php echoUOJPageHeader ( HTML :: stripTags ( $problem [ 'title' ]) . ' - 编辑 - 题目管理' ) ?>
2022-10-02 06:25:22 +00:00
< ? php if ( isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
< div class = " row " >
< div class = " col-lg-9 " >
< ? php endif ?>
< ? php if ( isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
2022-10-03 06:40:53 +00:00
< h1 class = " h2 " >
2022-10-02 06:25:22 +00:00
< ? php else : ?>
< h1 class = " page-header text-center " >
< ? php endif ?>
#<?=$problem['id']?>. <?=$problem['title']?> 管理
</ h1 >
2022-10-03 06:40:53 +00:00
< ul class = " nav
< ? php if ( isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
nav - pills my - 3
< ? php else : ?>
nav - tabs
< ? php endif ?> " role="tablist">
< li class = " nav-item " >
< a class = " nav-link active " href = " /problem/<?= $problem['id'] ?>/manage/statement " role = " tab " >
题面
</ a >
</ li >
< li class = " nav-item " >
< a class = " nav-link " href = " /problem/<?= $problem['id'] ?>/manage/managers " role = " tab " >
管理者
</ a >
</ li >
< li class = " nav-item " >
< a class = " nav-link " href = " /problem/<?= $problem['id'] ?>/manage/data " role = " tab " >
数据
</ a >
</ li >
2022-10-02 06:25:22 +00:00
< ? php if ( ! isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
2022-10-03 06:40:53 +00:00
< li class = " nav-item " >
< a class = " nav-link " href = " /problem/<?= $problem['id'] ?> " role = " tab " >
返回
</ a >
</ li >
2022-10-02 06:25:22 +00:00
< ? php endif ?>
2016-07-18 16:39:37 +00:00
</ ul >
2022-09-18 12:47:34 +00:00
2022-10-03 06:40:53 +00:00
< ? php if ( isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
< div class = " card card-default " >
< div class = " card-body " >
< ? php endif ?>
< div class = " mb-2
< ? php if ( ! isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
mt - 3
< ? php endif ?> ">
2022-09-18 12:47:34 +00:00
< p > 提示: </ p >
< ol >
< li > 请勿引用不稳定的外部资源(如来自个人服务器的图片或文档等),以便备份及后期维护; </ li >
< li > 请勿在题面中直接插入大段 HTML 源码,这可能会破坏页面的显示,可以考虑使用 < a href = " http://island205.github.io/h2m/ " > 转换工具 </ a > 转换后再作修正; </ li >
< li > 图片上传推荐使用 < a href = " https://smms.app " target = " _blank " > SM . MS </ a > 图床,以免后续产生外链图片大量失效的情况。 </ li >
</ ol >
</ div >
2022-10-02 06:25:22 +00:00
< hr >
2016-07-18 16:39:37 +00:00
< ? php $problem_editor -> printHTML () ?>
2022-10-02 06:25:22 +00:00
< ? php if ( isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
</ div >
</ div >
< ? php endif ?>
< ? php if ( isset ( $REQUIRE_LIB [ 'bootstrap5' ])) : ?>
</ div >
< aside class = " col mt-3 mt-lg-0 " >
< div class = " card card-default mb-2 " >
< ul class = " nav nav-pills nav-fill flex-column " role = " tablist " >
< li class = " nav-item text-start " >
< a href = " /problem/<?= $problem['id'] ?> " class = " nav-link " role = " tab " >
< i class = " bi bi-journal-text " ></ i >
< ? = UOJLocale :: get ( 'problems::statement' ) ?>
</ a >
</ li >
< li class = " nav-item text-start " >
< a href = " /problem/<?= $problem['id'] ?>/solutions " class = " nav-link " role = " tab " >
< i class = " bi bi-journal-bookmark " ></ i >
< ? = UOJLocale :: get ( 'problems::solutions' ) ?>
</ a >
</ li >
2022-10-07 01:13:35 +00:00
< li class = " nav-item text-start " >
< a class = " nav-link " href = " /problem/<?= $problem['id'] ?>/statistics " >
< i class = " bi bi-graph-up " ></ i >
< ? = UOJLocale :: get ( 'problems::statistics' ) ?>
</ a >
</ li >
2022-10-02 06:25:22 +00:00
< li class = " nav-item text-start " >
2022-10-03 06:40:53 +00:00
< a class = " nav-link active " href = " # " role = " tab " >
2022-10-02 06:25:22 +00:00
< i class = " bi bi-sliders " ></ i >
< ? = UOJLocale :: get ( 'problems::manage' ) ?>
</ a >
</ li >
</ ul >
2022-10-07 01:13:35 +00:00
< div class = " card-footer bg-transparent " >
评价: < ? = getClickZanBlock ( 'P' , $problem [ 'id' ], $problem [ 'zan' ]) ?>
</ div >
2022-10-02 06:25:22 +00:00
</ div >
2022-10-03 06:28:33 +00:00
< ? php uojIncludeView ( 'sidebar' , array ()) ?>
2022-10-02 06:25:22 +00:00
</ aside >
</ div >
< script >
$ ( document ) . ready ( function () {
$ ( '.markdown-body table' ) . each ( function () {
$ ( this ) . addClass ( 'table table-bordered table-striped' );
});
});
</ script >
< ? php endif ?>
2016-07-18 16:39:37 +00:00
< ? php echoUOJPageFooter () ?>