Merge pull request #5 from Yasder5/laura

Laura
This commit is contained in:
Yass 2026-01-23 11:45:50 +01:00 committed by GitHub
commit 3b109f3732
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 296 additions and 37 deletions

View file

@ -3,6 +3,8 @@
require("../app/entities/project_entity.php"); require("../app/entities/project_entity.php");
require("../app/models/category_model.php"); require("../app/models/category_model.php");
require("../app/entities/category_entity.php"); require("../app/entities/category_entity.php");
require("../app/models/image_model.php");
require("../app/entities/image_entity.php");
/** /**
* Le controler des Project * Le controler des Project
@ -37,23 +39,24 @@
public function search(){ public function search(){
//variable pour faire fonctionner le script en footer
$strPage = "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']??''; $strKeywords = $_POST['keywords']??'';
$intAuthor = $_GET['author']??0; $intAuthor = $_POST['author']??0;
$intPeriod = $_GET['period']??0; $intPeriod = $_POST['period']??0;
$strDate = $_GET['date']??''; $strDate = $_POST['date']??'';
$strStartDate = $_GET['startdate']??''; $strStartDate = $_POST['startdate']??'';
$strEndDate = $_GET['enddate']??''; $strEndDate = $_POST['enddate']??'';
$intCategory = $_GET['category']??0; $intCategory = $_POST['category']??0;
// Récupération des projetc
// Récupération des Projects
$objProjectModel = new ProjectModel; $objProjectModel = new ProjectModel;
$arrProject = $objProjectModel->findAll(intAuthor:$intAuthor, intPeriod:$intPeriod, strDate:$strDate,
// Depuis PHP 8 - accès direct aux paramètres strKeywords:$strKeywords, strStartDate:$strStartDate, strEndDate:$strEndDate, intCategory:$intCategory);
$arrProject = $objProjectModel->findAll();
// Initialisation d'un tableau => objets // Initialisation d'un tableau => objets
$arrProjectToDisplay = array(); $arrProjectToDisplay = array();
@ -61,7 +64,6 @@
foreach($arrProject as $arrDetProject){ foreach($arrProject as $arrDetProject){
$objProject = new Project; $objProject = new Project;
$objProject->hydrate($arrDetProject); $objProject->hydrate($arrDetProject);
$arrProjectToDisplay[] = $objProject; $arrProjectToDisplay[] = $objProject;
} }
@ -84,9 +86,30 @@
* Fonction d'affichage de la page projet * Fonction d'affichage de la page projet
*/ */
public function project (){ public function project (){
$objProjectModel = new ProjectModel;
$arrProject = $objProjectModel->findAll(4);
$arrProjectToDiplay = array();
foreach($arrProject as $arrDetProject){
$objProject = new Project;
$objProject->hydrate($arrDetProject);
$arrProjectToDiplay[] = $objProject;
}
$objImageModel = new ImageModel;
$arrImage = $objImageModel->findAllImage(4);
$arrImageToDiplay = array();
foreach($arrImage as $arrDetImage){
$objImage = new Image;
$objImage->hydrate($arrDetImage);
$arrImageToDiplay[] = $objImage;
}
include("../app/views/partials/header.php"); include("../app/views/partials/header.php");
include('../app/views/project.php'); include('../app/views/project.php');
include('../app/views/partials/footer.php'); include('../app/views/partials/footer.php');
} }
} }

View file

