S2OJ/web/app/controllers/subdomain/blog/index.php

64 lines
2.1 KiB
PHP
Raw Normal View History

2016-07-18 16:39:37 +00:00
<?php
2022-11-06 02:26:21 +00:00
requireLib('hljs');
requireLib('mathjax');
2022-10-22 13:12:13 +00:00
2022-11-06 02:26:21 +00:00
Auth::check() || redirectToLogin();
2022-11-11 23:10:34 +00:00
UOJUserBlog::userIsOwner(Auth::user()) || UOJUser::checkPermission(Auth::user(), 'blogs.view') || UOJResponse::page403();
2022-03-17 04:00:03 +00:00
2022-11-06 02:26:21 +00:00
$blogs_pag = new Paginator([
'col_names' => ['*'],
'table_name' => 'blogs',
'cond' => "poster = '" . UOJUserBlog::id() . "' and is_hidden = 0",
'tail' => 'order by post_time desc',
'page_len' => 5
]);
2022-10-08 06:10:14 +00:00
2022-11-06 02:26:21 +00:00
$all_tags = DB::selectAll("select distinct tag from blogs_tags where blog_id in (select id from blogs where $blogs_cond)");
?>
<?php echoUOJPageHeader(UOJUserBlog::id() . '的博客') ?>
2016-07-18 16:39:37 +00:00
<div class="row">
2022-10-22 13:12:13 +00:00
<div class="col-lg-9">
2022-11-06 02:26:21 +00:00
<?php if ($blogs_pag->isEmpty()) : ?>
<div class="text-muted">此人很懒,什么博客也没留下。</div>
<?php else : ?>
<?php
foreach ($blogs_pag->get() as $blog_info) {
$blog = new UOJBlog($blog_info);
$blog->echoView(['is_preview' => true]);
}
?>
2016-07-18 16:39:37 +00:00
<?php endif ?>
2022-11-06 02:26:21 +00:00
<?= $blogs_pag->pagination() ?>
2016-07-18 16:39:37 +00:00
</div>
2022-10-22 13:12:13 +00:00
<div class="col-lg-3">
2023-02-07 11:36:48 +00:00
<img class="media-object img-thumbnail center-block uoj-user-avatar" alt="<?= UOJUserBlog::id() ?> Avatar" src="<?= HTML::avatar_addr(UOJUserBlog::user(), 512) ?>" />
2022-11-11 23:10:34 +00:00
<?php if (UOJUserBlog::userCanManage(Auth::user()) && UOJUser::checkPermission(Auth::user(), 'blogs.create')) : ?>
2022-11-06 02:26:21 +00:00
<div class="btn-group d-flex mt-3">
<a href="<?= HTML::blog_url(UOJUserBlog::id(), '/post/new/write') ?>" class="btn btn-primary">
<i class="bi bi-pencil-square"></i>
写新博客
</a>
<a href="<?= HTML::blog_url(UOJUserBlog::id(), '/slide/new/write') ?>" class="btn btn-primary">
<i class="bi bi-file-earmark-slides"></i>
写新幻灯片
</a>
</div>
<?php endif ?>
2022-10-22 13:12:13 +00:00
<div class="card border-info mt-3">
2023-02-16 08:57:42 +00:00
<div class="card-header fw-bold bg-info">标签</div>
<div class="card-body">
2022-11-06 02:26:21 +00:00
<?php if ($all_tags) : ?>
<?php foreach ($all_tags as $tag) : ?>
<?php echoBlogTag($tag['tag']) ?>
<?php endforeach ?>
<?php else : ?>
<div class="text-muted">暂无</div>
<?php endif ?>
</div>
</div>
2016-07-18 16:39:37 +00:00
</div>
</div>
2022-11-06 02:26:21 +00:00
2016-07-18 16:39:37 +00:00
<?php echoUOJPageFooter() ?>