Exemplo n.º 1
0
 public function index()
 {
     // EVENT
     $tmp = $this->modelConnect->checkConnect();
     $events['top'] = $this->modelEvent->getTop();
     $events['last'] = $this->modelEvent->getLast();
     $events['nbConnect'] = (int) $tmp['COUNT(*)'];
     foreach ($events['top'] as $key => $value) {
         if (strlen($events['top'][$key]['description']) > 200) {
             $events['top'][$key]['description'] = substr($events['top'][$key]['description'], 0, strpos($events['top'][$key]['description'], ' ', 200));
             $events['top'][$key]['description'] .= ' ... ';
         }
     }
     foreach ($events['last'] as $key => $value) {
         if (strlen($events['last'][$key]['description']) > 200) {
             $events['last'][$key]['description'] = substr($events['last'][$key]['description'], 0, strpos($events['last'][$key]['description'], ' ', 200));
             $events['last'][$key]['description'] .= ' ... ';
         }
     }
     $lastUser = $this->userModel->getLastUser();
     // ARTICLE
     $modelArticle = new ArticleModel();
     $article['top'] = $modelArticle->getTop();
     $article['last'] = $modelArticle->getLast();
     $article['top'] = $this->getInfos($article['top']);
     $article['top']['text'] = substr($article['top']['text'], 0, strpos($article['top']['text'], ' ', 1000));
     $article['top']['text'] .= ' ... ';
     foreach ($article['last'] as &$art) {
         $art['text'] = substr($art['text'], 0, strpos($art['text'], ' ', 70));
         $art['text'] .= ' ... ';
         $art = $this->getInfos($art);
     }
     $this->getView()->render('home/index', ['events' => $events, 'article' => $article, 'lastUsers' => $lastUser]);
 }