Nevädzova 6 - Obchodné centrum RETRO BRATISLAVA (Ružinov)
0908 777 700

Materiály - Fototapety

itemsPerPage = 5; $this->range = 8; $this->currentPage = 1; $this->total = 0; $this->textNav = true; $this->itemSelect = array(5,25,50,100,'All'); //private values $this->_navigation = array( 'next'=>'Next', 'pre' =>'Pre', 'ipp' =>'Item per page' ); $parsed_url = parse_url($_SERVER['REQUEST_URI']); $this->_link = $parsed_url['path']; $this->_url_vars = $parsed_url['query']; $this->_pageNumHtml = ''; $this->_itemHtml = ''; $this->_remove_pagination_from_url(); } /** * paginate main function * * @author The-Di-Lab * @access public * @return type */ public function paginate() { //get current page if(isset($_GET['current'])){ $this->currentPage = $_GET['current']; } //get item per page if(isset($_GET['item'])){ $this->itemsPerPage = $_GET['item']; } //get page numbers $this->_pageNumHtml = $this->_getPageNumbers(); //get item per page select box $this->_itemHtml = $this->_getItemSelect(); } /** * return pagination numbers in a format of UL list * * @author The-Di-Lab * @access public * @param type $parameter * @return string */ public function pageNumbers() { if(empty($this->_pageNumHtml)){ exit('Please call function paginate() first.'); } return $this->_pageNumHtml; } /** * return jump menu in a format of select box * * @author The-Di-Lab * @access public * @return string */ public function itemsPerPage() { if(empty($this->_itemHtml)){ exit('Please call function paginate() first.'); } return $this->_itemHtml; } /** * return page numbers html formats * * @author The-Di-Lab * @access public * @return string */ private function _getPageNumbers() { $html = '
    '; //previous link button if($this->textNav&&($this->currentPage>1)){ echo '
  • '; } //do ranged pagination only when total pages is greater than the range if($this->total > $this->range){ $start = ($this->currentPage <= $this->range)?1:($this->currentPage - $this->range); $end = ($this->total - $this->currentPage >= $this->range)?($this->currentPage+$this->range): $this->total; }else{ $start = 1; $end = $this->total; } //loop through page numbers for($i = $start; $i <= $end; $i++){ echo 'currentPage) echo " class='active'"; echo '>'.$i.'(current)'; } //next link button if($this->textNav&&($this->currentPage<$this->total)){ echo '
  • '; } $html .= '
'; return $html; } /** * return item select box * * @author The-Di-Lab * @access public * @return string */ private function _getItemSelect() { $items = ''; $ippArray = $this->itemSelect; foreach($ippArray as $ippOpt){ $items .= ($ippOpt == $this->itemsPerPage) ? "\n":"\n"; } return "".$this->_navigation['ipp']." \n"; } private function _remove_pagination_from_url(){ $url_vars_parts = array(); $url_vars_parts = explode("&",$this->_url_vars); $url_vars_parts_clean = array(); for($i = 0; $i < count($url_vars_parts); ++$i) { if (strpos($url_vars_parts[$i], 'page=') === false) $url_vars_parts_clean[] = $url_vars_parts[$i]; } //print_r($url_vars_parts_clean); $this->_url_vars = implode("&",$url_vars_parts_clean); } } ?>