public function index($category_id = NULL)
 {
     session_start();
     $isLoggedIn = Authentification::isLoggedIn();
     $view->isLoggedIn = $isLoggedIn;
     if ($category_id != NULL) {
         $view = new XView(Article_List);
         $view->articles = ArticleModel::getArticleListByCategory($category_id);
         $this->__common($view);
         return;
     }
     $view = new XView(Article_Table_View);
     $view->title = 'XRAT | Articles';
     $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 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);
 }