refactor(problem): remove UOJProblem::type()

This commit is contained in:
Baoshuo Ren 2023-01-19 16:06:42 +08:00
parent 4d54fdf705
commit 4647a8c8ba
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
5 changed files with 9 additions and 13 deletions

View File

@ -241,10 +241,10 @@ if (UOJContest::cur()) {
</h1> </h1>
<?php <?php
if (UOJProblem::cur()->type() == 'local') { if (UOJProblem::info('type') == 'local') {
$time_limit = $conf instanceof UOJProblemConf ? $conf->getVal('time_limit', 1) : null; $time_limit = $conf instanceof UOJProblemConf ? $conf->getVal('time_limit', 1) : null;
$memory_limit = $conf instanceof UOJProblemConf ? $conf->getVal('memory_limit', 256) : null; $memory_limit = $conf instanceof UOJProblemConf ? $conf->getVal('memory_limit', 256) : null;
} else if (UOJProblem::cur()->type() == 'remote') { } else if (UOJProblem::info('type') == 'remote') {
$time_limit = UOJProblem::cur()->getExtraConfig('time_limit'); $time_limit = UOJProblem::cur()->getExtraConfig('time_limit');
$memory_limit = UOJProblem::cur()->getExtraConfig('memory_limit'); $memory_limit = UOJProblem::cur()->getExtraConfig('memory_limit');
} }

View File

@ -10,7 +10,7 @@ requirePHPLib('data');
UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404(); UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404();
UOJProblem::cur()->userCanManage(Auth::user()) || UOJResponse::page403(); UOJProblem::cur()->userCanManage(Auth::user()) || UOJResponse::page403();
UOJProblem::cur()->type() === 'local' || UOJResponse::page404(); UOJProblem::info('type') === 'local' || UOJResponse::page404();
$problem = UOJProblem::info(); $problem = UOJProblem::info();
$problem_extra_config = UOJProblem::cur()->getExtraConfig(); $problem_extra_config = UOJProblem::cur()->getExtraConfig();

View File

@ -82,7 +82,7 @@ if (isSuperUser(Auth::user())) {
管理者 管理者
</a> </a>
</li> </li>
<?php if (UOJProblem::cur()->type() == 'local') : ?> <?php if (UOJProblem::info('type') === 'local') : ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/manage/data" role="tab"> <a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/manage/data" role="tab">
数据 数据

View File

@ -84,7 +84,7 @@ $difficulty_form->handle = function () {
}; };
$difficulty_form->runAtServer(); $difficulty_form->runAtServer();
if (UOJProblem::cur()->type() == 'remote') { if (UOJProblem::info('type') == 'remote') {
$remote_online_judge = UOJProblem::cur()->getExtraConfig('remote_online_judge'); $remote_online_judge = UOJProblem::cur()->getExtraConfig('remote_online_judge');
$remote_problem_id = UOJProblem::cur()->getExtraConfig('remote_problem_id'); $remote_problem_id = UOJProblem::cur()->getExtraConfig('remote_problem_id');
$remote_provider = UOJRemoteProblem::$providers[$remote_online_judge]; $remote_provider = UOJRemoteProblem::$providers[$remote_online_judge];
@ -269,7 +269,7 @@ $solution_view_type_form->runAtServer();
管理者 管理者
</a> </a>
</li> </li>
<?php if (UOJProblem::cur()->type() == 'local') : ?> <?php if (UOJProblem::info('type') == 'local') : ?>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/manage/data" role="tab"> <a class="nav-link" href="/problem/<?= UOJProblem::info('id') ?>/manage/data" role="tab">
数据 数据
@ -431,7 +431,7 @@ $solution_view_type_form->runAtServer();
</div> </div>
</div> </div>
<?php if (UOJProblem::cur()->type() == 'remote') : ?> <?php if (UOJProblem::info('type') == 'remote') : ?>
<div class="card mt-3"> <div class="card mt-3">
<div class="card-header fw-bold"> <div class="card-header fw-bold">
重新爬取题目信息 重新爬取题目信息

View File

@ -344,10 +344,6 @@ class UOJProblem {
$this->info = $info; $this->info = $info;
} }
public function type() {
return $this->info['type'];
}
public function getTitle(array $cfg = []) { public function getTitle(array $cfg = []) {
$cfg += [ $cfg += [
'with' => 'id', 'with' => 'id',
@ -387,7 +383,7 @@ class UOJProblem {
} }
public function getProviderLink() { public function getProviderLink() {
if ($this->type() == 'local') { if ($this->info['type'] == 'local') {
return HTML::tag('a', ['href' => HTML::url('/')], UOJConfig::$data['profile']['oj-name-short']); return HTML::tag('a', ['href' => HTML::url('/')], UOJConfig::$data['profile']['oj-name-short']);
} }
@ -464,7 +460,7 @@ class UOJProblem {
return $key === null ? $extra_config : $extra_config[$key]; return $key === null ? $extra_config : $extra_config[$key];
} }
public function getCustomTestRequirement() { public function getCustomTestRequirement() {
if ($this->type() == 'remote') { if ($this->info['type'] == 'remote') {
return []; return [];
} }