mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
40 lines
851 B
PHP
40 lines
851 B
PHP
<?php
|
|
|
|
class BlogActions extends Actions
|
|
{
|
|
const URL_STEM = '/news';
|
|
|
|
public static function executeIndex()
|
|
{
|
|
$posts = Blog::getPosts();
|
|
usort($posts, function(Post $a, Post $b) {
|
|
return strcasecmp($b->getDate()->format('Y-m-d'), $a->getDate()->format('Y-m-d'));
|
|
});
|
|
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
|
|
return ['blog/index', [
|
|
'posts' => $posts,
|
|
'page' => $page
|
|
]];
|
|
}
|
|
|
|
public static function executePost($slug)
|
|
{
|
|
$post = Blog::getPost($slug);
|
|
if (!$post)
|
|
{
|
|
return ['page/404', []];
|
|
}
|
|
return ['blog/post', [
|
|
'post' => $post
|
|
]];
|
|
}
|
|
|
|
public static function prepareAuthor(array $vars)
|
|
{
|
|
$post = $vars['post'];
|
|
return [
|
|
'authorName' => $post->getAuthorName(),
|
|
'authorBioHtml' => $post->getAuthorBioHtml()
|
|
];
|
|
}
|
|
}
|