From e32653bace9bc4d0dc31a1c51d8d2a1a71725d96 Mon Sep 17 00:00:00 2001 From: Baptiste D Date: Thu, 9 Nov 2023 10:13:56 +0100 Subject: [PATCH] =?UTF-8?q?correction=20bug=20vue=20offres=20&=20ajout=20l?= =?UTF-8?q?ien=20vers=20d=C3=A9tail=20fonctionnel?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/src/controleur/UtilisateurControleur.php | 19 ++++++++++--------- php/src/metier/Offre.php | 2 +- php/src/modele/OffreModele.php | 16 +++++++++------- php/templates/offres.html | 3 ++- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/php/src/controleur/UtilisateurControleur.php b/php/src/controleur/UtilisateurControleur.php index 32779df..91f93f2 100755 --- a/php/src/controleur/UtilisateurControleur.php +++ b/php/src/controleur/UtilisateurControleur.php @@ -18,7 +18,7 @@ class UtilisateurControleur global $twig; if (!isset($_REQUEST["action"])) { //$action = NULL; - $action = "creerOffre"; + $action = "consultOffers"; } else { $action = \App\config\Validation::nettoyerString($_REQUEST["action"]); } @@ -33,8 +33,8 @@ class UtilisateurControleur case "inscription": $this->inscription(); break; - case "consulterOffres": - $this->consulterOffres(); + case "consultOffers": + $this->consultOffers(); break; case "consulterProfilLimite": $this->consulterProfilLimite(); @@ -103,15 +103,15 @@ class UtilisateurControleur //TODO } - protected function consulterOffres() + protected function consultOffers() { - $offreMdl = new OffreModele(); + $offerMdl = new OffreModele(); global $twig; $twig->addExtension(new TwigExtensions()); // Ajouter l'extension personnalisée à l'environnement Twig - $offres = $offreMdl->getOffers(); - echo $twig->render('offreDetail.html', []); - //echo $twig->render('offres.html', ['offres' => $offres]); + $offers = $offerMdl->getOffers(); + + echo $twig->render('offres.html', ['offres' => $offers]); } protected function creerOffre() @@ -129,7 +129,7 @@ class UtilisateurControleur } } if (isset($_FILES['image'])) { - $typesMime = array('image/jpeg', 'image/png', 'image/gif', 'image/bmp'); + $typesMime = array('image/jpeg', 'image/png', 'image/gif', 'image/bmp','image/webp'); $file = $_FILES['image']['tmp_name']; @@ -178,6 +178,7 @@ class UtilisateurControleur if($offre != NULL) { echo $twig->render("OffreDetailTest.html",['offre' => $offre]); + return; } } diff --git a/php/src/metier/Offre.php b/php/src/metier/Offre.php index 0c47fbb..fde551f 100755 --- a/php/src/metier/Offre.php +++ b/php/src/metier/Offre.php @@ -185,7 +185,7 @@ class Offre return $this->description; } - public function getImgId(): int + public function Id(): int { return $this->img->getId(); } diff --git a/php/src/modele/OffreModele.php b/php/src/modele/OffreModele.php index 3c814f0..d795f0a 100644 --- a/php/src/modele/OffreModele.php +++ b/php/src/modele/OffreModele.php @@ -67,8 +67,8 @@ class OffreModele public function getOffers() : array { $res = $this->offreGw->getOffers(); - $offres[] = $this->CreateOffers($res); - return $offres; + $offers = $this->CreateOffers($res); + return $offers; } @@ -89,16 +89,16 @@ class OffreModele $alGw = new AlumniGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); $imgGw = new ImageGateway(new Connection("mysql:host=localhost;dbname=dbAlica", "test", "test")); - $offres=[]; + $offers=[]; foreach ($res as $row) { - $res = $imgGw->obtenirParId($row['image']); - $img = new Image(intval($res[0]["id"]),$res[0]['nom'], $res[0]['taille'], $res[0]['type'], $res[0]['blob']); + $imgRaw = $imgGw->obtenirParId($row['image']); + $img = new Image(intval($imgRaw[0]["id"]),$imgRaw[0]['nom'], $imgRaw[0]['taille'], $imgRaw[0]['type'], $imgRaw[0]['blob']); $resal = $alGw->ObtenirParId($row['offreur']); $alumni = new Alumni($resal[0]['id'],$resal[0]['mail'],$resal[0]['mdp'],$resal[0]['role']); - $offres[]=new Offre($row['id'], + $offers[]=new Offre($row['id'], $alumni, $row['titre'], $row['description'], @@ -115,7 +115,9 @@ class OffreModele $row['websiteURL'], $row['remote']); } - return $offres; + + + return $offers; } diff --git a/php/templates/offres.html b/php/templates/offres.html index ecdd654..47d1781 100644 --- a/php/templates/offres.html +++ b/php/templates/offres.html @@ -64,7 +64,8 @@
- +