Exemple #1
0
 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();
 }
Exemple #2
0
 /**
  * Create pager
  */
 public function render()
 {
     $this->template->paginator = $this->paginator;
     $this->template->max_for_normal = $this->max_for_normal;
     $this->template->edge_page_count = $this->edge_page_count;
     $this->template->middle_page_count = $this->middle_page_count;
     $this->template->grid_dir = __DIR__;
     if ($this->paginator->getPageCount() > $this->max_for_normal) {
         $this->template->setFile(dirname(__FILE__) . '/templates/Pager/PagerAdvanced.latte');
     } else {
         $this->template->setFile(dirname(__FILE__) . '/templates/Pager/Pager.latte');
     }
     $this->template->render();
 }
 /**
  * Returns the total number of pages.
  *
  * @return int|NULL
  */
 public function getPageCount()
 {
     if (!$this->itemsOnFirstPage) {
         return parent::getPageCount();
     }
     return $this->itemCount === NULL ? NULL : (int) ceil(1 + ($this->itemCount - $this->itemsOnFirstPage) / $this->itemsPerPage);
 }
Exemple #4
0
 public function renderDefault($page = 1, $filter = '%')
 {
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(5);
     $paginator->setPage($page);
     $results = count($this->database->table('users')->where('username LIKE ? OR email LIKE ?', $filter, $filter));
     $paginator->setItemCount($results);
     $this->template->totalPages = $paginator->getPageCount();
     $this->template->page = $paginator->page;
     $this->template->filter = $filter;
     $this->template->users = $this->database->table('users')->order('username')->where('username LIKE ? OR email LIKE ?', $filter, $filter)->limit($paginator->getLength(), $paginator->getOffset());
 }
 public function renderDefault($page = 1, $filter = '%')
 {
     $paginator = new Nette\Utils\Paginator();
     $paginator->setItemsPerPage(3);
     // the number of records on page
     $paginator->setPage($page);
     //current page, default 1
     $users = $this->database->table('users')->where('login LIKE ? OR email LIKE ?', $filter, $filter)->limit($paginator->getLength(), $paginator->getOffset());
     $this->template->users = $users;
     $this->template->filter = $filter;
     $this->template->totalPosts = $this->database->table('users')->count();
     $paginator->setItemCount($this->template->totalPosts);
     $this->template->totalPages = $paginator->getPageCount();
     $this->template->page = $paginator->page;
     $this->template->pageCount = $paginator->getItemsPerPage();
 }
 /**
  * @param array $arr
  * @param Utils\Paginator $paginator
  * @return array
  */
 private function skipSteps(array $arr, Utils\Paginator $paginator)
 {
     $radius = $this->skipRadius;
     if ($radius) {
         $quotient = ($paginator->getPageCount() - 1) / $radius;
         for ($i = 0; $i <= $radius; $i++) {
             $arr[] = (int) round($quotient * $i) + $paginator->getFirstPage();
         }
         $arr = array_unique($arr);
         sort($arr);
     }
     return $arr;
 }
Exemple #7
0
 /**
  * @return string
  * @internal
  */
 public function nextLink()
 {
     if ($this->page !== $this->paginator->getPageCount()) {
         return $this->stepLink($this->page + 1);
     }
 }