/** * @throws HTTP_Exception_404 * @throws Kohana_Exception * * show pagination list news */ public function action_list() { if (isset($_GET['page'])) { $get['page'] = Security::encode_php_tags(HTML::chars($_GET['page'])); } else { $get['page'] = 1; } $valid = Validation::factory($get); $valid->rule('page', 'numeric'); if (!$valid->check()) { HTTP::redirect('/'); } if ((int) $get['page'] <= 0) { $get['page'] = 1; } $items_per_page = Kohana::$config->load('pagination')->get('default')['items_per_page']; $news = new Model_New(); $data = $news->getPagination(((int) $get['page'] - 1) * (int) $items_per_page, $items_per_page); if ($data) { $session = Session::instance(); $session->set("page", $get['page']); $total_items = $news->getCount(); $content = View::factory($this->newsView); $content->bind('data', $data); $content->pagination = Pagination::factory(array('total_items' => $total_items)); $this->template->content = $content; } else { throw new HTTP_Exception_404('File not found!'); } }