From 8a66fc8e7bca6c8973353e557d4e65c31efa2d14 Mon Sep 17 00:00:00 2001 From: Björn Geiger Date: Tue, 5 Jul 2011 13:46:50 +0200 Subject: Notifier und Pagination hinzugefügt --- library/Poolctrl/Pagination.php | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 library/Poolctrl/Pagination.php (limited to 'library/Poolctrl/Pagination.php') diff --git a/library/Poolctrl/Pagination.php b/library/Poolctrl/Pagination.php new file mode 100644 index 0000000..7f1a596 --- /dev/null +++ b/library/Poolctrl/Pagination.php @@ -0,0 +1,98 @@ +requestpage; + if($max == null) + $max = $this->numpages; + if($url == null) + $url = $this->pageUrl; + + #print_a($url,$selected,$max); + + $str = "
"; + if ( 1 <= $selected){ + $str .= "<<"; + $str .= ""; + }else{ + $str .= "<<"; + $str .= "<"; + } + + # + $rightleft = 2; + for($i=0;$i<($max);$i++){ + if($selected == $i) + $str .= "".($i+1) ." "; + else if($i >= $selected -$rightleft && $i <= $selected+$rightleft) + $str .= "".($i+1) ." "; + } + + # + if ( $max-2 >= $selected){ + $str .= "> "; + $str .= ">> "; + }else{ + $str .= "> "; + $str .= ">> "; + } + + $str .= "
"; + return $str; + } + public function setPerPage($perpage){ + $this->perpage = $perpage; + return $this; + } + public function getPerPage(){ + return $this->perpage; + } + public function setRequestPage($requestpage){ + if($requestpage < 0 || !is_numeric($requestpage) ) + $requestpage = 0; + if($requestpage >= $this->numpages) + $requestpage = $this->numpages-1; + $this->requestpage = $requestpage; + return $this; + } + public function getRequestPage(){ + return $this->requestpage; + } + public function setElement($element){ + $this->element = $element; + $this->maxNumber = count($element); + $this->numpages = ceil(count($element)/$this->perpage); + return $this; + } + public function getStartItem(){ + return $this->requestpage * $this->perpage; + } + public function getElements(){ + return array_slice($this->element,$this->getStartItem(),$this->getPerPage(),true); + } + public function setPageUrl($url){ + $this->pageUrl = $url; + return $this; + } + +} + -- cgit v1.2.3-55-g7522