Ejemplo n.º 1
0
 /**
  * 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()]];
 }
Ejemplo n.º 2
0
 /**
  * Metodo llamado por la función INDEX.
  * @return array
  */
 protected function dataIndex()
 {
     $comments = Comments::selectAll();
     $output = [];
     if ($comments !== \FALSE) {
         $output = $comments->getAll();
     }
     foreach ($output as $value) {
         $contents = strip_tags($value->getCommentContents());
         if (isset($contents[30])) {
             $contents = substr($contents, 0, 30) . ' [...]';
         }
         $value->setCommentContents($contents);
     }
     return ['comments' => $output];
 }