summaryrefslogtreecommitdiffstats
path: root/library/Pbs/Pagination.php
diff options
context:
space:
mode:
authorSimon2011-04-04 15:20:51 +0200
committerSimon2011-04-04 15:20:51 +0200
commita3e623e49336f6b07f7b7cb5ef39045469536b26 (patch)
tree1de41d5fe31d5018701039530aa90575db66d0c9 /library/Pbs/Pagination.php
parentgraphische auswertung der datenbank (diff)
downloadpbs2-a3e623e49336f6b07f7b7cb5ef39045469536b26.tar.gz
pbs2-a3e623e49336f6b07f7b7cb5ef39045469536b26.tar.xz
pbs2-a3e623e49336f6b07f7b7cb5ef39045469536b26.zip
Pagination angepasst
Diffstat (limited to 'library/Pbs/Pagination.php')
-rw-r--r--library/Pbs/Pagination.php50
1 files changed, 48 insertions, 2 deletions
diff --git a/library/Pbs/Pagination.php b/library/Pbs/Pagination.php
index 179f2f7..2213373 100644
--- a/library/Pbs/Pagination.php
+++ b/library/Pbs/Pagination.php
@@ -1,8 +1,24 @@
<?php
-class Pbs_Pagination{
- public function pagination($url,$selected,$max){
+class Pbs_Pagination{
+
+ private $element;
+ private $perpage;
+ private $requestpage;
+ private $maxNumber;
+ private $numpages;
+ private $pageUrl;
+
+ public function pagination($url=null,$selected=null,$max=null){
+ if($selected == null)
+ $selected = $this->requestpage;
+ if($max == null)
+ $max = $this->numpages;
+ if($url == null)
+ $url = $this->pageUrl;
+
#print_a($url,$selected,$max);
+
$str = "<div class='pbs_pagination'>";
if ( 1 <= $selected){
$str .= "<a href='$url/page/0' >&lt;&lt;</a>";
@@ -33,6 +49,36 @@ class Pbs_Pagination{
$str .= "</div>";
return $str;
}
+ public function setPerPage($perpage){
+ $this->perpage = $perpage;
+ }
+ public function getPerPage(){
+ return $this->perpage;
+ }
+ public function setRequestPage($requestpage){
+ if($requestpage < 0 || !is_numeric($requestpage) )
+ $requestpage = 0;
+ if($rrequestpage >= $this->numpages)
+ $requestpage = $this->numpages-1;
+ $this->requestpage = $requestpage;
+ }
+ public function getRequestPage(){
+ return $this->requestpage;
+ }
+ public function setElement($element){
+ $this->element = $element;
+ $this->maxNumber = count($element);
+ $this->numpages = ceil(count($element)/$this->perpage);
+ }
+ public function getStartItem(){
+ return $this->requestpage * $this->perpage;
+ }
+ public function getElements(){
+ return array_slice($this->element,$this->getStartItem(),$this->getPerPage());
+ }
+ public function setPageUrl($url){
+ $this->pageUrl = $url;
+ }
}