commit
046bce1849
11 changed files with 206 additions and 40 deletions
|
|
@ -1,17 +1,19 @@
|
||||||
<?php
|
<?php
|
||||||
require("../app/models/project_model.php");
|
require("../app/models/project_model.php");
|
||||||
require("../app/entities/project_entity.php");
|
require("../app/entities/project_entity.php");
|
||||||
|
require("../app/models/category_model.php");
|
||||||
|
require("../app/entities/category_entity.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Le controler des Project
|
* Le controler des Project
|
||||||
* @author Yasser
|
* @author Yasser & Laura
|
||||||
*/
|
*/
|
||||||
class ProjectCtrl{
|
class ProjectCtrl{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fonction d'affichage de la page d'acceuil
|
* Fonction d'affichage de la page d'acceuil
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function home(){
|
public function home(){
|
||||||
|
|
||||||
$objProjectModel = new ProjectModel;
|
$objProjectModel = new ProjectModel;
|
||||||
|
|
@ -29,16 +31,27 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fonction d'affichage de la barre de recherche
|
||||||
|
*/
|
||||||
|
|
||||||
public function search(){
|
public function search(){
|
||||||
|
|
||||||
// inclusion du header
|
// inclusion du header
|
||||||
include('../app/views/partials/header.php');
|
include('../app/views/partials/header.php');
|
||||||
|
|
||||||
//Récupérer les informations du Formulaire
|
//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
|
// Récupération des Projects
|
||||||
$objProjectModel = new ProjectModel;
|
$objProjectModel = new ProjectModel;
|
||||||
//$arrProject = findAll(0, $strKeywords, $intAuthor, $intPeriod, $strDate, $strStartDate, $strEndDate);
|
|
||||||
// Depuis PHP 8 - accès direct aux paramètres
|
// Depuis PHP 8 - accès direct aux paramètres
|
||||||
$arrProject = $objProjectModel->findAll();
|
$arrProject = $objProjectModel->findAll();
|
||||||
|
|
||||||
|
|
@ -53,11 +66,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupération des utilisateurs
|
// Récupération des utilisateurs
|
||||||
require("../app/models/user_model.php");
|
require_once("../app/models/user_model.php");
|
||||||
$objUserModel = new UserModel;
|
$objUserModel = new UserModel;
|
||||||
$arrUser = $objUserModel->findAllUsers();
|
$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/search.php');
|
||||||
include('../app/views/partials/footer.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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -32,18 +32,11 @@ class UserCtrl{
|
||||||
$arrError[] = "Mail ou mot de passe invalide";
|
$arrError[] = "Mail ou mot de passe invalide";
|
||||||
}else{
|
}else{
|
||||||
// Ajoute l'utilisateur en session
|
// Ajoute l'utilisateur en session
|
||||||
/*$_SESSION['firstname'] = $arrResult['user_firstname'];
|
|
||||||
$_SESSION['name'] = $arrResult['user_name'];
|
|
||||||
$_SESSION['id'] = $arrResult['user_id'];*/
|
|
||||||
// j'enlève le mot de passe avant la session
|
|
||||||
//unset($arrResult['user_pwd']);
|
|
||||||
$_SESSION['user'] = $arrResult;
|
$_SESSION['user'] = $arrResult;
|
||||||
$_SESSION['success'] = "Bienvenue, vous êtes bien connecté";
|
$_SESSION['success'] = "Bienvenue, vous êtes bien connecté";
|
||||||
|
|
||||||
header("Location:index.php");
|
header("Location:index.php");
|
||||||
exit;
|
exit;
|
||||||
//var_dump($_SESSION);
|
|
||||||
//var_dump("Connecté");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -55,8 +48,6 @@ class UserCtrl{
|
||||||
|
|
||||||
public function logout(){
|
public function logout(){
|
||||||
session_start();
|
session_start();
|
||||||
/*session_destroy();
|
|
||||||
session_start();*/
|
|
||||||
|
|
||||||
// on supprime l'utilisateur en session
|
// on supprime l'utilisateur en session
|
||||||
unset($_SESSION['user']);
|
unset($_SESSION['user']);
|
||||||
|
|
|
||||||
55
app/entities/category_entity.php
Normal file
55
app/entities/category_entity.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
require_once("mother_entity.php");
|
||||||
|
/**
|
||||||
|
* Classe d'un objet Projet
|
||||||
|
* @author Laura
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Category extends Entity{
|
||||||
|
|
||||||
|
private int $_id;
|
||||||
|
protected string $_name = '';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructeur (j'ai toujours pas compris à quoi ça sert)
|
||||||
|
*/
|
||||||
|
public function __construct(){
|
||||||
|
$this->_prefix = 'category_';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Méthode Getter et Setter
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récuperation de l'id du Projet
|
||||||
|
* @return int l'id de la catégorie
|
||||||
|
*/
|
||||||
|
public function getId():int{
|
||||||
|
return $this->_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mise à jour de l'id de la catégorie
|
||||||
|
* @param int le nouvelle id
|
||||||
|
*/
|
||||||
|
public function setId($id){
|
||||||
|
$this->_id = $id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récuperation du nom de la catégorie
|
||||||
|
* @return string nom de la catégorie
|
||||||
|
*/
|
||||||
|
public function getName(){
|
||||||
|
return $this->_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mise à jour du nom de la catégorie
|
||||||
|
* @param string le nouveau nom de la catégorie
|
||||||
|
*/
|
||||||
|
public function setName($name){
|
||||||
|
$this->_name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,4 +19,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function nettoyer(string $strText){
|
||||||
|
$strText = trim($strText);
|
||||||
|
$strText = str_replace("<script>", "", $strText);
|
||||||
|
$strText = str_replace("</script>", "", $strText);
|
||||||
|
return $strText;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
25
app/models/category_model.php
Normal file
25
app/models/category_model.php
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
require_once('../config/database.php');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Classe d'un objet Projet
|
||||||
|
* @author Laura
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CategoryModel extends Connect{
|
||||||
|
|
||||||
|
public function findAllCategory(int $intLimit=0):array{
|
||||||
|
|
||||||
|
// Ecrire la requête
|
||||||
|
$strRq = "SELECT category.*
|
||||||
|
FROM category";
|
||||||
|
|
||||||
|
|
||||||
|
if ($intLimit > 0){
|
||||||
|
$strRq .= " LIMIT ".$intLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lancer la requête et récupérer les résultats
|
||||||
|
return $this->_db->query($strRq)->fetchAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -58,11 +58,6 @@
|
||||||
public function insert(object $objUser):bool{
|
public function insert(object $objUser):bool{
|
||||||
|
|
||||||
// 2. Construire la requête
|
// 2. Construire la requête
|
||||||
/*$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd)
|
|
||||||
VALUES ('".$objUser->getName()."',
|
|
||||||
'".$objUser->getFirstname()."',
|
|
||||||
'".$objUser->getMail()."',
|
|
||||||
'".$objUser->getPwdHash()."')";*/
|
|
||||||
$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd)
|
$strRq = "INSERT INTO users (user_name, user_firstname, user_mail, user_pwd)
|
||||||
VALUES (:name, :firstname, :mail, :pwd)";
|
VALUES (:name, :firstname, :mail, :pwd)";
|
||||||
// Préparer la requête
|
// Préparer la requête
|
||||||
|
|
@ -74,8 +69,6 @@
|
||||||
$rqPrep->bindValue(":pwd", $objUser->getPwdHash(), PDO::PARAM_STR);
|
$rqPrep->bindValue(":pwd", $objUser->getPwdHash(), PDO::PARAM_STR);
|
||||||
|
|
||||||
// 3. Executer la requête
|
// 3. Executer la requête
|
||||||
//var_dump($strRq);die;
|
|
||||||
//return $db->exec($strRq);
|
|
||||||
return $rqPrep->execute();
|
return $rqPrep->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
<?php
|
<?php
|
||||||
foreach($arrProjectToDiplay as $objProject){
|
foreach($arrProjectToDiplay as $objProject){
|
||||||
include("../app/views/partials/project.php");
|
include("../app/views/partials/preview.php");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</section>
|
</section>
|
||||||
31
app/views/project.php
Normal file
31
app/views/project.php
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<body>
|
||||||
|
<section class="container mt-5 p-5 d-flex flex-column align-items-center">
|
||||||
|
<div>
|
||||||
|
<h2>Alimenter votre projet</h2>
|
||||||
|
<button type="button" class="btn btn-primary btn-lg">+</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Description</h3>
|
||||||
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||||
|
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||||
|
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Photos behind the scene</h3>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<img >
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h3>Other projects</h3>
|
||||||
|
<div class="row mb-2">
|
||||||
|
<?php
|
||||||
|
foreach($arrProjectToDiplay as $objProject){
|
||||||
|
include("../app/views/partials/preview.php");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<section>
|
||||||
|
</body>
|
||||||
|
|
@ -27,13 +27,23 @@
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label for="author" class="form-label">Auteur</label>
|
<label for="author" class="form-label">Auteur</label>
|
||||||
<select class="form-select" id="author" name="author">
|
<select class="form-select" id="author" name="author">
|
||||||
<option value="0">Tous les auteurs</option>
|
<option value="0" <?php echo ($intAuthor == 0)?'selected':''; ?>>Tous les auteurs</option>
|
||||||
|
<?php
|
||||||
|
foreach($arrUser as $arrDetUser){
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $arrDetUser['user_id']; ?>"
|
||||||
|
<?php echo ($intAuthor == $arrDetUser['user_id'])?'selected':''; ?>
|
||||||
|
>
|
||||||
|
<?php echo $arrDetUser['user_firstname'].' '.$arrDetUser['user_name']; ?>
|
||||||
|
</option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="col-12">
|
<div class="col-6">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend class="form-label">Type de recherche par date</legend>
|
<legend class="form-label">Type de recherche par date</legend>
|
||||||
<div class="form-check form-check-inline">
|
<div class="form-check form-check-inline">
|
||||||
|
|
@ -43,6 +53,7 @@
|
||||||
name="period"
|
name="period"
|
||||||
id="period-exact"
|
id="period-exact"
|
||||||
value="0"
|
value="0"
|
||||||
|
<?php echo ($intPeriod == 0)?'checked':'' ; ?>
|
||||||
aria-controls="date-exact date-range">
|
aria-controls="date-exact date-range">
|
||||||
<label class="form-check-label" for="period-exact">
|
<label class="form-check-label" for="period-exact">
|
||||||
Date exacte
|
Date exacte
|
||||||
|
|
@ -55,6 +66,7 @@
|
||||||
name="period"
|
name="period"
|
||||||
id="period-range"
|
id="period-range"
|
||||||
value="1"
|
value="1"
|
||||||
|
<?php echo ($intPeriod == 1)?'checked':'' ; ?>
|
||||||
aria-controls="date-exact date-range">
|
aria-controls="date-exact date-range">
|
||||||
<label class="form-check-label" for="period-range">
|
<label class="form-check-label" for="period-range">
|
||||||
Période
|
Période
|
||||||
|
|
@ -62,6 +74,29 @@
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- AJOUT RECHERCHE PAR CATEGORIE -->
|
||||||
|
<div class="col-6">
|
||||||
|
<fieldset>
|
||||||
|
<legend class="form-label">Type de recherche par catégories</legend>
|
||||||
|
<div class="col-md-6">
|
||||||
|
<label for="author" class="form-label">Catégorie</label>
|
||||||
|
<select class="form-select" id="category" name="category">
|
||||||
|
<option value="0" <?php echo ($intCategory == 0)?'selected':''; ?>>Toutes les catégories</option>
|
||||||
|
<?php
|
||||||
|
foreach($arrCategory as $arrDetCategory){
|
||||||
|
?>
|
||||||
|
<option value="<?php echo $arrDetCategory['category_id']; ?>"
|
||||||
|
<?php echo ($intCategory == $arrDetCategory['category_id'])?'selected':''; ?>
|
||||||
|
>
|
||||||
|
<?php echo $arrDetCategory['category_name']; ?>
|
||||||
|
</option>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col-md-6" id="date-exact">
|
<div class="col-md-6" id="date-exact">
|
||||||
<label for="date" class="form-label">Date</label>
|
<label for="date" class="form-label">Date</label>
|
||||||
|
|
@ -71,7 +106,7 @@
|
||||||
id="date"
|
id="date"
|
||||||
name="date"
|
name="date"
|
||||||
aria-describedby="date-help"
|
aria-describedby="date-help"
|
||||||
value="" >
|
value="<?php echo $strDate; ?>" >
|
||||||
<small id="date-help" class="form-text text-muted">
|
<small id="date-help" class="form-text text-muted">
|
||||||
Format: JJ/MM/AAAA
|
Format: JJ/MM/AAAA
|
||||||
</small>
|
</small>
|
||||||
|
|
@ -86,7 +121,7 @@
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="startdate"
|
id="startdate"
|
||||||
name="startdate"
|
name="startdate"
|
||||||
value="" >
|
value="<?php echo $strStartDate; ?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<label for="enddate" class="form-label">Date de fin</label>
|
<label for="enddate" class="form-label">Date de fin</label>
|
||||||
|
|
@ -95,7 +130,7 @@
|
||||||
class="form-control"
|
class="form-control"
|
||||||
id="enddate"
|
id="enddate"
|
||||||
name="enddate"
|
name="enddate"
|
||||||
value="" >
|
value="<?php echo $strEndDate; ?>" >
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -127,9 +162,9 @@
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
foreach($arrProjectToDisplay as $objProject){
|
foreach($arrProjectToDisplay as $objProject){
|
||||||
include("../app/views/partials/project.php");
|
include("../app/views/partials/preview.php");
|
||||||
} ?>
|
} ?>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
0
sfq.txt
Normal file
0
sfq.txt
Normal file
Loading…
Add table
Add a link
Reference in a new issue