Restructuration du git et ajout de la fonctionnalité de création de portfolio
This commit is contained in:
parent
dfaaedbda8
commit
3c80c52529
43 changed files with 1818 additions and 0 deletions
92
app/controllers/project_controller.php
Normal file
92
app/controllers/project_controller.php
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
require("../app/models/project_model.php");
|
||||
require("../app/entities/project_entity.php");
|
||||
require("../app/models/category_model.php");
|
||||
require("../app/entities/category_entity.php");
|
||||
|
||||
/**
|
||||
* Le controler des Project
|
||||
* @author Yasser & Laura
|
||||
*/
|
||||
class ProjectCtrl{
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la page d'acceuil
|
||||
*/
|
||||
|
||||
public function home(){
|
||||
|
||||
$objProjectModel = new ProjectModel;
|
||||
$arrProject = $objProjectModel->findAll(4);
|
||||
$arrProjectToDisplay = array();
|
||||
foreach($arrProject as $arrDetProject){
|
||||
$objProject = new Project;
|
||||
$objProject->hydrate($arrDetProject);
|
||||
$arrProjectToDisplay[] = $objProject;
|
||||
}
|
||||
|
||||
include('../app/views/partials/header.php');
|
||||
include('../app/views/home.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la barre de recherche
|
||||
*/
|
||||
|
||||
public function search(){
|
||||
|
||||
// inclusion du header
|
||||
include('../app/views/partials/header.php');
|
||||
|
||||
//Récupérer les informations du Formulaire
|
||||
$strKeywords = $_GET['keywords']??'';
|
||||
$intAuthor = $_GET['author']??0;
|
||||
$intPeriod = $_GET['period']??0;
|
||||
$strDate = $_GET['date']??'';
|
||||
$strStartDate = $_GET['startdate']??'';
|
||||
$strEndDate = $_GET['enddate']??'';
|
||||
$intCategory = $_GET['category']??0;
|
||||
|
||||
// Récupération des Projects
|
||||
$objProjectModel = new ProjectModel;
|
||||
|
||||
// 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_once("../app/models/user_model.php");
|
||||
$objUserModel = new UserModel;
|
||||
$arrUser = $objUserModel->findAllUsers();
|
||||
|
||||
// Récupération des catégories
|
||||
require_once("../app/models/category_model.php");
|
||||
$objCategoryModel = new CategoryModel;
|
||||
$arrCategory = $objCategoryModel->findAllCategory();
|
||||
|
||||
|
||||
include('../app/views/search.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
}
|
||||
|
||||
/**
|
||||
* Fonction d'affichage de la page projet
|
||||
*/
|
||||
|
||||
public function project (){
|
||||
include("../app/views/partials/header.php");
|
||||
include('../app/views/project.php');
|
||||
include('../app/views/partials/footer.php');
|
||||
}
|
||||
}
|
||||
61
app/controllers/user_controller.php
Normal file
61
app/controllers/user_controller.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
require("../app/models/user_model.php");
|
||||
require("../app/entities/user_entity.php");
|
||||
|
||||
class UserCtrl{
|
||||
|
||||
public function login(){
|
||||
include("../app/views/partials/header.php");
|
||||
|
||||
$strMail = $_POST['mail']??"";
|
||||
$strPwd = $_POST['pwd']??"";
|
||||
|
||||
// Tester le formulaire
|
||||
$arrError = [];
|
||||
if (count($_POST) > 0) {
|
||||
// Vérifier le formulaire
|
||||
if ($strMail == ""){
|
||||
$arrError['mail'] = "Le mail est obligatoire";
|
||||
}
|
||||
if ($strPwd == ""){
|
||||
$arrError['pwd'] = "Le mot de passe est obligatoire";
|
||||
}
|
||||
|
||||
// Si le formulaire est rempli correctement
|
||||
if (count($arrError) == 0){
|
||||
// Vérifier l'utilisateur en BDD
|
||||
$objUserModel = new UserModel;
|
||||
$arrResult = $objUserModel->verifUser($strMail, $strPwd);
|
||||
//var_dump($arrResult);
|
||||
if ($arrResult === false){ // Si la base de données ne renvoie rien
|
||||
$arrError[] = "Mail ou mot de passe invalide";
|
||||
}else{
|
||||
// Ajoute l'utilisateur en session
|
||||
$_SESSION['user'] = $arrResult;
|
||||
$_SESSION['success'] = "Bienvenue, vous êtes bien connecté";
|
||||
|
||||
header("Location:index.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
include("../app/views/login.php");
|
||||
include("../app/views/partials/footer.php");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function logout(){
|
||||
session_start();
|
||||
|
||||
// on supprime l'utilisateur en session
|
||||
unset($_SESSION['user']);
|
||||
|
||||
$_SESSION['success'] = "Vous êtes bien déconnecté";
|
||||
|
||||
header("Location:index.php");
|
||||
exit;
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue