From 0157af04c41afb71369a6c12e1e4228dc0d6fec5 Mon Sep 17 00:00:00 2001 From: machaonix Date: Mon, 29 Nov 2021 22:28:38 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9organisation=20du=20r=C3=A9pertoire?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Validation.php | 35 -------------- gateways/CompteGateway.php | 98 -------------------------------------- gateways/Gateway.php | 7 --- gateways/ListeGateway.php | 95 ------------------------------------ gateways/TacheGateway.php | 96 ------------------------------------- 5 files changed, 331 deletions(-) delete mode 100644 Validation.php delete mode 100644 gateways/CompteGateway.php delete mode 100644 gateways/Gateway.php delete mode 100644 gateways/ListeGateway.php delete mode 100644 gateways/TacheGateway.php diff --git a/Validation.php b/Validation.php deleted file mode 100644 index 18d2e9c..0000000 --- a/Validation.php +++ /dev/null @@ -1,35 +0,0 @@ -array("regexp"=>"([0-9]|([A-F]|[a-f])){6}"))); - } - public static function validerEffectuationTache($estFait) - { - return filter_var($estFait, FILTER_VALIDATE_BOOL); - } - - public static function netoyerEtValiderTache(string $nom, string $comm, string $couleur, $estFait) - { - $nom = self::netoyerNomTache($nom); - $comm = self::netoyerCommentaireTache($comm); - $couleurValide = self::validerCouleurTache($couleur); - $estFaitValide = self::validerEffectuationTache($estFait); - - return array( - 'nom' => $nom, - 'commentaire' => $comm, - 'couleur' => $couleurValide, - 'estFait' => $estFaitValide - ); - } -} diff --git a/gateways/CompteGateway.php b/gateways/CompteGateway.php deleted file mode 100644 index 1577ec4..0000000 --- a/gateways/CompteGateway.php +++ /dev/null @@ -1,98 +0,0 @@ -conn = $conn; - } - - public function inserer($itemAInserer) - { - if(get_class($itemAInserer) != "Compte") - { - throw new TypeError("L'élement à inserer doit être de type compte"); - } - - $requette = "INSERT INTO _Compte(pseudonyme, dateCreation, motDePasse) - VALUSES(:pseudo, :date, :mdp)"; - return $this->conn->executeQuerry($requette, [ - ":pseudo" => [$itemAInserer->getPseudonyme(), PDO::PARAM_STR], - ":date" => ["STR_TO_DATE(".$itemAInserer->getDateCreation().")", PDO::PARAM_STR], - ":mdp" => [$itemAInserer->getMotDePasse(), PDO::PARAM_STR] - ]); - } - - public function modifier($itemAModifier) - { - if(get_class($itemAInserer) != "Compte") - { - throw new TypeError("L'élement à modifier doit être de type compte"); - } - $requette = "UPDATE _Compte SET pseudonyme=:pseudo, dateCreation=:date, motDePasse=:mdp"; - return $this->conn->executeQuerry($requette, [ - ":pseudo" => [$itemAModifier->getPseudonyme(), PDO::PARAM_STR], - ":date" => [$itemAModifier->getDateCreation(), PDO::PARAM_STR], - ":mdp" => [$itemAModifier->getMotDePasse(), PDO::PARAM_STR] - ]); - - } - - public function supprimer($itemASupprimer) - { - if(get_class($itemAInserer) != "Compte") - { - throw new TypeError("L'élement à supprimer doit être de type compte"); - } - $requette = "DELETE FROM _Compte WHERE compteID=:id"; - return $this->conn->executeQuerry($requette, [ - ":id" => [$itemAModifier->getID(), PDO::PARAM_INT] - ]); - - } - - public function getCompteParPseudo(string $pseudo) : iterable - { - $requete = "SELECT * FROM _Compte WHERE pseudonyme=:pseudo"; - - if(!$this->conn->executeQuerry($requete, [":pseudo" => [$pseudo, PDO::PARAM_STR]])) - { - return array(); - } - $comptesSQL = $this->conn->getResults(); - $comptes = array(); - $listes = array(); - $requete = "SELECT * FROM _TodoList WHERE Createur=:id"; - - foreach($comptesSQL as $compte) - { - if(!$this->conn->executeQuerry($requete, [":id" => [$compte["compteID", PDO::PARAM_STR]])) - { - $listes = array(); - } - else - { - $listesSQL = $this->conn->getResults(); - foreach($listesSQL as $liste) - { - $listes[] = new TodoList( - $liste["listeID"], - $liste["nom"], - $liste["Createur"], - $liste["dateCreation"], - $liste["public"] - ); - } - } - $comptes[] = new Compte( - $compte["pseudonyme"], - $compte["dateCreation"], - $listes, - $compte["motDePasse"], - $compte["compteID"] - ); - return $comptes; - } - } -} diff --git a/gateways/Gateway.php b/gateways/Gateway.php deleted file mode 100644 index ebe6752..0000000 --- a/gateways/Gateway.php +++ /dev/null @@ -1,7 +0,0 @@ -conn = $conn; - } - - public function inserer($l) : bool - { - $requete = "INSERT INTO _TodoList(nom, dateCreation, public, createur) - VALUES(:nom, :date, :pub, :createur)"; - return $this->conn->executeQuery($requete, - ":nom" => [$l->getNom(), PDO::PARAM_STR], - ":date" => ["STR_TO_DATE(".$l->getDateCreation().")", PDO::PARAM_STR], - ":pub" => [$l->estPublic(), PDO::PARAM_BOOL], - ":createur" => [$l->getCreateur(), PDO::PARAM_INT] - ]); - } - - public function supprimer($l) : bool - { - $requete = "DELETE FROM _TodoList WHERE listeID=:id"; - return $this->conn->executeQuery($requete,[ - ":id"=>[$l->getID(), PDO::PARAM_INT] - ]); - } - - public function modifier($l) : bool - { - $requete="UPDATE _TodoList SET - nom=:n, public=:p"; - return $this->conn->executeQuery($requete, [ - ":n" => [$l->getNom(), PDO::PARAM_STR], - ":p" => [$l->estPublic(), PDO::PARAM_BOOL] - ]); - } - public function listeParDate(int $page, int $nbTache) : iterable - { - $lites = array(); - $requete = "SELECT * FROM _TodoList ORDER BY dateCreation LIMIT (:p -1)+:n, :n"; - $isOK=$this->conn->executeQuery($requete, [ - ":p" => [$page, PDO::PARAM_INT], - ":n" => [$nbTache, PDO::PARAM_INT] - ]); - if(!$isOK) - { - return array(); - } - - $res = $this->conn->getResults(); - - foreach($res as $liste) - { - $listes[] = new TodoList( - $liste["listeID"], - $liste["nom"], - $liste["Createur"], - $liste["dateCreation"], - $liste["public"] - ); - } - return $listes; - } - public function listeParNom() : iterable - { - $lites = array(); - $requete = "SELECT * FROM _TodoList ORDER BY nom LIMIT (:p -1)+:n, :n"; - $isOK=$this->conn->executeQuery($requete, [ - ":p" => [$page, PDO::PARAM_INT], - ":n" => [$nbTache, PDO::PARAM_INT] - ]); - if(!$isOK) - { - return array(); - } - - $res = $this->conn->getResults(); - - foreach($res as $liste) - { - $listes[] = new TodoList( - $liste["listeID"], - $liste["nom"], - $liste["Createur"], - $liste["dateCreation"], - $liste["public"] - ); - } - return $listes; - } -} diff --git a/gateways/TacheGateway.php b/gateways/TacheGateway.php deleted file mode 100644 index fe38d88..0000000 --- a/gateways/TacheGateway.php +++ /dev/null @@ -1,96 +0,0 @@ -conn = $conn; - } -//------------------------------ -// Méthodes pérsonalisées - - public function inserer($itemAInserer) - { - if(get_class($itemAInserer) != "Tache") - { - throw new TypeError("L'item à inserer doit être une Tache"); - } - $requette = "INSERT INTO _Tache(NomTache, TacheFaite, Commentaire, Couleur) VALUES( - :nom, :fait, :commentaire, :couleur - )"; - - return $this->conn->executeQuery($requette, [ - ':nom' => [$itemAInserer->nom, PDO::PARAM_STR], - ':fait'=> [$itemAInserer->estFait, PDO::PARAM_BOOL], - ':commentaire' => [$itemAInserer->commentaire, PDO::PARAM_STR], - ':couleur' => [$itemAInserer->couleur, PDO::PARAM_STR] - ]); - } - - public function modifier($itemAModifier) - { - if(get_class($itemAInserer) != "Tache") - { - throw new TypeError("L'item à modifier doit être une Tache"); - } - $requette = "UPDATE _Tache SET - NomTache = :nom, - Commentaire = :commentaire, - Couleur = :couleur, - TacheFaite = :fait - WHERE - tacheID = :id"; - return $this->conn->executeQuery($requette,[ - ':nom' => [$itemAModifier->nom, PDO::PRAM_STR], - ':commentaire' => [$itemAModifier->commentaire, PDO::PARAM_STR], - ':couleur' => [$itemAModifier->couleur, PDO::PARAM_STR], - ':fait' => [$itemAModifier->estFait, PDO::PARAM_BOOL] - ]); - } - - public function supprimer($itemASupprimer) - { - if(get_class($itemAInserer) != "Tache") - { - throw new TypeError("L'item à supprimer doit être une Tache"); - } - $requette = "DELETE FROM _Tache WHERE tacheID=:id"; - return $this->conn->executeQuery($requette, - [':id', [$itemASupprimer->tacheID]] - ); - - } - - public function getTacheParListe(TodoList $l) : iterable - { - $requete = "SELECT * FROM _Tache WHERE listID=:id"; - if(!$this->conn->executeQuery($requete, - [":id" => [$l->getID()]])) - { - return array(); - } - - $res = $this->conn->getResults(); - $taches = array(); - foreach($res as $tache) - { - $taches[] = new Tache( - $tache["NomTache"], - $tache["TacheFaite"], - $tache["Commentaire"], - $tache["Couleur"], - $tache["tacheID"] - ); - } - return $taches; - } -}