public function index()
 {
     $view = new XView(Article_Table_View);
     $view->title = 'XRAT | Main Page';
     $view->total_groups = ceil(ArticleModel::getCount());
     $view->articles = ArticleModel::getArticles(0, $view->total_groups);
     foreach ($view->articles as $article) {
         $last_commentator = CommentModel::getAuthorByCommentId($article->id);
         if ($last_commentator == NULL) {
             $last_commentator = $article->author;
         }
         $article->set('last_commentator', $last_commentator);
         $comment_count = CommentModel::getCommentCountByArticle($article->id);
         $article->set('comment_count', $comment_count);
         $view_count = ViewsModel::getViewNumber($article->id);
         $article->set('view_count', $view_count);
     }
     $this->__common($view);
 }
 public function view($id, $args = NULL)
 {
     if ($_POST['post_comment']) {
         CommentModel::add($_POST['content'], $_POST['parent_comment'], $_POST['author_id'], $_POST['article_id']);
     }
     session_start();
     if (Authentification::isLoggedIn()) {
         ViewsModel::incrementView($id, $_SESSION['id']);
     }
     $view = new XView(Article_View);
     $view->title = 'Article | View';
     $view->article = ArticleModel::getArticleById($id);
     $view->comments = CommentModel::getCommentTreeByArticleID($id, -1);
     $view->likes = LikesModel::getLikeNumber($id);
     $view->parent_comment = $args;
     $this->__common($view);
 }