public function indexAction()
 {
     $title = "Register";
     $styles = [STYLES . 'register.css'];
     $scripts = [SCRIPTS . 'register.js'];
     $this->loadView(LAYOUT, 'Register/index', $title, $styles, $scripts, ['csrf_token_register' => Security::generateCSRFToken('csrf_token_register')]);
 }
 public function crudAction()
 {
     if (Security::getUserRole() === 'ROLE_ADMIN') {
         $css = [STYLES . 'grid.css'];
         $js = [SCRIPTS . 'category.js', SCRIPTS . 'category-crud.js', SCRIPTS . 'categories.js'];
         $this->loadView(LAYOUT, 'Category/Admin/index', 'Categories', $css, $js, ['csrf_token_category' => Security::generateCSRFToken('csrf_token_category')]);
     } else {
         Helper::redirectTo(WEB . 'categories');
     }
 }
 public function crudAction()
 {
     if (Security::getUserRole() === 'ROLE_ADMIN') {
         $comments = $this->loadModel('Comment')->loadAll();
         $css = [STYLES . 'comments.css'];
         $js = [SCRIPTS . 'comment.js', SCRIPTS . 'comment-crud.js'];
         $this->loadView(LAYOUT, 'Comments/Admin/index', 'Comments', $css, $js, ['comments' => $comments, 'csrf_token_comment' => Security::generateCSRFToken('csrf_token_comment')]);
     } else {
         Helper::redirectTo(WEB . 'comments');
     }
 }
function isTokenGenerated($isUserLoggedIn)
{
    return $isUserLoggedIn ? 0 : Security::generateCSRFToken('csrf_token_login');
}
 /**
  * @access public
  * @param int
  */
 public function readAction($id)
 {
     if (filter_var($id, FILTER_VALIDATE_INT)) {
         if ($this->isAJAX()) {
             if ($this->isRequestMethod('GET')) {
                 $news = $this->read($id);
                 if (sizeof($this->read($id)) == 1) {
                     $categories = $this->loadModel('LOC')->findByNewsId($id);
                     http_response_code(200);
                     echo json_encode(array('news' => $news, 'categories' => $categories));
                 } else {
                     http_response_code(204);
                 }
             }
         } else {
             $news = $this->read($id);
             if (sizeof($this->read($id)) == 1) {
                 $comments = $this->loadModel('Comment')->findByNewsId($id);
                 $css = ['news.css'];
                 $js = [SCRIPTS . 'comment.js', SCRIPTS . 'comments.js'];
                 $this->loadView(LAYOUT, 'News/User/detail', 'News', $css, $js, ['news' => $news[0], 'comments' => $comments, 'isUserLoggedIn' => Security::isUserLoggedIn(), 'csrf_token_comment' => Security::generateCSRFToken('csrf_token_comment')]);
             } else {
                 Helper::redirectTo(WEB . 'news/category/all');
             }
         }
     }
 }