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

View file

@ -1,5 +1,7 @@
<?php
require_once("mother_entity.php");
/**
* Classe d'un objet Projet
* @author Laura
@ -20,7 +22,7 @@ class Category extends Entity{
// 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
*/
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
* @author Yass
* @author Yass & Laura
*/
class Entity{

View file

@ -1,9 +1,9 @@
<?php
require_once('../config/database.php');
/**
* Classe d'un objet Projet
* @author Laura
/**
* Traitement des requêtes pour les catégories
* @author : Laura
*/
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
require_once('../config/database.php');
/**
* Traitement des requêtes pour les projets
* @author : Laura
*/
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
$strRq = "SELECT project.*,
@ -12,12 +19,58 @@
FROM project
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){
$strRq .= " LIMIT ".$intLimit;
}
// Lancer la requête et récupérer les résultats
var_dump($strRq);
return $this->_db->query($strRq)->fetchAll();
}
}

View file

@ -1,5 +1,32 @@
<h2>coucou c'est le footer</h2>
<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>
<footer class="footer container-fluid d-flex justify-content-around">
<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>
</html>

View file

@ -1,24 +1,24 @@
<body>
<section class="container mt-5 p-5 d-flex flex-column align-items-center">
<div>
<section class="container mt-5 p-5 d-flex flex-column align-items-center justify-content-center">
<h2>Alimenter votre projet</h2>
<button type="button" class="btn btn-primary btn-lg">+</button>
</div>
<div class="justify-content-center align-items-center">
<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 class="col-12">
<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.
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 class="col-12">
<h3 class="fw-semibold fs-3 my-5">Photos behind the scene</h3>
<div class="row my-2">
<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 class="col-12">
<h3>Other projects</h3>
<div class="row mb-2">
<div class="row my-2">
<?php
foreach($arrProjectToDiplay as $objProject){
include("../app/views/partials/preview.php");

View file

@ -86,8 +86,7 @@
foreach($arrCategory as $arrDetCategory){
?>
<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']; ?>
</option>
<?php
@ -168,3 +167,28 @@
</section>
</div>
</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%;
padding: 0.75rem;
}
.footer{
color: white;
background-color: #0000ff;
}
.footer ul{
list-style: none;
}
.footer a{
text-decoration: none;
color: white;
}