예제 #1
0
 /**
  * действие для отображения списка книг - Books
  *
  * @param Request $request
  * @return int
  */
 public function indexAction(Request $request)
 {
     $bookModel = new BookModel();
     $page = $request->get('page');
     $count = $bookModel->getBooksCount();
     $books = $bookModel->getList($page);
     $pagination = new Pagination(array('itemsCount' => $count, 'itemsPerPage' => BookModel::BOOKS_PER_PAGE, 'currentPage' => $page));
     $args = array('books' => $books, 'pagination' => $pagination);
     return $this->render('index', $args);
 }
 public function getPagination()
 {
     $request = new Request();
     $bookModel = new BookModel();
     $itemsCount = $bookModel->getBooksCount();
     $itemsPerPage = BOOKS_PER_PAGE;
     $currentPage = $request->get('page') ? (int) $request->get('page') : 1;
     if ($currentPage < 0) {
         throw new Exception('Bad request', 400);
     }
     $pagination = new Pagination($currentPage, $itemsCount, $itemsPerPage);
     $args['pagination'] = $pagination->buttons;
     return $this->render('pagination', $args);
     //Debugger::PrintR($args);
 }