From f16876399586e48b23a35f6e30f07e3d4218c4cc Mon Sep 17 00:00:00 2001 From: bastien ollier Date: Fri, 16 Dec 2022 21:34:45 +0100 Subject: [PATCH] add nb article par page --- controllers/ControllerAdmin.php | 2 ++ controllers/FrontController.php | 8 ++++---- gateways/GatewayConfigAdmin.php | 2 +- vues/administration.php | 8 ++++++++ 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/controllers/ControllerAdmin.php b/controllers/ControllerAdmin.php index b693924..1fe2132 100644 --- a/controllers/ControllerAdmin.php +++ b/controllers/ControllerAdmin.php @@ -19,6 +19,8 @@ class ControllerAdmin { case "goToAdministration": $gatewaySources = new GatewaySources(new Connection($dsn,$user,$pass)); $listeSources = $gatewaySources->getSources(); + $gate = new GatewayConfigAdmin(new Connection($dsn, $user, $pass)); + $nbArticlePages = $gate->getConfigAdmin(1); require($vues['administration']); break; case "refreshData": diff --git a/controllers/FrontController.php b/controllers/FrontController.php index 9965012..1d5205b 100644 --- a/controllers/FrontController.php +++ b/controllers/FrontController.php @@ -26,13 +26,13 @@ class FrontController{ if(isset($_GET['page'])){ $page = $_GET['page']; } - $listeNews = $gatewayNews->getNews($page,10); + $gate = new GatewayConfigAdmin(new Connection($dsn, $user, $pass)); + $nbArticlePages = $gate->getConfigAdmin(1); + $listeNews = $gatewayNews->getNews($page,$nbArticlePages); $pageAvant = $page - 1; $pageApres = $page + 1; - $gate = new GatewayConfigAdmin(new Connection($dsn, $user, $pass)); - $nbArticlePages = $gate->getConfigAdmin(1); - var_dump($nbArticlePages); + $pageMAX = $gatewayNews->getNbNews()/$nbArticlePages + 1; require($vues['listeNews']); } diff --git a/gateways/GatewayConfigAdmin.php b/gateways/GatewayConfigAdmin.php index d9604ca..1d9e1cf 100644 --- a/gateways/GatewayConfigAdmin.php +++ b/gateways/GatewayConfigAdmin.php @@ -11,7 +11,7 @@ class GatewayConfigAdmin public function getConfigAdmin($idConfig) { $query = "SELECT * FROM configadmin WHERE :idConfig;"; - $this->con->executeQuery($query, array(':idConfig' => array($idConfig, PDO::PARAM_STR))); + $this->con->executeQuery($query, array(':idConfig' => array($idConfig, PDO::PARAM_INT))); $results=$this->con->getResults(); return $results[0]["value"]; } diff --git a/vues/administration.php b/vues/administration.php index 9b5289c..18748ed 100644 --- a/vues/administration.php +++ b/vues/administration.php @@ -34,5 +34,13 @@ +
+
+ '; + ?> + +
+
\ No newline at end of file