Esempio n. 1
0
 /**
  *
  * Display single page
  * @throws HTTP_Exception_404
  */
 public function action_view($seotitle)
 {
     $post = new Model_Post();
     $post->where('status', '=', 1)->where('seotitle', '=', $seotitle)->cached()->limit(1)->find();
     if ($post->loaded()) {
         Breadcrumbs::add(Breadcrumb::factory()->set_title($post->title));
         $this->template->title = $post->title;
         $this->template->meta_description = $post->description;
         $previous = new Model_Post();
         $previous = $previous->where('status', '=', 1)->order_by('created', 'desc')->where('id_post', '<', $post->id_post)->limit(1)->find();
         $next = new Model_Post();
         $next = $next->where('status', '=', 1)->where('id_post', '>', $post->id_post)->limit(1)->find();
         $this->template->bind('content', $content);
         $this->template->content = View::factory('pages/blog/post', array('post' => $post, 'next' => $next, 'previous' => $previous));
     } else {
         //throw 404
         throw new HTTP_Exception_404();
     }
 }
Esempio n. 2
0
 /**
  *
  * Display single page
  * @throws HTTP_Exception_404
  */
 public function action_view($seotitle)
 {
     $post = new Model_Post();
     // if visitor or user with ROLE_USER display post with STATUS_ACTIVE
     if (!Auth::instance()->logged_in() or Auth::instance()->logged_in() and Auth::instance()->get_user()->id_role == Model_Role::ROLE_USER) {
         $post->where('status', '=', Model_Post::STATUS_ACTIVE);
     }
     $post->where('seotitle', '=', $seotitle)->where('id_forum', 'IS', NULL)->cached()->limit(1)->find();
     if ($post->loaded()) {
         Breadcrumbs::add(Breadcrumb::factory()->set_title($post->title));
         $this->template->title = $post->title;
         $this->template->meta_description = $post->description;
         $previous = new Model_Post();
         $previous = $previous->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', 'IS', NULL)->order_by('created', 'desc')->where('id_post', '<', $post->id_post)->limit(1)->find();
         $next = new Model_Post();
         $next = $next->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', 'IS', NULL)->where('id_post', '>', $post->id_post)->limit(1)->find();
         $this->template->bind('content', $content);
         $this->template->content = View::factory('pages/blog/post', array('post' => $post, 'next' => $next, 'previous' => $previous));
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }
Esempio n. 3
0
 /**
  *
  * Display single topic with replies and allows to reply
  * @throws HTTP_Exception_404
  */
 public function action_topic()
 {
     $errors = NULL;
     $topic = new Model_Post();
     $topic->where('status', '=', Model_Post::STATUS_ACTIVE)->where('seotitle', '=', $this->request->param('seotitle', NULL))->where('id_forum', 'IS NOT', NULL)->where('id_post_parent', 'IS', NULL)->cached()->limit(1)->find();
     if ($topic->loaded()) {
         $forum = $topic->forum;
         $errors = $this->add_topic_reply($topic, $forum);
         Breadcrumbs::add(Breadcrumb::factory()->set_title($forum->name)->set_url(Route::url('forum-list', array('forum' => $forum->seoname))));
         Breadcrumbs::add(Breadcrumb::factory()->set_title($topic->title));
         $this->template->title = $topic->title . ' - ' . $forum->name . ' - ' . __('Forum');
         $this->template->meta_description = $topic->title . ' ' . __('in') . ' ' . core::config('general.site_name') . ' ' . __('forums');
         //getting all the topic replies, pagination
         $replies = new Model_Post();
         $replies = $replies->where('id_post_parent', '=', $topic->id_post)->where('status', '=', Model_Post::STATUS_ACTIVE);
         $replies_count = clone $replies;
         $pagination = Pagination::factory(array('view' => 'pagination', 'total_items' => $replies_count->count_all(), 'items_per_page' => self::$items_per_page))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action(), 'seotitle' => $this->request->param('seotitle'), 'forum' => $forum->seoname));
         $pagination->title($this->template->title);
         $replies = $replies->order_by('created', 'asc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
         $pagination = $pagination->render();
         $previous = new Model_Post();
         $previous = $previous->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', '=', $topic->id_forum)->where('id_post', '<', $topic->id_post)->where('id_post_parent', 'IS', NULL)->order_by('created', 'desc')->limit(1)->find();
         $next = new Model_Post();
         $next = $next->where('status', '=', Model_Post::STATUS_ACTIVE)->where('id_forum', '=', $topic->id_forum)->where('id_post', '>', $topic->id_post)->where('id_post_parent', 'IS', NULL)->limit(1)->find();
         $this->template->bind('content', $content);
         $this->template->content = View::factory('pages/forum/topic', array('topic' => $topic, 'next' => $next, 'previous' => $previous, 'replies' => $replies, 'errors' => $errors, 'forum' => $forum, 'pagination' => $pagination));
     } else {
         //throw 404
         throw HTTP_Exception::factory(404, __('Page not found'));
     }
 }