From 4fd89380c010fbf34f5032d5de83736b06c74c55 Mon Sep 17 00:00:00 2001 From: Yass Date: Thu, 15 Jan 2026 18:03:42 +0100 Subject: [PATCH] version pour laura et besnik --- app/controllers/project_controller.php | 33 +++++- app/controllers/user_controller.php | 70 ------------- app/models/project_model.php | 50 +-------- app/models/user_model.php | 2 +- app/views/partials/header.php | 4 + app/views/search.php | 135 +++++++++++++++++++++++++ 6 files changed, 174 insertions(+), 120 deletions(-) create mode 100644 app/views/search.php diff --git a/app/controllers/project_controller.php b/app/controllers/project_controller.php index 596d713..8859d06 100644 --- a/app/controllers/project_controller.php +++ b/app/controllers/project_controller.php @@ -3,7 +3,7 @@ require("../app/entities/project_entity.php"); /** - * Le controler des article + * Le controler des Project * @author Yasser */ class ProjectCtrl{ @@ -29,4 +29,35 @@ } + public function search(){ + + // inclusion du header + include('../app/views/partials/header.php'); + + //Récupérer les informations du Formulaire + + // Récupération des Projects + $objProjectModel = new ProjectModel; + //$arrProject = findAll(0, $strKeywords, $intAuthor, $intPeriod, $strDate, $strStartDate, $strEndDate); + // Depuis PHP 8 - accès direct aux paramètres + $arrProject = $objProjectModel->findAll(); + + // Initialisation d'un tableau => objets + $arrProjectToDisplay = array(); + // Boucle de transformation du tableau de tableau en tableau d'objets + foreach($arrProject as $arrDetProject){ + $objProject = new Project; + $objProject->hydrate($arrDetProject); + + $arrProjectToDisplay[] = $objProject; + } + + // Récupération des utilisateurs + require("../app/models/user_model.php"); + $objUserModel = new UserModel; + $arrUser = $objUserModel->findAllUsers(); + + include('../app/views/search.php'); + include('../app/views/partials/footer.php'); + } } \ No newline at end of file diff --git a/app/controllers/user_controller.php b/app/controllers/user_controller.php index 454bddb..e6d39d9 100644 --- a/app/controllers/user_controller.php +++ b/app/controllers/user_controller.php @@ -52,76 +52,6 @@ class UserCtrl{ } - public function create(){ - // Variables d'affichage - $strH2 = "Créer un compte"; - $strP = "Inscrivez-vous"; - // Variables technique - $strPage = "create_account"; - - // inclusion du header - include("views/_partial/header.php"); - - // Traitement du formulaire - //var_dump($_POST); - $strName = $_POST['name']??""; - $strFirstname = $_POST['firstname']??""; - $strMail = $_POST['mail']??""; - $strPwd = $_POST['pwd']??""; - $strPwdConfirm = $_POST['pwd_confirm']??""; - $objUser = new User; - $objUser->hydrate($_POST); - - /* - $objUser->setName($strName); - $objUser->setFirstname($strFirstname); - $objUser->setMail($strMail); - $objUser->setPwd($strPwd); - */ - // Tester le formulaire - $arrError = []; - if (count($_POST) > 0) { - if ($objUser->getName() == ""){ - $arrError['name'] = "Le nom est obligatoire"; - } - if ($objUser->getFirstname() == ""){ - $arrError['firstname'] = "Le prénom est obligatoire"; - } - if ($objUser->getMail() == ""){ - $arrError['mail'] = "Le mail est obligatoire"; - }else if (!filter_var($objUser->getMail(), FILTER_VALIDATE_EMAIL)){ - $arrError['mail'] = "Le format du mail n'est pas correct"; - } - $strRegex = "/^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{16,}$/"; - if ($objUser->getPwd() == ""){ - $arrError['pwd'] = "Le mot de passe est obligatoire"; - }else if (!preg_match($strRegex, $objUser->getPwd())){ - $arrError['pwd'] = "Le mot de passe ne correspond pas aux règles"; - }else if($objUser->getPwd() != $strPwdConfirm){ - $arrError['pwd_confirm'] = "Le mot de passe et sa confirmation ne sont pas identiques"; - } - // Ajouter la vérification du mot de passe par regex - - // Si le formulaire est rempli correctement - if (count($arrError) == 0){ - // => Ajout dans la base de données - $objUserModel = new UserModel; - //$intNbInsert = $objUserModel->insert($strName, $strFirstname, $strMail, $strPwd); - $boolInsert = $objUserModel->insert($objUser); - if ($boolInsert === true){ - $_SESSION['success'] = "Le compte a bien été créé"; - //header("Location:index.php"); - //exit; - }else{ - $arrError[] = "Erreur lors de l'ajout"; - } - //var_dump("tout est ok"); - } - } - include("views/create_account.php"); - include("views/_partial/footer.php"); - } - public function logout(){ session_start(); diff --git a/app/models/project_model.php b/app/models/project_model.php index 14251fe..85742ae 100644 --- a/app/models/project_model.php +++ b/app/models/project_model.php @@ -1,11 +1,9 @@ 0){ - /*if ($boolWhere){ - $strRq .= " AND "; - }else{ - $strRq .= " WHERE "; - }*/ - $strRq .= $strWhere." project_creator = ".$intAuthor; - $strWhere = " AND "; - } - - // Recherche par dates - if ($intPeriod == 0){ - // Par date exacte - if ($strDate != ''){ - $strRq .= $strWhere." project_creation_date = '".$strDate."'"; - } - }else{ - // Par période de dates - if ($strStartDate != '' && $strEndDate != ''){ - //if ( ($strStartDate != '') && ($strEndDate != '') ){ Parethèses selon le développeur - pas de changement si que des && - Attention || - $strRq .= $strWhere." project_creation_date BETWEEN '".$strStartDate."' AND '".$strEndDate."'"; - }else{ - if ($strStartDate != ''){ - // A partir de - $strRq .= $strWhere." project_creation_date >= '".$strStartDate."'"; - }else if ($strEndDate != ''){ - // Avant le - $strRq .= $strWhere." project_creation_date <= '".$strEndDate."'"; - } - } - } - - $strRq .= " ORDER BY project_creation_date DESC"; if ($intLimit > 0){ $strRq .= " LIMIT ".$intLimit; diff --git a/app/models/user_model.php b/app/models/user_model.php index 1cf56d2..aaa33c3 100644 --- a/app/models/user_model.php +++ b/app/models/user_model.php @@ -1,5 +1,5 @@ À propos + + diff --git a/app/views/search.php b/app/views/search.php new file mode 100644 index 0000000..51945f0 --- /dev/null +++ b/app/views/search.php @@ -0,0 +1,135 @@ +
+

Rechercher parmi les articles

+
+
+
+

+ + Rechercher des articles +

+ +
+
+ + + + Recherchez dans les titres et contenus + +
+ +
+ + +
+ + +
+
+ Type de recherche par date +
+ + +
+
+ + +
+
+
+ +
+ + + + Format: JJ/MM/AAAA + +
+ + + +
+ + +
+
+
+
+ + +
+

Liste des projets

+
+ +
+

Pas de résultats

+
+ +
+
+
+