mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 15:28:41 +00:00
chore(web): use UOJTime::$time_now
This commit is contained in:
parent
277e69f507
commit
71901efa5f
@ -95,41 +95,44 @@
|
|||||||
<h2 class="card-title h4">
|
<h2 class="card-title h4">
|
||||||
<?= UOJLocale::get('assignments') ?>
|
<?= UOJLocale::get('assignments') ?>
|
||||||
</h5>
|
</h5>
|
||||||
<?php
|
<?php
|
||||||
$now = new DateTime();
|
echoLongTable(
|
||||||
echoLongTable(
|
[
|
||||||
['groups_assignments.list_id as list_id', 'lists.title as title', 'groups_assignments.end_time as end_time'],
|
'groups_assignments.list_id as list_id',
|
||||||
'groups_assignments left join lists on lists.id = groups_assignments.list_id',
|
'lists.title as title',
|
||||||
"groups_assignments.group_id = {$group['id']} and groups_assignments.end_time > addtime(now(), '-168:00:00')",
|
'groups_assignments.end_time as end_time'
|
||||||
'order by end_time desc, list_id desc',
|
],
|
||||||
<<<EOD
|
'groups_assignments left join lists on lists.id = groups_assignments.list_id',
|
||||||
<tr>
|
"groups_assignments.group_id = {$group['id']} and groups_assignments.end_time > addtime(now(), '-168:00:00')",
|
||||||
<th style="width:3em" class="text-center">ID</th>
|
'order by end_time desc, list_id desc',
|
||||||
<th style="width:12em">标题</th>
|
<<<EOD
|
||||||
<th style="width:4em">状态</th>
|
<tr>
|
||||||
<th style="width:8em">结束时间</th>
|
<th style="width:3em" class="text-center">ID</th>
|
||||||
</tr>
|
<th style="width:12em">标题</th>
|
||||||
|
<th style="width:4em">状态</th>
|
||||||
|
<th style="width:8em">结束时间</th>
|
||||||
|
</tr>
|
||||||
EOD,
|
EOD,
|
||||||
function($row) use ($group, $now) {
|
function($row) use ($group) {
|
||||||
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
||||||
|
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo '<td class="text-center">', $row['list_id'], '</td>';
|
echo '<td class="text-center">', $row['list_id'], '</td>';
|
||||||
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '/assignment/', $row['list_id'],'">', HTML::escape($row['title']), '</a>', '</td>';
|
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '/assignment/', $row['list_id'],'">', HTML::escape($row['title']), '</a>', '</td>';
|
||||||
if ($end_time < $now) {
|
if ($end_time < UOJTime::$time_now) {
|
||||||
echo '<td class="text-danger">已结束</td>';
|
echo '<td class="text-danger">已结束</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '<td class="text-success">进行中</td>';
|
echo '<td class="text-success">进行中</td>';
|
||||||
}
|
}
|
||||||
echo '<td>', $end_time->format('Y-m-d H:i:s'), '</td>';
|
echo '<td>', $end_time->format('Y-m-d H:i:s'), '</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
'echo_full' => true,
|
'echo_full' => true,
|
||||||
'div_classes' => ['table-responsive'],
|
'div_classes' => ['table-responsive'],
|
||||||
'table_classes' => ['table', 'align-middle', 'mb-0'],
|
'table_classes' => ['table', 'align-middle', 'mb-0'],
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -54,7 +54,8 @@
|
|||||||
return '名称过长';
|
return '名称过长';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HTML::escape($title) === '') {
|
$title = HTML::escape($title);
|
||||||
|
if ($title === '') {
|
||||||
return '无效编码';
|
return '无效编码';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +200,6 @@ function(res) {
|
|||||||
EOD);
|
EOD);
|
||||||
$add_new_assignment_form->runAtServer();
|
$add_new_assignment_form->runAtServer();
|
||||||
|
|
||||||
$now = new DateTime();
|
|
||||||
$hidden_time = new DateTime();
|
$hidden_time = new DateTime();
|
||||||
$hidden_time->sub(new DateInterval('P7D'));
|
$hidden_time->sub(new DateInterval('P7D'));
|
||||||
} elseif ($cur_tab == 'users') {
|
} elseif ($cur_tab == 'users') {
|
||||||
@ -349,7 +349,7 @@ EOD);
|
|||||||
<th style="width:8em">操作</th>
|
<th style="width:8em">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
EOD,
|
EOD,
|
||||||
function($row) use ($group, $now, $hidden_time) {
|
function($row) use ($group, $hidden_time) {
|
||||||
$list = queryProblemList($row['list_id']);
|
$list = queryProblemList($row['list_id']);
|
||||||
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ EOD,
|
|||||||
echo '</td>';
|
echo '</td>';
|
||||||
if ($end_time < $hidden_time) {
|
if ($end_time < $hidden_time) {
|
||||||
echo '<td class="text-secondary">已隐藏</td>';
|
echo '<td class="text-secondary">已隐藏</td>';
|
||||||
} elseif ($end_time < $now) {
|
} elseif ($end_time < UOJTime::$time_now) {
|
||||||
echo '<td class="text-danger">已结束</td>';
|
echo '<td class="text-danger">已结束</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '<td class="text-success">进行中</td>';
|
echo '<td class="text-success">进行中</td>';
|
||||||
|
@ -55,7 +55,8 @@
|
|||||||
return '标题过长';
|
return '标题过长';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HTML::escape($title) === '') {
|
$title = HTML::escape($title);
|
||||||
|
if ($title === '') {
|
||||||
return '无效编码';
|
return '无效编码';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,18 +81,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tags_raw as $tag) {
|
foreach ($tags_raw as $tag) {
|
||||||
$tag = trim($tag);
|
$tag = HTML::escape(trim($tag));
|
||||||
|
|
||||||
if (strlen($tag) == 0) {
|
if (strlen($tag) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen($tag) > 30) {
|
if (strlen($tag) > 30) {
|
||||||
return '标签 “' . HTML::escape($tag) .'” 太长';
|
return '标签 “' . $tag .'” 太长';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (in_array($tag, $tags, true)) {
|
if (in_array($tag, $tags, true)) {
|
||||||
return '标签 “' . HTML::escape($tag) .'” 重复出现';
|
return '标签 “' . $tag .'” 重复出现';
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags[] = $tag;
|
$tags[] = $tag;
|
||||||
@ -322,7 +323,6 @@ function(res) {
|
|||||||
EOD);
|
EOD);
|
||||||
$add_new_assignment_form->runAtServer();
|
$add_new_assignment_form->runAtServer();
|
||||||
|
|
||||||
$now = new DateTime();
|
|
||||||
$hidden_time = new DateTime();
|
$hidden_time = new DateTime();
|
||||||
$hidden_time->sub(new DateInterval('P7D'));
|
$hidden_time->sub(new DateInterval('P7D'));
|
||||||
}
|
}
|
||||||
@ -480,7 +480,7 @@ EOD,
|
|||||||
<th style="width:8em">操作</th>
|
<th style="width:8em">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
EOD,
|
EOD,
|
||||||
function($row) use ($list, $now, $hidden_time) {
|
function($row) use ($list, $hidden_time) {
|
||||||
$group = queryGroup($row['group_id']);
|
$group = queryGroup($row['group_id']);
|
||||||
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $row['end_time']);
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ EOD,
|
|||||||
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '">', HTML::escape($group['title']), '</a>', '</td>';
|
echo '<td>', '<a class="text-decoration-none" href="/group/', $group['id'], '">', HTML::escape($group['title']), '</a>', '</td>';
|
||||||
if ($end_time < $hidden_time) {
|
if ($end_time < $hidden_time) {
|
||||||
echo '<td class="text-secondary">已隐藏</td>';
|
echo '<td class="text-secondary">已隐藏</td>';
|
||||||
} elseif ($end_time < $now) {
|
} elseif ($end_time < UOJTime::$time_now) {
|
||||||
echo '<td class="text-danger">已结束</td>';
|
echo '<td class="text-danger">已结束</td>';
|
||||||
} else {
|
} else {
|
||||||
echo '<td class="text-success">进行中</td>';
|
echo '<td class="text-success">进行中</td>';
|
||||||
|
@ -56,15 +56,12 @@
|
|||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
<?php foreach ($assignments as $assignment): ?>
|
<?php foreach ($assignments as $assignment): ?>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<?php
|
<?php $end_time = DateTime::createFromFormat('Y-m-d H:i:s', $assignment['end_time']); ?>
|
||||||
$end_time = DateTime::createFromFormat('Y-m-d H:i:s', $assignment['end_time']);
|
|
||||||
$now = new DateTime();
|
|
||||||
?>
|
|
||||||
<a href="<?= HTML::url('/group/'.$assignment['group_id'].'/assignment/'.$assignment['list_id']) ?>" class="fw-bold text-decoration-none">
|
<a href="<?= HTML::url('/group/'.$assignment['group_id'].'/assignment/'.$assignment['list_id']) ?>" class="fw-bold text-decoration-none">
|
||||||
<?= $assignment['title'] ?>
|
<?= $assignment['title'] ?>
|
||||||
<?php if ($end_time < $now): ?>
|
<?php if ($end_time < UOJTime::$time_now): ?>
|
||||||
<sup class="fw-normal text-danger">overdue</sup>
|
<sup class="fw-normal text-danger">overdue</sup>
|
||||||
<?php elseif ($end_time->getTimestamp() - $now->getTimestamp() < 86400): ?>
|
<?php elseif ($end_time->getTimestamp() - UOJTime::$time_now->getTimestamp() < 86400): ?>
|
||||||
<sup class="fw-normal text-danger">soon</sup>
|
<sup class="fw-normal text-danger">soon</sup>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user