Ejemplo n.º 1
0
 public function actionArticle()
 {
     $article_db = new ArticleDB();
     $article_db->load($this->request->id);
     //загружаем id для выгрузки нужной статьи из базы
     if (!$article_db->isSaved()) {
         $this->notFound();
     } else {
         $this->title = $article_db->title;
         $this->meta_desc = $article_db->meta_desc;
         $this->meta_key = $article_db->meta_key;
         $hornav = $this->getHornav();
         //горизонтальная навигация
         if ($article_db->section) {
             $this->section_id = $article_db->section->id;
             $hornav->addData($article_db->section->title, $article_db->section->link);
             $this->url_active = URL::get("section", "", array("id" => $article_db->section->id));
         }
         if ($article_db->category) {
             $hornav->addData($article_db->category->title, $article_db->category->link);
             $this->url_active = URL::get("category", "", array("id" => $article_db->category->id));
         }
         $hornav->addData($article_db->title);
         $prev_article_db = new ArticleDB();
         $prev_article_db->loadPrevArticle($article_db);
         $next_article_db = new ArticleDB();
         $next_article_db->loadNextArticle($article_db);
         $article = new Article();
         $article->hornav = $hornav;
         $article->auth_user = $this->auth_user;
         $article->article = $article_db;
         if ($prev_article_db->isSaved()) {
             $article->prev_article = $prev_article_db;
         }
         if ($next_article_db->isSaved()) {
             $article->next_article = $next_article_db;
         }
         $article->link_register = URL::get("register");
         $comments = CommentDB::getAllOnArticleID($article_db->id);
         $article->comments = $comments;
         $this->render($article);
     }
 }