/** * Displays a knowledge base article * * @return void */ public function articleTask() { // Incoming $alias = Request::getVar('alias', ''); $id = Request::getInt('id', 0); // Load the article $article = $alias ? Article::oneByAlias($alias) : Article::oneOrFail($id); if (!$article->get('id')) { throw new Exception(Lang::txt('COM_KB_ERROR_ARTICLE_NOT_FOUND'), 404); } if (!$article->get('state')) { throw new Exception(Lang::txt('COM_KB_ERROR_ARTICLE_NOT_FOUND'), 404); } // Is the user logged in? if (!User::isGuest()) { // See if this person has already voted $vote = Vote::blank()->find($article->get('id'), User::get('id'), Request::ip(), 'article'); $this->view->vote = $vote->get('vote'); } else { $this->view->vote = strtolower(Request::getVar('vote', '')); } // Load the category object $category = Category::oneOrFail($article->get('category')); if (!$category->get('published')) { throw new Exception(Lang::txt('COM_KB_ERROR_ARTICLE_NOT_FOUND'), 404); } $this->view->catid = $category->get('id'); if ($category->get('parent_id') > 1) { $this->view->catid = $category->get('parent_id'); } $this->view->set('article', $article)->set('category', $category)->set('archive', $this->archive)->setLayout('article')->display(); }