예제 #1
0
 public function initialize($config = array())
 {
     foreach ($config as $key => $value) {
         if (property_exists($this, $key)) {
             $this->{$key} = $value;
         }
     }
     if (!isset($this->app)) {
         $this->app = \Rapyd\Application::getInstance();
     }
     //unset current pagination
     $this->url = $this->app->url->remove('reset' . $this->cid)->append('pag' . $this->cid, "-pag-")->get() . $this->hash;
     // Core pagination values
     $this->total_items = (int) max(0, $this->total_items);
     $this->items_per_page = (int) max(1, $this->items_per_page);
     $this->total_pages = (int) ceil($this->total_items / $this->items_per_page);
     if (!isset($this->current_page)) {
         $this->current_page = (int) min(max(1, $this->app->url->value('pag' . $this->cid)), max(1, $this->total_pages));
     }
     $this->current_first_item = (int) min(($this->current_page - 1) * $this->items_per_page + 1, $this->total_items);
     $this->current_last_item = (int) min($this->current_first_item + $this->items_per_page - 1, $this->total_items);
     // If there is no first/last/previous/next page, relative to the
     // current page, value is set to FALSE. Valid page number otherwise.
     $this->first_page = $this->current_page == 1 ? false : 1;
     $this->last_page = $this->current_page >= $this->total_pages ? false : $this->total_pages;
     $this->previous_page = $this->current_page > 1 ? $this->current_page - 1 : false;
     $this->next_page = $this->current_page < $this->total_pages ? $this->current_page + 1 : false;
     if ($this->num_links) {
         $this->nav_start = $this->current_page - $this->num_links > 0 ? $this->current_page - ($this->num_links - 1) : 1;
         $this->nav_end = $this->current_page + $this->num_links < $this->total_pages ? $this->current_page + $this->num_links : $this->total_pages;
     } else {
         $this->nav_start = 1;
         $this->nav_end = $this->total_pages;
     }
 }
예제 #2
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     //inherit cid from datafilter
     if (isset($this->source) and is_object($this->source)) {
         $this->cid = $this->source->cid;
     } else {
         $this->cid = parent::getIdentifier();
     }
     $this->app = \Rapyd\Application::getInstance();
 }