options = array_merge(array( 'total' => 0, 'nr_per_page' => 25, 'between' => 3, 'qs' => 'pages' ),$options); $get = 1; if(isset($_GET[$this->options['qs']])) $get = (int) $_GET[$this->options['qs']]; if(isset($get) && !empty($get)){ $limit_x = (($get-1)*$this->options['nr_per_page']); }else{ $limit_x = 0; } $this->limit = $limit_x.','.$this->options['nr_per_page']; $this->options['pages'] = ceil($this->options['total']/$this->options['nr_per_page']); $last = $this->options['pages']; $this->options['current_page'] = $limit_x/$this->options['nr_per_page']+1; $start = 1; $stop = $this->options['current_page'] + $this->options['between']; if($this->options['current_page'] > $this->options['between']) $start = $this->options['current_page'] - $this->options['between']; if($this->options['pages'] < $stop) $stop = $this->options['pages']; if($this->options['total'] > $this->options['nr_per_page']){ $nav = ''.__('Page', 'huddle').' '.($this->options['current_page']).' '.__('of', 'huddle').' '.$this->options['pages'].' '; $gets = array(); foreach($_GET as $gk=>$gv){ if($gk != $this->options['qs']) array_push($gets,$gk.'='.$gv); } $base_url = current(explode('?', $_SERVER['REQUEST_URI'])).'?'.implode('&',$gets); if($limit_x != 0) $nav .= ' '; for($nr = $start; $nr <= $stop; $nr++ ){ if($limit_x != ($nr-1)*$this->options['nr_per_page']) $nav .= ''.$nr.' '; else $nav .= ''.$nr.' '; } if($get != $last) $nav .= ' '; $this->nav = $nav; } } function nav(){ return '
'.$this->nav.'
'; } function limit(){ return $this->limit; } function get($i){ if($this->options[$i]) return $this->options[$i]; return false; } }