From e5d5cfe0cc77c7f019988090490472637a572848 Mon Sep 17 00:00:00 2001 From: Quitta Date: Mon, 5 Aug 2013 05:27:19 +0200 Subject: [PATCH] pagination seems to work! :) --- .../ryzom_ams/ams_lib/autoload/pagination.php | 33 +- .../ryzom_ams/www/html/inc/libuserlist.php | 19 +- .../tools/server/ryzom_ams/www/html/table.php | 704 ++++++++++++++++++ .../www/html/templates/libuserlist.tpl | 13 +- 4 files changed, 739 insertions(+), 30 deletions(-) diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php index e653afbb9..a4890f980 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/pagination.php @@ -5,6 +5,7 @@ class Pagination{ private $element_array; private $last; private $current; + private $amountOfRows; function __construct($query,$db,$nrDisplayed,$resultClass) { if (!(isset($_GET['pagenum']))){ @@ -16,7 +17,7 @@ class Pagination{ //Here we count the number of results $db = new DBLayer($db); $rows = $db->executeWithoutParams($query)->rowCount(); - + $this->amountOfRows = $rows; //the array hat will contain all users if($rows > 0){ @@ -55,39 +56,41 @@ class Pagination{ return $this->last; } + public function getCurrent(){ + return $this->current; + } public function getElements(){ return $this->element_array; } + public function getAmountOfRows(){ + return $this->amountOfRows; + } public function getLinks($nrOfLinks){ $pageLinks = Array(); - $pageLinks[] = 1; //if amount of showable links is greater than the amount of pages: show all! if ($this->last <= $nrOfLinks){ - for($var = 2; $var <= $this->last; $var++){ + for($var = 1; $var <= $this->last; $var++){ $pageLinks[] = $var; } }else{ - $offset = ($nrOfLinks-3)/2 ; - print "offset:" . $offset . ""; + $offset = ($nrOfLinks-1)/2 ; $startpoint = $this->current - $offset; $endpoint = $this->current + $offset; - print "startpointX:" . $startpoint . ""; - if($startpoint < 2){ - $startpoint = 2; - $endpoint = $startpoint + $nrOfLinks - 3; - }else if($endpoint > $this->last-1){ - $endpoint = $this->last-1; - $startpoint = $endpoint - ($nrOfLinks -3); + + if($startpoint < 1){ + $startpoint = 1; + $endpoint = $startpoint + $nrOfLinks - 1; + }else if($endpoint > $this->last){ + $endpoint = $this->last; + $startpoint = $endpoint - ($nrOfLinks -1); } - print "startpoint:" . $startpoint . ""; - print "endpoint:" . $endpoint . ""; + for($var = $startpoint; $var <= $endpoint; $var++){ $pageLinks[] = $var; } - $pageLinks[] = $this->last; } return $pageLinks; } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php index 5748e3fb6..66e8b9634 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/libuserlist.php @@ -4,19 +4,12 @@ function libuserlist(){ if(Ticket_User::isAdmin($_SESSION['ticket_user'])){ - $pagination = new Pagination("SELECT * FROM ams_querycache","lib",1,"Querycache"); - print "1 elements / page
"; - print "7 links max"; - print "

"; - print "last page="; - print_r($pagination->getLast()); - print "
----------------------------------------------
"; - print "elements:"; - print_r($pagination->getElements()); - print "
----------------------------------------------
"; - print "links:"; - print_r($pagination->getLinks(7)); - exit; + $pagination = new Pagination("SELECT * FROM ams_querycache","lib",2,"Querycache"); + $pageResult['liblist'] = Gui_Elements::make_table($pagination->getElements() , Array("getSID","getType"), Array("id","type")); + $pageResult['links'] = $pagination->getLinks(5); + $pageResult['lastPage'] = $pagination->getLast(); + $pageResult['currentPage'] = $pagination->getCurrent(); + //check if shard is online try{ diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/table.php b/code/ryzom/tools/server/ryzom_ams/www/html/table.php index d0eb7d815..0a023296c 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/table.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/table.php @@ -210,6 +210,710 @@ + + David R + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Chris Jack + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Jack Chris + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Muhammad Usman + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Sheikh Heera + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Helen Garner + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Saruar Ahmed + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + Ahemd Saruar + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + David R + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Chris Jack + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Jack Chris + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Muhammad Usman + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Sheikh Heera + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Helen Garner + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Saruar Ahmed + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + Ahemd Saruar + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + David R + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Chris Jack + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Jack Chris + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Muhammad Usman + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Sheikh Heera + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Helen Garner + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Saruar Ahmed + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + Ahemd Saruar + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + David R + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Chris Jack + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Jack Chris + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Muhammad Usman + 2012/01/01 + Member + + Active + + + + + View + + + + Edit + + + + Delete + + + + + Sheikh Heera + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Helen Garner + 2012/02/01 + Staff + + Banned + + + + + View + + + + Edit + + + + Delete + + + + + Saruar Ahmed + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + + + Ahemd Saruar + 2012/03/01 + Member + + Pending + + + + + View + + + + Edit + + + + Delete + + + Habib Rizwan 2012/01/21 diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl index 645de53f2..6c8f9af09 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/libuserlist.tpl @@ -46,7 +46,7 @@
- +
@@ -64,7 +64,16 @@ {/foreach} -
{$id}
+ +
+
    +
  • «
  • + {foreach from=$links item=link} +
  • {$link}
  • + {/foreach} +
  • »
  • +
+