/** * @param int $page Nacita dalsi clanky */ public function handleSetPage($page) { if ($this->paginator->getPage() != $page) { $this->paginator->setPage($page); $this->redrawControl('posts'); $this->redrawControl('pagin'); } }
public function render() { $startingPage = $this->paginator->getPage() - $this->threshold; $startingPage = $startingPage < 1 ? 1 : $startingPage; $this->template->startingPage = $startingPage; $closingPage = $this->paginator->getPage() + $this->threshold; $closingPage = $closingPage > $this->paginator->getPageCount() ? $this->paginator->getPageCount() : $closingPage; $this->template->closingPage = $closingPage; $this->template->hasUndisclosed = $startingPage !== 2 || $closingPage !== $this->paginator->getPageCount() - 1; $this->template->paginator = $this->paginator; $this->template->pageParameter = $this->pageParameter; $this->template->setFile(__DIR__ . '/PaginatorControl.latte'); $this->template->render(); }
public function getData() { $this->paginator->setItemsPerPage($this->itemsPerPage); $this->paginator->setItemCount($this->dataset->getCount()); $this->paginator->setPage($this->page); $this->page = $this->paginator->getPage(); $this->dataset->setLimit($this->paginator->length, $this->paginator->offset); // TODO: IDataSource::setOrderBy() is optional if (empty($this->orderColumn) && !empty($this->defaultOrderColumn)) { $this->dataset->setOrderBy($this->defaultOrderColumn, $this->defaultOrderDir === self::ASC); } elseif (!empty($this->orderColumn)) { $this->dataset->setOrderBy($this->orderColumn, $this->orderDir === self::ASC); } return $this->dataset->getData(); }
public function __construct(User $user, CommentsManager $commentsManager, ResourceAuthorizator $resourceAuthorizator, CaptchaManager $captchaManager, IRatingControlFactory $rating, $forWhat, $forId) { $this->user = $user; $this->paginator = new Paginator(); $this->commentsManager = $commentsManager; $this->resourceAuthorizator = $resourceAuthorizator; $this->captchaManager = $captchaManager; $this->rating = $rating; $this->commentsManager->setComments($forWhat, $forId, $this->user->isLoggedIn() ? $this->user->id : null); $this->paginator->setItemCount($this->commentsManager->countComments()); $this->paginator->setItemsPerPage(8); $this->paginator->setPage(1); $this->page = $this->paginator->getPage(); $this->lastPage = $this->paginator->getLastPage(); }
/** * @return int */ public function getPage() { if ($this->page === NULL) { $this->page = parent::getPage(); } return $this->page; }
/** * Výpis uživatelů * @param int */ public function renderDefault($page = 1) { $paginator = new Paginator(); $pocet = $this->uzivateleModel->pocet(); $paginator->setPage($page)->setItemsPerPage(self::POLOZEK_NA_STRANKU)->setItemCount($pocet); if ($paginator->getPage() != $page) { // je li page nastavena na neexistující, je přesměrována $this->redirect('this', array('page' => $paginator->getPage())); } $data = FALSE; if ($pocet) { $data = $this->uzivateleModel->vypis($paginator); } $this->template->data = $data; $this->template->pocetDat = $pocet; $this->template->paginator = $paginator; $this->template->opravneni = $this->opravneni; }
/** * Nastavuje stranku paginatoru pro zobrazeni komentaru * @param int $page */ public function handleSetCommentPage($page = NULL) { if ($page === NULL) { $page = $this->paginator->getPage() + 1; } if ($this->paginator->getPage() != $page) { $this->paginator->setPage($page); $this->redrawControl('comments'); $this->redrawControl('pagin'); } }
public function renderDetail($id, $page = 1) { $allProducts = $this->productService->getProductsInCategory(self::BASE_LANG, $id); $paginator = new Paginator(); $paginator->setItemsPerPage(self::ITEMS_PER_PAGE); $paginator->setItemCount(count($allProducts)); $paginator->setPage((int) $page); $products = array_slice($allProducts, self::ITEMS_PER_PAGE * $paginator->getPage() - 1, $paginator->getItemsPerPage()); if (!$products && 0 === count($allProducts)) { throw new BadRequestException(); } $this->template->paginator = $paginator; $this->template->products = $products; }
public function saveState(array &$params, $reflection = NULL) { $this->page = $this->paginator->getPage(); parent::saveState($params, $reflection); }
/** * Get next page URL * @param Paginator $paginator * @return Link */ private function getNextPageUrl(Paginator $paginator) { $url = clone $this->request->getUrl(); parse_str($url->getQuery(), $query); $paginator->setPage($paginator->getPage() + 1); $query['offset'] = $paginator->getOffset(); $query['limit'] = $paginator->getItemsPerPage(); $url->appendQuery($query); return new Link($url, Link::NEXT); }
/** * Returns current page index * * @return int */ public function getCurrentPageIndex() { return $this->paginator->getPage() - 1; }