From 25af41e0b835dc50fc7ae750c49252d1a15e3df1 Mon Sep 17 00:00:00 2001 From: "nicolas.franco" Date: Thu, 22 Dec 2022 19:00:17 +0100 Subject: [PATCH] index.php first try --- config/config.php | 7 +-- controller/FrontCtrl.php | 32 +++++++------ controller/VisitorCtrl.php | 75 ++++++++++++++++++------------- dal/TaskGateway.php | 5 ++- index.php | 9 ++-- model/TaskModel.php | 4 +- model/UserModel.php | 5 ++- tests/test.php | 10 +++-- view/connection.php | 4 +- view/home.php | 6 +-- view/newList.php | 92 ++++++++++++++++++++++++++++++++++++++ view/register.php | 4 +- 12 files changed, 184 insertions(+), 69 deletions(-) create mode 100644 view/newList.php diff --git a/config/config.php b/config/config.php index e2a19d3..126dc3f 100644 --- a/config/config.php +++ b/config/config.php @@ -1,7 +1,8 @@ \ No newline at end of file diff --git a/controller/FrontCtrl.php b/controller/FrontCtrl.php index 848978b..ba1f3cf 100644 --- a/controller/FrontCtrl.php +++ b/controller/FrontCtrl.php @@ -1,24 +1,28 @@ usrMdl = new UserModel($con); + $this->action_User = array('deconnexion','loadListePriv','newListPrivate'); try{ - $user = $this->usrMdl.isConnected(); // cette fonction retourne quoi? - $action = $_REQUEST['action']; + $this->isUser = $this->usrMdl->isConnected(); // cette fonction retourne quoi? + if(isset($_REQUEST['action'])) + $action = $_REQUEST['action']; + else + $action = null; - if(($i = array_search($action,$action_User)) !== false){ # si action dans la liste d'actions user - if(!$user){ # si pas conncter + if(($i = array_search($action,$this->action_User)) !== false){ # si action dans la liste d'actions user + if(!$this->isUser){ # si pas conncter # appel controlleur visiteur avec action connecter - require("VisitCtrl.php"); - $visitCtrl = new VisitCtrl(); + require("VisitorCtrl.php"); + $visitCtrl = new VisitorCtrl($con); $visitCtrl->goconnexion(); } else { # sinon # handle action avec controlleur user @@ -28,8 +32,8 @@ class FrontController } else { # sinon forcement action visiteur # appel controlleur visiteur avec l'action - require("VisitCtrl.php"); - $visitCtrl = new VisitCtrl(); + require("VisitorCtrl.php"); + $visitCtrl = new VisitorCtrl($con,$this->isUser); } } catch (Exception $e){ // verifier si catch bon require("../view/erreur.php"); diff --git a/controller/VisitorCtrl.php b/controller/VisitorCtrl.php index 8807105..fa61be4 100644 --- a/controller/VisitorCtrl.php +++ b/controller/VisitorCtrl.php @@ -1,15 +1,22 @@ isUser = $isUser; $dvueErreur = array(); - $taskModel = new TaskModel($con); - $userModel = new UserModel($con); + $this->taskModel = new TaskModel($con); + $this->userModel = new UserModel($con); try{ - $action = $_REQUEST['action']; + if(isset($_REQUEST['action'])) + $action = $_REQUEST['action']; + else + $action = null; + switch($action){ case null: $this->loadHome(); @@ -70,48 +77,54 @@ class VisitorCtrl } } catch (Exception $e) { - require("../view/erreur.php"); - } - - function loadHome(){ - $public_lists = $this->taskModel.loadPublicList(); - require("../view/home.php"); + require("view/erreur.php"); } + } + function loadHome(){ + $public_lists = $this->taskModel->loadPublicLists(); + $user = $this->isUser; + require("view/home.php"); + } - function go_connection(){ - # rediriger vers la page de connection - } + function go_connection(){ + # rediriger vers la page de connection + } - function connection(){ - $this->userModel->connexion($user,$mdp); - } - - function go_list(){ + function connection(){ + $this->userModel->connexion($user,$mdp); + } - } + function go_register(){ + # rediriger vers la page de register + } - function makeList(){ + function register(){ + $this->userModel->connexion($user,$mdp); + } + + function go_list(){ - } + } - function eraseList(){ + function makeList(){ - } + } - function go_task(){ + function eraseList(){ - } + } - function addTask(){ + function go_task(){ - } + } - function eraseTask(){ + function addTask(){ - } - } + function eraseTask(){ + } + } ?> \ No newline at end of file diff --git a/dal/TaskGateway.php b/dal/TaskGateway.php index efc0dfa..bcf5695 100644 --- a/dal/TaskGateway.php +++ b/dal/TaskGateway.php @@ -1,6 +1,7 @@ diff --git a/model/TaskModel.php b/model/TaskModel.php index 245228c..c0b05ec 100644 --- a/model/TaskModel.php +++ b/model/TaskModel.php @@ -1,6 +1,6 @@ addList('private','nifranco'); +//$mt->addList('private','nifranco'); // $lists = $mt->loadPublicLists(); // foreach($lists as $l){ @@ -44,9 +45,12 @@ $mt->addList('private','nifranco'); // $mt->addList('002','todo2','nifranco'); // $mt->modifList('2','nom','22do'); //mt->supList('2'); + + $public_lists = $mt->loadPrivateLists('nifranco'); $user = true; -//require("../view/home.php"); +//require("../view/newList.php"); +require("../view/home.php"); //require("../view/register.php"); //require("../view/connection.php"); /* ------------- @@ -68,7 +72,7 @@ require('../controller/UserCtrl.php'); // Test Modèle User -//$mu = new UserModel($con); +$mu = new UserModel($con); //$res = $mu->connexion('nifranco','achanger'); //var_dump($res); // $mdl->ajouter('Anna', 'unmdptrescomplique'); diff --git a/view/connection.php b/view/connection.php index 57586de..8693fb0 100644 --- a/view/connection.php +++ b/view/connection.php @@ -6,7 +6,7 @@ - +
@@ -70,6 +70,6 @@
- + \ No newline at end of file diff --git a/view/home.php b/view/home.php index 8540f2c..679d31d 100644 --- a/view/home.php +++ b/view/home.php @@ -6,7 +6,7 @@ - +
@@ -15,7 +15,7 @@
Home - New List + + New List + My Lists 🔒'; @@ -110,7 +110,7 @@ - + diff --git a/view/newList.php b/view/newList.php new file mode 100644 index 0000000..e363d52 --- /dev/null +++ b/view/newList.php @@ -0,0 +1,92 @@ + + + + + + + + + + + +
+ + + +
+ + + +
+
+
+
+
+
+
+ +

New List

+
+
+
+ +
+
+ +
+ +
+ + +
'; + } + ?> + + +
+
+
+
+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/view/register.php b/view/register.php index 5a5fa54..57d7a8f 100644 --- a/view/register.php +++ b/view/register.php @@ -6,7 +6,7 @@ - +
@@ -70,6 +70,6 @@
- + \ No newline at end of file