mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 13:28:41 +00:00
feat(web/problem/solutions): add quick_add_new_solution_form
This commit is contained in:
parent
71ecc24d19
commit
5f15f832af
@ -100,6 +100,29 @@ if (UOJProblem::cur()->userCanManage(Auth::user()) || UOJProblem::cur()->userPer
|
|||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
$add_new_solution_form->runAtServer();
|
$add_new_solution_form->runAtServer();
|
||||||
|
|
||||||
|
if (UOJUser::checkPermission(Auth::user(), 'blogs.create')) {
|
||||||
|
$quick_add_new_solution_form = new UOJForm('quick_add_new_solution');
|
||||||
|
$quick_add_new_solution_form->config['submit_container']['class'] = '';
|
||||||
|
$quick_add_new_solution_form->config['submit_button']['class'] = 'btn btn-link text-decoration-none p-0';
|
||||||
|
$quick_add_new_solution_form->config['submit_button']['text'] = '快速新建文章';
|
||||||
|
$quick_add_new_solution_form->handle = function () {
|
||||||
|
DB::insert([
|
||||||
|
"insert into blogs",
|
||||||
|
"(title, content, content_md, poster, is_hidden, post_time, active_time)",
|
||||||
|
"values", DB::tuple([
|
||||||
|
'【题解】' . UOJProblem::cur()->getTitle(), '', '',
|
||||||
|
Auth::id(), false, DB::now(), DB::now()
|
||||||
|
])
|
||||||
|
]);
|
||||||
|
|
||||||
|
$blog_id = DB::insert_id();
|
||||||
|
|
||||||
|
redirectTo(HTML::blog_url(Auth::id(), "/post/{$blog_id}/write"));
|
||||||
|
die();
|
||||||
|
};
|
||||||
|
$quick_add_new_solution_form->runAtServer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$pag_config = [
|
$pag_config = [
|
||||||
@ -261,18 +284,16 @@ $pag = new Paginator($pag_config);
|
|||||||
您当前无法为本题新增题解。
|
您当前无法为本题新增题解。
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer bg-transparent">
|
<?php if (isset($quick_add_new_solution_form)) : ?>
|
||||||
<a target="_blank" class="text-decoration-none" href="<?= HTML::blog_url(Auth::id(), '/post/new/write?title=' . urlencode('【题解】#' . UOJProblem::info('id') . '. ' . UOJProblem::info('title')) . '&is_hidden=0') ?>">
|
<div class="card-footer bg-transparent">
|
||||||
快速新建文章
|
<?php $quick_add_new_solution_form->printHTML() ?>
|
||||||
</a>
|
</div>
|
||||||
<div class="small text-muted mt-1">发布文章后,请返回本页输入博客 ID</div>
|
<?php endif ?>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php uojIncludeView('sidebar'); ?>
|
<?php uojIncludeView('sidebar') ?>
|
||||||
<!-- End right col -->
|
|
||||||
</aside>
|
</aside>
|
||||||
|
<!-- end right col -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php echoUOJPageFooter() ?>
|
<?php echoUOJPageFooter() ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user