fix(blogs): list order

This commit is contained in:
Baoshuo Ren 2023-02-17 18:45:48 +08:00
parent 025ec365c4
commit d91f72491f
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
2 changed files with 3 additions and 21 deletions

View File

@ -3,7 +3,7 @@ requirePHPLib('form');
Auth::check() || redirectToLogin(); Auth::check() || redirectToLogin();
function echoBlogItem($info) { function echoBlog($info) {
$blog = new UOJBlog($info); $blog = new UOJBlog($info);
$poster = UOJUser::query($blog->info['poster']); $poster = UOJUser::query($blog->info['poster']);
@ -60,7 +60,7 @@ $pag = new Paginator([
'table_name' => 'blogs', 'table_name' => 'blogs',
'col_names' => ['id', 'poster', 'title', 'post_time', 'active_time', 'zan', 'is_hidden'], 'col_names' => ['id', 'poster', 'title', 'post_time', 'active_time', 'zan', 'is_hidden'],
'cond' => '1', 'cond' => '1',
'tail' => 'order by post_time desc', 'tail' => 'order by post_time desc, id desc',
'post_filter' => function ($info) { 'post_filter' => function ($info) {
return (new UOJBlog($info))->userCanView(Auth::user()); return (new UOJBlog($info))->userCanView(Auth::user());
}, },
@ -104,7 +104,7 @@ $pag = new Paginator([
<?php endif ?> <?php endif ?>
<?php foreach ($pag->get() as $idx => $row) : ?> <?php foreach ($pag->get() as $idx => $row) : ?>
<?php echoBlogItem($row) ?> <?php echoBlog($row) ?>
<?php endforeach ?> <?php endforeach ?>
</div> </div>
</div> </div>

View File

@ -983,24 +983,6 @@ function echoHacksList($cond, $tail, $config, $user) {
); );
} }
function echoBlog($blog, $config = array()) {
global $REQUIRE_LIB;
$default_config = array(
'blog' => $blog,
'show_title_only' => false,
'is_preview' => false
);
foreach ($default_config as $key => $val) {
if (!isset($config[$key])) {
$config[$key] = $val;
}
}
$config['REQUIRE_LIB'] = $REQUIRE_LIB;
uojIncludeView('blog-preview', $config);
}
function echoBlogTag($tag) { function echoBlogTag($tag) {
echo ' <a class="uoj-blog-tag">', '<span class="badge bg-secondary">', HTML::escape($tag), '</span></a> '; echo ' <a class="uoj-blog-tag">', '<span class="badge bg-secondary">', HTML::escape($tag), '</span></a> ';
} }