function newcommentAction() { if (!$this->user->isLoggedIn()) { throw new \Exception('User not logged in.'); } $this->postsRepo->newComment($this->getParameter('id'), $this->user->getId(), $_POST['text']); header('Location: index.php?controller=Post&action=default&id=' . $this->getParameter('id')); }
function defaultAction() { $this->defaultData(); $current_page = $this->getParameter('page') ? $this->getParameter('page') : 1; $offset = ($current_page - 1) * self::POSTS_PER_PAGE; $posts = $this->postsRepo->getPosts(self::POSTS_PER_PAGE, $offset, PostsRepository::ORDER_TOP); $this->view->posts = $posts; $this->view->action = 'default'; $this->view->page = $current_page; $this->view->end = ceil($this->postsRepo->countPosts() / self::POSTS_PER_PAGE); $this->view->render('home/home'); }