S2OJ/web/app/controllers/announcements.php

85 lines
2.0 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
if (!Auth::check() && UOJConfig::$data['switch']['force-login']) {
redirectToLogin();
2022-03-17 04:00:03 +00:00
}
if (!isNormalUser($myUser) && UOJConfig::$data['switch']['force-login']) {
2022-04-03 10:18:17 +00:00
become403Page();
}
2022-10-07 10:24:11 +00:00
if (!isset($_COOKIE['bootstrap4'])) {
$REQUIRE_LIB['bootstrap5'] = '';
}
2016-07-18 16:39:37 +00:00
requirePHPLib('form');
function echoBlogCell($blog) {
$level = $blog['level'];
switch ($level) {
case 0:
$level_str = '';
break;
case 1:
$level_str = '<span style="color:red">[三级置顶]</span> ';
break;
case 2:
$level_str = '<span style="color:red">[二级置顶]</span> ';
break;
case 3:
$level_str = '<span style="color:red">[一级置顶]</span> ';
break;
}
echo '<tr>';
echo '<td>' . $level_str . getBlogLink($blog['id']) . '</td>';
echo '<td>' . getUserLink($blog['poster']) . '</td>';
echo '<td>' . $blog['post_time'] . '</td>';
echo '</tr>';
}
$header = <<<EOD
<tr>
<th width="60%">标题</th>
<th width="20%">发表者</th>
<th width="20%">发表日期</th>
</tr>
EOD;
$config = [
'table_classes' => ['table', 'table-hover'],
2022-09-18 13:06:18 +00:00
'page_len' => 40
2016-07-18 16:39:37 +00:00
];
2022-10-07 10:24:11 +00:00
if (isset($REQUIRE_LIB['bootstrap5'])) {
$config['div_classes'] = ['card', 'my-3'];
$config['table_classes'] = ['table', 'uoj-table', 'mb-0'];
}
2022-09-18 04:58:35 +00:00
?>
2016-07-18 16:39:37 +00:00
<?php echoUOJPageHeader(UOJLocale::get('announcements')) ?>
2022-10-07 10:24:11 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
<div class="row">
<!-- left col -->
<div class="col-lg-9">
<?php endif ?>
<h1 class="h2">
<?= UOJLocale::get('announcements') ?>
</h1>
2016-07-18 16:39:37 +00:00
<?php echoLongTable(array('blogs.id', 'poster', 'title', 'post_time', 'zan', 'level'), 'important_blogs, blogs', 'is_hidden = 0 and important_blogs.blog_id = blogs.id', 'order by level desc, important_blogs.blog_id desc', $header, 'echoBlogCell', $config); ?>
2022-10-07 10:24:11 +00:00
<?php if (isset($REQUIRE_LIB['bootstrap5'])): ?>
</div>
<!-- end left col -->
<!-- right col -->
<aside class="col mt-3 mt-lg-0">
<?php uojIncludeView('sidebar', array()) ?>
</aside>
<!-- end right col -->
</div>
<?php endif ?>
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>