@ -1,5 +1,7 @@
<?php <?php
require_once("mother_entity.php"); require_once("mother_entity.php");
/** /**
* Classe d'un objet Projet * Classe d'un objet Projet
* @author Laura * @author Laura
@ -20,7 +22,7 @@ class Category extends Entity{
// Méthode Getter et Setter // Méthode Getter et Setter
/** /**
* Récuperation de l'id du Projet * Récuperation de l'id de la catégorie
* @return int l'id de la catégorie * @return int l'id de la catégorie
*/ */
public function getId():int{ public function getId():int{

View file

@ -0,0 +1,91 @@
<?php
require_once("mother_entity.php");
/**
* Classe d'un objet Projet
* @author Laura
*/
class Image extends Entity{
private int $_id;
private string $_name = '';
private string $_alt = '';
private string $_status ='';
private int $_project = 0;
//le construc habituel
public function __construct(){
$this->_prefix = 'image_';
}
// Méthode Getter et Setter
/**
* Récuperation de l'id de l'image
* @return int l'id de l'image
*/
public function getId():int{
return $this->_id;
}
/**
* Mise à jour de l'id de l'image
* @param int le nouvelle id
*/
public function setId($id){
$this->_id = $id;
}
/**
* Récuperation du nom de l'image
* @return string nom de l'image
*/
public function getName(){
return $this->_name;
}
/**
* Mise à jour du nom de l'image
* @param string le nouveau nom de l'image
*/
public function setName($name){
$this->_name = $name;
}
/**
* Récuperation de l'alt
* @return string contenu de l'alt
*/
public function getAlt(){
return $this->_alt;
}
/**
* Mise à jour de l'alt
* @param string le nouveau contenu de l'alt
*/
public function setAlt($alt){
$this->_alt = $alt;
}
/**
* Récuperation du statut de la photo
* @return string du statut
*/
public function getStatus(){
return $this->_status;
}
/**
* Mise à jour du statut de la photo
* @param string le nouveau statut de la photo
*/
public function setStatus($status){
$this->_status = $status;
}
}

View file

@ -2,7 +2,7 @@
/** /**
* Classe d'un Mere de tout objet * Classe d'un Mere de tout objet
* @author Yass * @author Yass & Laura
*/ */
class Entity{ class Entity{

View file

@ -1,10 +1,10 @@
<?php <?php
require_once('../config/database.php'); require_once('../config/database.php');
/** /**
* Classe d'un objet Projet * Traitement des requêtes pour les catégories
* @author Laura * @author : Laura
*/ */
class CategoryModel extends Connect{ class CategoryModel extends Connect{

View file

@ -0,0 +1,25 @@
<?php
require_once('../config/database.php');
/**
* Traitement de la requête pour les images
* @author Laura
*/
class ImageModel extends Connect{
public function findAllImage(int $intLimit=0):array{
// Ecrire la requête
$strRq = "SELECT image.*
FROM image";
if ($intLimit > 0){
$strRq .= " LIMIT ".$intLimit;
}
// Lancer la requête et récupérer les résultats
return $this->_db->query($strRq)->fetchAll();
}
}

View file

@ -1,9 +1,16 @@
<?php <?php
require_once('../config/database.php'); require_once('../config/database.php');
/**
* Traitement des requêtes pour les projets
* @author : Laura
*/
class ProjectModel extends Connect{ class ProjectModel extends Connect{
public function findAll(int $intLimit=0):array{ public function findAll(int $intLimit=0, string $strKeywords='', int $intAuthor=0,
int $intPeriod=0, string $strDate='', string $strStartDate='',
string $strEndDate='', int $intCategory=0):array{
// Ecrire la requête // Ecrire la requête
$strRq = "SELECT project.*, $strRq = "SELECT project.*,
@ -12,12 +19,58 @@
FROM project FROM project
INNER JOIN users ON user_id = project_user"; INNER JOIN users ON user_id = project_user";
$strWhere = " WHERE ";
// Recherche par mot clé
if ($strKeywords != '') {
$strRq .= " WHERE (project_title LIKE '%".$strKeywords."%'
OR project_content LIKE '%".$strKeywords."%') ";
//$boolWhere = true;
$strWhere = " AND ";
}
// Recherche par auteur
if ($intAuthor > 0){
$strRq .= $strWhere." user_id = ".$intAuthor;
$strWhere = " AND ";
}
// Recherche par catégorie
if ($intCategory > 0){
$strRq .= $strWhere." project_category = ".$intCategory;
$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 != ''){
$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){ if ($intLimit > 0){
$strRq .= " LIMIT ".$intLimit; $strRq .= " LIMIT ".$intLimit;
} }
// Lancer la requête et récupérer les résultats // Lancer la requête et récupérer les résultats
var_dump($strRq);
return $this->_db->query($strRq)->fetchAll(); return $this->_db->query($strRq)->fetchAll();
} }
} }

View file

@ -1,5 +1,32 @@
<h2>coucou c'est le footer</h2> <footer class="footer container-fluid d-flex justify-content-around">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js" integrity="sha384-FKyoEForCGlyvwx9Hj09JcYn3nv7wiPVlz7YYwJrWVcXK/BmnVDxM+D2scQbITxI" crossorigin="anonymous"></script> <div class="col-3">
<ul>
<li><a href="#">Découvrir</a>
<li><a href="#">Customisation</a>
<li><a href="#">Emploi</a>
<li><a href="#">A propos</a>
</ul>
</div>
<div class="col-3">
<ul>
<li><a href="#">Recruter</a>
<li><a href="#">Partenariat</a>
<li><a href="#">Blog</a>
<li><a href="#">Aide et support</a>
</ul>
</div>
<div class="col-3">
<ul>
<li><a href="#">Politique de confidentialité</a>
<li><a href="#">Politique sur les données</a>
<li><a href="#">CGU</a>
<li><a href="#">CGV</a>
</ul>
</div>
<div class="col-3">
<p>Suivez-nous</p>
</div>
</footer>
</body> </body>
</html> </html>

View file

@ -1,24 +1,24 @@
<body> <body>
<section class="container mt-5 p-5 d-flex flex-column align-items-center"> <section class="container mt-5 p-5 d-flex flex-column align-items-center justify-content-center">
<div> <h2>Alimenter votre projet</h2>
<h2>Alimenter votre projet</h2> <div class="justify-content-center align-items-center">
<button type="button" class="btn btn-primary btn-lg">+</button> <button type="button" class="btn btn-primary rounded-circle d-flex justify-content-center align-items-center"><span class="fs-4 fw-bold text-white mb-2 ms-2 me-2">+</span></button>
</div> </div class="col-12">
<div> <div>
<h3>Description</h3> <h3 class="fw-semibold fs-3 my-5">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. <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. 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> Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div> </div>
<div> <div class="col-12">
<h3>Photos behind the scene</h3> <h3 class="fw-semibold fs-3 my-5">Photos behind the scene</h3>
<div class="row mb-2"> <div class="row my-2">
<img > <img class="bd-placeholder-img" width="200" height="250" src="<?= isset($objImage) ? '../../public/assets/img/'.$objImage->getName() : '' ?>" alt="<?php echo $objImage->getAlt(); ?>" loading="lazy">
</div> </div>
</div> </div>
<div> <div class="col-12">
<h3>Other projects</h3> <h3>Other projects</h3>
<div class="row mb-2"> <div class="row my-2">
<?php <?php
foreach($arrProjectToDiplay as $objProject){ foreach($arrProjectToDiplay as $objProject){
include("../app/views/partials/preview.php"); include("../app/views/partials/preview.php");

View file

@ -86,8 +86,7 @@
foreach($arrCategory as $arrDetCategory){ foreach($arrCategory as $arrDetCategory){
?> ?>
<option value="<?php echo $arrDetCategory['category_id']; ?>" <option value="<?php echo $arrDetCategory['category_id']; ?>"
<?php echo ($intCategory == $arrDetCategory['category_id'])?'selected':''; ?> <?php echo ($intCategory == $arrDetCategory['category_id'])?'selected':''; ?> >
>
<?php echo $arrDetCategory['category_name']; ?> <?php echo $arrDetCategory['category_name']; ?>
</option> </option>
<?php <?php
@ -168,3 +167,28 @@
</section> </section>
</div> </div>
</section> </section>
<script>
// Gestion de l'affichage des champs de date
const periodRadios = document.querySelectorAll('input[name="period"]');
const dateExact = document.getElementById('date-exact');
const dateRange = document.getElementById('date-range');
function toggleDateFields() {
const selectedPeriod = document.querySelector('input[name="period"]:checked').value;
if (selectedPeriod === '0') {
dateExact.style.display = 'block';
dateRange.style.display = 'none';
} else {
dateExact.style.display = 'none';
dateRange.style.display = 'block';
}
}
periodRadios.forEach(radio => {
radio.addEventListener('change', toggleDateFields);
});
// Initialisation au chargement
toggleDateFields();
</script>

View file

@ -96,3 +96,17 @@ body {
height: 20%; height: 20%;
padding: 0.75rem; padding: 0.75rem;
} }
.footer{
color: white;
background-color: #0000ff;
}
.footer ul{
list-style: none;
}
.footer a{
text-decoration: none;
color: white;
}