routeSQL : push on the last page if the values are too high

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2001 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-03-11 10:42:34 +00:00
parent a45db83b9e
commit 177c6bd1e8

View File

@@ -157,14 +157,17 @@ class routeSQL
$titles = $this->objectDB->titles (); $titles = $this->objectDB->titles ();
if ($page === null || $page === "") $page = 1; if ($page === null || $page === "") $page = 1;
if ($num === null || $num === "") $num = 10; if ($num === null || $num === "") $num = 10;
$page = intval ($page);
$num = intval ($num);
if ($num > 1000) if ($num > 1000)
$route->redirect ("/".$this->url_prefix."?page=$page&num=1000", ""); $route->redirect ("/".$this->url_prefix."?page=$page&num=1000", "");
if ($page < 1) if ($page < 1)
$route->redirect ("/".$this->url_prefix."?page=1&num=$num", ""); $route->redirect ("/".$this->url_prefix."?page=1&num=$num", "");
// TODO : Push on the last page // Push on the last page if the values are too high
if ($page*$num > count ($datas)) if ($page*$num > count ($datas))
{ {
$route->redirect ("/".$this->url_prefix, ""); $maxPage = intval(count ($datas)/$num);
$route->redirect ("/".$this->url_prefix."?page=$maxPage&num=$num", "");
} }
$content = $this->showflash (); $content = $this->showflash ();