Amélioration du code, vue, Controlleur...

pull/11/head
Emre KARTAL 2 years ago
parent d672c5132c
commit de3fbfb47e

@ -51,7 +51,7 @@ class CtrlVisiteur {
} catch (PDOException $e) } catch (PDOException $e)
{ {
//si erreur BD, pas le cas ici //si erreur BD, pas le cas ici
$dVueEreur[] = "Erreur inattendue!!! "; $dVueEreur[] = "Erreur BD!!! ";
require ($rep.$vues['erreur']); require ($rep.$vues['erreur']);
} }

@ -3,6 +3,7 @@ class ListeGateway{
private $con; private $con;
public function __construct(){ public function __construct(){
global $dsn,$user,$pass;
$this->con=new Connection($dsn,$user,$pass); $this->con=new Connection($dsn,$user,$pass);
} }
@ -26,7 +27,7 @@ class ListeGateway{
} }
public function getListe(int $offset, int $limit){ public function getListe(int $offset, int $limit){
$query = "SELECT * FROM ToDoListe_Liste LIMITS $offset,$limit"; $query = "SELECT * FROM ToDoList_Liste LIMITS $offset,$limit";
$this->con->executeQuery($query); $this->con->executeQuery($query);
$results=$this->con->getResults(); $results=$this->con->getResults();
return $results; return $results;
@ -40,13 +41,13 @@ class ListeGateway{
} }
public function getListePublic($offset,$limit){ public function getListePublic($offset,$limit){
$query = "SELECT * FROM ToDoListe_Liste AND estPublic LIMITS $offset,$limit"; $query = "SELECT * FROM ToDoList_Liste AND estPublic LIMITS $offset,$limit";
$this->con->executeQuery($query); $this->con->executeQuery($query);
$tab = []; $listes = [];
foreach ($this->con->getResults() as $liste) { foreach ($this->con->getResults() as $liste) {
$tab[] = new Liste($liste["id"],$liste["nom"],$liste["description"],$liste["dateCreation"],$liste["estPublic"],$liste["idUtilisateur"]); $listes[] = new Liste($liste["id"],$liste["nom"],$liste["description"],$liste["dateCreation"],$liste["estPublic"],$liste["idUtilisateur"]);
} }
return $tab; return $listes;
} }
} }
?> ?>

@ -1,7 +1,5 @@
<?php <?php
namespace modeles;
class Modele class Modele
{ {
@ -12,18 +10,18 @@ class Modele
public static function CreerUtilisateur(){ public static function CreerUtilisateur(){
global $dVueEreur; global $dVueEreur;
$userGtw = new UtilisateurGateway(); $userGtw = new UtilisateurGateway();
$verif = Validation::val_form_user($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["password-Form"],$_POST["mail-Form"],$dVueEreur); // $verif = Validation::val_form_user($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["password-Form"],$_POST["mail-Form"],$dVueEreur);
if($verif == false){ // if($verif == false){
throw new Exception(); // throw new Exception();
} // }
$hash = password_hash($_POST[password-Form], PASSWORD_DEFAULT); // $hash = password_hash($_POST[password-Form], PASSWORD_DEFAULT);
$userGtw->AjouterUtilisateur($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["mail-Form"],$_POST["password-Form"]); $userGtw->AjouterUtilisateur($_POST["nom-Form"],$_POST["prenom-Form"],$_POST["pseudo-Form"],$_POST["mail-Form"],$_POST["password-Form"]);
} }
public static function RecupererListePublic(){ public static function RecupererListePublic(){
$userGtw = new UtilisateurGateway(); $userGtw = new ListeGateway();
$userGtw->getListePublic(); return $userGtw->getListe(0,10);
} }

@ -3,6 +3,7 @@ class UtilisateurGateway{
private $con; private $con;
public function __construct(){ public function __construct(){
global $dsn,$user,$pass;
$this->con=new Connection($dsn,$user,$pass); $this->con=new Connection($dsn,$user,$pass);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 896 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

@ -18,7 +18,7 @@
<?php <?php
foreach($listes as $liste){ foreach($listes as $liste){
echo "<center>$liste->getNom()</center>"; echo '<center>$liste->getNom()</center>';
} }
?> ?>

@ -21,7 +21,7 @@
<div class="login-card-header"> <div class="login-card-header">
<h1>Inscrivez-vous</h1> <h1>Inscrivez-vous</h1>
</div> </div>
<form class="login-card-form"> <form method="POST" class="login-card-form">
<div class="row"> <div class="row">
<div class="col-md-6 mb-4"> <div class="col-md-6 mb-4">
<div class="form-outline"> <div class="form-outline">

@ -10,7 +10,7 @@ $pass='achanger';
$dsn='mysql:host=londres.uca.local;dbname=dbemkartal1'; $dsn='mysql:host=londres.uca.local;dbname=dbemkartal1';
//Vues //Vues
$vues['erreur']='vues/erreur.php'; $vues['erreur']='Vue/html/erreur.php';
$vues['inscription']='Vue/html/inscription.php'; $vues['inscription']='Vue/html/inscription.php';
$vues['listPublic']='Vue/html/PageListePublic.php'; $vues['listPublic']='Vue/html/PageListePublic.php';
$vues['login']='Vue/html/login.php'; $vues['login']='Vue/html/login.php';

Loading…
Cancel
Save