refactor(super_manage/judger): uoj_form_v2

This commit is contained in:
Baoshuo Ren 2023-01-16 22:09:47 +08:00
parent 8da485e595
commit ac45c82f44
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -953,38 +953,36 @@ if ($cur_tab == 'index') {
$custom_test_deleter->config['submit_container']['class'] = 'col-auto'; $custom_test_deleter->config['submit_container']['class'] = 'col-auto';
$custom_test_deleter->runAtServer(); $custom_test_deleter->runAtServer();
} elseif ($cur_tab == 'judger') { } elseif ($cur_tab == 'judger') {
$judger_adder = new UOJBs4Form('judger_adder'); $judger_adder = new UOJForm('judger_adder');
$judger_adder->addInput( $judger_adder->addInput('judger_adder_name', [
'judger_adder_name', 'div_class' => 'col-auto',
'text', 'label' => '评测机名称',
'评测机名称', 'validator_php' => function ($x, &$vdata) {
'',
function ($x, &$vdata) {
if (!validateUsername($x)) { if (!validateUsername($x)) {
return '不合法'; return '不合法';
} }
if (DB::selectCount("select count(*) from judger_info where judger_name='$x'") != 0) { if (DB::selectCount("select count(*) from judger_info where judger_name='$x'") != 0) {
return '不合法'; return '不合法';
} }
$vdata['name'] = $x; $vdata['name'] = $x;
return ''; return '';
}, },
null ]);
);
$judger_adder->handle = function (&$vdata) { $judger_adder->handle = function (&$vdata) {
$password = uojRandString(32); $password = uojRandString(32);
DB::insert("insert into judger_info (judger_name,password) values('{$vdata['name']}','{$password}')"); DB::insert("insert into judger_info (judger_name, password) values('{$vdata['name']}', '{$password}')");
}; };
$judger_adder->submit_button_config['align'] = 'compressed'; $judger_adder->config['form']['class'] = 'row gy-2 gx-3 align-items-end';
$judger_adder->config['submit_container']['class'] = 'col-auto';
$judger_adder->runAtServer(); $judger_adder->runAtServer();
$judger_deleter = new UOJBs4Form('judger_deleter'); $judger_deleter = new UOJForm('judger_deleter');
$judger_deleter->addInput( $judger_deleter->addInput('judger_deleter_name', [
'judger_deleter_name', 'div_class' => 'col-auto',
'text', 'label' => '评测机名称', 'validator_php' => function ($x, &$vdata) {
'评测机名称',
'',
function ($x, &$vdata) {
if (!validateUsername($x)) { if (!validateUsername($x)) {
return '不合法'; return '不合法';
} }
@ -994,12 +992,12 @@ if ($cur_tab == 'index') {
$vdata['name'] = $x; $vdata['name'] = $x;
return ''; return '';
}, },
null ]);
);
$judger_deleter->handle = function (&$vdata) { $judger_deleter->handle = function (&$vdata) {
DB::delete("delete from judger_info where judger_name='{$vdata['name']}'"); DB::delete("delete from judger_info where judger_name='{$vdata['name']}'");
}; };
$judger_deleter->submit_button_config['align'] = 'compressed'; $judger_deleter->config['form']['class'] = 'row gy-2 gx-3 align-items-end';
$judger_deleter->config['submit_container']['class'] = 'col-auto';
$judger_deleter->runAtServer(); $judger_deleter->runAtServer();
} elseif ($cur_tab == 'image_hosting') { } elseif ($cur_tab == 'image_hosting') {
if (isset($_POST['submit-delete_image']) && $_POST['submit-delete_image'] == 'delete_image') { if (isset($_POST['submit-delete_image']) && $_POST['submit-delete_image'] == 'delete_image') {