S2OJ/web/app/views/sidebar.php

122 lines
4.4 KiB
PHP
Raw Normal View History

2022-11-11 00:20:33 +00:00
<?php
$purifier = HTML::purifier_inline();
2023-01-15 03:13:43 +00:00
$parsedown = HTML::parsedown(['username_with_color' => true]);
2022-11-11 00:20:33 +00:00
?>
2022-11-06 02:26:21 +00:00
<?php if (Auth::check()) : ?>
<?php if (!Auth::property('email')) : ?>
<div class="alert alert-warning d-flex align-items-center mb-2" role="alert">
<div class="flex-shrink-0 me-3">
<i class="fs-4 bi bi-exclamation-triangle-fill"></i>
</div>
<div>
<div class="fw-bold mb-2">请完善个人资料</div>
<div class="small">您还没有填写您的电子邮件地址,请前往 <a href="/user/<?= Auth::id() ?>/edit">个人资料编辑</a> 页面补全信息,以便接收最新的安全和功能通知。</div>
</div>
</div>
<?php endif ?>
2022-11-06 02:26:21 +00:00
<?php if (!isset($groups_hidden)) : ?>
2022-11-11 00:20:33 +00:00
<?php $groups = UOJGroup::queryGroupsOfUser(Auth::user()); ?>
2022-11-06 02:26:21 +00:00
<?php if (!empty($groups)) : ?>
<div class="card card-default mb-2" id="group-user-announcements">
2023-02-12 11:23:23 +00:00
<div class="card-header fw-bold">
<?= UOJLocale::get('groups') ?>
</div>
2022-11-06 02:26:21 +00:00
<ul class="list-group list-group-flush">
<?php foreach ($groups as $group) : ?>
<li class="list-group-item">
2022-11-11 00:20:33 +00:00
<?= $group->getLink(['class' => 'fw-bold']) ?>
<?php if ($group->info['announcement']) : ?>
2022-11-06 02:26:21 +00:00
<div class="text-break">
2022-11-11 00:20:33 +00:00
<?= $purifier->purify($parsedown->line($group->info['announcement'])) ?>
2022-11-06 02:26:21 +00:00
</div>
<?php else : ?>
<div class="text-muted">
<?= UOJLocale::get('none') ?>
</div>
<?php endif ?>
</li>
<?php endforeach ?>
</ul>
</div>
2022-11-06 02:26:21 +00:00
<?php if (!isset($assignments_hidden)) : ?>
<?php
$assignments = [];
foreach ($groups as $group) {
2022-11-11 00:20:33 +00:00
$assignments = array_merge($assignments, array_map(fn ($x) => UOJGroupAssignment::query($x, $group), $group->getActiveAssignmentIds()));
2022-11-06 02:26:21 +00:00
}
2023-02-12 11:23:23 +00:00
usort($assignments, fn ($a, $b) => $a->info['end_time']->getTimestamp() - $b->info['end_time']->getTimestamp());
2022-11-06 02:26:21 +00:00
?>
2022-11-11 00:20:33 +00:00
<?php if (!empty($assignments)) : ?>
2022-11-06 02:26:21 +00:00
<div class="card card-default mb-2" id="group-assignments">
2023-02-12 11:23:23 +00:00
<div class="card-header fw-bold">
2022-11-06 02:26:21 +00:00
<?= UOJLocale::get('assignments') ?>
</div>
<ul class="list-group list-group-flush">
<?php foreach ($assignments as $assignment) : ?>
<li class="list-group-item">
2022-11-11 00:20:33 +00:00
<?= $assignment->getLink(['class' => 'fw-bold', 'with' => 'sup']) ?>
2022-11-06 02:26:21 +00:00
<div class="text-end small text-muted">
2022-11-11 00:20:33 +00:00
截止时间: <?= $assignment->info['end_time']->format('Y-m-d H:i') ?>
2022-11-06 02:26:21 +00:00
</div>
</li>
<?php endforeach ?>
</ul>
</div>
2022-09-25 06:16:36 +00:00
<?php endif ?>
<?php endif ?>
<?php endif ?>
2022-11-06 02:26:21 +00:00
<?php endif ?>
<?php endif ?>
<?php if (Auth::check()) : ?>
<?php if (!isset($upcoming_contests_hidden)) : ?>
<?php $upcoming_contests = UOJContest::queryUpcomingContests(Auth::user(), 5); ?>
2022-11-06 02:26:21 +00:00
<div class="card card-default mb-2" id="group-user-announcements">
2023-02-12 11:23:23 +00:00
<div class="card-header fw-bold">
<?= UOJLocale::get('contests::upcoming contests') ?>
2022-11-06 02:26:21 +00:00
</div>
<ul class="list-group list-group-flush">
<?php foreach ($upcoming_contests as $contest) : ?>
2022-11-11 00:20:33 +00:00
<?php if ($contest->info['cur_progress'] == CONTEST_NOT_STARTED || $contest->info['cur_progress'] == CONTEST_IN_PROGRESS) : ?>
2022-11-06 02:26:21 +00:00
<li class="list-group-item text-center">
2022-11-11 00:20:33 +00:00
<?= $contest->getLink(['class' => 'fw-bold']) ?>
2022-11-06 02:26:21 +00:00
<div class="small">
2022-11-11 00:20:33 +00:00
<?php if ($contest->info['cur_progress'] == CONTEST_IN_PROGRESS) : ?>
2022-11-06 02:26:21 +00:00
<?= UOJLocale::get('contests::in progress') ?>
<?php else : ?>
2022-11-11 00:20:33 +00:00
<?php $rest_seconds = $contest->info['start_time']->getTimestamp() - UOJTime::$time_now->getTimestamp(); ?>
2022-11-06 02:26:21 +00:00
<?php if ($rest_seconds > 86400) : ?>
<?= UOJLocale::get('contests::will start in x days', ceil($rest_seconds / 86400)) ?>
<?php else : ?>
2023-02-26 10:03:00 +00:00
<div class="countdown" data-rest="<?= $rest_seconds ?>"></div>
2022-11-06 02:26:21 +00:00
<?php endif ?>
<?php endif ?>
</div>
</li>
<?php endif ?>
<?php endforeach ?>
2022-11-11 00:20:33 +00:00
<?php if (empty($upcoming_contests)) : ?>
2022-11-06 02:26:21 +00:00
<li class="list-group-item text-center">
<?= UOJLocale::get('none') ?>
</li>
<?php endif ?>
</ul>
<div class="card-footer bg-transparent text-center small">
<a class="text-decoration-none" href="<?= HTML::url('/contests?all=true') ?>">
<?= UOJLocale::get('view all') ?>
</a>
</div>
</div>
<?php endif ?>
<?php else : ?>
<div class="card">
<div class="card-body">
<a href="<?= HTML::url('/login') ?>">登录</a> 查看更多内容。
</div>
2022-09-25 06:16:36 +00:00
</div>
2022-11-06 02:26:21 +00:00
<?php endif ?>