Add global feed

This commit is contained in:
Jill Stingray 2020-06-11 12:51:12 +03:00
parent 0049dbc5c7
commit e0e2d78ab8
3 changed files with 34 additions and 0 deletions

View file

@ -105,6 +105,30 @@ final class WallPresenter extends OpenVKPresenter
$this->template->posts[] = $this->posts->get($post->id); $this->template->posts[] = $this->posts->get($post->id);
} }
function renderGlobalFeed(): void
{
$this->assertUserLoggedIn();
$page = (int) ($_GET["p"] ?? 1);
$pPage = (int) ($_GET["posts"] ?? OPENVK_DEFAULT_PER_PAGE);
$posts = DatabaseConnection::i()
->getContext()
->table("posts")
->where("deleted", 0)
->order("created DESC");
$this->template->_template = "Wall/Feed.xml";
$this->template->globalFeed = true;
$this->template->paginatorConf = (object) [
"count" => sizeof($posts),
"page" => (int) ($_GET["p"] ?? 1),
"amount" => sizeof($posts->page($page, $pPage)),
"perPage" => $pPage,
];
foreach($posts->page($page, $pPage) as $post)
$this->template->posts[] = $this->posts->get($post->id);
}
function renderHashtagFeed(string $hashtag): void function renderHashtagFeed(string $hashtag): void
{ {
$hashtag = rawurldecode($hashtag); $hashtag = rawurldecode($hashtag);

View file

@ -3,6 +3,14 @@
{block header} {block header}
{_"feed"} {_"feed"}
<div n:if="!isset($globalFeed)" style="float: right;">
<span>
<b>
<a href="/feed/all">Все новости</a>
</b>
</span>
</div>
{/block} {/block}
{block content} {block content}

View file

@ -71,6 +71,8 @@ routes:
handler: "Notification->feed" handler: "Notification->feed"
- url: "/feed" - url: "/feed"
handler: "Wall->feed" handler: "Wall->feed"
- url: "/feed/all"
handler: "Wall->globalFeed"
- url: "/feed/hashtag/{?hashTag}" - url: "/feed/hashtag/{?hashTag}"
handler: "Wall->hashtagFeed" handler: "Wall->hashtagFeed"
placeholders: placeholders: