From 65d4ad2d24ea4cba6b93c7a66bbbf686d4c1d2bb Mon Sep 17 00:00:00 2001 From: Anna BOUDOUL Date: Wed, 14 Dec 2022 17:31:05 +0100 Subject: [PATCH] suite controleur --- controller/FrontCtrl.php | 11 +++--- controller/UserCtrl.php | 39 +++++++++++---------- dal/TaskGateway.php | 12 ++++--- index.php | 4 +-- model/TaskModel.php | 2 +- tests/credentials.php | 2 +- tests/test.php | 8 +++-- view/liste.php | 29 +++++++++------- view/{newList.html => newList.php} | 0 view/{list.html => task.php} | 56 ++++++++++++------------------ 10 files changed, 83 insertions(+), 80 deletions(-) rename view/{newList.html => newList.php} (100%) rename view/{list.html => task.php} (60%) diff --git a/controller/FrontCtrl.php b/controller/FrontCtrl.php index 96e95dd..a6118a8 100644 --- a/controller/FrontCtrl.php +++ b/controller/FrontCtrl.php @@ -3,26 +3,27 @@ require_once('../model/UserModel.php'); class FrontController { - private UserModel $ursMdl; + private UserModel $ursMdl; // private $action_User; function __construct(){ session_start(); $ursMdl = new UserModel(); try{ - $user = $this->usrMdl.isUser(); // cette fonction retourne quoi? + $user = $this->usrMdl->isUser(); // cette fonction retourne quoi? $action = $_REQUEST['action']; if(($i = array_search($action,$action_User)) !== false){ # si action dans la liste d'actions user if($user == null){ # si pas conncter # appel controlleur visiteur avec action connecter require("VisitCtrl.php"); - $visitCtrl = new VisitCtrl(); - $visitCtrl->goconnexion(); + $visitCtrl = new VisitCtrl(); + $visitCtrl->goconnexion(); //header ou inclure vue conn } else { # sinon # handle action avec controlleur user require("UserCtrl.php"); - $userCtrl = new UserCtrl(); + $userCtrl = new UserCtrl();$visitCtrl = new VisitCtrl(); + $visitCtrl->goconnexion(); } } else { # sinon forcement action visiteur diff --git a/controller/UserCtrl.php b/controller/UserCtrl.php index 063ae51..435e6b6 100644 --- a/controller/UserCtrl.php +++ b/controller/UserCtrl.php @@ -8,33 +8,36 @@ class UserCtrl public function __construct(Connection $con){ $this->con = $con; $this->model = new UserModel($this->con); - try{ - $action=$_REQUEST['action']; - switch($action){ + // try{ + // $action=$_REQUEST['action']; + // switch($action){ - // voir les listes privees - case 'voir_liste_priv': - $this->loadListePriv(); - break; + // // voir les listes privees + // case 'voir_liste_priv': + // $this->loadListePriv(); + // break; - // ajouter une liste privee - case 'creer_liste_priv': - $this->newListPrivate(); - break; + // // ajouter une liste privee + // case 'creer_liste_priv': + // $this->newListPrivate(); + // break; - } - } catch(Exception $e) { - require("../view/erreur.php"); - } + // } + // } catch(Exception $e) { + // require("../view/erreur.php"); + // } } public function loadListePriv(){ $name = "Liste privée"; - $TabList = array(); + $taskmdl = new TaskModel($this->con); + $TabTask = $taskmdl->loadPublicLists(); + var_dump($TabTask); // $TabList[] = new ListTask(0, "Projet PHP"); // $TabList[] = new ListTask(1, "Projet Blazor"); - $TabListPriv = $this->model->getPrivateList(); - require("../view/liste.php"); + // $TabListPriv = $this->model->loadPrivateLists(); + // require("../view/liste.php"); + require("../view/task.php"); } public function newListPrivate(){ diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index 8bff2ee..dc4c141 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -55,6 +55,7 @@ class TaskGateway # une fois pour prendre toutes les listes qui ont l'id de l'user # pour toutes ces listes (foreach), find toutes chaque tache associé public function find($table, $element="", $valeur=""){ + $tabResult = array(); if($table =='task'){ if(strcmp($element,"")==0) { @@ -71,10 +72,10 @@ class TaskGateway $results=$this->con->getResults(); foreach($results as $row) { - $tabTaches[]=new Task($row['id'],$row['titre'],$row['description'],$row['priorite'], + $tabResult[]=new Task($row['id'],$row['titre'],$row['description'],$row['priorite'], $row['idList'],$row['dateDebut'],$row['dateFin'],$row['isDone']); } - return $tabTaches; + return $tabResult; } else if($table == 'list'){ if(strcmp($element,"")==0) @@ -92,12 +93,15 @@ class TaskGateway $results=$this->con->getResults(); foreach($results as $row) { - $tabList[]=new ListTask($row['id'],$row['nom'],$row['user'],$row['dc']); + $tabResult[]=new ListTask($row['id'],$row['nom'],$row['user'],$row['dc']); } - return $tabList; + return $tabResult; } } +// SELECT tache.id FROM Tache tache, Liste liste +// tache.idListe = liste.id AND liste.user IS NULL; + /* # LIST FUNCTIONS */ /*create, update, delete, read(select info)*/ public function insertL(ListTask $l){ diff --git a/index.php b/index.php index 5fe3c7f..efbdd90 100644 --- a/index.php +++ b/index.php @@ -2,7 +2,7 @@ $fc = new FrontCtrl(); $TMessage = array(); - require_once(controller/FrontCtrl.php); - require(erreur.php); + require_once("controller/FrontCtrl.php"); + require("erreur.php"); ?> diff --git a/model/TaskModel.php b/model/TaskModel.php index 7554801..2542815 100644 --- a/model/TaskModel.php +++ b/model/TaskModel.php @@ -60,7 +60,7 @@ class TaskModel function loadPublicLists() { - return $this->gtw->find('list','user','NULL'); + return $this->gtw->find('list','user', 'RicharlisonR9'); } } ?> diff --git a/tests/credentials.php b/tests/credentials.php index 9d5efdf..e7d7377 100644 --- a/tests/credentials.php +++ b/tests/credentials.php @@ -1,4 +1,4 @@ diff --git a/tests/test.php b/tests/test.php index 0f867d3..5c7b402 100644 --- a/tests/test.php +++ b/tests/test.php @@ -7,15 +7,16 @@ echo "

2do test

"; # Test de la Gateway Tache # nouvelle tache -$t = new Task(5,'tacheNotErr','desc.','urgent','001'); + # connection include("credentials.php"); $con = new Connection('mysql:host=localhost;dbname=dbanboudoul', 'anboudoul', 'achanger'); # gateway +// $t = new Task(3,'richarlison voltar pro flu','desc.','urgent','0'); // $tgt = new TaskGateway($con); -//$tgt->insert($t); +// $tgt->insertT($t); //$tgt->delete('10'); # test find @@ -27,7 +28,7 @@ foreach($tasks as $i) // $mt= new TaskModel($con); //$mt->addTask('3','testIsDone','desc.','urgent','001'); //$mt->modifTask('3','isDone','1'); -//$tasks = $mt->getTaskBy('titre','tache1'); +// //$tasks = $mt->getTaskBy('titre','tache1'); // $tasks = $mt->getAllTask(); // foreach($tasks as $i) // echo $i->get_id()."
"; @@ -66,6 +67,7 @@ require('../controller/UserCtrl.php'); // $mdl->connexion('Aeryn', 'wtfmec'); $usrctrl = new UserCtrl($con); +// $usrctrl->loadListePriv(); $usrctrl->loadListePriv(); ?> diff --git a/view/liste.php b/view/liste.php index d11235d..0cf1a4c 100644 --- a/view/liste.php +++ b/view/liste.php @@ -1,14 +1,19 @@ - + + + - '; - echo '

'.$name.'

'; - echo '
'; - foreach($TabList as $liste){ - echo ''; - } - echo '
'; -?> \ No newline at end of file + rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" + crossorigin="anonymous"> + + + '.$name.'
'; + echo '
'; + foreach($TabList as $liste){ + echo ''; + } + echo '
'; + ?> + + diff --git a/view/newList.html b/view/newList.php similarity index 100% rename from view/newList.html rename to view/newList.php diff --git a/view/list.html b/view/task.php similarity index 60% rename from view/list.html rename to view/task.php index 7563734..dc58cc5 100644 --- a/view/list.html +++ b/view/task.php @@ -23,40 +23,28 @@ - - - - - - - - - - - - - - - - - - - - - - - -
TaskImportanceActions
Faire le controlleurUrgent - - -
Finir les vuesMoyen - - -
Gestion des erreursImportant - - - -
+ + + Task + Importance + Actions + + + + + '.$task->get_titre().' + '.$task->get_priorite().' + + + + + '; + } + ?> + +