Ejemplo n.º 1
0
 public function __construct(DibiDataSource $datasource, $itemsPerPage = 20)
 {
     $this->datasource = $datasource;
     $this->itemsPerPage = $itemsPerPage;
     $this->getPaginator();
     parse_str($_SERVER['QUERY_STRING'], $vars);
     if (isset($vars[$this->var_name])) {
         $this->paginator->setPage($vars[$this->var_name]);
     }
     unset($vars[$this->var_name]);
     $this->url = $_SERVER['SCRIPT_NAME'] . '?' . http_build_query($vars);
     $this->paginator->setItemsPerPage($this->itemsPerPage);
     $this->paginator->setItemCount(count($this->datasource));
 }
Ejemplo n.º 2
0
 /**
  * Creates the paginator test.
  * @param \Attibee\Paginator\Paginator $p the paginator object
  * @return \Attibee\Paginator\Paginator the paginator object
  */
 protected function createPaginator(Paginator $p = null)
 {
     if (!$p) {
         return null;
     }
     $p->setTotalItems(100);
     $p->setNumberPages(5);
     $p->setItemsPerPage(5);
     return $p;
 }