public function viewsNewsAction() { $data_page = $this->index('basic_page'); $indexModel = new IndexModel(); $data_news_arr = $indexModel->getViews('news'); foreach ($data_news_arr as $k => $v) { if ($v['description']) { $data_news_arr[$k]['short_text'] = $this->cropString($v['description'], 600, '...'); } elseif ($v['text']) { $data_news_arr[$k]['short_text'] = $this->cropString($v['text'], 600, '...'); } else { $data_news_arr[$k]['short_text'] = ''; } $data_news_arr[$k]['date'] = date('y.m.d', strtotime($v['date'])); } $items_count = count($data_news_arr); $items_per_page = Config::get('news_per_page'); $request = new Request(); $currentPage = $request->get('page') ? (int) $request->get('page') : 1; $data_pagination = self::getPagination($items_count, $items_per_page, $currentPage); if ($items_count) { $data_news_page = array_chunk($data_news_arr, $items_per_page, true); if (isset($data_news_page[$currentPage - 1])) { $data_news_page = $data_news_page[$currentPage - 1]; } else { throw new Exception('Page (' . Router::getUri() . ') not found', 404); } } else { $data_news_page = null; } $data_url = explode('?', Router::getUri()); $lang = Router::getLanguage() == Config::get('default_language') ? '' : Router::getLanguage() . '/'; $args = array('data_page' => $data_page, 'data_news' => $data_news_page, 'data_pagination' => $data_pagination, 'data_url' => $data_url[0], 'lang' => $lang, 'img' => $data_page['img']); return $this->render($args); }