mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Add global feed
This commit is contained in:
parent
0049dbc5c7
commit
e0e2d78ab8
3 changed files with 34 additions and 0 deletions
|
@ -105,6 +105,30 @@ final class WallPresenter extends OpenVKPresenter
|
|||
$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
|
||||
{
|
||||
$hashtag = rawurldecode($hashtag);
|
||||
|
|
|
@ -3,6 +3,14 @@
|
|||
|
||||
{block header}
|
||||
{_"feed"}
|
||||
|
||||
<div n:if="!isset($globalFeed)" style="float: right;">
|
||||
<span>
|
||||
<b>
|
||||
<a href="/feed/all">Все новости</a>
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block content}
|
||||
|
|
|
@ -71,6 +71,8 @@ routes:
|
|||
handler: "Notification->feed"
|
||||
- url: "/feed"
|
||||
handler: "Wall->feed"
|
||||
- url: "/feed/all"
|
||||
handler: "Wall->globalFeed"
|
||||
- url: "/feed/hashtag/{?hashTag}"
|
||||
handler: "Wall->hashtagFeed"
|
||||
placeholders:
|
||||
|
|
Loading…
Reference in a new issue