From d672c5132c5f94193c001b40b11f25f86c07c1ce Mon Sep 17 00:00:00 2001 From: Emre KARTAL Date: Fri, 2 Dec 2022 21:03:50 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lioration=20du=20visuel,=20Navbar=20r?= =?UTF-8?q?=C3=A9aliser=20pour=20qu=20il=20s=20adapte=20=C3=A0=20l=20utili?= =?UTF-8?q?sateur=20et=20le=20visiteur,=20le=20modele=20et=20controleur=20?= =?UTF-8?q?est=20maintenant=20bien=20structurer,=20le=20probl=C3=A8me=20re?= =?UTF-8?q?ste=20l=20autoload?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Controller/CtrlVisiteur.php | 132 ++++++++++++++++-------------- src/Modele/Classe/Liste.php | 13 +-- src/Modele/ListeGateway.php | 24 +++--- src/Modele/Modele.php | 34 ++++++++ src/Modele/ModeleUtilisateur.php | 28 ------- src/Modele/TacheGateway.php | 10 +-- src/Modele/UtilisateurGateway.php | 1 + src/Vue/css/inscription.css | 13 --- src/Vue/css/style.css | 2 +- src/Vue/html/NavBar.php | 43 +++++++--- src/Vue/html/PageListePublic.php | 99 ++++++++++++++++------ src/Vue/html/inscription.php | 92 +++++++++++---------- src/Vue/html/login.php | 11 +-- src/config/Validation.php | 2 +- src/config/config.php | 8 +- 15 files changed, 290 insertions(+), 222 deletions(-) create mode 100644 src/Modele/Modele.php delete mode 100644 src/Modele/ModeleUtilisateur.php delete mode 100644 src/Vue/css/inscription.css diff --git a/src/Controller/CtrlVisiteur.php b/src/Controller/CtrlVisiteur.php index 8130c0f..7ceded9 100644 --- a/src/Controller/CtrlVisiteur.php +++ b/src/Controller/CtrlVisiteur.php @@ -5,93 +5,101 @@ class CtrlVisiteur { function __construct() { global $rep,$vues; - + $dVueEreur = array (); try{ - $action=NULL; - if(isset($_REQUEST['action'])){ - $action = $_REQUEST["action"]; - } + $action=NULL; + if(isset($_REQUEST['action'])){ + $action = $_REQUEST["action"]; + } - switch($action) { + switch($action) { - //pas d'action, on réinitialise 1er appel - case NULL: - $this->Reinit(); - break; + //pas d'action, on réinitialise 1er appel + case NULL: + $this->Reinit(); + break; - case "validationFormulaire": - $this->ValidationFormulaire($dVueEreur); - break; + case "validationFormulaire": + $this->ValidationFormulaire($dVueEreur); + break; - case "redirectionLogin": - $this->redirectionLogin($dVueEreur); - break; + case "seConnecter": + $this->seConnecter($dVueEreur); + break; - case "redirectionInscription": - $this->redirectionInscription($dVueEreur); - break; + case "redirectionListePublic": + $this->ConsulterListePublic($dVueEreur); + break; - case "seConnecter": - $this->seConnecter($dVueEreur); - break; + case "redirectionLogin": + $this->redirectionLogin($dVueEreur); + break; - case "ConsulterListe": - $this->ConsulterListe(); - break; + case "redirectionInscription": + $this->redirectionInscription($dVueEreur); + break; - //mauvaise action - default: - $dVueEreur[] = "Erreur d'appel php"; - require ($rep.$vues['home']); - break; - } + //mauvaise action + default: + $dVueEreur[] = "Erreur d'appel php"; + require ($rep.$vues['home']); + break; + } - } catch (PDOException $e) - { - //si erreur BD, pas le cas ici - $dVueEreur[] = "Erreur inattendue!!! "; - require ($rep.$vues['erreur']); + } catch (PDOException $e) + { + //si erreur BD, pas le cas ici + $dVueEreur[] = "Erreur inattendue!!! "; + require ($rep.$vues['erreur']); - } - catch (Exception $e2) - { + } + catch (Exception $e2) + { $dVueEreur[] = "Erreur inattendue!!! "; require ($rep.$vues['erreur']); - } + } - //fin - exit(0); - }//fin constructeur + //fin + exit(0); + }//fin constructeur - function Reinit() { - global $rep,$vues; - require ($rep.$vues['login']); - } + function Reinit() { + global $rep,$vues; + require ($rep.$vues['listPublic']); + } - function ValidationFormulaire(array $dVueEreur) { - require ($rep.$vues['inscription']); - } + function ValidationFormulaire(array $dVueEreur) { + global $rep,$vues; + Modele::CreerUtilisateur(); + require ($rep.$vues['login']); + } - function redirectionLogin(array $dVueEreur) { - require ($rep.$vues['login']); - } + function redirectionLogin(array $dVueEreur) { + global $rep,$vues; + require ($rep.$vues['login']); + } - function redirectionInscription(array $dVueEreur) { - require ($rep.$vues['inscription']); - } + function redirectionInscription(array $dVueEreur) { + global $rep,$vues; + require ($rep.$vues['inscription']); + } - function seConnecter(array $dVueEreur) { - require ($rep.$vues['login']); - } + function seConnecter(array $dVueEreur) { + global $rep,$vues; + require ($rep.$vues['login']); + } + + function ConsulterListePublic(array $dVueEreur) { + global $rep,$vues; + Modele::RecupererListePublic(); + require ($rep.$vues['listPublic']); + } - function ConsulterListe(){ - require ($rep.$vues['listeVue']); - } }//fin class diff --git a/src/Modele/Classe/Liste.php b/src/Modele/Classe/Liste.php index f3ba958..0045625 100644 --- a/src/Modele/Classe/Liste.php +++ b/src/Modele/Classe/Liste.php @@ -6,17 +6,18 @@ class Liste { private $id; private $nom; + private $description; private $dateCreation; private $estPublic; - private $idUser; + private $idUtilisateur; - public function __construct($id, $nom, $dateCreation, $estPublic, $idUser){ + public function __construct($id, $nom, $description, $dateCreation, $estPublic, $idUser){ $this->id = $id; $this->nom = $nom; $this->description = $description; $this->dateCreation = $dateCreation; $this->estPublic = $estPublic; - $this->idUser = $idUser; + $this->idUtilisateur = $idUtilisateur; } //Id @@ -55,13 +56,13 @@ class Liste $this->estPublic = $estPublic; } - //IdUser + //idUtilisateur public function getIdUser(){ - return $this->idUser; + return $this->idUtilisateur; } public function setIdUser($idUser){ - $this->idUser = $idUser; + $this->idUtilisateur = $idUtilisateur; } } diff --git a/src/Modele/ListeGateway.php b/src/Modele/ListeGateway.php index 04fb9e5..3f81c2c 100644 --- a/src/Modele/ListeGateway.php +++ b/src/Modele/ListeGateway.php @@ -2,28 +2,27 @@ class ListeGateway{ private $con; - public function __construct(Connection $con){ - $this->con=$con; + public function __construct(){ + $this->con=new Connection($dsn,$user,$pass); } public function Ajouter(string $nom, Date $dateCreation, bool $estValide, int $idCreateur, bool $estPublic){ $query='INSERT INTO ToDoList_Liste(nom, dateCreation,estValide, createur, estPublic) VALUES(:nom, :dateCreation, :estValide, :idCreateur, :estPublic)'; $this->con->executeQuery($query, array('nom' => array($nom, PDO::PARAM_STRING)), - array('dateCreation' => array($dateCreation, PDO::PARAM_STRING)), - array('estValide' => array($estValide, PDO::PARAM_BOOL)), - array('idCreateur' => array($idCreateur, PDO::PARAM_INT)), - array('estPublic' => array($estPublic, PDO::PARAM_INT)) - ) + array('dateCreation' => array($dateCreation, PDO::PARAM_STRING)), + array('estValide' => array($estValide, PDO::PARAM_BOOL)), + array('idCreateur' => array($idCreateur, PDO::PARAM_INT)), + array('estPublic' => array($estPublic, PDO::PARAM_INT))); } - public function Editer(Liste $Liste, string $nom,){ + public function Editer(Liste $Liste){ $query='UPDATE ToDoListe_Liste SET nom=:nom WHERE id=:id'; $this->con->executeQuery($query, array('nom' => array($Liste->getNom(), PDO::PARAM_STRING)), array('id' => array($Liste->getId()),PDO::PARAM_INT)); } public function Supprimer(int $id){ $query='DELETE FROM ToDoListe_Liste WHERE id=:id'; - $this->con->executeQuery($query,'id' => array($id, PDO::PARAM_STRING))); + $this->con->executeQuery($query,array('id' => array($id, PDO::PARAM_STRING))); } public function getListe(int $offset, int $limit){ @@ -43,8 +42,11 @@ class ListeGateway{ public function getListePublic($offset,$limit){ $query = "SELECT * FROM ToDoListe_Liste AND estPublic LIMITS $offset,$limit"; $this->con->executeQuery($query); - $results=$this->con->getResults(); - return $results; + $tab = []; + foreach ($this->con->getResults() as $liste) { + $tab[] = new Liste($liste["id"],$liste["nom"],$liste["description"],$liste["dateCreation"],$liste["estPublic"],$liste["idUtilisateur"]); + } + return $tab; } } ?> \ No newline at end of file diff --git a/src/Modele/Modele.php b/src/Modele/Modele.php new file mode 100644 index 0000000..5c1e65b --- /dev/null +++ b/src/Modele/Modele.php @@ -0,0 +1,34 @@ +AjouterUtilisateur($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["mail-Form"],$_POST["password-Form"]); + } + + public static function RecupererListePublic(){ + $userGtw = new UtilisateurGateway(); + + $userGtw->getListePublic(); + } + + + + + + +} diff --git a/src/Modele/ModeleUtilisateur.php b/src/Modele/ModeleUtilisateur.php deleted file mode 100644 index f1a22f6..0000000 --- a/src/Modele/ModeleUtilisateur.php +++ /dev/null @@ -1,28 +0,0 @@ -AjouterUtilisateur(); - } - - - - - - - -} diff --git a/src/Modele/TacheGateway.php b/src/Modele/TacheGateway.php index 4a9ad67..28c98c3 100644 --- a/src/Modele/TacheGateway.php +++ b/src/Modele/TacheGateway.php @@ -1,8 +1,8 @@ con=$con; + public function __construct(){ + $this->con=new Connection($dsn,$user,$pass); } public function Ajouter(string $nom, string $description, Date $dateCreation, bool $estValide, int $idCreateur){ @@ -11,17 +11,17 @@ class TacheGateway{ array('description' => array($description, PDO::PARAM_STRING)), array('dateCreation' => array($dateCreation, PDO::PARAM_STRING)), array('estValide' => array($estValide, PDO::PARAM_BOOL)), - array('idCreateur' => array($idCreateur, PDO::PARAM_INT))) + array('idCreateur' => array($idCreateur, PDO::PARAM_INT))); } public function Editer(Tache $tache, string $nom, string $description){ $query='UPDATE ToDoListe_Tache SET nom=:nom, description =:description WHERE id=:id'; - $this->con->executeQuery($query, array('nom' => array($tache->getNom(), PDO::PARAM_STRING)), array('description' => array($tache->getdescription(), PDO::PARAM_STRING)), array('id' => array($tache->getId()),PDO::PARAM_INT)); + $this->con->executeQuery($query, array('nom' => array($tache->getNom(), PDO::PARAM_STRING)), array('description' => array($tache->getdescription(), PDO::PARAM_STRING)), array('id' => array($tache->getId(),PDO::PARAM_INT))); } public function Supprimer(Tache $tache){ $query='DELETE FROM ToDoList_Tache WHERE id=:id'; - $this->con->executeQuery($query,'id' => array($tache->getId(), PDO::PARAM_STRING))); + $this->con->executeQuery($query,'id' => array($tache->getId(), PDO::PARAM_STRING)); } } ?> \ No newline at end of file diff --git a/src/Modele/UtilisateurGateway.php b/src/Modele/UtilisateurGateway.php index fcd6e9c..5b34fd5 100644 --- a/src/Modele/UtilisateurGateway.php +++ b/src/Modele/UtilisateurGateway.php @@ -1,5 +1,6 @@ con=new Connection($dsn,$user,$pass); diff --git a/src/Vue/css/inscription.css b/src/Vue/css/inscription.css deleted file mode 100644 index 2830096..0000000 --- a/src/Vue/css/inscription.css +++ /dev/null @@ -1,13 +0,0 @@ -body { - background: linear-gradient(to right, #B7FBFB,#38B6FF); - font-family: sans-serif; -} - -body::before { - content: ''; - position: absolute; - background: rgba(255,255,255, .15); - inset: 0; - transform: rotate(-5deg); - z-index: -1; -} diff --git a/src/Vue/css/style.css b/src/Vue/css/style.css index ec3da44..bb3129c 100644 --- a/src/Vue/css/style.css +++ b/src/Vue/css/style.css @@ -288,7 +288,7 @@ body::before { border-color: #38b6ff; height: 2rem; width: 5rem; - margin-left: 21rem; + margin-left: 1rem; margin-bottom: 1rem; font-size: 90%; align-items: center; diff --git a/src/Vue/html/NavBar.php b/src/Vue/html/NavBar.php index e8bc2ac..4a15ba8 100644 --- a/src/Vue/html/NavBar.php +++ b/src/Vue/html/NavBar.php @@ -1,21 +1,40 @@ -
-
+ + - \ No newline at end of file + diff --git a/src/Vue/html/PageListePublic.php b/src/Vue/html/PageListePublic.php index f457800..81ad260 100644 --- a/src/Vue/html/PageListePublic.php +++ b/src/Vue/html/PageListePublic.php @@ -1,38 +1,32 @@ - + - + Home Page - + + - - - + + - - - - + + $liste->getNom()"; + } + ?>