S2OJ/web/app/controllers/index.php

146 lines
4.3 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
$blogs = DB::selectAll([
"select blogs.id, title, poster, post_time from important_blogs inner join blogs on important_blogs.blog_id = blogs.id",
"where", [
"is_hidden" => 0,
], "order by level desc, important_blogs.blog_id desc",
DB::limit(5)
]);
$countdowns = DB::selectAll([
"select title, end_time from countdowns",
"order by end_time asc",
]);
$friend_links = DB::selectAll([
"select title, url from friend_links",
"order by level desc, id asc",
]);
?>
<?php echoUOJPageHeader(UOJConfig::$data['profile']['oj-name-short']) ?>
2022-04-03 11:33:50 +00:00
<div class="row">
2022-09-26 23:57:01 +00:00
<div class="col-lg-9">
2022-04-03 11:33:50 +00:00
<div class="card card-default">
<div class="card-body">
2022-10-22 13:12:13 +00:00
<h4 class="card-title">
<?= UOJLocale::get('announcements') ?>
</h4>
<table class="table table-sm">
2016-07-18 16:39:37 +00:00
<thead>
<tr>
2022-10-22 13:12:13 +00:00
<th style="width:60%"></th>
2016-07-18 16:39:37 +00:00
<th style="width:20%"></th>
<th style="width:20%"></th>
</tr>
</thead>
2022-11-06 02:26:21 +00:00
<tbody>
2022-09-23 13:00:17 +00:00
<?php $now_cnt = 0; ?>
2022-11-06 02:26:21 +00:00
<?php foreach ($blogs as $blog_info) : ?>
2022-09-23 13:00:17 +00:00
<?php
2022-11-06 02:26:21 +00:00
$blog = new UOJBlog($blog_info);
$now_cnt++;
2022-09-23 13:00:17 +00:00
?>
<tr>
2022-11-06 02:26:21 +00:00
<td><?= $blog->getLink(['show_new_tag' => true]) ?></td>
<td>by <?= UOJUser::getLink($blog->info['poster']) ?></td>
2022-11-06 02:26:21 +00:00
<td><small><?= $blog->info['post_time'] ?></small></td>
2022-09-23 13:00:17 +00:00
</tr>
<?php endforeach ?>
2022-11-06 02:26:21 +00:00
<?php for ($i = $now_cnt + 1; $i <= 5; $i++) : ?>
<tr>
<td colspan="233">&nbsp;</td>
</tr>
2022-09-23 13:00:17 +00:00
<?php endfor ?>
2016-07-18 16:39:37 +00:00
</tbody>
</table>
2022-10-22 13:12:13 +00:00
<div class="text-end">
<a class="text-decoration-none" href="/announcements">
<?= UOJLocale::get('all the announcements') ?>
</a>
</div>
2016-07-18 16:39:37 +00:00
</div>
</div>
2022-11-06 02:26:21 +00:00
<?php if (Auth::check()) : ?>
2023-01-17 05:58:07 +00:00
<div class="card mt-4">
<div class="card-header bg-transparent">
<h4 class="mb-0"><?= UOJLocale::get('top solver') ?></h4>
</div>
<?php UOJRanklist::printHTML(['top10' => true, 'flush' => true]) ?>
<div class="card-footer bg-transparent text-center">
<a href="/solverlist">
<?= UOJLocale::get('view all') ?>
</a>
2022-04-03 11:33:50 +00:00
</div>
</div>
2022-11-06 02:26:21 +00:00
<?php else : ?>
2022-09-21 03:27:03 +00:00
<div class="mt-4 card card-default">
<div class="card-body text-center">
<a role="button" class="btn btn-outline-primary" href="<?= HTML::url('/login') ?>">登录</a> 以查看更多内容。
</div>
</div>
2022-04-03 11:33:50 +00:00
<?php endif ?>
2016-07-18 16:39:37 +00:00
</div>
2022-09-29 00:18:49 +00:00
<div class="col mt-4 mt-lg-0">
<div class="d-none d-lg-block mb-4">
2022-04-03 11:33:50 +00:00
<img class="media-object img-thumbnail" src="/images/logo.png" alt="Logo" />
</div>
2022-09-26 10:56:38 +00:00
<div class="card card-default mb-2">
2023-02-16 08:57:42 +00:00
<div class="card-header fw-bold">
<?= UOJLocale::get('countdowns') ?>
2022-09-23 13:00:17 +00:00
</div>
2022-04-03 11:33:50 +00:00
<div class="card-body">
2022-10-22 13:12:13 +00:00
<ul class="list-unstyled mb-0">
2022-11-06 02:26:21 +00:00
<?php foreach ($countdowns as $countdown) : ?>
2022-04-03 11:33:50 +00:00
<?php
$end_time = UOJTime::str2time($countdown['end_time'])->getTimestamp();
$now_time = UOJTime::$time_now->getTimestamp();
$diff = floor(($end_time - $now_time) / (24 * 60 * 60));
2022-04-03 11:33:50 +00:00
?>
2022-09-21 02:58:45 +00:00
<li>
2022-11-06 02:26:21 +00:00
<?php if ($diff > 0) : ?>
<?= UOJLocale::get('x days before countdown {title}', $countdown['title'], $diff) ?>
<?php elseif ($diff == 0) : ?>
<?= UOJLocale::get('{rest} before countdown {title}', $countdown['title'], $end_time - $now_time) ?>
2022-11-06 02:26:21 +00:00
<?php else : ?>
<?= UOJLocale::get("countdown {title} has begun", $countdown['title']) ?>
2022-04-03 11:33:50 +00:00
<?php endif ?>
2022-09-21 02:58:45 +00:00
</li>
2022-04-03 11:33:50 +00:00
<?php endforeach ?>
2022-09-21 03:33:42 +00:00
</ul>
2022-11-06 02:26:21 +00:00
<?php if (count($countdowns) == 0) : ?>
<div class="text-center">
<?= UOJLocale::get('none') ?>
</div>
2022-09-23 13:00:17 +00:00
<?php endif ?>
2022-04-03 11:33:50 +00:00
</div>
2022-03-21 02:51:31 +00:00
</div>
2022-09-26 10:56:38 +00:00
2022-11-06 02:26:21 +00:00
<?php if (Auth::check()) : ?>
2022-10-22 13:12:13 +00:00
<?php uojIncludeView('sidebar', ['assignments_hidden' => '', 'groups_hidden' => '']) ?>
2022-09-26 10:56:38 +00:00
<?php endif ?>
<div class="card card-default mb-2">
2023-02-16 08:57:42 +00:00
<div class="card-header fw-bold">
<?= UOJLocale::get('friend links') ?>
2022-10-22 13:12:13 +00:00
</div>
2022-04-03 13:27:40 +00:00
<div class="card-body">
2022-10-22 13:12:13 +00:00
<ul class="ps-3 mb-0">
2022-11-06 02:26:21 +00:00
<?php foreach ($friend_links as $friend_link) : ?>
2022-09-21 03:33:42 +00:00
<li>
2022-11-06 02:26:21 +00:00
<a class="text-decoration-none" href="<?= $friend_link['url'] ?>" target="_blank">
2022-10-22 13:12:13 +00:00
<?= $friend_link['title'] ?>
</a>
2022-09-21 03:33:42 +00:00
</li>
<?php endforeach ?>
2022-04-03 13:27:40 +00:00
</ul>
2022-11-06 02:26:21 +00:00
<?php if (count($friend_links) == 0) : ?>
<div class="text-center">
<?= UOJLocale::get('none') ?>
</div>
2022-09-23 13:00:17 +00:00
<?php endif ?>
2022-04-03 13:27:40 +00:00
</div>
</div>
2022-03-21 02:51:31 +00:00
</div>
</div>
2022-04-03 11:33:50 +00:00
2022-03-21 02:51:31 +00:00
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>