Example #1
0
 public function ArticleViewAction()
 {
     $request = Project::getRequest();
     $article_model = new ArticleModel();
     $data = array();
     $this->BaseSiteData();
     $id = (int) $request->getKeyByNumber(0);
     $pageId = (int) $request->getKeyByNumber(1);
     if ($id > 0) {
         $article_page_model = new ArticlePageModel();
         $article_tree_model = new ArticleTreeModel();
         $article_vote_model = new ArticleVoteModel();
         $article_pager = new ArticlePagerView();
         $votes = $article_vote_model->loadByArticleUser($id, Project::getUser()->getDbUser()->id);
         $pages = $article_page_model->loadByArticleId($id);
         $data['article'] = $article_model->load($id);
         $data['tab_list'] = TabController::getMainArticleTabs(false, false, false, false, true, $article_model->title);
         $data['category'] = $article_tree_model->load($article_model->articles_tree_id);
         $data['page_content'] = $pages[$pageId];
         $data['pager_view'] = $article_pager->ShowPager(count($pages), $pageId, 'Article', 'ArticleView', array($id));
         $data['vote_status'] = count($votes);
         $data = array_merge($data, $article_vote_model->rateByArticleId($id));
         $article_model->views++;
         $article_model->save();
         if ($article_model->allowcomments > 0) {
             $controller = new BaseCommentController();
             $data['comment_list'] = $controller->CommentList($id, $request->getKeyByNumber(1), 0, 'Article', 'ArticleView', 'article', array($id));
         }
         $this->_view->ViewArticle($data);
         $this->_view->parse();
     }
 }
Example #2
0
 public function SaveArticleAction()
 {
     $request = Project::getRequest();
     $id = (int) $request->id;
     $article_model = new ArticleModel();
     $article_page_model = new ArticlePageModel();
     $article_model->load($id);
     $article_model->user_id = Project::getUser()->getDbUser()->id;
     $article_model->articles_tree_id = $request->article_cat;
     $article_model->title = $request->article_title;
     $article_model->allowcomments = (bool) $request->allow_comment;
     $article_model->rate_status = (bool) $request->allow_rate;
     $article_model->creation_date = date("Y-m-d H:i:s");
     $id = $article_model->save();
     for ($i = 0; $i < count($request->title_page); $i++) {
         $article_page_model = new ArticlePageModel();
         $article_page_model->load($request->id_page[$i]);
         $article_page_model->article_id = $id;
         $article_page_model->title = $request->title_page[$i];
         $article_page_model->p_text = $request->content_page[$i];
         $article_page_model->save();
     }
     $data = array();
     $this->_makeArticleList($data);
     $this->_view->AjaxArticleList($data);
     $this->_view->ajax();
 }