/**
  * Metodo llamado por la funcion index.
  * @return array
  */
 protected function dataIndex()
 {
     $posts = new Posts();
     $users = new Users();
     $comments = new Comments();
     $categories = new Categories();
     $lastPosts = $posts->lastData(5);
     $lastComments = $comments->lastData(5);
     foreach ($lastPosts as $value) {
         $title = $value->getPostTitle();
         if (isset($title[30])) {
             $title = substr($title, 0, 30) . ' [...]';
         }
         $value->setPostTitle($title);
     }
     foreach ($lastComments as $value) {
         //Borra las etiquetas html
         $contents = strip_tags($value->getCommentContents());
         if (isset($contents[30])) {
             $contents = substr($contents, 0, 30) . ' [...]';
         }
         $value->setCommentContents($contents);
     }
     return ['github' => $this->lastUpdateGitHub(), 'lastPosts' => $lastPosts, 'lastComments' => $lastComments, 'count' => ['post' => $posts->count(), 'page' => 0, 'category' => $categories->count(), 'comment' => $comments->count(), 'user' => $users->count()]];
 }
 /**
  * Metodo llamado por la función INDEX.
  * @return array
  */
 protected function dataIndex()
 {
     $posts = Posts::selectAll();
     $output = [];
     if ($posts !== \FALSE) {
         $output = $posts->getAll();
     }
     return ['posts' => $output];
 }
Exemple #3
0
 /**
  * Metodo llamado por la función INDEX.
  * @return array
  */
 protected function dataIndex()
 {
     $posts = Posts::selectAll();
     $output = [];
     if ($posts !== \FALSE) {
         $output = $posts->getAll();
     }
     foreach ($output as $post) {
         $title = $post->getPostTitle();
         if (isset($title[30])) {
             $title = substr($title, 0, 30) . ' [...]';
         }
         $post->setPostTitle($title);
     }
     return ['posts' => $output];
 }