S2OJ/web/app/controllers/blogs.php

87 lines
2.2 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
requireLib('bootstrap5');
requirePHPLib('form');
2022-03-17 04:00:03 +00:00
2022-11-06 02:26:21 +00:00
Auth::check() || redirectToLogin();
?>
2016-07-18 16:39:37 +00:00
<?php echoUOJPageHeader(UOJLocale::get('blogs')) ?>
2022-09-26 12:55:56 +00:00
<div class="row">
2022-11-06 02:26:21 +00:00
<!-- left col -->
<div class="col-lg-9">
<!-- title container -->
<div class="d-flex flex-wrap justify-content-between align-items-center">
<h1>
<?= UOJLocale::get("blogs overview") ?>
</h1>
2022-10-22 13:12:13 +00:00
2022-11-06 02:26:21 +00:00
<?php if (Auth::check()) : ?>
<div class="text-end">
<div class="btn-group">
<a href="<?= HTML::blog_url(Auth::id(), '/') ?>" class="btn btn-secondary btn-sm">
我的博客首页
</a>
2022-11-11 23:10:34 +00:00
<?php if (UOJUser::checkPermission(Auth::user(), 'blogs.create')) : ?>
<a href="<?= HTML::blog_url(Auth::id(), '/post/new/write') ?>" class="btn btn-primary btn-sm">
<i class="bi bi-pencil"></i>
写新博客
</a>
<?php endif ?>
2022-11-06 02:26:21 +00:00
</div>
</div>
<?php endif ?>
</div>
<!-- end title container -->
2022-10-22 13:12:13 +00:00
2022-11-06 02:26:21 +00:00
<?php
echoLongTable(
['id', 'poster', 'title', 'post_time', 'zan', 'is_hidden'],
'blogs',
2022-11-11 23:10:34 +00:00
'1',
2022-11-06 02:26:21 +00:00
'order by post_time desc',
<<<EOD
2022-11-11 23:10:34 +00:00
<tr>
<th>标题</th>
<th style="width:200px">发表者</th>
<th style="width:200px">发表日期</th>
<th style="width:50px" class="text-center">评价</th>
</tr>
EOD,
2022-11-06 02:26:21 +00:00
function ($info) {
$blog = new UOJBlog($info);
2022-09-26 12:55:56 +00:00
2022-11-06 02:26:21 +00:00
echo '<tr>';
echo '<td>';
echo $blog->getLink();
if ($blog->info['is_hidden']) {
echo ' <span class="badge text-bg-danger"><i class="bi bi-eye-slash-fill"></i> ', UOJLocale::get('hidden'), '</span> ';
}
echo '</td>';
echo '<td>' . UOJUser::getLink($blog->info['poster']) . '</td>';
2022-11-06 02:26:21 +00:00
echo '<td>' . $blog->info['post_time'] . '</td>';
echo '<td class="text-center">' . ClickZans::getCntBlock($blog->info['zan']) . '</td>';
echo '</tr>';
},
[
'page_len' => 10,
'div_classes' => ['card', 'my-3', 'table-responsive'],
'table_classes' => ['table', 'uoj-table', 'mb-0'],
2022-11-11 23:10:34 +00:00
'post_filter' => function ($info) {
return (new UOJBlog($info))->userCanView(Auth::user());
},
2022-11-06 02:26:21 +00:00
]
);
?>
</div>
2022-09-26 12:55:56 +00:00
2022-11-06 02:26:21 +00:00
<!-- right col -->
<aside class="col-lg-3 mt-3 mt-lg-0">
<?php uojIncludeView('sidebar') ?>
</aside>
<!-- end right col -->
2022-09-26 12:55:56 +00:00
</div>
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>