0byt3m1n1
Path:
/
home1
/
aserty
/
public_html
/
appartsoft.info
/
wp-content
/
plugins
/
phpBay
/
includes
/
[
Home
]
File: pagination.class.php
<?php class pb_pagination{ var $total_pages = -1; var $limit = null; var $target = ""; var $page = 1; var $adjacents = 100; var $showCounter = false; var $className = "pb_pagination"; var $parameterName = "page"; var $urlF = false; var $nextT = PB_TEMP_PAGING_NEXT; var $nextI = "»"; //► var $prevT = PB_TEMP_PAGING_PREVIOUS; var $prevI = "«"; //◄ var $jskw = ""; var $calculate = false; #Total items function items($value){$this->total_pages = (int) $value;} #how many items to show per page function limit($value){$this->limit = (int) $value;} #Page to sent the page value function target($value){$this->target = $value;} #Current page function currentPage($value){$this->page = (int) $value;} #How many adjacent pages should be shown on each side of the current page? function adjacents($value){$this->adjacents = (int) $value;} #show counter? function showCounter($value=""){$this->showCounter=($value===true)?true:false;} #to change the class name of the pagination div function changeClass($value=""){$this->className=$value;} function nextLabel($value){$this->nextT = $value;} function nextIcon($value){$this->nextI = $value;} function prevLabel($value){$this->prevT = $value;} function prevIcon($value){$this->prevI = $value;} #to change the class name of the pagination div function parameterName($value=""){$this->parameterName=$value;} #to change urlFriendly function urlFriendly($value="%"){ if(eregi('^ *$',$value)){ $this->urlF=false; return false; } $this->urlF=$value; } var $pagination; function pagination(){} function show(){ if(!$this->calculate) if($this->calculate()) echo '<div class="' . $this->className . '">' . $this->pagination . '</div>'; } function getOutput(){ if(!$this->calculate) if($this->calculate()) return '<div class="' . $this->className . '">' . $this->pagination . '</div>'; } function get_pagenum_link($id){ return "javascript:Page_" . $this->jskw . "(" . $id . ")"; } function calculate(){ $this->pagination = ""; $this->calculate == true; $n = trim($this->nextT.' '.$this->nextI); $p = trim($this->prevI.' '.$this->prevT); if($this->page) $start = ($this->page - 1) * $this->limit; else $start = 0; $prev = $this->page - 1; $next = $this->page + 1; $lastpage = ceil($this->total_pages/$this->limit); $lpm1 = $lastpage - 1; if($lastpage > 1){ if($this->page){ if($this->page > 1) $this->pagination .= '<a href="' . $this->get_pagenum_link($prev) . '" class="prev">' . $p . '</a>'; else $this->pagination .= '<span class="disabled">' . $p . '</span>'; } if ($lastpage < 7 + ($this->adjacents * 2)){ for ($counter = 1; $counter <= $lastpage; $counter++){ if ($counter == $this->page) $this->pagination .= '<span class="current">' . $counter . '</span>'; else $this->pagination .= '<a href="' . $this->get_pagenum_link($counter) . '">' . $counter . '</a>'; } } elseif($lastpage > 5 + ($this->adjacents * 2)){ if($this->page < 1 + ($this->adjacents * 2)){ for ($counter = 1; $counter < 4 + ($this->adjacents * 2); $counter++){ if ($counter == $this->page) $this->pagination .= '<span class="current">' . $counter . '</span>'; else $this->pagination .= '<a href="' . $this->get_pagenum_link($counter) . '">' . $counter . '</a>'; } $this->pagination .= '...'; $this->pagination .= '<a href="' . $this->get_pagenum_link($lpm1) . '">' . $lpm1 . '</a>'; $this->pagination .= '<a href="' . $this->get_pagenum_link($lastpage) . '">' . $lastpage . '</a>'; } elseif($lastpage - ($this->adjacents * 2) > $this->page && $this->page > ($this->adjacents * 2)){ $this->pagination .= '<a href="' . $this->get_pagenum_link(1) . '">1</a>'; $this->pagination .= '<a href="' . $this->get_pagenum_link(2) . '">2</a>'; $this->pagination .= "..."; for ($counter = ($this->page - $this->adjacents); ($counter <= $this->page + $this->adjacents); $counter++) if ($counter == $this->page) { $this->pagination .= '<span class="current">' . $counter . '</span>'; } elseif ($counter > $this->page) { $this->pagination .= '<a href="' . $this->get_pagenum_link($counter) . '">' . $counter . '</a>'; } $this->pagination .= '...'; $this->pagination .= '<a href="' . $this->get_pagenum_link($lpm1) . '">' . $lpm1 . '</a>'; $this->pagination .= '<a href="' . $this->get_pagenum_link($lastpage) . '">' . $lastpage . '</a>'; } else { $this->pagination .= '<a href="' . $this->get_pagenum_link(1) . '">1</a>'; $this->pagination .= '<a href="' . $this->get_pagenum_link(2) . '">2</a>'; $this->pagination .= "..."; for ($counter = $lastpage - (2 + ($this->adjacents * 2)); $counter <= $lastpage; $counter++) if ($counter == $this->page) $this->pagination .= '<span class="current">' . $counter . '</span>'; else $this->pagination .= '<a href="' . $this->get_pagenum_link($counter) . '">' . $counter . '</a>'; } } if($this->page){ if ($this->page < $counter - 1) $this->pagination .= '<a href="' . $this->get_pagenum_link($next) . '" class="next">' . $n . '</a>'; else $this->pagination .= '<span class="disabled">' . $n . '</span>'; if($this->showCounter)$this->pagination .= '<div class="pagination_data">(' . $this->total_pages . ' Pages)</div>'; } } return true; } } ?>