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 7d32403de..e653afbb9 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
@@ -38,47 +38,52 @@ class Pagination{
$max = 'limit ' .($this->current- 1) * $page_rows .',' .$page_rows;
//This is your query again, the same one... the only difference is we add $max into it
- $data = $dbl->executeWithoutParams($query . $max);
+ $data = $db->executeWithoutParams($query . " " . $max);
$this->element_array = Array();
//This is where we put the results in a resultArray to be sent to smarty
while($row = $data->fetch(PDO::FETCH_ASSOC)){
$element = new $resultClass();
- $element.set($row);
+ $element->set($row);
$this->element_array[] = $element;
}
}
}
- function getLast(){
+ public function getLast(){
return $this->last;
}
- function getElements(){
+ public function getElements(){
return $this->element_array;
}
- function getPagination($nrOfLinks){
+ 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 = 1; $var <= $this->last; $var++){
+ for($var = 2; $var <= $this->last; $var++){
$pageLinks[] = $var;
}
}else{
- $pageLinks[] = 1;
- $offset = (ceil($nrOfLinks/2)-1);
+ $offset = ($nrOfLinks-3)/2 ;
+ print "offset:" . $offset . "";
$startpoint = $this->current - $offset;
$endpoint = $this->current + $offset;
+ print "startpointX:" . $startpoint . "";
if($startpoint < 2){
$startpoint = 2;
- $endpoint = $startpoint + $nrOfLinks - 2;
- }else if($endpoint > $this->last){
- $endpoint = $this->last;
- $startpoint = $this->last - $nrOfLinks -2;
+ $endpoint = $startpoint + $nrOfLinks - 3;
+ }else if($endpoint > $this->last-1){
+ $endpoint = $this->last-1;
+ $startpoint = $endpoint - ($nrOfLinks -3);
}
+ print "startpoint:" . $startpoint . "";
+ print "endpoint:" . $endpoint . "";
for($var = $startpoint; $var <= $endpoint; $var++){
$pageLinks[] = $var;
}
diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/querycache.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/querycache.php
new file mode 100644
index 000000000..9ca6c627d
--- /dev/null
+++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/querycache.php
@@ -0,0 +1,83 @@
+setSID($values['SID']);
+ $this->setType($values['type']);
+ $this->setQuery($values['query']);
+ $this->setDb($values['db']);
+ }
+
+
+ //return constructed element based on SID
+ public function load_With_SID( $id) {
+ $dbl = new DBLayer("lib");
+ $statement = $dbl->execute("SELECT * FROM ams_querycache WHERE SID=:id", array('id' => $id));
+ $row = $statement->fetch();
+ $this->set($row);
+ }
+
+
+ //update private data to DB.
+ public function update(){
+ $dbl = new DBLayer("lib");
+ $query = "UPDATE ams_querycache SET type= :t, query = :q, db = :d WHERE SID=:id";
+ $values = Array('id' => $this->getSID(), 't' => $this->getType(), 'q' => $this->getQuery(), 'd' => $this->getDb());
+ $statement = $dbl->execute($query, $values);
+ }
+
+ ////////////////////////////////////////////Getters////////////////////////////////////////////////////
+
+ public function getSID(){
+ return $this->SID;
+ }
+
+
+ public function getType(){
+ return $this->type;
+ }
+
+
+ public function getQuery(){
+ return $this->query;
+ }
+
+ public function getDb(){
+ return $this->db;
+ }
+
+ ////////////////////////////////////////////Setters////////////////////////////////////////////////////
+
+ public function setSID($s){
+ $this->SID = $s;
+ }
+
+
+ public function setType($t){
+ $this->type = $t;
+ }
+
+ public function setQuery($q){
+ $this->query= $q;
+ }
+
+ public function setDb($d){
+ $this->db= $d;
+ }
+
+}
\ No newline at end of file
diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php
index 037440d72..7f0bfc4a0 100644
--- a/code/ryzom/tools/server/ryzom_ams/www/config.php
+++ b/code/ryzom/tools/server/ryzom_ams/www/config.php
@@ -19,7 +19,7 @@ $cfg['db']['lib']['name'] = 'ryzom_ams_lib';
$cfg['db']['lib']['user'] = 'shard';
$cfg['db']['lib']['pass'] = '';
-$cfg['db']['shard']['host'] = 'localhost';
+$cfg['db']['shard']['host'] = 'localhosti';
$cfg['db']['shard']['port'] = '3306';
$cfg['db']['shard']['name'] = 'nel';
$cfg['db']['shard']['user'] = 'shard';
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 b83b59f01..5748e3fb6 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
@@ -3,52 +3,20 @@
function libuserlist(){
if(Ticket_User::isAdmin($_SESSION['ticket_user'])){
- //This checks to see if there is a page number. If not, it will set it to page 1
- if (!(isset($_GET['pagenum']))){
- $pagenum = 1;
- }else{
- $pagenum = $_GET['pagenum'];
- }
- //Here we count the number of results
- $dbl = new DBLayer("lib");
- $rows = $dbl->executeWithoutParams("SELECT * FROM ams_querycache")->rowCount();
-
- //the array hat will contain all users
- $pageResult['liblist'] = Array();
- if($rows > 0){
- //This is the number of results displayed per page
- $page_rows = 2;
-
- //This tells us the page number of our last page
- $last = ceil($rows/$page_rows);
-
- //this makes sure the page number isn't below one, or more than our maximum pages
- if ($pagenum < 1)
- {
- $pagenum = 1;
- }else if ($pagenum > $last) {
- $pagenum = $last;
- }
-
- //This sets the range to display in our query
- $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
-
- //This is your query again, the same one... the only difference is we add $max into it
- $data = $dbl->executeWithoutParams("SELECT * FROM ams_querycache $max");
-
- //This is where we put the results in a resultArray to be sent to smarty
-
- $i = 0;
- while($row = $data->fetch(PDO::FETCH_ASSOC)){
- $decode = json_decode($row['query']);
- $pageResult['liblist'][$i]['id'] = $row['SID'];
- $pageResult['liblist'][$i]['type'] = $row['type'];
- //$pageResult['liblist'][$i]['name'] = $decode[0];
- //$pageResult['liblist'][$i]['mail'] = $decode[2];
- $i++;
- }
- }
+ $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;
//check if shard is online
try{
diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php
index a43198ae7..b14cbb40c 100644
--- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php
+++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php
@@ -1,6 +1,6 @@