Compare commits

..

35 Commits

Author SHA1 Message Date
Maxime ROCHER da2a2395d8 pagination favoris
1 month ago
Maxime ROCHER 25c49e6600 modifications légères header
1 month ago
Maxime ROCHER 248d75441d pagination recherche
1 month ago
Maxime ROCHER 9fec0c90b3 création du style pour ajouter une quote et deplacement du bouton
1 month ago
Maxime ROCHER 331d139b29 Mise à jour de 'README.md'
3 months ago
Maxime ROCHER dde7c7736f Mise à jour de 'README.md'
3 months ago
Leni BEAULATON 434c6f4144 Mise à jour de 'README.md'
3 months ago
Leni BEAULATON f7bd335735 Mise à jour de 'README.md'
3 months ago
brongniart c909aae222 correction petite erreur
3 months ago
Kentin BRONGNIART 3403a5592c Merge pull request 'Création du Quiz random' (#30) from ajoutQuiz into master
3 months ago
brongniart 63ab93f3ca merge
3 months ago
brongniart 42aa62aece Création du Quiz random
3 months ago
Maxime ROCHER 8f99b30a0e retour au quiz dispo
3 months ago
Maxime ROCHER 00a9cc3641 Merge branch 'ajoutQuiz'
3 months ago
Maxime ROCHER 165b1fcbd9 jsp
3 months ago
brongniart dfa5813ace style Profil
3 months ago
Maxime ROCHER f61062ae8a style Accueil quote & review style recherche
3 months ago
Kevin MONDEJAR 0b226224cf Merge pull request 'modifCitation' (#25) from modifCitation into master
3 months ago
kevin.modejar 48c5114e0c merge modifCitation
3 months ago
kevin.modejar 4c365356a2 ajourt type de source
3 months ago
Maxime ROCHER 37f0c11f4c fix AccueilQuiz
3 months ago
Maxime ROCHER 342a9f1de8 Merge branch 'ajoutQuiz' of https://codefirst.iut.uca.fr/git/WikiFantasy/WF-Website into ajoutQuiz
3 months ago
Maxime ROCHER a38e64c2bc t
3 months ago
kevin.modejar 5090c8407e Page d'erreur
3 months ago
Maxime ROCHER 7e553a63e7 Merge branch 'ajoutQuiz' of https://codefirst.iut.uca.fr/git/WikiFantasy/WF-Website into ajoutQuiz
3 months ago
Maxime ROCHER 82b2b047c5 modifs CSS +ajout font
3 months ago
kevin.modejar cd767ee45a j'avais oublier un <<
3 months ago
kevin.modejar ca81cd84bf merge
3 months ago
kevin.modejar c25b7b5030 Submit Quote
3 months ago
kevin.modejar fda3d1e68f Submit Quote
3 months ago
kevin.modejar 60e2f0729f resolution conflit
3 months ago
kevin.modejar c86de066fd modif ajout citation
3 months ago
kevin.modejar ccc48431e8 debut ajout quiz aléatoire
3 months ago
Maxime ROCHER 8c848bc67d ajout liste quiz
3 months ago
kevin.modejar ab176cb06e modif quiz
3 months ago

@ -1,2 +1,73 @@
# WikiFantasyWeb
# Projet web What the Fantasy
Current deployment state : [![Build Status](https://codefirst.iut.uca.fr/api/badges/WhatTheFantasy/WF-Website/status.svg)](https://codefirst.iut.uca.fr/WhatTheFantasy/WF-Website)
## Description
Le site **What the Fantasy** est une application web permettant aux utilisateurs de découvrir des citations célèbres du monde de la fantasy. En plus de pouvoir lire et apprécier les citations, les utilisateurs peuvent créer un compte pour interagir avec elles en les likant, en les commentant, et en participant à des quiz à thème ou aléatoires.
### Fonctionnalités principales
- **Découverte de citations** : Parcourez une large sélection de citations tirées de l'univers de la fantasy.
- **Interaction avec les citations** : Les utilisateurs connectés peuvent **liker** et **commenter** les citations.
- **Création de compte utilisateur** : Inscription et connexion des utilisateurs pour accéder à des fonctionnalités supplémentaires.
- **Quiz interactifs** : Les utilisateurs peuvent participer à des quiz à thème (par exemple, quiz sur les personnages de la fantasy) ou un quiz aléatoire pour deviner qui a dit une citation parmi une liste d'auteurs célèbres.
## Prérequis
Avant d'exécuter le site, vous devez avoir installé les éléments suivants sur votre machine :
- **Apache2** : Le serveur web Apache2 pour héberger le site.
- [Installation d'Apache2](https://httpd.apache.org/docs/)
- **PHP** : Le langage côté serveur utilisé pour gérer la logique d'interaction et les données dynamiques.
- Vous pouvez installer PHP sur votre serveur via [ces instructions](https://www.php.net/manual/en/install.php).
- **PostgreSQL** : La base de données pour stocker les utilisateurs, citations et résultats des quiz.
- [Installation de PostgreSQL](https://www.postgresql.org/download/)
- **JavaScript** : Pour les fonctionnalités interactives côté client.
## Installation
### 1. Cloner le dépôt
Clonez le dépôt Git sur votre machine locale avec la commande suivante :
```bash
git clone https://codefirst.iut.uca.fr/git/WhatTheFantasy/WF-Website.git
```
### 2. Installer Apache2, PHP et MySQL/MariaDB
**Sur Ubuntu/Debian (exemple d'installation) :**
```bash
sudo apt update
sudo apt install apache2
```
Cela installera Apache2.
**Lancer le serveur Apache**
Assurez-vous que le serveur Apache2 est en fonctionnement. Sur Ubuntu/Debian, vous pouvez redémarrer Apache avec la commande suivante :
```bash
sudo systemctl restart apache2
```
**Sur Windows :**<br/>
Téléchargez et installez [XAMPP](https://www.apachefriends.org/download.html), qui inclut Apache, PHP
## Auteurs
BRONGNIART Kentin<br/>
BEAULATON Léni<br/>
ROCHER Maxime<br/>
MONDEJAR Kevin<br/>
GUICHARD-MONTGUERS Louis<br/>
NGUYEN Tommy<br/>

@ -13,10 +13,11 @@ $login = '';
$mdp = '';
//$racine='/~kemondejar/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-Website /~kemondejar/WF-Website
$racine='/~marocher8/WF-Website';
$racine='/~lebeaulato/WF-Website'; // /~kekentin/WF/WF-Website /~lebeaulato/WF-Website /~kemondejar/WF-Website
//$racine='/WF-Website';
//$repImg='/home/UCA/kemondejar/public_html/WF-Website/public/images/';
$repImg='/';
@ -33,6 +34,11 @@ $vues['create'] = 'vue/create.php';
$vues['quiz'] = 'vue/quiz.php';
$vues['endQuiz'] = 'vue/endQuiz.php';
$vues['submitQuote'] = 'vue/submitQuote.php';
$vues['recap'] = 'vue/recap.php';
$vues['accueilQuiz'] = 'vue/accueilQuiz.php';
$vues['quizRandom'] = 'vue/quizRandom.php';
$vues['endQuizRandom'] = 'vue/endQuizRandom.php';
//Style css

@ -0,0 +1,3 @@
<svg width="87" height="87" viewBox="0 0 87 87" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M74.6088 3.04338L75.4246 2.22758C76.0386 1.6139 76.7675 1.12717 77.5696 0.795191C78.3717 0.463209 79.2314 0.292471 80.0995 0.292725C80.9676 0.292979 81.8271 0.464221 82.629 0.796673C83.431 1.12912 84.1596 1.61628 84.7732 2.23031C85.3869 2.84435 85.8736 3.57325 86.2056 4.37539C86.5375 5.17753 86.7083 6.0372 86.708 6.90533C86.7078 7.77345 86.5365 8.63303 86.2041 9.43497C85.8716 10.2369 85.3845 10.9655 84.7705 11.5792L83.9547 12.3895C85.3502 13.9547 86.0942 15.9944 86.0341 18.0905C85.9741 20.1866 85.1145 22.1803 83.6317 23.663L27.2828 80.0192C26.9305 80.3696 26.4895 80.6175 26.0071 80.7364L4.10699 86.2116C3.64869 86.3257 3.16866 86.3193 2.71356 86.1931C2.25846 86.0668 1.84377 85.8249 1.50981 85.4909C1.17584 85.1569 0.933963 84.7422 0.807679 84.2871C0.681396 83.832 0.675004 83.352 0.789126 82.8936L6.26415 60.9929C6.38394 60.5124 6.63182 60.0734 6.98138 59.7226L59.7715 6.93077C59.2436 6.55917 58.6012 6.38613 57.9581 6.44224C57.3149 6.49834 56.7122 6.77997 56.2566 7.23738L38.2328 25.2672C37.9783 25.5217 37.6761 25.7236 37.3436 25.8614C37.011 25.9991 36.6546 26.07 36.2946 26.07C35.9347 26.07 35.5783 25.9991 35.2457 25.8614C34.9132 25.7236 34.611 25.5217 34.3565 25.2672C34.102 25.0127 33.9001 24.7105 33.7623 24.3779C33.6246 24.0454 33.5537 23.6889 33.5537 23.329C33.5537 22.969 33.6246 22.6126 33.7623 22.28C33.9001 21.9475 34.102 21.6453 34.3565 21.3908L52.3912 3.36642C53.8748 1.88272 55.87 1.02315 57.9673 0.964094C60.0646 0.905041 62.105 1.65099 63.6697 3.04886C65.1741 1.70436 67.1207 0.960681 69.1382 0.959672C71.1558 0.958662 73.1032 1.70039 74.6088 3.04338Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@ -15,7 +15,7 @@ if(!isset($_SESSION['theme'])){
require_once __DIR__ . '/config/config.php';
require __DIR__ . '/vendor/autoload.php';
//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'postgres');
//$co = new \Gateway\Connection('pgsql:host=localhost;dbname=wikifantasy3;', 'postgres', 'sucepute');
$co = new \Gateway\Connection('pgsql:host=localhost;dbname=dbkekentin;', 'kekentin', 'passwd');
//twig

Binary file not shown.

Before

Width:  |  Height:  |  Size: 152 KiB

After

Width:  |  Height:  |  Size: 28 KiB

@ -115,8 +115,6 @@ function editFieldPassWd(id) {
inputNewPass.focus();// Mettre le focus sur le premier champ de saisie
}
function editFieldImage(id,path) {
var pElement = document.getElementById('imagePost');

@ -1,25 +1,31 @@
/* @import url('https://fonts.googleapis.com/css2?family=Lemon&display=swap'); */
@import url(./styleScroll.css);
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Roboto+Condensed:ital,wght@0,100..900;1,100..900&family=Roboto:ital,wght@0,100..900;1,100..900&display=swap');
:root {
--main-dark-background-color: #120B1D;
--main-dark-text-color : #ffffff;
--main-dark-gradient : linear-gradient(45deg, #4a148c, #7b1fa2);
--main-dark-other-color : #000000;
--main-light-background-color: #cccccc;
/*--main-light-background-color: #ffffff;*/
--main-light-text-color : #000;
--main-light-gradient : linear-gradient(90deg, #46BE73, #BAEBF6);
/*--main-light-gradient : linear-gradient(-90deg, #f3e0f7, #dd9aff);*/
/*--main-light-gradient : linear-gradient(45deg, #73CFF6, #DE95CA);*/
--main-light-background-color: #ffffff;
--main-light-text-color : #000000;
/*--main-light-gradient : linear-gradient(90deg, #46BE73, #BAEBF6);*/
/*--main-light-gradient : linear-gradient(90deg, #AAB9CF, #BDD4E7);*/
--main-light-gradient : #84e4a9;
--main-light-other-color : #46BE73;
/*--main-light-other-color : #f8eaff;*/
/*--main-light-other-color : #d2d2d8;*/
/* --main-light-gradient : #94d3ac;
--main-light-other-color : #75b48d; */
}
*{
font-family: "roboto condensed", sans-serif;
font-weight: 600;
}
/* Général */
body{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
margin : 0%;
}
@ -62,7 +68,7 @@ body.dark-mode .header{
/* Light mode */
body.light-mode{
background-color: var(--main-light-background-color);
background-image: url("../../images/chaos.png");
color: var(--main-light-text-color);
}
@ -96,7 +102,7 @@ body.light-mode .header img{
}
.light-mode .theme-icon:hover, .light-mode .nav a:hover {
filter: brightness(0) saturate(100%) invert(84%) sepia(88%) saturate(6613%) hue-rotate(276deg) brightness(89%) contrast(95%);
filter: brightness(0) saturate(100%) invert(100%) sepia(0%) saturate(0%) hue-rotate(271deg) brightness(103%) contrast(101%);
}
/* écran par défaut */
@ -171,6 +177,18 @@ body{
height : 7vh;
}
.error{
display:block;
margin-top: 30vh;
text-align: center;
font-size: 5em;
}
.explanation{
text-align: center;
font-size: 3em;
}
/* écran tablette*/
@media (max-width: 834px) or (max-aspect-ratio : 1/1){

@ -30,4 +30,69 @@ body.light-mode .citation-du-jour {
transform: scale(1.02);
z-index: 5;
position: relative;
}
}
/* ====== PAGINATION STYLES ====== */
.pagination-container {
display: flex;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.pagination-container select {
display: flex;
justify-content: center;
align-items: center;
margin: 0 10px;
padding: 5px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
}
.pagination-container button {
display: flex;
justify-content: center;
align-items: center;
background: var(--main-light-gradient);
border: none;
border-radius: 5px;
padding: 5px 10px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s ease;
}
.pagination-container button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Spinner style */
.spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
border-left-color: #000;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
margin-left: 10px;
display: none;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Adaptation pour dark mode */
body.dark-mode .pagination-container button {
background: var(--main-dark-gradient);
color: #fff;
}
body.dark-mode .pagination-container select {
border: 1px solid #555;
background: #333;
color: #fff;
}

@ -0,0 +1,76 @@
@import url(./style.css); /* Import de style.css */
h2{
text-align: center;
font-size: 2em;
padding-top: 15px;
font-weight: bolder;
}
h3{
text-align: center;
margin-left: 15px;
margin-right: 15px;
margin-top: -5px;
text-decoration: none;
}
a{
text-decoration: none;
}
.linkQuiz img{
width: 14vw;
height: 22vh;
object-fit: cover;
border-radius: 10px 10px 0px 0px;
margin : 10px;
}
.quizCard{
text-align: center;
border-radius: 15px;
box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.2);
}
.quiz-container{
margin-left: auto;
margin-right: auto;
display: flex;
justify-content: start;
align-items: self-start;
gap: 2vw;
margin-top: 2em;
min-height: 68vh;
width: 95vw;
padding: 15px;
border-radius: 15px;
}
/* Dark mode */
.dark-mode h3 {
color: white;
}
.dark-mode .quizCard {
background: var(--main-dark-gradient);
}
.dark-mode .quiz-container {
background: black;
}
/* Light mode */
.light-mode h3 {
color: black;
}
.light-mode .quizCard {
background: var(--main-light-gradient);
}
.light-mode .quiz-container {
background: #46BE73;
}

@ -1 +1,70 @@
@import url(./style.css); /* Import de style.css */
@import url(./style.css);
body.dark-mode .creation form.add {
background-color: var(--main-dark-other-color);
border-radius: 25px;
padding: 20px;
max-width: 600px;
margin: 40px auto;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
color: var(--main-dark-text-color);
}
body.light-mode .creation form.add {
background-color: var(--main-light-other-color);
border-radius: 25px;
padding: 20px;
max-width: 600px;
margin: 40px auto;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
color: var(--main-light-text-color);
}
.creation form.add input[type="text"],
.creation form.add input[type="number"],
.creation form.add textarea {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
.creation form.add input[type="file"] {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border-radius: 5px;
box-sizing: border-box;
}
.creation form.add input[type="radio"] {
width: auto;
margin-right: 5px;
vertical-align: middle;
}
.creation form.add label {
display: block;
margin-bottom: 5px;
}
.creation form.add input[type="submit"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #ffffff;
cursor: pointer;
transition: background-color 0.3s ease;
}
.creation form.add input[type="submit"]:hover {
background-color: #f9f9f9;
}
.creation form.add h1 {
text-align: center;
margin-bottom: 20px;
}

@ -27,7 +27,7 @@ body.light-mode .resultat {
/* ====== ECRAN DEFAUT ====== */
h1 {
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
text-align: center;
}

@ -61,7 +61,7 @@ body.light-mode a{
}
h1{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
text-align: center;
font-size: 32px;
margin-top: 10%;
@ -71,7 +71,7 @@ p{
margin-top: 6%;
margin-bottom: 2%;
font-size: 20px;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}
.login{
@ -88,11 +88,11 @@ p{
font-size: 1em;
text-align: center;
padding-top: 1%;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}
.buttonSudmite{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
border: none;
padding: 2%;
border-radius: 25px;

@ -34,7 +34,7 @@ body.dark-mode .imgModify{
body.light-mode .inputPasswd{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
margin-top: 2%;
color: black;
}
@ -77,7 +77,7 @@ body.light-mode .login{
body.light-mode .inputPasswd{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
margin-top: 2%;
color: black;
}
@ -90,7 +90,7 @@ body.light-mode .saveButtonPasswd {
/* ====== ECRAN DEFAUT ====== */
h1{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
text-align: center;
font-size: 35px;
}
@ -99,7 +99,7 @@ p{
margin-top: 4%;
margin-bottom: 2%;
font-size: 20px;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}
::backdrop {
@ -110,10 +110,15 @@ p{
height: 60%;
font-size: 15px;
text-align: center;
<<<<<<< HEAD
justify-content: start;
align-items: flex-start;
font-family: "Lemon", serif;
=======
font-family: "roboto condensed", sans-serif;
>>>>>>> 3403a5592cdba73a03915da872f39aba764534a6
display: flex;
flex-wrap: wrap;
border: 15px solid;
border-radius: 20px;
}
@ -132,7 +137,7 @@ p{
}
.buttonSudmite{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
border: none;
padding: 2%;
border-radius: 25px;
@ -146,7 +151,7 @@ p{
font-size: 15px;
text-align: center;
padding-top: 1%;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}
.login{
@ -172,7 +177,7 @@ p{
border-radius: 25px;
border: none;
font-size: 15px;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}

@ -22,7 +22,7 @@ body.dark-mode .submit-button {
body.dark-mode .buttonSudmite {
background: linear-gradient(90deg, #6100ff 0%, #1b0048 100%);
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
border: none;
color: white;
padding: 10px 20px;
@ -50,7 +50,7 @@ body.light-mode .answer {
/* ====== ECRAN DEFAUT ====== */
h1, h2, p {
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
text-align: center;
}

@ -160,7 +160,7 @@ body.light-mode .like-icon-none img {
background-color: #fff;
color: black;
display: flex;
font-family: "Lemon", sans-serif;
font-family: "roboto condensed", sans-serif;
flex-direction: column;
margin-bottom: 1vh;
border-radius: 20px;

@ -37,6 +37,7 @@ a.link-citation:hover {
justify-content: space-around;
width: 100%;
margin: 0 auto;
font-size: medium;
}
a.link-citation {

@ -1,120 +0,0 @@
/* Conteneur pour les suggestions en deux colonnes */
.suggestions-container {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
width: 100%;
margin: 0 auto;
}
a.link-citation {
text-decoration: none;
color: white;
width: 47.5%;
height: 100%;
}
/* Citations */
.citation-container {
background: linear-gradient(to right, #4a148c, #7b1fa2);
border-radius: 12px;
color: white;
display: flex;
width: 100%;
align-items: flex-start;
box-sizing: border-box;
padding: 0;
height: 150px;
overflow: hidden;
margin-bottom: 20px;
word-wrap: break-word; /* Permet de couper les mots trop longs */
word-break: break-word;
}
/* Fixe la taille pour s'assurer que toutes les citations restent cohérentes */
.citation-container .text-content {
flex-grow: 1;
display: flex;
flex-direction: column;
justify-content: center;
height: 150px;
}
.quote {
padding: 0;
overflow: hidden;
}
.citation-image {
width: 150px;
height: 100%;
object-fit: cover;
margin: 0;
border-radius: 0;
}
.text-content {
flex: 1;
padding: 10px;
display: flex;
flex-direction: column;
justify-content: center; /* Centre verticalement le texte */
word-wrap: break-word; /* Permet de couper les mots trop longs */
word-break: break-word;
}
.quoteContent {
font-size: 1.2em;
margin-bottom: 10px;
font-style: italic;
}
.citation .movie, .character, .year {
margin-bottom: 5px;
}
/* Mode sombre */
body.dark-mode .quote {
background: linear-gradient(45deg, #4a148c, #7b1fa2);
color:white;
}
/* Mode clair */
body.light-mode .quote {
background-image: linear-gradient(-28deg, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%);
color:black; /* Changer le texte en noir pour le mode clair */
}
body.light-mode .citation,
body.light-mode .movie,
body.light-mode .character,
body.light-mode .year {
color: black; /* Forcer le texte en noir pour le mode clair */
}
/* Responsive design */
@media (max-width: 768px) {
.suggestions-container {
flex-direction: column;
width: 100%;
}
.citation-container {
width: 100%; /* Chaque citation prend toute la largeur sur mobile */
max-width: 100%;
height: 100px; /* Supprimer la hauteur fixe sur mobile */
}
.citation-image {
width: 100px;
height: 100px;
}
.quote {
font-size: 1em;
}
}

@ -117,6 +117,13 @@ body.dark-mode .filtre label {
body.light-mode .search-container {
background: #ccc;
}
.light-mode form {
background-color: #fff;
margin-top: -30px;
padding-top: 35px;
}
body.light-mode .search-container input[type="search"] {
color: #000;
}
@ -141,4 +148,63 @@ body.light-mode .filtre label {
color: #000000;
cursor: pointer;
transition: all 0.3s ease;
}
}
/* ====== PAGINATION STYLES ====== */
.pagination-container {
display: flex;
justify-content: center;
align-items: center;
margin: 20px 0;
}
.pagination-container select {
margin: 0 10px;
padding: 5px;
font-size: 16px;
border-radius: 5px;
border: 1px solid #ccc;
}
.pagination-container button {
background: var(--main-light-gradient);
border: none;
border-radius: 5px;
padding: 5px 10px;
font-size: 16px;
cursor: pointer;
transition: background 0.3s ease;
}
.pagination-container button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Spinner style */
.spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
border-left-color: #000;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
margin-left: 10px;
display: none;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
/* Adaptation pour dark mode */
body.dark-mode .pagination-container button {
background: var(--main-dark-gradient);
color: #fff;
}
body.dark-mode .pagination-container select {
border: 1px solid #555;
background: #333;
color: #fff;
}

@ -50,7 +50,7 @@ body.light-mode a{
/* ====== ECRAN DEFAULT ====== */
h1{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
text-align: center;
font-size: 32px;
margin-top: 10%;
@ -68,7 +68,7 @@ p{
margin-top: 4%;
margin-bottom: 2%;
font-size: 20px;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}
.confirmer{
@ -87,7 +87,7 @@ p{
}
.btn{
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
border: none;
padding: 2%;
border-radius: 25px;
@ -101,7 +101,7 @@ p{
font-size: 1em;
text-align: center;
padding-top: 1%;
font-family: "Lemon", serif;
font-family: "roboto condensed", sans-serif;
}
.createAccount{

@ -1,31 +1,30 @@
@import url(./style.css);
/* ====== DARK MODE ====== */
body.dark-mode h1, body.dark-mode h2, body.dark-mode p {
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode p {
color: var(--main-dark-text-color);
}
body.dark-mode #box{
body.dark-mode #box {
background: var(--main-dark-other-color);
}
/* ====== LIGHT MODE ====== */
body.light-mode h1, body.light-mode h2, body.light-mode p {
body.light-mode h1,
body.light-mode h2,
body.light-mode p {
color: var(--main-light-text-color);
}
body.light-mode #box{
body.light-mode #box {
background: var(--main-light-other-color);
}
/* ====== ECRAN DEFAULT ====== */
h1, h2{
font-family: "Lemon", serif;
h1, h2 {
font-family: "roboto condensed", sans-serif;
text-align: center;
}
@ -39,13 +38,75 @@ h1, h2{
border-radius: 25px;
}
/* ====== STYLE SPÉCIFIQUE AU FORMULAIRE ====== */
#form select,
#form textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 15px;
box-sizing: border-box;
}
#form input[type="submit"] {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
background-color: #ffffff;
cursor: pointer;
transition: background-color 0.3s ease;
}
#form input[type="submit"]:hover {
background-color: #f9f9f9;
}
/* ====== STYLE SPÉCIFIQUE À LA PAGE DE CONFIRMATION ====== */
/* Espacement entre les blocs internes */
#box > div {
margin-bottom: 15px;
}
/* Style pour les libellés */
#box p {
margin: 0;
font-weight: bold;
}
/* Style pour les valeurs affichées */
#box h2 {
margin: 5px 0 0 0;
font-weight: normal;
}
/* ====== DIVERS ====== */
#contentField, #characterField, #sourceField, #imageField {
/* Style du bouton de retour */
#box button {
align-self: center;
width: 60%;
padding: 20px;
margin : 20px 20% ;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s ease;
font-size: 1rem;
}
#contentField p, #characterField p, #sourceField p, #imageField p {
/* Bouton en dark mode */
body.dark-mode #box button {
background-color: #ffffff;
color: black;
}
#confirm {
}
/* Bouton en light mode */
body.light-mode #box button {
background-color: #ffffff;
color: black;
}
#box button:hover {
background-color: #f9f9f9;
}

@ -1,108 +0,0 @@
/* header.css */
/* Styles généraux */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #120b1d;
font-family: "Lemon", serif;
margin-top: 200px;
}
/* Header */
.header {
display: flex;
position: fixed;
background-color: #000000;
right: 0;
top: 0;
width: 100%;
text-align: center;
padding: 20px;
}
.nav {
display: flex;
align-items: center;
vertical-align: center;
gap: 30px;
width: 40%;
}
.logo {
display: flex;
align-items: center;
justify-content: center;
width: 20%;
}
.user {
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
vertical-align: center;
gap: 30px;
width: 40%;
}
.search {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
vertical-align: center;
margin: 10px;
width: 70px;
height: 70px;
border-radius: 50%;
}
/* Mode sombre */
body.dark-mode {
background-color: #120B1D;
color: #ffffff;
}
body.dark-mode .header {
background-color: #000;
}
body.dark-mode .header img {
filter: invert(0%);
}
body.dark-mode .nav img:hover {
filter: invert(59%) sepia(96%) saturate(6733%) hue-rotate(275deg) brightness(112%) contrast(122%);
}
body.dark-mode .search {
background: white;
}
/* Mode clair */
body.light-mode {
background-color: #ffffff;
color: #000000;
}
body.light-mode .header {
background-color: #F4F1DE;
}
body.light-mode .header img {
filter: invert(100%);
}
body.light-mode .nav img:hover {
filter: invert(22%) sepia(6%) saturate(2269%) hue-rotate(193deg) brightness(98%) contrast(106%);
}
body.light-mode .search {
background: black;
}

@ -16,7 +16,7 @@ Class FrontControler{
global $twig,$racine;
$this->listAction = ['visitor' => array('accueil','search','quote','login','signin','validlogin','validsignin'),
'user' => array('quiz','commentary','logout','addComment','favorite','profil','addFav','supFav','changedata', 'submit', 'validsubmit', 'add','deleteAccount'),
'user' => array('quiz','randomQuiz','commentary','logout','addComment','favorite','profil','addFav','supFav','changedata', 'submit', 'validsubmit', 'add', 'accueilQuiz', 'deleteAccount'),
'admin' => array('null')];
$dVueEreur = [];
@ -37,37 +37,35 @@ Class FrontControler{
*/
// Route mapping using the router object
// Each route is associated with an HTTP method (GET|POST), a URL path, a controller, and a method within that controller.
//Visitor routes
$router->map('GET|POST', '/quote/[i:idQuote]', 'VisitorControler','quote');
$router->map('GET|POST', '/search', 'VisitorControler','search');
$router->map('GET|POST', '/login', 'VisitorControler','login');
$router->map('GET|POST', '/signin', 'VisitorControler','signin');
$router->map('GET|POST', '/validlogin', 'VisitorControler','validlogin');
$router->map('GET|POST', '/validsignin', 'VisitorControler','validsignin');
//User routes
$router->map('GET|POST', '/addComment', 'UserControler','addComment');
$router->map('GET|POST', '/quiz/[i:id]', 'UserControler','quiz');
$router->map('GET|POST', '/favorite', 'UserControler','favorite');
$router->map('GET|POST', '/search', 'VisitorControler','search');
$router->map('GET|POST', '/profil', 'UserControler','profil');
$router->map('GET|POST', '/login', 'VisitorControler','login');
$router->map('GET|POST', '/unlog', 'UserControler','unlog');
$router->map('GET|POST', '/signin', 'VisitorControler','signin');
$router->map('GET|POST', '/validlogin', 'VisitorControler','validlogin');
$router->map('GET|POST', '/validsignin', 'VisitorControler','validsignin');
$router->map('GET|POST', '/addFav/[i:id]', 'UserControler','addFav');
$router->map('GET|POST', '/supFav/[i:id]', 'UserControler','supFav');
$router->map('GET|POST', '/changedata', 'UserControler','changedata');
$router->map('GET|POST', '/submit', 'UserControler', 'submit');
$router->map('GET|POST', '/validsubmit', 'UserControler', 'validsubmit');
$router->map('GET|POST', '/validsubmit', 'UserControler','validsubmit');
$router->map('GET|POST', '/add', 'UserControler', 'add');
$router->map('GET|POST', '/accueilQuiz', 'UserControler', 'accueilQuiz');
$router->map('GET|POST', '/error', 'VisitorControler','error');
$router->map('GET|POST', '/randomQuiz', 'UserControler','randomQuiz');
$router->map('GET|POST', '/deleteAccount', 'UserControler', 'deleteAccount');
$match = $router->match();
$action = NULL;
if(!$match){
$dVueEreur[] = "Requête introuvable";
$dVueEreur = [404,"Page non trouvée"];
$this->vueErreur($dVueEreur);
}
else{
@ -75,9 +73,9 @@ Class FrontControler{
$action = $match['name'];
//If exist
//Si existe, on lappelle
if(!$this->ifExisteAction($action)){
$dVueEreur[] = "Action introuvable";
$dVueEreur = [404,"Action non trouvée"];
$this->vueErreur($dVueEreur);
}
@ -101,62 +99,25 @@ Class FrontControler{
}
/**
* Checks if a given action exists within the predefined lists of actions
* for admin, user, or visitor roles.
*
* @param string $action The action to check.
* @return bool True if the action exists in any of the lists; otherwise, false.
*/
private function ifExisteAction(string $action):bool {
// Check if the action exists in the 'admin' action list
if( in_array($action , $this->listAction['admin']) ||
// Check if the action exists in the 'user' action list
in_array($action , $this->listAction['user']) ||
// Check if the action exists in the 'visitor' action list
in_array($action , $this->listAction['visitor']) ) {
return true;
}
return false;
}
/**
* Verifies if the current user has the rights to perform a given action
* based on their role (admin, user, or visitor) and the predefined lists of actions.
*
* @param string $action The action to verify.
* @return bool True if the user has the rights to perform the action; otherwise, false.
*/
private function verifDroit(string $action):bool {
// Check if the action exists in the 'admin' action list and the user is an admin
if( in_array($action , $this->listAction['admin']) && $_SESSION["role"] == 'admin'){
return true;
}
// Check if the action exists in the 'user' action list and the user is an admin or a user
elseif( in_array($action , $this->listAction['user']) && ($_SESSION["role"] == 'admin' || $_SESSION["role"] == 'user') ) {
return true;
}
// Check if the action exists in the 'visitor' action list and the user is an admin, user, or visitor
elseif(in_array($action , $this->listAction['visitor']) && ($_SESSION["role"] == 'admin'|| $_SESSION["role"] == 'user'|| $_SESSION["role"] == 'visitor')) {
return true;
}
if( in_array($action , $this->listAction['admin']) && $_SESSION["role"] == 'admin') return true;
elseif( in_array($action , $this->listAction['user']) && ($_SESSION["role"] == 'admin' || $_SESSION["role"] == 'user') ) return true;
elseif(in_array($action , $this->listAction['visitor']) && ($_SESSION["role"] == 'admin'|| $_SESSION["role"] == 'user'|| $_SESSION["role"] == 'visitor')) return true;
return false;
}
/**
* Handles the display of errors by rendering an error view and optionally displaying
* the first error message from the provided error array.
*
* @param array $dVueErreur An array of error messages to be displayed.
* @return void
*/
private function vueErreur(array $dVueErreur){
private function vueErreur(array $erreur){
global $vues;
// Display the first error message in the array, if it exists
echo "{$dVueErreur[0]}";
// Include and render the error view from the `$vues` global array
require_once $vues['erreur'];
}

File diff suppressed because it is too large Load Diff

@ -42,121 +42,94 @@ Class VisitorControler {
$this->uMod = new UserModel(new UserGateway($co));
}
/**
* Handles the display of the homepage (accueil) by fetching the quote of the day
* and suggestions, then passing them to the appropriate view.
*
* @return void
*/
public function accueil(){
global $vues;// Access the global variable containing the paths to view files.
global $vues;
// Fetch the quote of the day in French
// Récupérer la citation du jour via AccueilGateway
$citationDuJour = $this->qMod->getQuoteOfTheDay('fr');
// Fetch a list of suggestions in French
$suggestions = $this->qMod->getSuggest(0, 'fr');
// Pass the fetched data to the "accueil" view for rendering.
// Passer les données à la vue
require_once $vues['accueil'];
}
/**
* Displays the details of a specific quote, including its favorite status,
* associated comments, and the quote's content itself.
*
* @param array $arg An associative array containing route parameters, such as the 'idQuote'.
* @return void
*/
public function quote(array $arg){
global $vues;// Access the global variable containing paths to view files.
global $vues;
$id= $arg['idQuote'] ?? 1;
// Check if the quote is marked as a favorite for the logged-in user.
if($id > 999999999){
$erreur = [404,"Citation inexistante pour le moment",'../'];
require_once($vues['erreur']);
exit();
}
$f = $this->uMod->isFavorite($_SESSION["user"],$id);
// Fetch the quote's details using its ID.
$q = $this->qMod->searchId($id);
// Retrieve all comments associated with the quote.
$c = $this->cMod->getComment($id);
// Include the 'quote' view, passing the fetched data for rendering.
require_once $vues['quote'];
if($q->getContent() != 'NULL'){
require_once $vues['quote'];
}
else{
$erreur = [404,"Citation inexistante pour le moment","../"];
require_once($vues['erreur']);
}
}
/**
* Displays the user's list of favorite items by rendering the favorite view.
*
* @return void
*/
public function favorite() {
global $vues;
require_once $vues['favorite'];
}
/**
* Handles the search functionality by processing input parameters,
* validating them, and passing the results to the search view.
*
* @param array $arg An associative array containing route parameters, such as filters ('filtre').
* @return void
*/
public function search(array $arg){
global $vues;
// Validate and retrieve the 'type' parameter from the POST request, defaulting to an empty string if not set.
$type = ( Verification::verifChar( $_POST['type'] ?? ""));
// Validate and retrieve the 'search' parameter from the POST request, defaulting to NULL if not set.
$search = ( Verification::verifChar( $_POST['search'] ?? NULL));
// Validate and retrieve the 'filtre' parameter from the route arguments, defaulting to an empty array if not set.
$filtre = ( Verification::verifArrayChar( $arg['filtre'] ?? []));
// Perform the search using the validated parameters.
$tq=$this->sMod->searchQuote($type,$search,$filtre);
require_once $vues['search'];
}
/**
* Displays the login page by rendering the login view.
*
* @return void
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function login()
{
global $vues;
require_once $vues['login'];
}
//global $twig;
//echo $twig->render("login.html.twig");
//$this -> toLogIn();
}
/**
* Displays the signin page by rendering the signin view.
*
* @return void
* @throws SyntaxError
* @throws RuntimeError
* @throws LoaderError
*/
public function signin(): void
{
global $vues;
require_once $vues['signin'];
//global $twig;
//echo $twig->render("login.html.twig");
//$this -> signin();
}
/**
* Validates user login credentials and initiates a session for authenticated users.
* Redirects to the home page upon successful login, or redisplays the login page with errors otherwise.
*
* @return void
*/
public function validlogin() : void
{
global $vues,$racine;
// Check if the form has been submitted via POST.
if ($_POST)
{
$pseudo = Verification::verifChar($_POST['pseudo'] ?? null);
@ -164,22 +137,18 @@ Class VisitorControler {
$user = $this -> uMod -> getUsername($pseudo);
// Check if the user exists in the database.
if ($user)
{
// Verify the provided password matches the stored hashed password.
if (password_verify($mdp, $user->getPassword()))
{
$_SESSION['user'] = Verification::verifChar($pseudo);
$_SESSION['role'] = 'user';
// Redirect the user to the home page upon successful login.
header("Location: ". $racine);
exit();
}else
{
global $twig;
$errors = "Identifiant ou mot de passe incorrect";
// Redisplay the login page with the error message.
require_once $vues['login'];
exit();
}
@ -188,47 +157,40 @@ Class VisitorControler {
{
global $twig;
$errors = "Identifiant ou mot de passe incorrect";
// Redisplay the login page with the error message
require_once $vues['login'];
exit();
}
}
}
}
/**
* Handles the user registration process, validating input, checking for duplicate users/emails,
* inserting a new user into the database, and initiating a session upon successful registration.
*
* @return void
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function validsignin() : void
{
global $vues,$racine;
// Check if the form has been submitted via POST.
if ($_POST) {
// Validate and sanitize the input fields from the POST request.
$pseudo = Verification::verifChar($_POST['pseudo'] ?? null);
$email = Verification::verifChar($_POST['email'] ?? null);
$mdp = Verification::verifChar($_POST['mdp'] ?? null);
$cmdp = Verification::verifChar($_POST['cmdp'] ?? null);
// Check if the passwords match.
if ($mdp != $cmdp) {
$errors[2] = "Mots de passe incorrects";
require_once $vues['signin'];
exit();
}
// Hash the password securely with bcrypt and a cost factor of 12.
$option = ['cost' => 12];
$hmdp = password_hash($mdp, PASSWORD_BCRYPT, $option);
// Check if the username or email is already in use.
$isUserAlreadyUsed = $this -> uMod -> getUsername($pseudo);
$isEmailAlreadyUsed = $this -> uMod -> getEmail($email);
// Handle cases where the username or email is already taken.
if ($isUserAlreadyUsed and !$isEmailAlreadyUsed) {
$errors[0] = "Pseudo déjà utilisé";
require_once $vues['signin'];
@ -245,11 +207,8 @@ Class VisitorControler {
require_once $vues['signin'];
exit();
}
else{
// Insert the new user into the database.
echo $this->uMod->insertUser($pseudo, $email, $hmdp);
}
// Send a confirmation email to the user after successful registration.
else echo $this->uMod->insertUser($pseudo, $email, $hmdp);
$this->sendEmailSubmit($email, $pseudo);
@ -260,36 +219,28 @@ Class VisitorControler {
}
}
/**
* Sends a confirmation email to the user after account creation.
* Includes an HTML message with an embedded image.
*
* @param string $email The recipient's email address.
* @param string $pseudo The recipient's username.
* @return string|null Returns an error message if the image cannot be loaded, otherwise null.
*/
function sendEmailSubmit(string $email, string $pseudo) {
// Subject of the email
// Génère les données du message
$sujet = "What The Fantasy - Création de compte";
// Path to the image file to be embedded in the email
$urlImage = "public/images/Baneer.png";
// Generate a unique boundary for separating parts of the email
// Génère une frontière unique pour l'email
$boundary = "-----=" . md5(uniqid(mt_rand()));
// Initialize email headers
//Instancie les headers
$headers = "From: noreply@whatTheFantasy.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/related; boundary=\"$boundary\"\r\n";
// Start building the email body
// Corps de l'email HTML avec l'image intégrée
$corpsMessage = "--$boundary\r\n";
$corpsMessage .= "Content-Type: text/html; charset=UTF-8\r\n";
$corpsMessage .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
// Add the HTML message content
// Ajoute le message HTML
$corpsMessage .= "<html>
<body>
<img src=\"cid:image1\" alt=\"Image\" style=\"width: 1200px; height: auto;\" />
@ -302,25 +253,24 @@ Class VisitorControler {
</body>
</html>\r\n";
// Add the embedded image as a related part
// Ajoute l'image en pièce jointe
$corpsMessage .= "--$boundary\r\n";
$corpsMessage .= "Content-Type: image/jpeg; name=\"image.jpg\"\r\n";
$corpsMessage .= "Content-Transfer-Encoding: base64\r\n";
$corpsMessage .= "Content-ID: <image1>\r\n\r\n";
// Read and encode the image file
$imageContent = file_get_contents($urlImage);
$imageContent = file_get_contents($urlImage);// Lecture et encodage de l'image en base64
if ($imageContent === false) {
return "Impossible de charger l'image spécifiée.";
}
// Encode and add the image content
$corpsMessage .= chunk_split(base64_encode($imageContent)) . "\r\n";
// End the email body with the closing boundary
$corpsMessage .= "--$boundary--";// Fin du corps de l'email
// Send the email
mail($email, $sujet, $corpsMessage, $headers);
mail($email, $sujet, $corpsMessage, $headers);// Envoi de l'email
}
}

@ -3,14 +3,14 @@ namespace Entity;
class CharacterEntity
{
// Properties
private int $id_character;
private string $name;
private string $img_path;
/**
* Constructor
*
* @param int $id_character
* @param string $name
* @param string $img_path
@ -23,8 +23,6 @@ class CharacterEntity
}
/**
* Get the character ID
*
* @return int
*/
public function getIdCharacter(): int
@ -33,8 +31,6 @@ class CharacterEntity
}
/**
* Set the character ID
*
* @param int $id_character
*/
public function setIdCharacter(int $id_character): void
@ -43,8 +39,6 @@ class CharacterEntity
}
/**
* Get the character name
*
* @return string
*/
public function getName(): string
@ -53,8 +47,6 @@ class CharacterEntity
}
/**
* Set the character name
*
* @param string $name
*/
public function setName(string $name): void
@ -63,8 +55,6 @@ class CharacterEntity
}
/**
* Get the image path
*
* @return string
*/
public function getImgPath(): string
@ -73,12 +63,12 @@ class CharacterEntity
}
/**
* Set the image path
*
* @param string $img_path
*/
public function setImgPath(string $img_path): void
{
$this->img_path = $img_path;
}
}

@ -13,8 +13,6 @@ class CommentaryEntity {
* @param int $id_comment
* @param string $comment
* @param string $date
* @param string $user
* @param string $img
*/
public function __construct(int $id_comment, string $comment, string $date, string $user, string $img)
{
@ -84,7 +82,7 @@ class CommentaryEntity {
/**
* @param string $user
*/
public function setUser(string $user): void
public function setUser(int $user): void
{
$this->user = $user;
}
@ -100,7 +98,7 @@ class CommentaryEntity {
/**
* @param string $img
*/
public function setImg(string $img): void
public function setImg(int $img): void
{
$this->img = $img;
}

@ -3,12 +3,10 @@ namespace Entity;
class FavoriteEntity
{
private int $id_user; // ID of the user
private int $id_quote; // ID of the quote
private int $id_user;
private int $id_quote;
/**
* Constructor to initialize the FavoriteEntity with user ID and quote ID
*
* @param int $id_user
* @param int $id_quote
*/
@ -19,8 +17,6 @@ class FavoriteEntity
}
/**
* Get the user ID
*
* @return int
*/
public function getIdUser(): int
@ -29,8 +25,6 @@ class FavoriteEntity
}
/**
* Set the user ID
*
* @param int $id_user
*/
public function setIdUser(int $id_user): void
@ -39,8 +33,6 @@ class FavoriteEntity
}
/**
* Get the quote ID
*
* @return int
*/
public function getIdQuote(): int
@ -49,12 +41,13 @@ class FavoriteEntity
}
/**
* Set the quote ID
*
* @param int $id_quote
*/
public function setIdQuote(int $id_quote): void
{
$this->id_quote = $id_quote;
}
}

@ -3,14 +3,13 @@ namespace Entity;
class ImageEntity
{
private int $idImg; // ID of the image
private string $imgPath; // Path to the image file
private int $idImg;
private string $imgPath;
/**
* Constructor for ImageEntity
*
* @param int $idImg ID of the image
* @param string $imgPath Path to the image file
* @param int $idImg
* @param string $imgPath
* @param string $isImgProfile
*/
public function __construct(int $idImg, string $imgPath)
{
@ -18,43 +17,25 @@ class ImageEntity
$this->imgPath = $imgPath;
}
/**
* Get the ID of the image
*
* @return int
*/
public function getIdImg(): int
{
return $this->idImg;
}
/**
* Set the ID of the image
*
* @param int $idImg
*/
public function setIdImg(int $idImg): void
{
$this->idImg = $idImg;
}
/**
* Get the path to the image file
*
* @return string
*/
public function getImgPath(): string
{
return $this->imgPath;
}
/**
* Set the path to the image file
*
* @param string $imgPath
*/
public function setImgPath(string $imgPath): void
{
$this->imgPath = $imgPath;
}
}

@ -1,175 +1,148 @@
<?php
namespace Entity;
class QuestionEntity
{
private int $id_question;
private string $question;
private string $answerA;
private string $answerB;
private string $answerC;
private string $answerD;
private string $cAnswer;
/**
* Constructor to initialize the QuestionEntity object.
*
* @param int $id_question The ID of the question.
* @param string $question The question text.
* @param string $answerA The text for answer A.
* @param string $answerB The text for answer B.
* @param string $answerC The text for answer C.
* @param string $answerD The text for answer D.
* @param string $cAnswer The correct answer.
*/
public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer)
{
$this->id_question = $id_question;
$this->question = $question;
$this->answerA = $answerA;
$this->answerB = $answerB;
$this->answerC = $answerC;
$this->answerD = $answerD;
$this->cAnswer = $cAnswer;
}
/**
* Get the ID of the question.
*
* @return int The ID of the question.
*/
public function getIdQuestion(): int
{
return $this->id_question;
}
/**
* Set the ID of the question.
*
* @param int $id_question The ID of the question.
*/
public function setIdQuestion(int $id_question): void
{
$this->id_question = $id_question;
}
/**
* Get the question text.
*
* @return string The question text.
*/
public function getQuestion(): string
{
return $this->question;
}
/**
* Set the question text.
*
* @param string $question The question text.
*/
public function setQuestion(string $question): void
{
$this->question = $question;
}
/**
* Get the text for answer A.
*
* @return string The text for answer A.
*/
public function getAnswerA(): string
{
return $this->answerA;
}
/**
* Set the text for answer A.
*
* @param string $answerA The text for answer A.
*/
public function setAnswerA(string $answerA): void
{
$this->answerA = $answerA;
}
namespace Entity;
/**
* Get the text for answer B.
*
* @return string The text for answer B.
*/
public function getAnswerB(): string
class QuestionEntity
{
return $this->answerB;
}
/**
* Set the text for answer B.
*
* @param string $answerB The text for answer B.
*/
public function setAnswerB(string $answerB): void
{
$this->answerB = $answerB;
}
private int $id_question;
private string $question;
private string $answerA;
private string $answerB;
private string $answerC;
private string $answerD;
private string $cAnswer;
/**
* @param int $id_question
* @param string $question
* @param string $answerA
* @param string $answerB
* @param string $answerC
* @param string $answerD
* @param string $cAnswer
*/
public function __construct(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer)
{
$this->id_question = $id_question;
$this->question = $question;
$this->answerA = $answerA;
$this->answerB = $answerB;
$this->answerC = $answerC;
$this->answerD = $answerD;
$this->cAnswer = $cAnswer;
}
/**
* @return int
*/
public function getIdQuestion(): int
{
return $this->id_question;
}
/**
* @param int $id_question
*/
public function setIdQuestion(int $id_question): void
{
$this->id_question = $id_question;
}
/**
* @return string
*/
public function getQuestion(): string
{
return $this->question;
}
/**
* @param string $question
*/
public function setQuestion(string $question): void
{
$this->question = $question;
}
/**
* @return string
*/
public function getAnswerA(): string
{
return $this->answerA;
}
/**
* @param string $answerA
*/
public function setAnswerA(string $answerA): void
{
$this->answerA = $answerA;
}
/**
* @return string
*/
public function getAnswerB(): string
{
return $this->answerB;
}
/**
* @param string $answerB
*/
public function setAnswerB(string $answerB): void
{
$this->answerB = $answerB;
}
/**
* @return string
*/
public function getAnswerC(): string
{
return $this->answerC;
}
/**
* @param string $answerC
*/
public function setAnswerC(string $answerC): void
{
$this->answerC = $answerC;
}
/**
* @return string
*/
public function getAnswerD(): string
{
return $this->answerD;
}
/**
* @param string $answerD
*/
public function setAnswerD(string $answerD): void
{
$this->answerD = $answerD;
}
/**
* @return string
*/
public function getCAnswer(): string
{
return $this->cAnswer;
}
/**
* @param string $cAnswer
*/
public function setCAnswer(string $cAnswer): void
{
$this->cAnswer = $cAnswer;
}
/**
* Get the text for answer C.
*
* @return string The text for answer C.
*/
public function getAnswerC(): string
{
return $this->answerC;
}
/**
* Set the text for answer C.
*
* @param string $answerC The text for answer C.
*/
public function setAnswerC(string $answerC): void
{
$this->answerC = $answerC;
}
/**
* Get the text for answer D.
*
* @return string The text for answer D.
*/
public function getAnswerD(): string
{
return $this->answerD;
}
/**
* Set the text for answer D.
*
* @param string $answerD The text for answer D.
*/
public function setAnswerD(string $answerD): void
{
$this->answerD = $answerD;
}
/**
* Get the correct answer.
*
* @return string The correct answer.
*/
public function getCAnswer(): string
{
return $this->cAnswer;
}
/**
* Set the correct answer.
*
* @param string $cAnswer The correct answer.
*/
public function setCAnswer(string $cAnswer): void
{
$this->cAnswer = $cAnswer;
}
}

@ -3,25 +3,30 @@ namespace Entity;
class QuizEntity
{
// Properties
private int $id_quiz; // ID of the quiz
private int $nb_questions; // Number of questions in the quiz
public int $id_quiz;
public int $nb_quest;
public string $imgPath;
public string $title;
/**
* Constructor
*
* @param int $id_quiz ID of the quiz
* @param int $nb_questions Number of questions in the quiz
* @param int $id_quiz
* @param int $nb_quest
* @param string $imgPath
* @param string $title
*/
public function __construct(int $id_quiz, int $nb_questions)
public function __construct(int $id_quiz, int $nb_quest, string $imgPath, string $title)
{
$this->id_quiz = $id_quiz;
$this->nb_questions = $nb_questions;
$this->nb_quest = $nb_quest;
$this->imgPath = $imgPath;
$this->title = $title;
}
/**
* Get the ID of the quiz
*
* @return int
*/
public function getIdQuiz(): int
@ -30,8 +35,6 @@ class QuizEntity
}
/**
* Set the ID of the quiz
*
* @param int $id_quiz
*/
public function setIdQuiz(int $id_quiz): void
@ -40,22 +43,50 @@ class QuizEntity
}
/**
* Get the number of questions in the quiz
*
* @return int
*/
public function getNbQuestions(): int
{
return $this->nb_questions;
return $this->nb_quest;
}
/**
* @param int $nb_quest
*/
public function setNbQuestions(int $nb_quest): void
{
$this->nb_quest = $nb_quest;
}
/**
* @return string
*/
public function getIdImg(): string
{
return $this->imgPath;
}
/**
* @param string $imgPath
*/
public function setIdImg(string $imgPath): void
{
$this->imgPath = $imgPath;
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* Set the number of questions in the quiz
*
* @param int $nb_questions
* @param string $title
*/
public function setNbQuestions(int $nb_questions): void
public function setTitle(string $title): void
{
$this->nb_questions = $nb_questions;
$this->title = $title;
}
}

@ -1,16 +1,15 @@
<?php
namespace Entity;
class QuizQuestionEntity
{
private int $id_question; // ID of the question
private int $id_quiz; // ID of the quiz
private int $id_question;
private int $id_quiz;
/**
* Constructor to initialize the QuizQuestionEntity
*
* @param int $id_question ID of the question
* @param int $id_quiz ID of the quiz
* @param int $id_question
* @param int $id_quiz
*/
public function __construct(int $id_question, int $id_quiz)
{
@ -19,9 +18,7 @@ class QuizQuestionEntity
}
/**
* Get the ID of the question
*
* @return int ID of the question
* @return int
*/
public function getIdQuestion(): int
{
@ -29,9 +26,7 @@ class QuizQuestionEntity
}
/**
* Set the ID of the question
*
* @param int $id_question ID of the question
* @param int $id_question
*/
public function setIdQuestion(int $id_question): void
{
@ -39,9 +34,7 @@ class QuizQuestionEntity
}
/**
* Get the ID of the quiz
*
* @return int ID of the quiz
* @return int
*/
public function getIdQuiz(): int
{
@ -49,12 +42,13 @@ class QuizQuestionEntity
}
/**
* Set the ID of the quiz
*
* @param int $id_quiz ID of the quiz
* @param int $id_quiz
*/
public function setIdQuiz(int $id_quiz): void
{
$this->id_quiz = $id_quiz;
}
}

@ -1,32 +1,19 @@
<?php
namespace Entity;
class Quote{
use Enum\TypeSourceEnum;
class Quote{
// Represents the unique identifier for the quote
private int $id;
// The content of the quote
private string $content;
// The characteristic or attribute associated with the quote
private string $carac;
// The file path to the image associated with the quote
private string $imgPath;
// The title source of the quote
private string $titleSrc;
// The date source of the quote
private string $dateSrc;
// The number of likes the quote has received
private int $like;
// The language of the quote
private string $langue;
private TypeSourceEnum $type;
/**
* @param int $id
@ -38,7 +25,7 @@
* @param int $like
* @param string $langue
*/
public function __construct(int $id, string $content, string $carac, string $imgPath, string $titleSrc, string $dateSrc, int $like, string $langue)
public function __construct(int $id, string $content, string $carac, string $imgPath, string $titleSrc, string $dateSrc, int $like, string $langue, TypeSourceEnum $type)
{
$this->id = $id;
$this->content = $content;
@ -48,6 +35,7 @@
$this->dateSrc = $dateSrc;
$this->like = $like;
$this->langue = $langue;
$this->type = $type;
}
/**
@ -178,7 +166,13 @@
$this->langue = $langue;
}
public function getType(): TypeSourceEnum{
return $this->type;
}
public function setType(TypeSourceEnum $type){
$this->type = $type;
}
}
?>

@ -3,111 +3,67 @@ namespace Entity;
class ResultsEntity
{
// Property to store the quiz ID
private int $idQuiz;
// Property to store the user ID
private int $idUser;
// Property to store the number of points
private int $nbPts;
// Property to store the time
private int $time;
/**
* Constructor to initialize the properties
*
* @param int $idQuiz The ID of the quiz
* @param int $idUser The ID of the user
* @param int $time The time taken
* @param int $nbPts The number of points
*/
public function __construct(int $idQuiz, int $idUser, int $time, int $nbPts)
{
$this->idQuiz = $idQuiz;
$this->idUser = $idUser;
$this->time = $time;
$this->nbPts = $nbPts;
}
/**
* Get the user ID
*
* @return int The ID of the user
*/
public function getIdUser(): int
{
return $this->idUser;
}
/**
* Set the user ID
*
* @param int $idUser The ID of the user
*/
public function setIdUser(int $idUser): void
{
$this->idUser = $idUser;
}
/**
* Get the quiz ID
*
* @return int The ID of the quiz
*/
public function getIdQuiz(): int
{
return $this->idQuiz;
}
/**
* Set the quiz ID
*
* @param int $idQuiz The ID of the quiz
*/
public function setIdQuiz(int $idQuiz): void
{
$this->idQuiz = $idQuiz;
}
/**
* Get the time taken
*
* @return int The time taken
*/
public function getTime(): int
{
return $this->time;
}
/**
* Set the time taken
*
* @param int $time The time taken
*/
public function setTime(int $time): void
{
$this->time = $time;
}
/**
* Get the number of points
*
* @return int The number of points
*/
public function getNbPts(): int
{
return $this->nbPts;
}
/**
* Set the number of points
*
* @param int $nbPts The number of points
*/
public function setNbPts(int $nbPts): void
{
$this->nbPts = $nbPts;
}
private int $idUser;
private int $nbPts;
private int $time;
/**
* @param int $idQuiz
* @param int $idUser
* @param int $time
* @param int $nbPts
*/
public function __construct(int $idQuiz, int $idUser, int $time, int $nbPts)
{
$this -> idQuiz = $idQuiz;
$this -> idUser = $idUser;
$this -> time = $time;
$this -> nbPts = $nbPts;
}
}

@ -5,33 +5,28 @@ use Enum\TypeSourceEnum;
class SourceEntity
{
private int $id_source; // ID of the source
private int $id_source;
private string $title; // Title of the source
private string $title;
private string $date; // Date of the source
private string $date;
private TypeSourceEnum $type; // Type of the source
private TypeSourceEnum $type;
/**
* Constructor to initialize the SourceEntity object
*
* @param int $id_source
* @param string $title
* @param string $date
* @param TypeSourceEnum $type
*/
public function __construct(int $id_source, string $title, string $date, TypeSourceEnum $type)
{
$this->id_source = $id_source;
$this->title = $title;
$this->date = $date;
//$this->type = $type; // Uncomment this line to initialize the type
//$this->type = $type;
}
/**
* Get the ID of the source
*
* @return int
*/
public function getIdSource(): int
@ -40,8 +35,6 @@ class SourceEntity
}
/**
* Set the ID of the source
*
* @param int $id_source
*/
public function setIdSource(int $id_source): void
@ -50,8 +43,6 @@ class SourceEntity
}
/**
* Get the title of the source
*
* @return string
*/
public function getTitle(): string
@ -60,8 +51,6 @@ class SourceEntity
}
/**
* Set the title of the source
*
* @param string $title
*/
public function setTitle(string $title): void
@ -70,8 +59,6 @@ class SourceEntity
}
/**
* Get the date of the source
*
* @return string
*/
public function getDate(): string
@ -80,8 +67,6 @@ class SourceEntity
}
/**
* Set the date of the source
*
* @param string $date
*/
public function setDate(string $date): void
@ -89,23 +74,17 @@ class SourceEntity
$this->date = $date;
}
/**
* Get the type of the source
*
* @return TypeSourceEnum
*/
public function getType(): TypeSourceEnum
{
return $this->type;
}
/**
* Set the type of the source
*
* @param TypeSourceEnum $type
*/
public function setType(TypeSourceEnum $type): void
{
$this->type = $type;
}
}

@ -6,4 +6,14 @@ enum TypeSourceEnum : string {
case VideoGame = 'video-game';
case Anime = 'anime';
case Serie = 'serie';
public static function fromName(string $name): string
{
foreach (self::cases() as $status) {
if( $name === $status->name ){
return $status->value;
}
}
throw new \ValueError("$name is not a valid backing value for enum " . self::class );
}
}

@ -8,142 +8,77 @@ use PDO;
class CharacterGateway extends Gateway
{
/**
* Creates a new character record in the database.
*
* This method inserts a new character into the `caracter` table using the provided character
* ID, name, and image path.
*
* @param int $id_character The unique ID for the character.
* @param string $name The name of the character.
* @param string $img_char The path to the character's image.
*
* @return bool Returns `true` if the character was successfully created,
* or `false` if the insertion failed (e.g., due to a database error).
*/
public function create(int $id_character, string $name, string $img_char) : bool
public function create(int $id_character, string $name , string $img_char) : bool
{
// SQL query to insert a new character into the "caracter" table
$query = "INSERT INTO caracter
VALUES(:id_caracter, :caracter, :id_img)";
$query = "
INSERT INTO caracter
VALUES(:id_caracter, :caracter, :id_img)
";
// Execute the query with the provided parameters
return $this->co->executeQuery($query, [
return $this -> co -> executeQuery($query, [
'id_caracter' => array($id_character, PDO::PARAM_INT),
'caracter' => array($name, PDO::PARAM_STR),
'id_img' => array($img_char, PDO::PARAM_STR)
'id_img' => array($img_char, PDO::PARAM_INT)
]);
}
}
/**
* Finds a character by its ID in the database.
*
* This method retrieves a character from the `caracter` table by its unique character ID.
*
* @param int $id The unique ID of the character to retrieve.
*
* @return array Returns an array containing the character data if found, or an empty array if no matching character is found.
*/
public function findById(int $id) : array
{
// SQL query to select a character by its unique ID
$query = "SELECT * FROM caracter WHERE id_caracter = :id_c";
// Execute the query with the provided character ID
$this->co->executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
// Return the results (array of matching character data)
return $this->co->getResults();
$this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
return $this -> co -> getResults();
}
/**
* Finds a character by its name in the database.
*
* This method retrieves a character from the `caracter` table by its name.
*
* @param string $name The name of the character to retrieve.
*
* @return array Returns an array containing the character data if found, or an empty array if no matching character is found.
*/
public function findByName(string $name) : array
{
// SQL query to select a character by its name
$query = "SELECT * FROM caracter WHERE caracter = :n";
// Execute the query with the provided character name
$this->co->executeQuery($query, ["n" => array($name, PDO::PARAM_STR)]);
// Return the results (array of matching character data)
return $this->co->getResults();
$this -> co -> executeQuery($query, ["n" => array($name, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
/**
* Retrieves all characters from the database.
*
* This method fetches all rows from the `caracter` table, ordering them by the character name (`caracter`) in ascending order.
*
* @return array Returns an array of all characters. Each character is represented as an associative array with column names as keys.
*/
public function findAll() : array
{
// SQL query to retrieve all characters from the 'caracter' table, ordered by character name in ascending order
$query = "SELECT * FROM caracter ORDER BY caracter ASC";
// Execute the query
$this->co->executeQuery($query);
// Return the results, which is an array of all character records
return $this->co->getResults();
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
/**
* Deletes a character from the database by its ID.
*
* This method removes a character from the `caracter` table based on the provided character ID (`id_caracter`).
* It executes a DELETE SQL query to remove the record from the database.
*
* @param int $id The ID of the character to be deleted.
*
* @return bool Returns `true` if the deletion was successful, `false` otherwise.
*/
public function delete(int $id) : bool
{
// SQL query to delete a character from the 'caracter' table by character ID
$query = "DELETE FROM caracter WHERE id_caracter = :id_c";
// Execute the query using the provided character ID, binding the parameter to an integer
return $this -> co -> executeQuery($query, ["id_c" => array($id, PDO::PARAM_INT)]);
}
/**
* Updates the details of a character in the database.
*
* This method updates a character's name and associated image in the `caracter` table
* based on the provided character ID (`id_caracter`).
*
* @param int $id_char The ID of the character to be updated.
* @param string $name The new name for the character.
* @param string $img_char The new image path for the character.
*
* @return bool Returns `true` if the update was successful, `false` otherwise.
*/
public function update(int $id_char, string $name, string $img_char) : bool
{
// SQL query to update the character's name and image based on character ID
$query = "UPDATE caracter
$query = "
UPDATE caracter
SET caracter = :n, id_img = :i
WHERE id_caracter = :id_c";
WHERE id_caracter = :id_c
";
// Execute the query, binding the parameters for character ID, name, and image path
return $this -> co -> executeQuery($query, [
"id_c" => array($id_char, PDO::PARAM_INT),
"caracter" => array($name, PDO::PARAM_STR),
"i" => array($img_char, PDO::PARAM_STR)
"i" => array($img_char, PDO::PARAM_INT)
]);
}
public function getLastId():int{
$query = "SELECT id_caracter FROM Caracter;";
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
foreach($res as $r){
$tab[] = $r["id_caracter"];
}
$id = 1;
while(in_array($id,$tab))
{
$id=$id+1;
}
return $id;
}
}

@ -4,205 +4,70 @@ use PDO;
class CommentaryGateway extends Gateway{
/**
* Finds the first available ID for a new comment in the Commentary table.
*
* This method retrieves all existing comment IDs from the Commentary table, determines the first unused ID,
* and returns it. If there are no comments in the table, it returns `1` as the starting ID.
*
* @return int The first available ID for a new comment.
*/
public function firstIdComment(): int
{
// Define the query to fetch all comment IDs from the Commentary table
$query = "SELECT id_comment FROM Commentary;";
// Execute the query and fetch the results
$this->co->executeQuery($query);
$res = $this->co->getResults();
// Initialize an array to store existing comment IDs
public function firstIdComment():int{
$query = "Select id_comment from Commentary;";
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
$tab = null;
// Populate the array with IDs from the result set
foreach ($res as $r) {
foreach($res as $r){
$tab[] = $r["id_comment"];
}
// If no comments exist, return 1 as the starting ID
if ($tab == null) {
if($tab == null){
return 1;
}
// Initialize the ID counter
$id = 1;
// Increment the ID until a gap is found (i.e., an ID that is not in the array)
while (in_array($id, $tab)) {
$id = $id + 1;
}
// Return the first available ID
$id=1;
while(in_array($id,$tab)){$id=$id+1;}
return $id;
}
public function create(string $comment ,string $idUser, int $idQuote) :bool {
$id=$this->firstIdComment();
/**
* Creates a new comment in the database.
*
* This method inserts a new comment for a given quote and user into the `Commentary` table.
* It automatically generates a unique comment ID by calling the `firstIdComment()` method.
*
* @param string $comment The text content of the comment.
* @param string $idUser The ID of the user who is posting the comment.
* @param int $idQuote The ID of the quote that the comment is associated with.
*
* @return bool `true` if the comment was successfully created, `false` otherwise.
*/
public function create(string $comment, string $idUser, int $idQuote): bool
{
// Get the first available comment ID using the firstIdComment method
$id = $this->firstIdComment();
// Prepare the SQL query to insert a new comment
$query = "INSERT INTO Commentary(quote, users, datec, comment, id_comment)
VALUES(:idQuote, :idUser, CURRENT_DATE, :comment, :idComment)";
// Execute the query with the provided parameters
return $this->co->executeQuery($query, array(
$query="INSERT INTO Commentary(quote,users,datec,comment,id_comment) VALUES(:idQuote, :idUser , CURRENT_DATE,:comment ,:idComment)";
return $this -> co -> executeQuery($query, array(
"comment" => array($comment, PDO::PARAM_STR),
"idUser" => array($idUser, PDO::PARAM_STR),
"idQuote" => array($idQuote, PDO::PARAM_INT),
"idComment" => array($id, PDO::PARAM_INT)
));
"idComment" => array($id, PDO::PARAM_INT)));
}
public function findById(int $id) : array {
/**
* Retrieves a commentary by its unique ID.
*
* This method queries the `Commentary` table to find a comment by its `id_comment`.
* It returns an array containing the details of the comment if found.
*
* @param int $id The unique ID of the comment to retrieve.
*
* @return array An array containing the commentary details (or an empty array if no comment is found).
*/
public function findById(int $id): array
{
// SQL query to find the commentary by its unique ID
$query = "SELECT *
FROM Commentary
WHERE id_comment = :id_comment";
// Execute the query with the provided comment ID as a parameter
$this->co->executeQuery($query, array("id_comment" => $id));
// Return the results from the query execution
return $this->co->getResults();
}
$query="SELECT * FROM Commentary WHERE id_comment = :id_comment";
/**
* Retrieves all comments associated with a specific quote.
*
* This method queries the `Commentary`, `Users`, and `Image` tables to find all comments related
* to a specific quote, and returns the details of each comment, including the commenter's username,
* the commenter's profile image path, and the comment itself, ordered by date in descending order.
*
* @param int $id The ID of the quote for which comments are being retrieved.
*
* @return array An array containing the details of all comments associated with the specified quote.
* Each entry includes the comment ID, comment date, content, username, and profile image path.
*/
public function findByQuote(int $id): array
{
// SQL query to retrieve comments for a specific quote, joining with the Users and Image tables
$query = "SELECT c.id_comment, c.dateC, c.comment, u.username, i.imgPath
FROM Commentary c
JOIN Users u ON u.id_user = c.users
JOIN Image i ON i.id_img = u.img
WHERE quote = :idQuote
ORDER BY c.datec DESC";
// Execute the query with the provided quote ID as a parameter
$this->co->executeQuery($query, array("idQuote" => array($id, PDO::PARAM_STR)));
// Return the results from the query execution
return $this->co->getResults();
$this -> co -> executeQuery($query, array("id_comment" => $id));
return $res = $this -> co -> getResults();
}
public function findByQuote(int $id) : array{
$query="SELECT c.id_comment, c.dateC, c.comment, u.username, i.imgPath FROM Commentary c JOIN Users u ON u.id_user = c.users JOIN Image i ON i.id_img = u.img WHERE quote = :idQuote ORDER BY c.datec DESC";
$this -> co -> executeQuery($query, array("idQuote" => array($id,PDO::PARAM_STR)));
return $res = $this -> co -> getResults();
}
/**
* Retrieves all comments from the database.
*
* This method executes a query to fetch all records from the `Commentary` table,
* and returns the details of each comment stored in the database.
*
* @return array An array containing all the comments in the `Commentary` table.
* Each entry includes details of the comment, such as the comment's ID,
* creation date, content, user who made the comment, and the quote associated with it.
*/
public function findAll() : array
{
// SQL query to retrieve all comments from the `Commentary` table
$query = "SELECT * FROM Commentary";
public function findAll() : array {
$query="SELECT * FROM Commentary";
$this -> co -> executeQuery($query);
return $res = $this -> co -> getResults();
}
// Execute the query
$this->co->executeQuery($query);
public function delete(int $id) : bool {
$query="DELETE FROM Commentary WHERE id_comment = :id_comment";
return $this -> co -> executeQuery($query, array("id_comment" => $id));
// Return the results from the query execution
return $this->co->getResults();
}
public function update(commentaryEntity $c) : bool {
/**
* Deletes a comment from the database.
*
* This method executes a query to delete a specific comment from the `Commentary` table
* based on the provided comment ID. It will remove the comment with the given ID if it exists.
*
* @param int $id The ID of the comment to be deleted.
*
* @return bool Returns `true` if the comment was successfully deleted,
* or `false` if the deletion failed (e.g., if the comment ID was not found).
*/
public function delete(int $id) : bool
{
// SQL query to delete a comment with the specified ID
$query = "DELETE FROM Commentary
WHERE id_comment = :id_comment";
// Execute the query and return the result
return $this->co->executeQuery($query, array("id_comment" => $id));
}
$query="UPDATE Commentary SET comment = :comment WHERE id_comment = :id_comment";
return $this -> co -> executeQuery($query, array(
"comment" => array($c->getComment(),PDO::PARAM_STR),
"id_comment" => array($c->getIdComment(),PDO::PARAM_INT))
);
/**
* Updates a comment in the database.
*
* This method executes a query to update the `comment` field of a specific comment in the
* `Commentary` table based on the provided `commentaryEntity` object. It will update the
* comment with the given ID if it exists.
*
* @param commentaryEntity $c The commentary entity containing the new comment content and comment ID.
*
* @return bool Returns `true` if the comment was successfully updated,
* or `false` if the update failed (e.g., if the comment ID was not found).
*/
public function update(commentaryEntity $c) : bool
{
// SQL query to update the comment based on its ID
$query = "UPDATE Commentary
SET comment = :comment
WHERE id_comment = :id_comment";
// Execute the query with the parameters from the commentary entity object
return $this->co->executeQuery($query, array(
"comment" => array($c->getComment(), PDO::PARAM_STR),
"id_comment" => array($c->getIdComment(), PDO::PARAM_INT)
));
}
}
?>

@ -6,139 +6,66 @@ use PDO;
class FavoriteGateway extends Gateway
{
/**
* Adds a new favorite entry to the `Favorite` table.
*
* This method inserts a record into the `Favorite` table, linking a user (`idUser`) with
* a specific quote (`idQuote`). It assumes that the `Favorite` table has two columns:
* - `user` (foreign key referencing the user's ID)
* - `quote` (foreign key referencing the quote's ID)
*
* @param int $idUser The ID of the user who is marking the quote as a favorite.
* Must correspond to an existing user in the database.
* @param int $idQuote The ID of the quote being marked as a favorite.
* Must correspond to an existing quote in the database.
*
* @return bool Returns `true` if the query was successfully executed, indicating the favorite
* was added. Returns `false` if the query execution failed.
*/
public function createFavoriteGateway(int $idUser, int $idQuote) : bool
{
// Define the SQL query to insert a new favorite entry
$query = "INSERT INTO Favorite
VALUES (:user, :quote)";
$query = "
INSERT INTO Favorite
VALUES (:user, :quote)
";
// Execute the query using the provided database connection and return the result
return $this->co->executeQuery($query, [
return $this -> co -> executeQuery($query, [
'user' => array($idUser, PDO::PARAM_INT),
'quote' => array($idQuote, PDO::PARAM_INT)
]);
}
/**
* Retrieves a specific favorite entry from the `Favorite` table.
*
* This method fetches a record from the `Favorite` table based on the provided user ID (`idUser`)
* and quote ID (`idQuote`). If the favorite exists, it returns the corresponding data as an array.
*
* @param int $idUser The ID of the user who favorited the quote. This must reference a valid user in the database.
* @param int $idQuote The ID of the quote that is favorited. This must reference a valid quote in the database.
*
* @return array Returns an associative array containing the favorite record if it exists.
* If no matching record is found, an empty array is returned.
*/
public function findFavoriteById(int $idUser, int $idQuote) : array
{
// Define the SQL query to fetch the favorite record
$query = "SELECT * FROM Favorite
WHERE user_f = :user AND quote_f = :quote";
$query = "
SELECT * FROM Favorite
WHERE user_f = :user AND quote_f = :quote
";
// Execute the query using the provided database connection
$this->co->executeQuery($query, [
$this -> co -> executeQuery($query, [
'user' => array($idUser, PDO::PARAM_INT),
'quote' => array($idQuote, PDO::PARAM_INT)
]);
// Return the query results as an array
return $this->co->getResults();
return $this -> co -> getResults();
}
/**
* Retrieves all favorites for a specific user from the `Favorite` table.
*
* This method fetches all records from the `Favorite` table where the `user_f` column
* matches the provided user ID. It allows retrieving all quotes favorited by a specific user.
*
* @param int $idUser The ID of the user whose favorites are being retrieved. This must reference a valid user in the database.
*
* @return array Returns an array of associative arrays, where each entry represents a favorite record.
* If the user has no favorites, an empty array is returned.
*/
public function findFavoriteByUser(int $idUser) : array
{
// Define the SQL query to fetch all favorites for the user
$query = "SELECT * FROM Favorite
WHERE user_f = :user";
$query = "
SELECT * FROM Favorite
WHERE user_f = :user
";
// Execute the query using the provided database connection
$this->co->executeQuery($query, ['user' => array($idUser, PDO::PARAM_INT)]);
$this -> co -> executeQuery($query, ['user' => array($idUser, PDO::PARAM_INT)]);
// Return the query results as an array
return $this->co->getResults();
return $this -> co -> getResults();
}
/**
* Retrieves all records from the `Favorite` table.
*
* This method fetches all the favorite records in the database, returning an array of
* all user-quote associations stored in the `Favorite` table.
*
* Use this method to get a global view of all user favorites, which can be useful for
* administrative tasks or debugging.
*
* @return array Returns an array of associative arrays where each entry represents a favorite record.
* If there are no records in the table, an empty array is returned.
*/
public function findAllFavorite() : array
{
// Define the SQL query to fetch all favorite records
$query = "SELECT * FROM Favorite";
// Execute the query using the provided database connection
$this->co->executeQuery($query);
$this -> co -> executeQuery($query);
// Return the results of the query as an array
return $this->co->getResults();
return $this -> co -> getResults();
}
/**
* Deletes a specific favorite record from the `Favorite` table.
*
* This method removes the association between a user and a quote in the `Favorite` table
* by matching the provided user ID and quote ID. It is typically used to allow users
* to unfavorite quotes or to clean up favorites.
*
* @param int $idUser The ID of the user whose favorite record is to be deleted. This must reference a valid user in the database.
* @param int $idQuote The ID of the quote to be removed from the user's favorites. This must reference a valid quote in the database.
*
* @return bool Returns `true` if the deletion query was executed successfully, otherwise `false`.
*/
public function deleteFavoriteGateway(int $idUser, int $idQuote) : bool
{
// Define the SQL query to delete a favorite record matching user ID and quote ID
$query = "DELETE FROM Favorite
WHERE user_f = :user AND quote_f = :quote";
$query = "
DELETE FROM Favorite
WHERE user_f = :user AND quote_f = :quote
";
// Execute the query with the provided parameters
return $this->co->executeQuery($query, [
return $this -> co -> executeQuery($query, [
'user' => array($idUser, PDO::PARAM_INT),
'quote' => array($idQuote, PDO::PARAM_INT)
]);
}
}

@ -6,148 +6,78 @@ use PDO;
class ImageGateway extends Gateway
{
/**
* Inserts a new image entry into the `Image` table in the database.
*
* This method executes an SQL query to insert a new record into the `Image` table with the specified image ID
* and image path. It uses the provided database connection to perform the insertion operation.
*
* The image data inserted includes:
* - The image ID (`idImg`).
* - The path to the image file (`imgPath`).
*
* **Note**: This method assumes that the `Image` table exists with at least the `id_img` and `img_path` columns.
*
* @param int $idImg The unique identifier for the image.
* @param string $imgPath The file path to the image (including the filename).
*
* @return bool Returns `true` if the query was successfully executed, `false` if there was an error.
*/
public function createImgGateway(int $idImg, string $imgPath) : bool
{
// Define the SQL query to insert a new image record
$query = "INSERT INTO Image
VALUES (:id_img, :img_path)";
$query = "
INSERT INTO Image
VALUES (:id_img, :img_path)
";
// Execute the query using the provided database connection and parameterized values
return $this->co->executeQuery($query, [
'id_img' => array($idImg, PDO::PARAM_INT), // Bind the image ID as an integer
'img_path' => array($imgPath, PDO::PARAM_STR), // Bind the image path as a string
return $this -> co -> executeQuery($query, [
'id_img' => array($idImg, PDO::PARAM_INT),
'img_path' => array($imgPath, PDO::PARAM_STR),
]);
}
/**
* Finds an image record from the `Image` table by its ID.
*
* This method executes a SQL query to retrieve the image record corresponding to the provided image ID (`$idImg`).
* The method returns all columns of the matching image from the `Image` table.
*
* **Note**: This method assumes that the `Image` table exists with at least the `id_img` and `img_path` columns.
*
* @param int $idImg The unique identifier for the image to retrieve.
*
* @return array Returns an associative array of the image record. The array contains key-value pairs where
* each key is a column name and the value is the corresponding column value from the `Image` table.
* If no matching record is found, it returns an empty array.
*/
public function findImgById(int $idImg) : array
{
// Define the SQL query to select an image by its ID
$query = "SELECT * FROM Image
WHERE id_img = :id_img";
$query = "
SELECT * FROM Image
WHERE id_img = :id_img
";
// Execute the query using the provided database connection and parameterized values
$this->co->executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
$this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
// Return the results of the query execution
return $this->co->getResults();
return $this -> co -> getResults();
}
/**
* Retrieves all image records from the `Image` table.
*
* This method executes a SQL query to fetch all records from the `Image` table
* and returns the results as an associative array. Each record corresponds to one image.
*
* **Note**: This method assumes that the `Image` table exists with appropriate columns,
* such as `id_img` and `img_path`.
*
* @return array Returns an array of associative arrays, where each associative array represents
* a single image record from the `Image` table. Each key in the associative array
* corresponds to a column name, and the value is the respective column value.
* If no records are found, returns an empty array.
*/
public function findAllImg() : array
{
// Define the SQL query to retrieve all image records
$query = "SELECT * FROM Image";
$query = "
SELECT * FROM Image
";
// Execute the query using the provided database connection
$this->co->executeQuery($query);
$this -> co -> executeQuery($query);
// Return the results of the query execution
return $this->co->getResults();
return $this -> co -> getResults();
}
/**
* Deletes an image record from the `Image` table based on the provided ID.
*
* This method executes a SQL query to delete a specific image record from the database,
* identified by its unique `id_img`.
*
* **Note**: This method assumes that the `Image` table exists and the `id_img` column
* is used as the primary key or a unique identifier for each image.
*
* @param int $idImg The ID of the image to be deleted from the `Image` table.
* Must be a valid integer corresponding to an existing image record.
*
* @return bool Returns `true` if the query was successfully executed, indicating the image
* record was deleted. Returns `false` if the query failed.
*/
public function deleteImgGateway(int $idImg) : bool
{
// Define the SQL query to delete an image record based on its ID
$query = "DELETE FROM Image
WHERE id_img = :id_img";
$query = "
DELETE FROM Image
WHERE id_img = :id_img
";
// Execute the query using the provided database connection and return the result
return $this->co->executeQuery($query, [
'id_img' => array($idImg, PDO::PARAM_INT)
]);
return $this -> co -> executeQuery($query, ['id_img' => array($idImg, PDO::PARAM_INT)]);
}
/**
* Updates the path of an image in the `Image` table based on the provided image ID.
*
* This method executes a SQL query to update the `imgPath` column for a specific image
* identified by its unique `id_img`. It assumes the `Image` table exists and contains
* the columns `id_image` and `imgPath`.
*
* @param int $idImg The ID of the image to be updated. Must correspond to an existing
* record in the `Image` table.
* @param string $imgPath The new path for the image. Must be a valid string representing
* the location of the image file.
*
* @return bool Returns `true` if the query was successfully executed, indicating that the
* image path was updated. Returns `false` if the query execution failed.
*/
public function updateImgGateway(int $idImg, string $imgPath) : bool
{
// Define the SQL query to update the image path based on the image ID
$query = "UPDATE Image
$query = "
UPDATE Image
SET imgPath = :img_path
WHERE id_image = :id_img";
WHERE id_image = :id_img
";
// Execute the query using the provided database connection and return the result
return $this->co->executeQuery($query, [
return $this -> co -> executeQuery($query, [
'id_img' => array($idImg, PDO::PARAM_INT),
'img_path' => array($imgPath, PDO::PARAM_STR)
]);
}
public function getLastId():int{
$query = "SELECT id_img FROM Image;";
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
foreach($res as $r){
$tab[] = $r["id_img"];
}
$id = 1;
while(in_array($id,$tab))
{
$id=$id+1;
}
return $id;
}
}

@ -6,196 +6,167 @@ use PDO;
class QuestionGateway extends Gateway
{
/**
* Creates a new question entry in the database.
*
* This method inserts a new question into the `Question` table, including the question text,
* multiple choice answers (A, B, C, D), and the correct answer.
*
* @param int $id_question The unique ID of the question.
* @param string $question The question text.
* @param string $answerA The first multiple choice answer.
* @param string $answerB The second multiple choice answer.
* @param string $answerC The third multiple choice answer.
* @param string $answerD The fourth multiple choice answer.
* @param string $cAnswer The correct answer among the options (A, B, C, D).
*
* @return bool Returns `true` if the question was successfully created, `false` otherwise.
*/
public function create(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
{
// SQL query to insert a new question with its answers and correct answer
$query = "INSERT INTO Question
VALUES (:id_q, :question, :answerA, :answerB, :answerC, :answerD, :cAnswer)";
$query = "
INSERT INTO Question
VALUES (:id_q, :question, :answerA, :answerB, :answerC, :answerD, :cAnswer)
";
// Execute the query, binding the parameters securely to prevent SQL injection
return $this -> co -> executeQuery($query, [
'id_q' => array($id_question, PDO::PARAM_INT),
'question' => array($question, PDO::PARAM_STR),
'answerA' => array($answerA, PDO::PARAM_STR),
'answerB' => array($answerB, PDO::PARAM_STR),
'answerC' => array($answerC, PDO::PARAM_STR),
'answerD' => array($answerD, PDO::PARAM_STR),
'cAnswer' => array($cAnswer, PDO::PARAM_STR),
array('id_q' => $id_question, PDO::PARAM_INT),
array('question' => $question, PDO::PARAM_STR),
array('answerA' => $answerA, PDO::PARAM_STR),
array('answerB' => $answerB, PDO::PARAM_STR),
array('answerC' => $answerC, PDO::PARAM_STR),
array('answerD' => $answerD, PDO::PARAM_STR),
array('cAnswer' => $cAnswer, PDO::PARAM_STR),
]);
}
/**
* Retrieves a question by its ID from the database.
*
* This method queries the `Question` table to find the question with the specified ID
* and returns all its details, including the question text, possible answers, and the correct answer.
*
* @param int $id The unique ID of the question to be retrieved.
*
* @return array An associative array containing the details of the question (if found).
* The keys correspond to the column names in the `Question` table.
* Returns an empty array if the question is not found.
*/
public function findById(int $id) : array
{
// SQL query to select the question with the specified ID
$query = "SELECT *
FROM Question
WHERE id_question = :id_q";
// Execute the query, binding the parameter securely to prevent SQL injection
$query = "SELECT * FROM Question WHERE id_question = :id_q";
$this -> co -> executeQuery($query, ['id_q' => array($id, PDO::PARAM_INT)]);
// Retrieve and return the results as an associative array
return $this -> co -> getResults();
}
/**
* Updates the text of a question in the database.
*
* This method modifies the `question` field of a specific question in the `Question` table,
* identified by its unique ID.
*
* @param int $id_q The unique ID of the question to be updated.
* @param string $newQuestion The new text to replace the current question text.
*
* @return bool Returns `true` if the query was successfully executed, or `false` otherwise.
*/
public function updateText(int $id_q, string $newQuestion) : bool
{
// SQL query to update the question text for a specific ID
$query = "UPDATE Question
$query = "
UPDATE Question
SET question = :question
WHERE id_question = :id_q";
WHERE id_question = :id_q
";
// Execute the query with bound parameters
return $this -> co -> executeQuery($query, [
'id_q' => array($id_q, PDO::PARAM_INT), // Bind the ID of the question
'question' => array($newQuestion, PDO::PARAM_STR) // Bind the new question text
'id_q' => array($id_q, PDO::PARAM_INT),
'question' => array($newQuestion, PDO::PARAM_STR)
]);
}
/**
* Updates the answers for a specific question in the database.
*
* This method modifies the answer options (`answerA`, `answerB`, `answerC`, `answerD`)
* and the correct answer (`cAnswer`) of a specific question identified by its unique ID.
*
* @param int $id_q The unique ID of the question to be updated.
* @param string $newA The new value for the first answer option (A).
* @param string $newB The new value for the second answer option (B).
* @param string $newC The new value for the third answer option (C).
* @param string $newD The new value for the fourth answer option (D).
* @param string $newCorrect The new correct answer.
*
* @return bool Returns `true` if the query was successfully executed, or `false` otherwise.
*/
public function updateAnswers(int $id_q, string $newA, string $newB, string $newC, string $newD, string $newCorrect): bool
{
// SQL query to update the answers and the correct answer for a specific question
$query = "UPDATE Question
$query = "
UPDATE Question
SET answerA = :answerA, answerB = :answerB,
answerC = :answerC, answerD = :answerD, cAnswer = :cAnswer
WHERE id_question = :id_q";
WHERE id_question = :id_q
";
// Execute the query with bound parameters
return $this -> co -> executeQuery($query, [
'id_q' => array($id_q, PDO::PARAM_INT), // Bind the ID of the question
'answerA' => array($newA, PDO::PARAM_STR), // Bind the new answer A
'answerB' => array($newB, PDO::PARAM_STR), // Bind the new answer B
'answerC' => array($newC, PDO::PARAM_STR), // Bind the new answer C
'answerD' => array($newD, PDO::PARAM_STR), // Bind the new answer D
'cAnswer' => array($newCorrect, PDO::PARAM_STR) // Bind the new correct answer
'id_q' => array($id_q, PDO::PARAM_INT),
'answerA' => array($newA, PDO::PARAM_STR),
'answerB' => array($newB, PDO::PARAM_STR),
'answerC' => array($newC, PDO::PARAM_STR),
'answerD' => array($newD, PDO::PARAM_STR),
'cAnswer' => array($newCorrect, PDO::PARAM_STR)
]);
}
/**
* Deletes a question from the database.
* Deletes a question from the database by its ID
*
* This method removes a specific question from the `Question` table based on its unique ID.
*
* @param int $id The unique ID of the question to be deleted.
*
* @return bool Returns `true` if the query was successfully executed, or `false` otherwise.
* @param int $id The ID of the question
* @return bool
*/
public function delete(int $id) : bool
{
// SQL query to delete a question by its ID
$query = "DELETE FROM Question
WHERE id_question = :id_q";
$query = "DELETE FROM Question WHERE id_question = :id_q";
// Execute the query with the provided ID
return $this -> co -> executeQuery($query, [
'id_q' => array($id, PDO::PARAM_INT) // Bind the ID parameter to the query
]);
return $this -> co -> executeQuery($query, ['id_q' => array($id, PDO::PARAM_INT)]);
}
/**
* Retrieves all questions from the database.
*
* This method fetches all records from the `Question` table, returning an array
* of questions with their associated details.
* Retrieves all quizzes from the database
*
* @return array Returns an array containing all the questions. Each question is represented
* as an associative array with keys corresponding to the table columns.
* @return QuestionEntity[] An array of `Question` objects
*/
public function findAll() : array
{
// SQL query to select all questions
$query = "SELECT * FROM Question";
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
// Execute the query
public function findRdmQuestion() : array
{
$query = "SELECT * FROM Question ORDER BY RANDOM() LIMIT 1";
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
public function getQuestionQuoteSrc(string $l) : array{
}
// Return all results as an array
/*--------------------------------------- Quiz Aléatoire ---------------------------------------*/
/*----------------------- Question + Reponce Corecte -----------------------*/
public function QuestionToReponceForQuoteToCarac(string $lang) : array
{
$query = "Select q.content as Question ,c.caracter as Reponce
from Quote Q
join Caracter c on c.id_caracter=q.id_caracter
where q.langue=:lang and q.isValide = 'true'
ORDER BY RANDOM()
LIMIT 1;";
$this -> co -> executeQuery($query, [':lang' => array($lang, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
public function QuestionToReponceForQuoteToTitle(string $lang) : array
{
$query = "Select q.content as Question ,s.title as Reponce
from Quote Q
join Source s on s.id_source=q.id_source
where q.langue=:lang and q.isValide = 'true'
ORDER BY RANDOM()
LIMIT 1;";
$this -> co -> executeQuery($query, [':lang' => array($lang, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
/**
* Retrieves a random question from the database.
*
* This method selects one random record from the `Question` table.
*
* @return array Returns an array containing the details of a randomly selected question.
* The result is an associative array with keys corresponding to the table columns.
*/
public function findRdmQuestion() : array
/*----------------------- Reponce Fausse -----------------------*/
public function FakeReponceForQuoteToCarac(string $lang,string $corecteReponce) : array
{
// SQL query to fetch a random question
$query = "SELECT *
FROM Question
ORDER BY RANDOM()
LIMIT 1";
$query = "Select c.caracter as Reponce
from Quote Q
join Caracter c on c.id_caracter=q.id_caracter
where q.langue = :lang And c.caracter != :corecteReponce and q.isValide = 'true'
ORDER BY RANDOM()
LIMIT 3;";
$this -> co -> executeQuery($query, [
':lang' => array($lang, PDO::PARAM_STR),
':corecteReponce' => array($lang, PDO::PARAM_STR)
]);
return $this -> co -> getResults();
}
// Execute the query
$this -> co -> executeQuery($query);
// Return the randomly selected question
public function FakeReponceForQuoteToTitle(string $lang,string $corecteReponce) : array
{
$query = "Select s.title as Reponce
from Quote Q
join Source s on s.id_source=q.id_source
where q.langue = :lang And s.title != :corecteReponce and q.isValide = 'true'
ORDER BY RANDOM()
LIMIT 3;";
$this -> co -> executeQuery($query, [
':lang' => array($lang, PDO::PARAM_STR),
':corecteReponce' => array($lang, PDO::PARAM_STR)
]);
return $this -> co -> getResults();
}
}

@ -8,98 +8,45 @@ use PDO;
class QuizGateway extends Gateway
{
/**
* Creates a new quiz in the database.
*
* This method inserts a new record into the `Quiz` table, specifying the quiz ID
* and the number of questions in the quiz.
*
* @param int $id_quiz The unique ID of the quiz.
* @param int $nb_questions The total number of questions in the quiz.
*
* @return bool Returns `true` if the query was successfully executed, or `false` otherwise.
*/
public function create(int $id_quiz, int $nb_questions) : bool
public function create(int $id_quiz, int $nb_questions, string $id_img, string $title) : bool
{
// SQL query to insert a new quiz into the Quiz table
$query = "INSERT INTO Quiz
VALUES (:id_q, :nb_q)";
$query = "
INSERT INTO Quiz
VALUES (:id_q, :nb_q, :id_img, :title)
";
// Execute the query with bound parameters
return $this -> co -> executeQuery($query, [
':id_q' => array($id_quiz, PDO::PARAM_INT), // Bind the quiz ID
':nb_q' => array($nb_questions, PDO::PARAM_INT) // Bind the number of questions
':id_q' => array($id_quiz, PDO::PARAM_INT),
':nb_q' => array($nb_questions, PDO::PARAM_INT),
':id_img' => array($id_img, PDO::PARAM_STR),
':title' => array($title, PDO::PARAM_STR)
]);
}
/**
* Retrieves a quiz from the database by its ID.
*
* This method fetches a single quiz record from the `Quiz` table, identified by its unique ID.
*
* @param int $id The unique ID of the quiz to retrieve.
*
* @return array Returns an associative array representing the quiz, with keys corresponding
* to the table columns. If no quiz is found, returns an empty array.
*/
public function findQuizById(int $id) : array
{
// SQL query to fetch a quiz by its ID
$query = "SELECT *
FROM Quiz
WHERE id_quiz = :id_q";
// Execute the query with the bound ID parameter
$this -> co -> executeQuery($query, [
':id_q' => array($id, PDO::PARAM_INT) // Bind the quiz ID
]);
// Return the result as an array
$query = "SELECT id_quiz, title, imgPath, nb_quest FROM Quiz q JOIN Image i on q.img = i.id_img WHERE id_quiz = :id_q";
$this -> co -> executeQuery($query, [':id_q' => array($id, PDO::PARAM_INT)]);
return $this -> co -> getResults();
}
/**
* Deletes a quiz from the database by its ID.
*
* This method removes a specific quiz from the `Quiz` table, identified by its unique ID.
*
* @param int $id The unique ID of the quiz to be deleted.
*
* @return bool Returns `true` if the query was successfully executed, or `false` otherwise.
*/
public function delete(int $id) : bool
{
// SQL query to delete a quiz by its ID
$query = "DELETE FROM Quiz
WHERE id_quiz = :id_q";
// Execute the query with the provided ID parameter
return $this -> co -> executeQuery($query, [
':id_q' => array($id, PDO::PARAM_INT) // Bind the quiz ID
]);
$query = "DELETE FROM Quiz WHERE id_quiz = :id_q";
return $this -> co -> executeQuery($query, [':id_q' => array($id, PDO::PARAM_INT)]);
}
/**
* Retrieves all quizzes from the database.
*
* This method fetches all records from the `Quiz` table, returning an array of results.
*
* @return array Returns an array containing all quizzes. Each quiz is represented as an associative array with its columns as keys.
*/
public function findAll() : array
{
// SQL query to select all records from the Quiz table
$query = "SELECT * FROM Quiz";
// Execute the query to fetch all quiz records
$query = "SELECT id_quiz, title, imgPath, nb_quest FROM Quiz q JOIN Image i on q.img = i.id_img";
$this -> co -> executeQuery($query);
// Return the results retrieved from the database
return $this -> co -> getResults();
}
public function getNumberOfQuestion(int $id) : intdiv{
$query = "SELECT nb_quest FROM quiz WHERE id_quiz = :id_q";
$this -> co -> executeQuery($query, [':id_q' => array($id, PDO::PARAM_INT)]);
return $this -> co -> getResults();
}
}

@ -6,26 +6,62 @@ use PDO;
class QuizQuestionGateway extends Gateway
{
/**
* Retrieves the questions associated with a specific quiz.
*
* This method fetches all records from the `Quiz_Question` table that are linked to a specific quiz by its ID.
*
* @param int $idQuiz The ID of the quiz for which the questions are to be retrieved.
*
* @return array Returns an array of questions linked to the provided quiz ID. Each question is represented as an associative array with its columns as keys.
*/
public function createQuizQuestionGateway(int $idQuiz, int $idQuestion): bool
{
$query = "
INSERT INTO Quiz_Question
VALUES (:id_quiz, :id_question)
";
return $this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_question' => array($idQuestion, PDO::PARAM_INT)
]);
}
public function findQuizQuestionById(int $idQuiz, int $idQuestion) : array
{
$query = "
SELECT * FROM Quiz_Question
WHERE quiz = :id_quiz AND question_qq = :id_question
";
$this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_question' => array($idQuestion, PDO::PARAM_INT)
]);
return $this -> co -> getResults();
}
public function findQuestionsFromQuiz(int $idQuiz) : array
{
// SQL query to select all records from the Quiz_Question table where the quiz ID matches the given ID
$query = "SELECT * FROM Quiz_Question
WHERE quiz = :id_quiz";
$query = "
SELECT * FROM Quiz_Question
WHERE quiz = :id_quiz
";
// Execute the query with the provided quiz ID
$this -> co -> executeQuery($query, ['id_quiz' => array($idQuiz, PDO::PARAM_INT)]);
// Return the results retrieved from the database
return $this -> co -> getResults();
}
public function deleteQuizQuestionGateway(int $idQuiz, int $idQuestion) : bool
{
$query = "
DELETE FROM Quiz_Question
WHERE quiz = :id_quiz AND question_qq = :id_question
";
return $this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_question' => array($idQuestion, PDO::PARAM_INT)
]);
}
# To do :
# Method that deletes all questions related to a quiz
}

@ -5,139 +5,87 @@ use PDOException;
Class QuoteGateway extends Gateway{
/**
* Searches for quotes that match the given criteria (quote content, language, and pagination).
*
* This method retrieves quotes from the `Quote` table that match a specified search term (`$quote`),
* belong to the specified language (`$language`), and are marked as valid. It also supports pagination.
*
* @param string $quote The search term to match within the content of the quotes.
* @param int $numpage The page number to retrieve, used for pagination. This number is used to calculate
* the offset in the query to return results for that specific page.
* @param string $language The language of the quotes to retrieve.
*
* @return array Returns an array of quotes matching the search criteria. Each quote is represented
* as an associative array with column names as keys.
*/
public function searchQuote(string $quote, int $numpage, string $language) : array
{
// SQL query to search for quotes with pagination and language filtering
$query = "SELECT q.id_quote, q.content, q.id_caracter, c.img_char, s.title, s.date, q.likes, q.langue
public function searchQuote(string $quote,int $numpage,string $language):array{
$query="SELECT q.id_quote, q.content, q.id_caracter, c.img_char, s.title, s.date, q.likes, q.langue
FROM Quote q
JOIN Source s ON s.id_source = q.id_source
WHERE content LIKE '%:quote%' AND is_valid = true AND langue = :langue
LIMIT 20 OFFSET :page*20;";
// Execute the query with the provided parameters
$this->co->executeQuery($query, [
':quote' => array($quote, PDO::PARAM_STR),
':page' => array($numpage, PDO::PARAM_INT),
':langue' => array($language, PDO::PARAM_STR)
]);
// Return the search results
$this->co->executeQuery($query,array(':quote' => array($quote,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':langue' => array($language,PDO::PARAM_STR)));
return $this->co->getResults();
}
public function searchSource(string $source,int $numpage,string $language):array{
/**
* Searches for a quote by its unique ID.
*
* This method retrieves a quote from the `Quote` table based on its ID (`$id`). It joins related tables
* (`Caracter`, `Source`, and `Image`) to fetch additional information such as character name, image path,
* source title, and the number of likes, only for valid quotes.
*
* @param string $id The unique identifier of the quote to retrieve.
*
* @return array Returns an associative array of the quote's details including content, character, image path,
* source title, date, likes, and language.
*/
public function searchId(string $id): array
{
// SQL query to search for a quote by its ID with related tables for additional information
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue
//recherche par source
$query="SELECT q.id_quote, q.content, c.character, c.img_path, s.title, s.date, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.id_quote = :id AND q.isvalide = true;";
JOIN Caracter c ON c.id_caracter = q.character
JOIN Source s ON s.id_source = q.id_source
WHERE s.title LIKE '%:source%' AND q.is_valid = true AND langue = :langue
LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':source' => array($source,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':langue' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
// Execute the query with the provided quote ID
$this->co->executeQuery($query, [':id' => array($id, PDO::PARAM_STR)]);
public function searchPers(string $Carac,int $numpage,string $language):array{
// Return the result set
return $this->co->getResults();
//recherche par personnage
$query="SELECT q.id_quote, q.content, c.character, c.img_path, s.title, s.date, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.character
JOIN Source s ON s.id_source = q.id_source
WHERE c.character LIKE '%:pers%' AND q.is_valid = true AND langue = :langue
LIMIT 20 OFFSET :page*20;";
$this->co->executeQuery($query,array(':pers' => array($Pers,PDO::PARAM_STR),':page' => array($numpage,PDO::PARAM_INT),':langue' => array($language,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
public function searchId(string $id):array{
/**
* Searches for quotes based on a search term and filter type.
*
* This method allows you to search for quotes by a specific criterion, such as character name (`personnage`),
* source title (`titre`), or the content of the quote itself. It joins related tables (`Caracter`, `Source`, and `Image`)
* to retrieve additional information such as the character's name, image, source title, and likes. The search is case-insensitive.
*
* @param string|null $type The type of search. Can be:
* - `personnage` to search by character name.
* - `titre` to search by source title.
* - `null` or any other value to search by quote content.
* If not provided or invalid, it defaults to searching by content.
*
* @param string|null $search The search term to look for in the chosen field (`personnage`, `titre`, or `content`).
* This parameter can be `null`, which will result in no filtering.
*
* @param array $filtre (Unused in this method, included for compatibility)
*
* @return array Returns an associative array of quotes matching the search criteria, including content, character name,
* image path, source title, date, likes, and language.
*/
public function search(?string $type, ?string $search, array $filtre): array
{
// Start building the query
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue
//recherche par id
$query="SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE lower()";
// Build the condition based on the $type parameter
if ($type == 'personnage') {
// Search by character name
$query .= "c.caracter) LIKE lower('%" . $search . "%')";
} elseif ($type == 'titre') {
// Search by source title
$query .= "s.title) LIKE lower('%" . $search . "%')";
} else {
// Default to searching by quote content
$query .= "q.content) LIKE lower('%" . $search . "%')";
WHERE q.id_quote = :id AND q.isvalide = true;";
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
public function search(?string $type,?string $search,array $filtre):array{
$query="SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dates, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE lower(";
if($type=='personnage'){
$query = $query . "c.caracter) LIKE lower('%" . $search . "%')";
}
elseif($type=='titre'){
$query = $query . "s.title) LIKE lower('%" . $search . "%')";
}
else{
$query = $query . "q.content) LIKE lower('%" . $search . "%')";
}
/* Categorie a rajouter
foreach($filtre as $fil){
$query = $query . " AND " . $fil
}*/
// Execute the query
$this->co->executeQuery($query, array());
$this->co->executeQuery($query,array());
// Get the results and return them
$result = $this->co->getResults();
$result=$this->co->getResults();
return $result;
}
/**
* Retrieves the quote of the day in the specified language.
*
* This method retrieves the quote of the day from the `DailyQuote` table, including associated information such as
* the character's name, image, source title, and the number of likes. The quote is filtered by its validity (`isValide = true`)
* and the language (`$language`). Only one quote is returned, and the most recent valid quote is chosen.
*
* @param string $language The language of the quote to retrieve (e.g., "English", "French", etc.).
*
* @return array Returns an associative array of the quote's details, including the quote content, character,
* character image path, source title, source date, likes, and language. If no result is found,
* an empty array is returned.
*/
public function getQuoteOfTheDay(string $language): array
{
// SQL query to retrieve the quote of the day in the specified language
public function getQuoteOfTheDay(string $language): array {
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dateS, q.likes, q.langue
FROM DailyQuote dq
JOIN Quote q ON dq.citation_id = q.id_quote
@ -147,16 +95,11 @@ Class QuoteGateway extends Gateway{
WHERE q.isValide = true AND q.langue = :language
ORDER BY q.id_quote DESC
LIMIT 1;";
try {
// Execute the query with the provided language parameter
$this->co->executeQuery($query, [':language' => [$language, PDO::PARAM_STR]]);
// Get the results and return the first (and only) result if available
$result = $this->co->getResults();
return $result[0] ?? []; // Return the first result or an empty array if no result is found
return $result[0] ?? [];
} catch (PDOException $e) {
// In case of a database error, catch the exception and display an error message
echo "Erreur dans getQuoteOfTheDay: " . $e->getMessage();
return [];
}
@ -164,141 +107,160 @@ Class QuoteGateway extends Gateway{
/**
* Retrieves a list of quote suggestions in the specified language with pagination.
*
* This method fetches a random selection of quotes that are marked as valid (`isValide = true`) in the specified language.
* The quotes are paginated, returning a set of 20 quotes per page, with each call providing a different set of suggestions
* due to the random ordering.
*
* @param int $numpage The page number for pagination. This value is used to calculate the offset for the query.
* Each page contains 20 quotes.
*
* @param string $language The language of the quotes to retrieve (e.g., "English", "French", etc.).
*
* @return array Returns an array of quotes, each with its content, associated character, character's image path,
* source title, source date, number of likes, and language. If no results are found, an empty array is returned.
*/
public function getSuggestions(int $numpage, string $language): array {
// SQL query to retrieve random quote suggestions based on the specified language and pagination
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dateS, q.likes, q.langue
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.isValide = true AND q.langue = :language
ORDER BY RANDOM()
LIMIT 20 OFFSET :offset;";
FROM Quote q
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE q.isValide = true AND q.langue = :language
ORDER BY RANDOM()
LIMIT 20 OFFSET :offset;";
// Execute the query with the provided language and offset for pagination
$this->co->executeQuery($query, [
':language' => [$language, PDO::PARAM_STR],
':offset' => [$numpage * 20, PDO::PARAM_INT] // Calculate the offset for pagination
':offset' => [$numpage * 20, PDO::PARAM_INT]
]);
// Return the result set (quotes)
return $this->co->getResults();
}
/**
* Retrieves a list of quotes marked as favorites by a specific user.
*
* This method fetches the quotes that are marked as favorites by the user, along with relevant information such as
* the character's name, image path, source title, and number of likes. It uses the `Favorite` table to identify the quotes
* favorited by the specified user.
*
* @param string $userId The ID of the user whose favorite quotes are to be retrieved.
*
* @return array Returns an array of quotes that are marked as favorites by the user, each with its content,
* associated character, character's image path, source title, source date, likes, and language.
* If no favorites are found, an empty array is returned.
*/
public function getFavorites(string $userId): array {
// SQL query to retrieve the list of favorite quotes for a specific user
$query = "SELECT q.id_quote, q.content, c.caracter, i.imgPath, s.title, s.dateS, q.likes, q.langue
FROM Favorite f
JOIN Quote q ON f.quote = q.id_quote
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE f.users = :userId;";
FROM Favorite f
JOIN Quote q ON f.quote = q.id_quote
JOIN Caracter c ON c.id_caracter = q.id_caracter
JOIN Source s ON s.id_source = q.id_source
JOIN Image i ON c.id_img = i.id_img
WHERE f.users = :userId";
try {
// Execute the query with the provided user ID
$this->co->executeQuery($query, [
':userId' => [$userId, PDO::PARAM_STR]
]);
// Return the results (favorites)
return $this->co->getResults();
} catch (PDOException $e) {
// In case of a database error, catch the exception and display an error message
echo "Erreur dans getFavorites: " . $e->getMessage();
return [];
}
}
/**
* Retrieves the next available auto-incremented quote ID.
*
* This method retrieves the next available `id_quote` by selecting the maximum `id_quote` in the `Quote` table and
* incrementing it by 1. This value can be used to set the `id_quote` for a new quote being inserted into the database.
*
* @return int Returns the next available quote ID (the maximum `id_quote` value + 1). If no quotes exist yet, it returns 1.
*/
public function autoincrement(): int
public function autoincrement() : int
{
// SQL query to retrieve the next available quote ID by selecting the maximum id_quote and adding 1
$query = "SELECT Max(id_quote) + 1 as id
FROM Quote;";
// Execute the query to get the maximum id_quote value
$query = "SELECT Max(id_quote) + 1 as id FROM Quote;";
$this->co->executeQuery($query);
return ($this -> co ->getResults())[0]['id'];
}
// Return the next available id (the result of the query), or 1 if no quotes are found
return ($this->co->getResults())[0]['id'];
public function addQuote(string $content, string $lang, int $idChar, int $idSrc, int $idUsr){
$id = $this->getLastId();
$query = "INSERT INTO Quote Values (:id,:content,0,:lang,false,'',:charac,:src,:user);";
try {
$this->co->executeQuery($query,[
':id' => [$id,PDO::PARAM_INT],
':content' => [$content,PDO::PARAM_STR],
':lang' => [$lang,PDO::PARAM_STR],
':charac' => [$idChar,PDO::PARAM_INT],
':src' => [$idSrc,PDO::PARAM_INT],
':user' => [$idUsr,PDO::PARAM_INT],
]);
}
catch (PDOException $e){
$error['501'] = 'Erreur lors de la création de la citation';
return error;
}
}
public function getLastId():int{
$query = "SELECT id_quote FROM Quote;";
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
foreach($res as $r){
$tab[] = $r["id_quote"];
}
$id = 1;
while(in_array($id,$tab))
{
$id=$id+1;
}
return $id;
}
/**
* Inserts a new quote into the Quote table, associated with a user, source, and character.
*
* This method inserts a new quote into the `Quote` table, setting various attributes like the content, language,
* image path, the user who created the quote, the source of the quote, and the character associated with the quote.
* The method automatically generates a new quote ID by using the `autoincrement` function, ensuring a unique ID
* for each new quote.
*
* @param string $content The content of the quote to be inserted.
* @param string $img_path The path to the image associated with the quote.
* @param string $langage The language of the quote (e.g., "English", "French").
* @param int $user The ID of the user who created the quote.
* @param int $source The ID of the source of the quote (e.g., book, movie).
* @param int $character The ID of the character associated with the quote.
*
* @return bool Returns true if the query executed successfully, false otherwise.
*/
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character) : bool
{
// SQL query to insert a new quote into the database
$query = "INSERT INTO Quote (id_quote, content, langue, reason, id_source, id_caracter, id_user_verif, img_path)
VALUES (:id, :content, :langage, :reason, :source, :character, :user, :img_path)";
// Execute the query with the provided parameters
return $this->co->executeQuery($query, [
':id' => array($this->autoincrement(), PDO::PARAM_INT), // Generate the next available quote ID
':content' => array($content, PDO::PARAM_STR), // Content of the quote
':img_path' => array($img_path, PDO::PARAM_STR), // Path to the image associated with the quote
':langage' => array($langage, PDO::PARAM_STR), // Language of the quote
':user' => array($user, PDO::PARAM_INT), // User ID who created the quote
':reason' => array('À vérifier', PDO::PARAM_STR), // Default value for the quote verification status
':source' => array($source, PDO::PARAM_STR), // Source ID (book, movie, etc.)
':character' => array($character, PDO::PARAM_STR) // Character ID associated with the quote
]);
//======================== PARTI ADMIN ========================
//Probablement à déplacer dans un autre fichier
public function getQuoteIsValide():array{
//obtenir les quotes en attentes de validation par l'admin
$query = 'SELECT * FROM Quote WHERE isValid=:bool';
$this->co->executeQuery($query,array(':bool' => array(false, PDO::PARAM_BOOL)));
return $this->co->getResults();
}
public function validQuote(int $id){
//Valider la quote par l'admin
$query ='UPDATE Quote SET isValid=:newValide WHERE id_Quote=:id';
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
}
public function invalidQuote(int $id){
//Invalide la quote par l'admin (suppression)
$query ='DELETE FROM Quote WHERE id_Quote=:id';
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_INT)));
}
public function updateContent(int $id, string $newContent):array{
//Update le contexte de quote passé en paramètre
$queryUpdate = 'UPDATE Quote SET content=:newContent WHERE id_quote=:idQuote';
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newContent'=> array($newContent, PDO::PARAM_STR)));
//Renvoie le nouveau contexte de quote
$queryReponse = 'SELECT content FROM Quote WHERE id_quote=:idQuote';
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateTimeCode(int $id, string $newTimeCode):array{
//Update le time code de quote passé en paramètre
$queryUpdate = 'UPDATE Quote SET timecode=:newTimeCode WHERE id_quote=:idQuote';
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newTimeCode'=> array($newTimeCode, PDO::PARAM_STR)));
//Renvoie le nouveau contexte de quote
$queryReponse = 'SELECT timecode FROM Quote WHERE id_quote=:idQuote';
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateDate(int $id, int $newDate):array{
//Update la date de quote passé en paramètre
$queryUpdate = 'UPDATE Source SET dateSource =:newdate WHERE idSource = (SELECT idSource FROM Quote WHERE idQuote =:idQuote)';
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newDate'=> array($newDate, PDO::PARAM_INT)));
//Renvoie la nouvelle date de quote
$queryReponse = 'SELECT s.dateSource FROM Source s, Quote q WHERE id_quote=:idQuote AND s.idSource = q.idSource';
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateTitle(int $id, string $newTitle):array{
//Update le titre de l'oeuvre de quote passé en paramètre
$queryUpdate = 'UPDATE Source SET title =:newTitle WHERE idSource = (SELECT idSource FROM Quote WHERE idQuote =:idQuote)';
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newTitle'=> array($newTitle, PDO::PARAM_STR)));
//Renvoie le nouveau titre de quote
$queryReponse = 'SELECT s.title FROM Source s, Quote q WHERE id_quote=:idQuote AND s.idSource = q.idSource';
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function updateNameCharacter(int $id, string $newNameCharacter):array{
//Update le personnage de l'oeuvre de quote passé en paramètre
$queryUpdate = 'UPDATE Character SET name =:newNameCharacter WHERE idCharacter = (SELECT idCharacter FROM Quote WHERE idQuote =:idQuote)';
$this->co->executeQuery($queryUpdate, array(':idQuote'=>array($id, PDO::PARAM_STR), ':newNameCharacter'=> array($newNameCharacter, PDO::PARAM_STR)));
//Renvoie le nouveau personnage de quote
$queryReponse = 'SELECT c.title FROM Character c, Quote q WHERE id_quote=:idQuote AND c.idCharacter = q.idCharacter';
$this->co->executeQuery($queryReponse, array(':idQuote'=>array($id, PDO::PARAM_STR)));
return $this->co->getResults();
}
}
?>

@ -0,0 +1,125 @@
<?php
namespace Gateway;
use PDO;
class ResultsGateway extends Gateway
{
public function createResultsGateway(int $idQuiz, int $idUser, int $nbPts, int $time) : bool
{
$query = "
INSERT INTO Results
VALUES (:id_quiz, :id_user, :nb_pts, :time)
";
return $this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_user' => array($idUser, PDO::PARAM_INT),
'nb_pts' => array($nbPts, PDO::PARAM_INT),
'time' => array($time, PDO::PARAM_INT)
]);
}
public function findResultsByQuiz(int $idQuiz) : array
{
$query = "
SELECT * FROM Results
WHERE quiz_r = :id_quiz
";
$this -> co -> executeQuery($query, ['id_quiz' => array($idQuiz, PDO::PARAM_INT)]);
return $this -> co -> getResults();
}
public function findResultsByUser(int $idUser) : array
{
$query = "
SELECT * FROM Results
WHERE user_r = :id_user
";
$this -> co -> executeQuery($query, ['id_user' => array($idUser, PDO::PARAM_INT)]);
return $this -> co -> getResults();
}
public function findResultsById(int $idQuiz, int $idUser) : array
{
$query = "
SELECT * FROM Results
WHERE quiz_r = :id_quiz AND user_r = :id_user
";
$this -> co -> executeQuery($query, [
'id_user' => array($idUser, PDO::PARAM_INT),
'id_quiz' => array($idQuiz, PDO::PARAM_INT)
]);
return $this -> co -> getResults();
}
public function findAllResults() : array
{
$query = "SELECT * FROM Results";
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
public function updateResults(int $idQuiz, int $idUser, ?int $score, ?int $time) : bool
{
if ($score && !$time)
{
$query = "
UPDATE Results
SET score = :score
WHERE quiz_r = :id_quiz AND user_r = :id_user
";
return $this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_user' => array($idUser, PDO::PARAM_INT),
'score' => array($score, PDO::PARAM_INT)
]);
}
else if (!$score && $time)
{
$query = "
UPDATE Results
SET time = :time
WHERE quiz_r = :id_quiz AND user_r = :id_user
";
return $this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_user' => array($idUser, PDO::PARAM_INT),
'time' => array($time, PDO::PARAM_INT)
]);
}
else
{
$query = "
UPDATE Results
SET score = :score AND time = :time
WHERE quiz_r = :id_quiz AND user_r = :id_user
";
return $this -> co -> executeQuery($query, [
'id_quiz' => array($idQuiz, PDO::PARAM_INT),
'id_user' => array($idUser, PDO::PARAM_INT),
'score' => array($score, PDO::PARAM_INT),
'time' => array($time, PDO::PARAM_INT)
]);
}
}
}

@ -6,147 +6,95 @@ use PDO;
class SourceGateway extends Gateway{
/**
* Inserts a new source into the Source table.
*
* This method inserts a new source into the `Source` table, setting attributes like the title and date of the source.
* It takes a `sourceEntity` object as an argument, which contains the data required for the insertion.
* The method assumes that the source entity is valid and contains the appropriate values for the title and date.
*
* @param sourceEntity $s The source entity object containing the source's title and date.
*
* @return bool Returns true if the query executed successfully, false otherwise.
*/
public function create(sourceEntity $s) : bool
{
// SQL query to insert a new source into the database
$query = "INSERT INTO Source
VALUES( :title, :date)";
// Execute the query with the parameters extracted from the source entity object
return $this->co->executeQuery($query, [
'title' => array($s->getTitle(), PDO::PARAM_STR), // The title of the source (e.g., book title, movie title)
'date' => array($s->getDate(), PDO::PARAM_STR), // The date of the source (e.g., publication date, release date)
// 'type' => array($s->getType(), PDO::PARAM_STR) // Optional: Add 'type' if needed (commented out for now)
$query = "
INSERT INTO Source
VALUES(:id, :title, :date)
";
return $this -> co -> executeQuery($query, [
"id" => array($s->getIdSource(), PDO::PARAM_INT),
"title" => array($s->getTitle(), PDO::PARAM_STR),
"date" => array($s->getDate(), PDO::PARAM_STR),
#"type" => array($s->getType(), PDO::PARAM_STR)
]);
}
/**
* Retrieves a source by its ID from the Source table.
*
* This method fetches the details of a source from the `Source` table by its `id_source`.
* It executes a query to retrieve the source record that matches the provided ID.
* If a source is found with the given ID, the details of the source are returned as an associative array.
*
* @param int $id The ID of the source to be retrieved.
*
* @return array An associative array containing the details of the source, or an empty array if no source is found.
*/
public function findById(int $id) : array
{
// SQL query to select a source by its ID
$query = "SELECT *
FROM Source
WHERE id_source = :id";
$query = "SELECT * FROM Source WHERE id_source = :id";
// Execute the query with the provided ID
$this->co->executeQuery($query, array("id" => array($id, PDO::PARAM_INT)));
// Return the result of the query
return $res = $this->co->getResults();
$this -> co -> executeQuery($query, array("id" => array($id, PDO::PARAM_INT)));
return $res = $this -> co -> getResults();
}
/**
* Retrieves a source by its title from the Source table.
*
* This method fetches the details of a source from the `Source` table by its `title`.
* It executes a query to retrieve the source record that matches the provided title.
* If a source is found with the given title, the details of the source are returned as an associative array.
*
* @param string $t The title of the source to be retrieved.
*
* @return array An associative array containing the details of the source, or an empty array if no source is found.
*/
public function findByTitle(string $t) : array
{
// SQL query to select a source by its title
$query = "SELECT *
FROM Source
WHERE title = :t";
$query = "SELECT * FROM Source WHERE title = :t";
$this -> co -> executeQuery($query, ["t" => array($t, PDO::PARAM_STR)]);
return $res = $this -> co -> getResults();
}
// Execute the query with the provided title
$this->co->executeQuery($query, ["t" => array($t, PDO::PARAM_STR)]);
public function findByDate(string $d) : array
{
$query = "SELECT * FROM Source WHERE dates = :d";
// Return the result of the query
return $res = $this->co->getResults();
$this -> co -> executeQuery($query, ["d" => array($d, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
/*
public function findByType(TypeSourceEnum $type) : array
{
$query = "SELECT * FROM Source WHERE type = :t";
$this -> co -> executeQuery($query, ["t" => array($type, PDO::PARAM_STR)]);
return $this -> co -> getResults();
}
*/
/**
* Retrieves all sources from the Source table.
*
* This method fetches all records from the `Source` table, sorted by the `title` column in ascending order.
* It executes a query to retrieve all source records and returns them as an associative array.
*
* @return array An array of associative arrays, each containing the details of a source.
*/
public function findAll() : array
{
// SQL query to select all sources from the Source table, ordered by title in ascending order
$query = "SELECT *
FROM Source
ORDER BY title ASC";
// Execute the query to fetch the results
$this->co->executeQuery($query);
// Return the result of the query
return $this->co->getResults();
$query = "SELECT * FROM Source ORDER BY title ASC";
$this -> co -> executeQuery($query);
return $this -> co -> getResults();
}
/**
* Deletes a source record from the Source table by its ID.
*
* This method deletes the record from the `Source` table where the `id_source` matches the provided ID.
* It executes the DELETE SQL query to remove the source from the database.
*
* @param int $id The ID of the source to delete.
* @return bool True if the delete was successful, false otherwise.
*/
public function delete(int $id) : bool
{
// SQL query to delete the source record with the given id_source
$query = "DELETE FROM Source
WHERE id_source = :id_s";
$query = "DELETE FROM Source WHERE id_source = :id_s";
// Execute the query with the provided source ID
return $this->co->executeQuery($query, ["id_s" => array($id, PDO::PARAM_INT)]);
$this -> co -> executeQuery($query, ["id_s" => array($id, PDO::PARAM_INT)]);
}
/**
* Updates an existing source record in the Source table.
*
* This method updates the `title` and `date` columns of the `Source` table for a given `id_source`.
* It executes the `UPDATE` SQL query to modify the record with the specified ID.
*
* @param sourceEntity $s The source entity containing the updated data (ID, title, and date).
* @return bool True if the update was successful, false otherwise.
*/
public function update(sourceEntity $s) : bool
{
// SQL query to update the title and date of a source record with the given id_source
$query = "UPDATE Source
$query = "
UPDATE Source
SET title = :t, date = :d
WHERE id_source = :id_s";
// Execute the query with the provided source entity data
WHERE id_source = :id_s
";
return $this->co->executeQuery($query, [
"id_s" => array($s->getIdSource(), PDO::PARAM_INT),
"t" => array($s->getTitle(), PDO::PARAM_STR),
"d" => array($s->getDate(), PDO::PARAM_STR)
"id_s" => array($s -> getIdSource(), PDO::PARAM_INT),
"t" => array($s -> getTitle(), PDO::PARAM_STR),
"d" => array($s -> getDate(), PDO::PARAM_STR)
]);
}
public function getLastId():int{
$query = "SELECT id_source FROM Source;";
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
foreach($res as $r){
$tab[] = $r["id_source"];
}
$id = 1;
while(in_array($id,$tab))
{
$id=$id+1;
}
return $id;
}
}

@ -4,117 +4,44 @@ use PDO;
Class UserGateway extends Gateway{
/**
* Gets the total number of users in the Users table.
*
* This method executes a `SELECT COUNT(*)` SQL query to count all the records in the `Users` table.
* It returns the count as an array.
*
* @return array An array containing the total number of users in the `Users` table.
*/
public function getNumberOfUsers() : array
{
// SQL query to count all users in the Users table
$query = "SELECT Count(*) FROM Users";
// Execute the query
$this->co->executeQuery($query);
$this -> co -> executeQuery($query);
// Return the result of the query
return $this->co->getResults();
return $this -> co -> getResults();
}
/**
* Finds the first available ID for a new user.
*
* This method fetches all existing user IDs from the `Users` table and
* returns the first integer ID that is not already in use.
*
* @return int The first available user ID.
*/
public function firstIdUser(): int
{
// SQL query to get all user IDs from the Users table
$query = "SELECT id_user FROM Users;";
// Execute the query to fetch all user IDs
$this->co->executeQuery($query);
$res = $this->co->getResults();
// Initialize an empty array to store the user IDs
foreach ($res as $r) {
public function firstIdUser():int{
$query = "Select id_user from Users;";
$this -> co -> executeQuery($query);
$res = $this -> co -> getResults();
foreach($res as $r){
$tab[] = $r["id_user"];
}
// Start checking for the first available ID from 1
$id = 1;
while (in_array($id, $tab)) {
// If the ID already exists, increment and check again
$id = $id + 1;
}
// Return the first available ID
$id=1;
while(in_array($id,$tab)){$id=$id+1;}
return $id;
}
/**
* Fetches a random image ID from the `image` table.
*
* This method selects a random row from the `image` table using the SQL
* clause `ORDER BY RANDOM()` and returns the `id_img` of the randomly selected image.
*
* @return int The ID of a random image.
*/
public function randomImg(): int
{
// SQL query to select a random image ID
$query = "SELECT id_img
FROM image
ORDER BY RANDOM()
LIMIT 1";
// Execute the query
public function randomImg():int{
$query = "SELECT id_img FROM image ORDER BY Random() LIMIT 1";
$this->co->executeQuery($query);
// Fetch the result
$res = $this->co->getResults();
// Return the ID of the randomly selected image
return $res[0][0];
}
/**
* Inserts a new user into the `Users` table.
*
* This method first generates a new user ID, retrieves a random image ID,
* and inserts the provided user details (pseudo, email, password, profile image)
* into the `Users` table.
*
* @param string $pseudo The username (pseudo) of the new user.
* @param string $email The email address of the new user.
* @param string $password The password for the new user.
* @param bool $isAdmin Whether the user is an admin (not used in this query).
* @param int $imgPrfl The ID of the profile image for the new user (assigned randomly).
*
* @return bool Whether the insertion was successful.
*/
public function insertUser(string $pseudo, string $email, string $password, bool $isAdmin, int $imgPrfl): bool
{
// Get the next available user ID using the firstIdUser method
$id = $this->firstIdUser();
// Get a random image ID using the randomImg method
$idImg = $this->randomImg();
// SQL query to insert the new user into the Users table
$query = "INSERT INTO Users(id_user, username, email, password, creation, img)
VALUES (:id, :pseudo, :email, :password, CURRENT_DATE, :imgPrfl);";
// Execute the query with the provided data
return $this->co->executeQuery($query, [
public function insertUser(string $pseudo, string $email, string $password, bool $isAdmin, int $imgPrfl) : bool {
$id=$this->firstIdUser();
$idImg=$this->randomImg();
$query = "
INSERT INTO Users(id_user,username,email,password,creation,img)
VALUES (:id, :pseudo, :email, :password, CURRENT_DATE, :imgPrfl);
";
return $this -> co -> executeQuery($query, [
":id" => [$id, PDO::PARAM_INT],
":pseudo" => [$pseudo, PDO::PARAM_STR],
":email" => [$email, PDO::PARAM_STR],
@ -123,477 +50,187 @@ Class UserGateway extends Gateway{
]);
}
public function delete(string $id) : bool{
/**
* Deletes a user from the `Users` table.
*
* This method takes a user ID (as a string) and removes the corresponding
* user from the `Users` table using the provided ID.
*
* @param string $id The ID of the user to be deleted.
* @return bool Whether the deletion was successful.
*/
public function delete(string $id): bool
{
// SQL query to delete a user from the Users table based on the user ID
$query = 'DELETE FROM Users
WHERE id_user = :id;';
// Execute the query with the provided user ID
return $this->co->executeQuery($query, [
':id' => [$id, PDO::PARAM_STR]
]);
// supretion user
$query='DELETE FROM Users WHERE id_user = :id;';
return $this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
}
/**
* Checks if a quote is in the user's favorite list.
*
* This method checks if a specific quote, identified by its ID,
* is already marked as a favorite by a user, identified by their username.
*
* @param string $username The username of the user.
* @param int $idq The ID of the quote.
* @return bool True if the quote is in the user's favorite list, false otherwise.
*/
public function inFavorite(string $username, int $idq): bool
{
// SQL query to count the number of favorites for the given user and quote
$query = 'SELECT count(*)
FROM Favorite f
JOIN Users u ON f.users = u.id_user
WHERE u.username = :user AND f.quote = :id';
// Execute the query with the provided parameters (username and quote ID)
$this->co->executeQuery($query, array(
':user' => array($username, PDO::PARAM_STR),
':id' => array($idq, PDO::PARAM_INT)
));
// Fetch the results and check if count is greater than or equal to 1
public function inFavorite(string $username, int $idq):bool{
$query = 'SELECT count(*) FROM Favorite f JOIN Users u ON f.users = u.id_user WHERE u.username = :user AND f.quote = :id';
$this->co->executeQuery($query, array(':user'=>array($username, PDO::PARAM_STR),':id'=>array($idq, PDO::PARAM_INT)));
$result = $this->co->getResults();
// Return true if the quote is in the favorites, otherwise false
return ($result[0]['count'] >= 1);
}
/**
* Adds a quote to a user's favorite list and increments the like count for the quote.
*
* This method performs two actions:
* 1. Adds the quote (identified by its ID) to the user's favorite list.
* 2. Increments the number of likes for the given quote.
*
* @param string $username The username of the user who is adding the quote to their favorites.
* @param int $id The ID of the quote being added to the favorites.
*/
public function addFavorite(string $username, int $id)
{
// First query: Insert a new favorite for the user and the specified quote.
$query = 'INSERT INTO Favorite VALUES (
(SELECT id_user FROM Users WHERE username = :username),
:id
)';
// Execute the query to add the quote to the user's favorites
$this->co->executeQuery($query, array(
':username' => array($username, PDO::PARAM_STR),
':id' => array($id, PDO::PARAM_INT)
));
// Second query: Increment the likes for the given quote.
public function addFavorite(string $username, int $id){
$query = 'INSERT INTO Favorite VALUES ((SELECT id_user FROM Users WHERE username = :username), :id)';
$this->co->executeQuery($query, array(':username' => array($username,PDO::PARAM_STR), ':id' => array($id,PDO::PARAM_INT)));
$query = 'UPDATE Quote SET likes = (likes + 1) WHERE id_quote = :id';
// Execute the query to update the like count for the quote
$this->co->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
$this->co->executeQuery($query, array(':id' => array($id,PDO::PARAM_INT)));
}
/**
* Removes a quote from a user's favorite list and decrements the like count for the quote.
*
* This method performs two actions:
* 1. Removes the specified quote from the user's favorites.
* 2. Decrements the number of likes for the given quote.
*
* @param string $username The username of the user who is removing the quote from their favorites.
* @param int $id The ID of the quote being removed from the favorites.
*/
public function supFavorite(string $username, int $id)
{
// First query: Get the user id based on the username.
$query = 'SELECT id_user
FROM Users
WHERE username = :username';
$this->co->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
public function supFavorite(string $username, int $id){
$query = 'SELECT id_user FROM Users WHERE username = :username';
$this->co->executeQuery($query, array(':username' => array($username,PDO::PARAM_STR)));
$result = $this->co->getResults()[0]['id_user'];
// Second query: Delete the quote from the user's favorites.
$query = 'DELETE FROM Favorite
WHERE users = :user AND quote = :id;';
$this->co->executeQuery($query, array(':user' => array($result, PDO::PARAM_INT), ':id' => array($id, PDO::PARAM_INT)));
// Third query: Decrement the like count for the quote.
$query = 'UPDATE Quote
SET likes = (likes - 1)
WHERE id_quote = :id';
$this->co->executeQuery($query, array(':id' => array($id, PDO::PARAM_INT)));
$query = 'DELETE FROM Favorite WHERE users = :user AND quote = :id;';
$this->co->executeQuery($query, array(':user' => array($result,PDO::PARAM_INT), ':id' => array($id,PDO::PARAM_INT)));
$query = 'UPDATE Quote SET likes = (likes - 1) WHERE id_quote = :id';
$this->co->executeQuery($query, array(':id' => array($id,PDO::PARAM_INT)));
}
// ===================== DELETE FUNCTION =====================
/**
* Deletes all commentaries made by a user.
*
* This method performs the following actions:
* 1. Finds all commentaries made by a specified user using their username.
* 2. Deletes all the commentaries associated with that user from the Commentary table.
*
* @param string $user The username of the user whose commentaries need to be deleted.
*/
public function deleteAllCommentaryUser(string $user)
{
// Query to delete all commentaries made by the user.
$query = 'DELETE FROM Commentary
WHERE users IN ( SELECT id_user
FROM Users
WHERE username = :user);';
// Execute the query with the provided username.
$this->co->executeQuery($query, array(':user' => array($user, PDO::PARAM_STR)));
public function deleteAllCommentaryUser(string $user){
$query = 'DELETE FROM Commentary WHERE users IN ( SELECT id_user FROM Users WHERE username = :user);';
$this->co->executeQuery($query, array(':user'=>array($user, PDO::PARAM_STR)));
}
/**
* Deletes all favorites associated with a user.
*
* This method performs the following actions:
* 1. Finds all favorite quotes associated with the user using their username.
* 2. Deletes all the entries in the Favorite table where this user is marked as the owner.
*
* @param string $user The username of the user whose favorites need to be deleted.
*/
public function deleteAllFavoriteUser(string $user)
{
// Query to delete all favorites associated with the user.
$query = 'DELETE FROM Favorite
WHERE users IN ( SELECT id_user
FROM Users
WHERE username = :user);';
// Execute the query with the provided username.
$this->co->executeQuery($query, array(':user' => array($user, PDO::PARAM_STR)));
public function deleteAllFavoriteUser(string $user){
$query = 'DELETE FROM Favorite WHERE users IN ( SELECT id_user FROM Users WHERE username = :user);';
$this->co->executeQuery($query, array(':user'=>array($user, PDO::PARAM_STR)));
}
/**
* Deletes a user from the Users table based on their username.
*
* @param string $user The username of the user to be deleted.
*/
public function deleteUser(string $user)
{
// SQL query to delete the user from the Users table based on their username.
$query = 'DELETE FROM Users
WHERE username = :user;';
// Execute the query with the username parameter.
$this->co->executeQuery($query, array(':user' => array($user, PDO::PARAM_STR)));
public function deleteUser(string $user){
$query = 'DELETE FROM Users WHERE username=:user;';
$this->co->executeQuery($query, array(':user'=>array($user, PDO::PARAM_STR)));
}
// ===================== GET FUNCTION =====================
/**
* Retrieves the favorite quotes of a user based on their user ID.
*
* @param string $id The ID of the user whose favorite quotes are to be fetched.
* @return array The list of favorite quotes of the user.
*/
public function getFavorite(string $id): array
{
// SQL query to retrieve all quotes that the user has marked as favorites.
$query = 'SELECT *
FROM Quote
WHERE id_quote IN (SELECT id_quote
FROM Favorite f JOIN Users u ON u.id_user = f.user_f
WHERE u.id_user = :id);';
// Execute the query with the user ID as a parameter.
$this->co->executeQuery($query, array(':id' => array($id, PDO::PARAM_STR)));
// Get the results of the query and return them.
$result = $this->co->getResults();
public function getFavorite(string $id):array{
//obtention favoris d'un user
$query='SELECT * FROM Quote WHERE id_quote IN (SELECT id_quote FROM Favorite f JOIN users u ON u.id_user = f.user_f WHERE u.id_user = :id);';
$this->co->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR)));
$result=$this->co->getResults();
return $result;
}
/**
* Retrieves the user ID based on the given username.
*
* @param string $username The username for which to retrieve the user ID.
* @return array The user ID corresponding to the given username.
*/
public function getIdUser(string $username): array
{
// SQL query to retrieve the user ID based on the username.
$query = 'SELECT id_user
FROM Users
WHERE username = :username';
// Execute the query with the provided username parameter.
$this->co->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
// Get the results of the query and return them.
public function getIdUser(string $username):array{
$query = 'SELECT id_user FROM Users WHERE username=:username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
}
// ===================== FIND FUNCTION =====================
/**
* Retrieves user information including their image based on the username.
*
* @param string $username The username of the user whose details are to be fetched.
* @return array An array containing user details and image information.
*/
public function findUsername(string $username): array
{
// SQL query to retrieve user details and their associated image.
$query = 'SELECT * FROM Users u
JOIN Image i ON i.id_img = u.img
WHERE username = :username';
// Execute the query with the provided username as a parameter.
$this->co->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
// Get the result of the query and return it.
return $this->co->getResults();
//obtenir les information d'un user
public function findDataUser(int $id):array{
$query = 'SELECT u.id_user , u.username , u.email , u.password , i.imgPath , u.creation FROM Users WHERE id_user=:idUser';
$this->co->executeQuery($query, array(':idUser'=>array($id, PDO::PARAM_STR)));
$result = $this->co->getResults();
return $result;
}
/**
* Retrieves user information based on their email.
*
* @param string $email The email of the user whose details are to be fetched.
* @return array An array containing the user's details.
*/
public function findEmail(string $email): array
{
// SQL query to retrieve user details based on email.
$query = 'SELECT *
FROM Users
WHERE email = :email';
// Execute the query with the provided email as a parameter.
$this->co->executeQuery($query, array(':email' => array($email, PDO::PARAM_STR)));
// Get the result of the query and return it.
// obtenir les informations d'un user selon son pseudo
public function findUsername(string $username):array{
$query = 'SELECT * FROM Users u Join Image i on i.id_img=u.img WHERE username= :username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
public function findEmail(string $email):array{
$query = 'SELECT * FROM Users WHERE email = :email';
$this->co->executeQuery($query, array(':email'=>array($email, PDO::PARAM_STR)));
return $this->co->getResults();
}
// ===================== CHECK FUNCTION =====================
/**
* Checks if a username already exists in the database.
*
* @param string $username The username to check.
* @return bool Returns true if the username exists, false otherwise.
*/
public function IsExisteUsername(string $username): bool
{
// SQL query to check if the username exists in the "Users" table.
$query = 'SELECT COUNT(*) as count
FROM Users
WHERE username = :username';
// Execute the query, binding the provided username parameter.
public function IsExisteUsername(string $username): bool {
$query = 'SELECT COUNT(*) as count FROM Users WHERE username = :username';
$this->co->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
// Get the query results.
$results = $this->co->getResults();
// Return true if the "count" is greater than 0, meaning the username exists.
return $results[0]['count'] > 0;
return $results[0]['count'] > 0; // retourne true si "count" > 0)
}
/**
* Checks if an email already exists in the database.
*
* @param string $email The email to check.
* @return bool Returns true if the email exists, false otherwise.
*/
public function IsExisteEmail(string $email): bool
{
// SQL query to check if the email exists in the "Users" table.
$query = 'SELECT COUNT(*) as count
FROM Users
WHERE email = :email';
// Execute the query, binding the provided email parameter.
public function IsExisteEmail(string $email): bool {
$query = 'SELECT COUNT(*) as count FROM Users WHERE email = :email';
$this->co->executeQuery($query, array(':email' => array($email, PDO::PARAM_STR)));
// Get the query results.
$results = $this->co->getResults();
// Return true if the "count" is greater than 0, meaning the email exists.
return $results[0]['count'] > 0;
return $results[0]['count'] > 0; // retourne true si "count" > 0)
}
/**
* Retrieves the password hash for a given username.
*
* @param string $username The username to search for.
* @return string|null The password hash if the username is found, null otherwise.
*/
public function getPasswordHash(string $username): ?string {
// SQL query to retrieve the password hash for a given username.
$query = 'SELECT password
FROM Users
WHERE username = :username';
// Execute the query with the provided username as the parameter.
$query = 'SELECT password FROM Users WHERE username = :username';
$this->co->executeQuery($query, array(':username' => array($username, PDO::PARAM_STR)));
// Get the results of the query.
$results = $this->co->getResults();
// If results are found, return the password hash, otherwise return null.
// Si un utilisateur est trouvé, retourner le hash du mot de passe, sinon null
return $results ? $results[0]['password'] : null;
}
// ===================== UPDATE FUNCTION =====================
/**
* Updates the username for a user.
*
* @param string $username The current username.
* @param string $newUsername The new username to set.
* @return array The result of the update, including the new username.
*/
public function updateUsername(string $username, string $newUsername): array {
// SQL query to update the username for the user with the current username
$queryUpdate = 'UPDATE Users
SET username=:newUsername
WHERE username=:username';
// Execute the update query with the provided parameters
$this->co->executeQuery($queryUpdate, array(
':username' => array($username, PDO::PARAM_STR),
':newUsername' => array($newUsername, PDO::PARAM_STR)
));
// SQL query to retrieve the updated username from the Users table
//Update Username
public function updateUsername(string $username, string $newUsername):array{
//Update le nom du user passé en paramètre
$queryUpdate = 'UPDATE Users SET username=:newUsername WHERE username=:username';
$this->co->executeQuery($queryUpdate, array(':username'=>array($username, PDO::PARAM_STR), ':newUsername'=> array($newUsername, PDO::PARAM_STR)));
//Renvoie le nouveau nom du user
$queryReponse = 'SELECT username FROM Users WHERE username=:idUser';
// Execute the query to fetch the updated username
$this->co->executeQuery($queryReponse, array(':idUser' => array($newUsername, PDO::PARAM_STR)));
// Return the result, which will contain the new username
$this->co->executeQuery($queryReponse, array(':idUser'=>array($newUsername, PDO::PARAM_STR)));
return $this->co->getResults();
}
//Update Email
public function updateEmail(string $username, string $newEmail):array{
//Update le email du user passé en paramètre
$queryUpdate = 'UPDATE Users SET email=:newEmail WHERE username=:username';
$this->co->executeQuery($queryUpdate, array(':username'=>array($username, PDO::PARAM_STR), ':newEmail'=> array($newEmail, PDO::PARAM_STR)));
/**
* Updates the email for a user based on their username.
*
* @param string $username The username of the user whose email will be updated.
* @param string $newEmail The new email to set for the user.
* @return array The result of the update, including the new email.
*/
public function updateEmail(string $username, string $newEmail): array {
// SQL query to update the email for the user with the specified username
$queryUpdate = 'UPDATE Users
SET email=:newEmail
WHERE username=:username';
// Execute the update query with the provided parameters (username and newEmail)
$this->co->executeQuery($queryUpdate, array(
':username' => array($username, PDO::PARAM_STR),
':newEmail' => array($newEmail, PDO::PARAM_STR)
));
// SQL query to retrieve the updated email from the Users table
//Renvoie le nouveau email du user
$queryReponse = 'SELECT email FROM Users WHERE username=:username';
// Execute the query to fetch the updated email
$this->co->executeQuery($queryReponse, array(':username' => array($username, PDO::PARAM_STR)));
// Return the result, which will contain the new email
$this->co->executeQuery($queryReponse, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
/**
* Updates the profile image for a user based on their username.
*
* @param string $username The username of the user whose image will be updated.
* @param string|null $newImage The new image ID or `null` to use a random image.
* @return array The result of the update, including the new image ID.
*/
public function updateImg(string $username, string $newImage): array {
// Determine the image ID to use
if ($newImage == null) {
// If no image provided, use a random image ID
public function updateImg(string $username,string $newImage):array{
if($newImage==null){
$id_image = $this->randomImg();
} else if (is_int((int)$newImage)) {
// If a valid image ID is provided, use it
$id_image = (int)$newImage;
} else {
// If the provided value is not valid, use a random image ID
}
else if(is_int((int)$newImage)){
$id_image=(int)$newImage;
}
else{
$id_image = $this->randomImg();
}
// SQL query to update the image for the user with the specified username
$query = 'UPDATE Users
SET img=:id_image
WHERE username=:username';
$this->co->executeQuery($query, array(
':username' => array($username, PDO::PARAM_STR),
':id_image' => array($id_image, PDO::PARAM_INT)
));
// SQL query to retrieve the updated image for the user
$queryReponse = 'SELECT img FROM Users WHERE username=:username';
$this->co->executeQuery($queryReponse, array(':username' => array($username, PDO::PARAM_STR)));
//Update l'image du user passé en paramètre
$query = 'UPDATE Users SET img=:id_image WHERE username=:username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':id_image'=> array($id_image, PDO::PARAM_INT)));
// Return the result, which will contain the new image ID
//Renvoie la nouvelle image du user
$queryReponse = 'SELECT img FROM Users WHERE username=:username';
$this->co->executeQuery($queryReponse, array(':username'=>array($username, PDO::PARAM_STR)));
return $this->co->getResults();
}
/**
* Updates the password for a user based on their username.
*
* @param string $username The username of the user whose password will be updated.
* @param string $newPassWd The new password to set for the user.
*/
public function updatePasswd(string $username, string $newPassWd): void {
// SQL query to update the password for the user with the specified username
$query = 'UPDATE Users
SET password=:newPassWd
WHERE username=:username';
// Execute the query with the provided parameters (username and new password)
$this->co->executeQuery($query, array(
':username' => array($username, PDO::PARAM_STR),
':newPassWd' => array($newPassWd, PDO::PARAM_STR)
));
public function updatePasswd(string $username, string $newPassWd):void{
//Update le passwd du user passé en paramètre
$query = 'UPDATE Users SET password=:newPassWd WHERE username=:username';
$this->co->executeQuery($query, array(':username'=>array($username, PDO::PARAM_STR), ':newPassWd'=> array($newPassWd, PDO::PARAM_STR)));
}
public function emailWithUser(string $user):array{
$query = 'SELECT email FROM Users WHERE username = :user';
$this->co->executeQuery($query, array(':user'=>array($user, PDO::PARAM_STR)));
return $this->co->getResults();
}
}
?>

@ -6,94 +6,81 @@ use Gateway\CharacterGateway;
use Gateway\Gateway;
class CharacterModel extends Model {
/**
* Creates a character by calling the gateway's create method.
*
* @param int $id_character The unique identifier for the character.
* @param string $name The name of the character.
* @param string $img_char The file path of the image associated with the character.
*
* @return bool Returns true if the character was successfully created, otherwise false.
*/
public function createCharacter(int $id_character, string $name, string $img_char) : bool {
return $this->gateway->create($id_character, $name, $img_char);
class CharacterModel extends Model
{
public function createCharacter(int $id_character, string $name , int $img_char) : bool
{
return $this -> gateway -> create($id_character, $name, $img_char);
}
/**
* Retrieves a character by its unique identifier.
*
* @param int $id_character The unique identifier of the character to retrieve.
*
* @return CharacterEntity|null Returns a CharacterEntity object if found, otherwise null.
*/
public function getCharacterById(int $id_character) : ?CharacterEntity {
// Attempt to find the character by ID using the gateway's findById method.
$c = $this->gateway->findById($id_character);
public function createCharacterWithoutId(string $name , int $img_char) : bool
{
$id_character = $this -> gateway -> getLastId();
return $this -> gateway -> create($id_character, $name, $img_char);
}
// If the character is found, create and return a new CharacterEntity object.
if ($c) {
public function getCharacterById(int $id_character) : ?CharacterEntity
{
$c = $this -> gateway -> findById($id_character);
if ($c)
return new CharacterEntity(
$c[0]['id_caracter'], // Character ID
$c[0]['caracter'], // Character name
$c[0]['id_img'] // Image ID associated with the character
$c[0]['id_caracter'],
$c[0]['caracter'],
$c[0]['id_img']
);
}
// If no character is found, return null.
return null;
}
/**
* Retrieves all characters from the database and returns them as an array of CharacterEntity objects.
*
* @return CharacterEntity[] Returns an array of CharacterEntity objects representing all characters.
*/
public function getAllCharacters() : array {
// Fetch all characters using the gateway's findAll method.
public function getAllPerso() :array{
$res = $this->gateway->findAll();
// Initialize an empty array to store the CharacterEntity objects.
$charac = [];
// Loop through each character in the result and create a CharacterEntity for each.
foreach ($res as $c) {
foreach($res as $c){
$charac[] = new CharacterEntity(
$c['id_caracter'], // Character ID
$c['caracter'], // Character name or description
$c['id_img'] // Image ID associated with the character
$c['id_caracter'],
$c['caracter'],
$c['id_img']
);
}
// Return the array of CharacterEntity objects.
return $charac;
}
/**
* Retrieves a character by its name.
*
* @param string $name The name of the character to retrieve.
*
* @return CharacterEntity|null Returns a CharacterEntity object if a character with the given name is found, otherwise null.
*/
public function getCharacterByName(string $name) : ?CharacterEntity {
// Attempt to find the character by name using the gateway's findByName method.
$c = $this->gateway->findByName($name);
// If the character is found, create and return a new CharacterEntity object.
if ($c) {
public function getCharacterByName(string $name) : ?CharacterEntity
{
$c = $this -> gateway -> findByName($name);
if ($c)
return new CharacterEntity(
$c[0]['id_caracter'], // Character ID
$c[0]['caracter'], // Character name or description
$c[0]['id_img'] // Image ID or path associated with the character
$c[0]['id_caracter'],
$c[0]['caracter'],
$c[0]['id_img']
);
return null;
}
public function getAllCharacters() : array
{
$c = $this -> gateway -> findAll();
$characters = [];
foreach ($c as $character)
{
$characters[] = new CharacterEntity(
$character['id_caracter'],
$character['caracter'],
$character['id_img']
);
}
return $characters;
}
// If no character is found, return null.
return null;
public function deleteCharacter(int $id_character) : bool
{
return $this -> gateway -> delete($id_character);
}
}
public function updateCharacter(int $id_character, string $name, int $img_char) : bool
{
return $this -> gateway -> update($id_character, $name, $img_char);
}
?>
}

@ -1,56 +1,45 @@
<?php
namespace Model;
use Entity\CommentaryEntity;
use Gateway\CommentaryGateway;
use Gateway\Gateway;
class CommentaryModel extends Model {
/**
* Creates a new comment associated with a specific quote and user.
*
* @param string $comment The content of the comment.
* @param string $idQuote The identifier of the quote the comment is associated with.
* @param string $idUser The identifier of the user who is creating the comment.
*
* @return bool Returns true if the comment was successfully created, otherwise false.
*/
public function createComment(string $comment, string $idQuote, string $idUser): bool {
// Calls the gateway's create method to insert the new comment into the data source.
return $this->gateway->create($comment, $idUser, $idQuote);
}
/**
* Retrieves all comments associated with a specific quote.
*
* @param int $id The unique identifier of the quote.
*
* @return CommentaryEntity[] Returns an array of CommentaryEntity objects representing all the comments for the given quote.
*/
public function getComment(int $id): array {
// Initialize an empty array to store the comment objects.
$com = [];
// Fetch all comments related to the given quote ID using the gateway's findByQuote method.
$res = $this->gateway->findByQuote($id);
foreach ($res as $comments){
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["datec"], $comments["username"], $comments["imgpath"]);
}
return $com;
}
// Loop through each comment in the result and create a CommentaryEntity object for each.
public function getComments(): array {
$res = $this->gateway->findAll();
foreach ($res as $comments) {
$com[] = new CommentaryEntity(
$comments["id_comment"], // Comment ID
$comments["comment"], // The content of the comment
$comments["datec"], // The date the comment was created
$comments["username"], // The username of the user who made the comment
$comments["imgpath"] // The image path associated with the user who made the comment
);
$com[] = new CommentaryEntity($comments["id_comment"], $comments["comment"], $comments["date"]);
}
// Return the array of CommentaryEntity objects.
return $com;
}
}
public function deleteComment(int $id_comment): bool {
return $this -> gateway -> delete($id_comment);
}
public function updateComment(int $id_comment, string $comment): bool {
?>
$c = $this -> getComment($id_comment);
if($c){
$c -> setComment($comment);
return $this->gateway -> update($c);
}
return false;
}
}

@ -0,0 +1,65 @@
<?php
namespace Model;
use Gateway\FavoriteGateway;
use Entity\FavoriteEntity;
use Gateway\Gateway;
class FavoriteModel extends Model
{
public function createFavoriteModel(int $idUser, int $idQuote) : bool
{
return $this -> gateway -> createFavoriteGateway($idUser, $idQuote);
}
public function getFavoriteById(int $idUser, int $idQuote) : ?FavoriteEntity
{
$res = $this -> gateway -> findFavoriteById($idUser, $idQuote);
if ($res)
{
return new FavoriteEntity (
$res[0]['user_f'],
$res[0]['quote_f'],
);
}
return null;
}
public function getFavoriteByUser(int $idUser) : array
{
$res = $this -> gateway -> findFavoriteByUser($idUser);
$favorites = [];
foreach ($res as $favorite)
{
$favorites = new FavoriteEntity (
$favorite['user_f'],
$favorite['quote_f']
);
}
return $favorites;
}
public function getAllFavorite() : array
{
$res = $this -> gateway -> findAllFavorite();
$favorites = [];
foreach ($res as $favorite)
{
$favorites = new FavoriteEntity (
$favorite['user_f'],
$favorite['quote_f']
);
}
return $favorites;
}
public function removeFavorite(int $idUser, int $idQuote) : bool
{
return $this -> gateway -> deleteFavoriteGateway($idUser, $idQuote);
}
}

@ -1,37 +1,63 @@
<?php
namespace Model;
use Entity\ImageEntity;
use Gateway\ImageGateway;
use Gateway\Gateway;
class ImageModel extends Model
{
public function createImgModel(int $idImg, string $imgPath) : bool
{
return $this -> gateway -> createImgGateway($idImg, $imgPath);
}
public function createImgModelWithoutId (string $imgPath) : int
{
$idImg = $this->gateway ->getLastId() ;
$this -> gateway -> createImgGateway($idImg, $imgPath, false);
return $idImg;
}
/**
* Retrieves all images from the database.
*
* @return ImageEntity[] Returns an array of ImageEntity objects representing all the images.
*/
public function getAllImg() : array {
// Fetch all images using the gateway's findAllImg method.
$res = $this->gateway->findAllImg();
public function getImgById(int $idImg) : ?ImageEntity
{
$res = $this -> gateway -> findImgById($idImg);
if ($res)
{
return new ImageEntity(
$res[0]['id_img'],
$res[0]['imgpath']
);
}
return null;
}
public function getAllImg() : array
{
$res = $this -> gateway -> findAllImg();
// Initialize an empty array to store the ImageEntity objects.
$images = [];
// Loop through each image in the result and create an ImageEntity object for each.
foreach ($res as $img) {
foreach ($res as $img)
{
$images[] = new ImageEntity(
$img['id_img'], // Image ID
$img['imgpath'] // Image path (location or URL of the image)
$img['id_img'],
$img['imgpath']
);
}
// Return the array of ImageEntity objects.
return $images;
}
}
?>
public function deleteImgModel(int $idImg) : bool
{
return $this -> gateway -> deleteImgGateway($idImg);
}
public function updateImgModel(int $idImg, string $imgPath) : bool
{
return $this -> gateway -> updateImgGateway($idImg, $imgPath);
}
}

@ -1,21 +1,12 @@
<?php
namespace Model;
use Gateway\Gateway;
class Model
{
// The gateway instance responsible for interacting with the data source.
protected Gateway $gateway;
/**
* Constructor that initializes the Model with a Gateway instance.
*
* @param Gateway $gate The Gateway instance used to interact with the data source.
*/
public function __construct(Gateway $gate){
// Assign the provided Gateway instance to the model's gateway property.
$this->gateway = $gate;
}
}

@ -7,60 +7,154 @@ use Gateway\Gateway;
class QuestionModel extends Model
{
public function createQuestion(int $id_question, string $question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
{
return $this -> gateway -> create($id_question, $question, $answerA, $answerB, $answerC, $answerD, $cAnswer);
/**
* Retrieves a question by its unique identifier.
*
* @param int $id_question The unique identifier of the question to retrieve.
*
* @return QuestionEntity|null Returns a QuestionEntity object if found, otherwise null.
*/
public function getQuestion(int $id_question) : ?QuestionEntity {
// Attempt to find the question by its ID using the gateway's findById method.
$q = $this->gateway->findById($id_question);
// If the question is found, create and return a new QuestionEntity object with the question details.
if ($q) {
}
public function getQuestion(int $id_question) : ?QuestionEntity
{
$q = $this -> gateway -> findById($id_question);
if ($q)
return new QuestionEntity(
$q[0]['id_question'], // Question ID
$q[0]['texte'], // The text/content of the question
$q[0]['answera'], // The first answer option
$q[0]['answerb'], // The second answer option
$q[0]['answerc'], // The third answer option
$q[0]['answerd'], // The fourth answer option
$q[0]['canswer'] // The correct answer
$q[0]['id_question'],
$q[0]['texte'],
$q[0]['answera'],
$q[0]['answerb'],
$q[0]['answerc'],
$q[0]['answerd'],
$q[0]['canswer']
);
}
// If no question is found, return null.
return null;
}
/**
* Retrieves a random question from the database.
*
* @return QuestionEntity|null Returns a QuestionEntity object if a random question is found, otherwise null.
*/
public function getRdmQuestion() : ?QuestionEntity {
// Fetch a random question using the gateway's findRdmQuestion method.
$q = $this->gateway->findRdmQuestion();
// If a random question is found, create and return a new QuestionEntity object with the question details.
if ($q) {
return new QuestionEntity(
$q['id_question'], // Question ID
$q['question'], // The text/content of the question
$q['answerA'], // The first answer option
$q['answerB'], // The second answer option
$q['answerC'], // The third answer option
$q['answerD'], // The fourth answer option
$q['cAnswer'] // The correct answer
public function updateTextQuestion(int $id_question, string $question) : bool
{
return $this -> gateway -> updateText($id_question, $question);
}
public function updateAnswersQuestion(int $id_question, string $answerA, string $answerB, string $answerC, string $answerD, string $cAnswer): bool
{
return $this -> gateway -> updateAnswers($id_question, $answerA, $answerB, $answerC, $answerD, $cAnswer);
}
public function deleteQuestion(int $id_question) : bool
{
return $this -> gateway -> delete($id_question);
}
public function getAllQuestions() : array
{
$q = $this -> gateway -> findAll();
$questions = [];
foreach ($q as $question) {
$questions[] = new QuestionEntity(
$question['id_question'],
$question['question'],
$question['answerA'],
$question['answerB'],
$question['answerC'],
$question['answerD'],
$question['cAnswer']
);
}
return $questions;
}
// If no random question is found, return null.
public function getRdmQuestion() : ?QuestionEntity
{
$q = $this -> gateway -> findRdmQuestion();
if ($q)
return new QuestionEntity(
$q['id_question'],
$q['question'],
$q['answerA'],
$q['answerB'],
$q['answerC'],
$q['answerD'],
$q['cAnswer']
);
return null;
}
}
?>
public function getRandomQuestion(string $quesType, string $repType, string $langue) : ?QuestionEntity{
switch([$questType,$repType]){
case ["Quote","Src"]:
$q = $this -> gateway -> getQuestionQuoteSrc($langue);
return new QuestionEntity(
$q[], //idQuote
$q[], //Quote
$q[], //SrcJuste
$q[], //rndSrc 1
$q[], //rndSrc 2
$q[], //rndSrc 3
$q[], //SrcJuste
);
case ["Quote","Charac"]:
$q = $this -> gateway -> getQuestionQuoteCharac($langue);
case ["Charac","Src"]:
$q = $this -> gateway -> getQuestionCharacSrc($langue);
case ["Charac","Quote"]:
$q = $this -> gateway -> getQuestionCharacQuote($langue);
case ["Src","Quote"]:
$q = $this -> gateway -> getQuestionSrcQuote($langue);
case ["Src","Charac"]:
$q = $this -> gateway -> getQuestionSrcCharac($langue);
case ["Test","Test"]:
return new QuestionEntity(-1,"1","1","2","3","4","1");
default :
return null;
}
}
/*--------------------------------------- Quiz Aléatoire ---------------------------------------*/
/*----------------------- Question compléte -----------------------*/
public function QuestionForQuoteToCarac(string $lang) : QuestionEntity
{
$questRep = $this->gateway->QuestionToReponceForQuoteToCarac($lang);
$quest = $questRep[0]['question'];
$cAnswer = $questRep[0]['reponce'];
$fake = $this->gateway->FakeReponceForQuoteToCarac($lang,$cAnswer);
$fakeRep = [$cAnswer];
foreach ($fake as $rep){
$fakeRep[]=$rep['reponce'];
}
shuffle($fakeRep);
return new QuestionEntity(-1,$quest,$fakeRep[0],$fakeRep[1],$fakeRep[2],$fakeRep[3],$cAnswer);
}
public function QuestionForQuoteToTitle(string $lang) : QuestionEntity
{
$questRep = $this->gateway->QuestionToReponceForQuoteToTitle($lang);
$quest = $questRep['question'];
$cAnswer = $questRep['reponce'];
$fake = $this->gateway->FakeReponceForQuoteToTitle($lang,$cAnswer);
$fakeRep = [$cAnswer];
foreach ($fake as $rep){
$fakeRep[]=$rep['reponce'];
}
$fakeRep=array_rand($fakeRep);
return new QuestionEntity(-1,$quest,$fakeRep[0],$fakeRep[1],$fakeRep[2],$fakeRep[3],$cAnswer);
}
}

@ -1,60 +1,53 @@
<?php
namespace Model;
use Entity\quizEntity;
use Entity\QuizEntity;
use Gateway\QuizGateway;
use Gateway\Gateway;
class QuizModel extends Model{
public function createQuiz(int $id_quiz, int $nb_questions, String $id_img, string $title) : bool
{
return $this -> gateway -> create($id_quiz, $nb_questions, $id_img, $title);
}
/**
* Retrieves a quiz by its unique identifier.
*
* @param int $id_quiz The unique identifier of the quiz to retrieve.
*
* @return quizEntity|null Returns a quizEntity object if found, otherwise null.
*/
public function getQuiz(int $id_quiz): ?quizEntity{
// Attempt to find the quiz by its ID using the gateway's findQuizById method.
$q = $this->gateway->findQuizById($id_quiz);
// If the quiz is found, create and return a new quizEntity object with the quiz details.
public function getQuiz(int $id_quiz): ?QuizEntity
{
$q = $this -> gateway -> findQuizById($id_quiz);
if ($q) {
return new quizEntity(
$q[0]['id_quiz'], // Quiz ID
$q[0]['nb_quest'] // The number of questions in the quiz
return new QuizEntity(
$q[0]['id_quiz'],
$q[0]['nb_quest'],
$q[0]['imgpath'],
$q[0]['title']
);
}
// If no quiz is found, return null.
return null;
}
/**
* Retrieves all quizzes from the database.
*
* @return quizEntity[] Returns an array of quizEntity objects representing all the quizzes.
*/
public function getAllQuiz() : array{
// Fetch all quizzes using the gateway's findAll method.
$q = $this->gateway->findAll();
// Initialize an empty array to store the quiz objects.
$quizzes = [];
// Loop through each quiz in the result and create a quizEntity object for each.
foreach ($q as $quiz) {
$quizzes[] = new quizEntity(
$quiz['id_quiz'], // Quiz ID
$quiz['nb_questions'] // The number of questions in the quiz
public function deleteQuiz(int $id_quiz) : bool
{
return $this -> gateway -> delete($id_quiz);
}
public function listQuiz() : array
{
$res = $this -> gateway -> findAll();
$quizs = [];
foreach ($res as $quiz)
{
$quizs[] = new QuizEntity(
$quiz['id_quiz'],
$quiz['nb_quest'],
$quiz['imgpath'],
$quiz['title']
);
}
// Return the array of quizEntity objects.
return $quizzes;
return $quizs;
}
}
?>
}

@ -14,37 +14,59 @@ use Gateway\Gateway;
class QuizQuestionModel extends Model
{
/**
* Retrieves all questions associated with a specific quiz.
*
* @param int $id The unique identifier of the quiz.
* @param Connection $co The database connection to be used for querying.
*
* @return QuestionEntity[] Returns an array of QuestionEntity objects representing all the questions in the quiz.
*/
public function getAllQuestionByQuiz(int $id, Connection $co): array{
// Fetch all questions related to the given quiz ID using the gateway's findQuestionsFromQuiz method.
public function createQuizQuestion(int $idQuiz, int $idQuestion): bool
{
return $this->gateway->create($idQuiz,$idQuestion);
}
public function findQuizQuestionByIdQuiz(int $id): ?QuizQuestionEntity
{
$q = $this ->gateway->findQuizQuestionByIdQuiz($id);
if ($q) {
return new QuizQuestionEntity(
$q['idQuiz'],
$q['idQuestion'],
);
}
return null;
}
public function getAllQuestionByQuiz(int $id, Connection $co): array
{
$q = $this->gateway->findQuestionsFromQuiz($id);
// Initialize an empty array to store the QuestionEntity objects.
$questions = [];
// Create a new QuestionGateway instance using the provided database connection.
$gateway = new QuestionGateway($co);
// Create a new QuestionModel instance, passing the QuestionGateway for data operations.
$qmdl = new QuestionModel($gateway);
// Loop through each question in the result and retrieve its full details using the QuestionModel.
foreach ($q as $question) {
// Add the full QuestionEntity object for each question to the questions array.
$questions[] = $qmdl->getQuestion($question[1]);
foreach ($q as $question){
$questions [] = $qmdl->getQuestion($question[1]);
}
// Return the array of QuestionEntity objects.
return $questions;
}
}
public function findAll(): array
{
$q = $this -> gateway -> findAll();
$quizzes = [];
foreach ($q as $quiz) {
$quizzes[] = new QuizQuestionEntity(
$quiz['idQuiz'],
$quiz['idQuestion']
);
}
return $quizzes;
}
public function deleteQuizQuestion(int $id): bool
{
return $this -> gateway -> delete($id);
}
?>
}

@ -1,164 +1,55 @@
<?php
namespace Model;
use Entity\Quote;
use Gateway\QuoteGateway;
use Gateway\Gateway;
use Enum\TypeSourceEnum;
class QuoteModel extends Model
{
/**
* Searches for a quote by its unique identifier.
*
* @param int $id The unique identifier of the quote to search for.
*
* @return Quote Returns a Quote object. If no quote is found, returns a default Quote with an ID of -1 and default values.
*/
public function searchId(int $id): Quote {
// Fetch the quote data by ID using the gateway's searchId method.
public function searchId(int $id): Quote{
$res = $this->gateway->searchId($id);
// If no result is found, return a default Quote with an ID of -1 and placeholder values.
if (count($res) == 0) {
return new Quote(-1, "NULL", "NULL", "NULL", "NULL", "NULL", 0, "Default");
} else {
// Otherwise, return the Quote object populated with data from the search result.
return new Quote(
$res[0]["id_quote"], // Quote ID
$res[0]["content"], // Quote content
$res[0]["caracter"], // Character associated with the quote
$res[0]["imgpath"], // Image path (associated with the quote or character)
$res[0]["title"], // Title of the quote
$res[0]["dates"], // Date the quote was created
$res[0]["likes"], // Number of likes for the quote
$res[0]["langue"] // Language of the quote
);
}
if( count($res) == 0)
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default");
else
return new Quote($res[0]["id_quote"],$res[0]["content"],$res[0]["caracter"],$res[0]["imgpath"],$res[0]["title"],$res[0]["dates"],$res[0]["likes"],$res[0]["langue"],TypeSourceEnum::Movie);
}
/**
* Retrieves suggestions for quotes based on the specified page number and language.
*
* @param int $numpage The page number for pagination.
* @param string $language The language to filter the suggestions by.
*
* @return Quote[] Returns an array of Quote objects representing the suggested quotes.
*/
public function getSuggest(int $numpage, string $language): array {
// Fetch suggestions from the gateway's getSuggestions method.
$res = $this->gateway->getSuggestions($numpage, $language);
// Initialize an empty array to store the resulting Quote objects.
$tabQ = [];
public function getSuggest(int $numpage, string $language):array{
$res = $this->gateway->getSuggestions($numpage,$language);
$tabQ=[];
// Loop through the result set and create Quote objects.
foreach ($res as $q) {
// Truncate the content if it's longer than 153 characters, appending '...' if necessary.
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"], 0, 150) . '...' : $q["content"];
// Create a new Quote object and add it to the tabQ array.
$tabQ[] = new Quote(
$q["id_quote"], // Quote ID
$q["content"], // Truncated content of the quote
$q["caracter"], // Character associated with the quote
$q["imgpath"], // Image path related to the quote
$q["title"], // Title of the quote
$q["dates"], // Date the quote was created
$q["likes"], // Number of likes the quote has received
$q["langue"] // Language of the quote
);
foreach($res as $q ){
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"];
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
}
// Return the array of Quote objects.
return $tabQ;
}
/**
* Retrieves the quote of the day for a specified language.
*
* @param string $language The language to filter the quote of the day by.
*
* @return Quote Returns the Quote of the Day. If no quote is found, returns a default Quote with an ID of -1 and default values.
*/
public function getQuoteOfTheDay(string $language): Quote {
// Fetch the quote of the day from the gateway's getQuoteOfTheDay method.
public function getQuoteOfTheDay(string $language):Quote{
$res = $this->gateway->getQuoteOfTheDay($language);
// If no result is found, return a default Quote with an ID of -1 and placeholder values.
if (count($res) == 0) {
return new Quote(-1, "NULL", "NULL", "NULL", "NULL", "NULL", 0, "Default");
} else {
// Truncate the content if it's longer than 153 characters, appending '...' if necessary.
$res["content"] = (strlen($res["content"]) > 153) ? substr($res["content"], 0, 150) . '...' : $res["content"];
// Return the Quote object populated with data from the quote of the day.
return new Quote(
$res["id_quote"], // Quote ID
$res["content"], // Truncated content of the quote
$res["caracter"], // Character associated with the quote
$res["imgpath"], // Image path associated with the quote
$res["title"], // Title of the quote
$res["dates"], // Date the quote was created
$res["likes"], // Number of likes the quote has received
$res["langue"] // Language of the quote
);
}
if( count($res) == 0)
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default",TypeSourceEnum::Movie);
else
$res["content"] = (strlen($res["content"]) > 153) ? substr($res["content"],0,150).'...' : $res["content"];
return new Quote($res["id_quote"],$res["content"],$res["caracter"],$res["imgpath"],$res["title"],$res["dates"],$res["likes"],$res["langue"],TypeSourceEnum::Movie) ;
}
/**
* Retrieves all favorite quotes for a specified user.
*
* @param string $userId The unique identifier of the user.
*
* @return Quote[] Returns an array of Quote objects representing the user's favorite quotes.
*/
public function getFavorites(string $userId): array {
// Fetch the user's favorite quotes from the gateway's getFavorites method.
$res = $this->gateway->getFavorites($userId);
$tabQ=[];
// Initialize an empty array to store the resulting Quote objects.
$tabQ = [];
// Loop through the result set and create Quote objects.
foreach ($res as $q) {
// Truncate the content if it's longer than 153 characters, appending '...' if necessary.
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"], 0, 150) . '...' : $q["content"];
// Create a new Quote object and add it to the tabQ array.
$tabQ[] = new Quote(
$q["id_quote"], // Quote ID
$q["content"], // Truncated content of the quote
$q["caracter"], // Character associated with the quote
$q["imgpath"], // Image path related to the quote
$q["title"], // Title of the quote
$q["dates"], // Date the quote was created
$q["likes"], // Number of likes the quote has received
$q["langue"] // Language of the quote
);
foreach($res as $q ){
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"];
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
}
// Return the array of favorite Quote objects.
return $tabQ;
}
/**
* Inserts a new quote for a specific user.
*
* @param string $content The content of the quote.
* @param string $img_path The image path associated with the quote.
* @param string $langage The language of the quote.
* @param int $user The ID of the user associated with the quote.
* @param int $source The source of the quote (e.g., the origin of the quote or where it was sourced from).
* @param int $character The character associated with the quote.
*
* @return bool Returns true if the quote was successfully inserted, otherwise false.
*/
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character): bool {
// Call the gateway's insert4User method to insert the new quote into the database.
return $this->gateway->insert4User($content, $img_path, $langage, $user, $source, $character);
public function addQuote(string $content, string $lang, int $idChar, int $idSrc, int $idUsr){
$this -> gateway -> addQuote($content,$lang,$idChar,$idSrc,$idUsr);
}
}
?>

@ -0,0 +1,91 @@
<?php
namespace Model;
use Entity\ResultsEntity;
use Gateway\ResultsGateway;
use Gateway\Gateway;
class ResultsModel extends Model
{
public function createResultsModel(int $idQuiz, int $idUser, int $score, int $time) : bool
{
return $this -> gateway -> createResultsGateway($idQuiz, $idUser, $score, $time);
}
public function getResultsByQuiz(int $idQuiz) : array
{
$res = $this -> gateway -> findResultsByQuiz($idQuiz);
$results = [];
foreach ($res as $result)
{
$results[] = new ResultsEntity (
$result['user_r'],
$result['quiz_r'],
$result['score'],
$result['time']
);
}
return $results;
}
public function getResultsByUser(int $idUser) : array
{
$res = $this -> gateway -> findResultsByUser($idUser);
$results = [];
foreach ($res as $result)
{
$results[] = new ResultsEntity (
$result['user_r'],
$result['quiz_r'],
$result['score'],
$result['time']
);
}
return $results;
}
public function getResultsById(int $idQuiz, int $idUser) : ?ResultsEntity
{
$res = $this -> gateway -> findResultsById($idQuiz, $idUser);
if ($res)
{
return new ResultsEntity (
$res['user_r'],
$res['quiz_r'],
$res['score'],
$res['time']
);
}
return null;
}
public function getAllResults() : array
{
$res = $this -> gateway -> findAllResults();
$results = [];
foreach ($res as $result)
{
$results[] = new ResultsEntity (
$result['user_r'],
$result['quiz_r'],
$result['score'],
$result['time']
);
}
return $results;
}
public function updateResultsModel(int $idQuiz, int $idUser, ?int $score, ?int $time) : bool
{
return $this -> gateway -> updateResults($idQuiz, $idUser, $score, $time);
}
}

@ -3,45 +3,20 @@
use Entity\Quote;
use Gateway\QuoteGateway;
use Gateway\Gateway;
use Enum\TypeSourceEnum;
class SearchModel extends Model
{
/**
* Searches for quotes based on specified filters and search criteria.
*
* @param string|null $type The type of quote to search for (optional).
* @param string|null $search The search term to filter quotes (optional).
* @param array $filtre Additional filters to refine the search (e.g., date range, category).
*
* @return Quote[] Returns an array of Quote objects that match the search criteria and filters.
*/
public function searchQuote(?string $type, ?string $search, array $filtre): array {
// Call the gateway's search method with the provided search criteria and filters.
$res = $this->gateway->search($type, $search, $filtre);
public function searchQuote(?string $type,?string $search,array $filtre): array{
$res = $this->gateway->search($type,$search,$filtre);
$tabQ=[];
// Initialize an empty array to store the resulting Quote objects.
$tabQ = [];
// Loop through the search results.
foreach ($res as $q) {
// Truncate the quote content to 150 characters, adding '...' if it's too long.
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"], 0, 150) . '...' : $q["content"];
// Create a new Quote object and add it to the tabQ array.
$tabQ[] = new Quote(
$q["id_quote"], // Quote ID
$q["content"], // The content of the quote (truncated if too long)
$q["caracter"], // The character associated with the quote
$q["imgpath"], // The image path associated with the quote (e.g., character image)
$q["title"], // The title of the quote
$q["dates"], // The date when the quote was made
$q["likes"], // The number of likes the quote has received
$q["langue"] // The language of the quote
);
foreach($res as $q ){
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"];
$tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
}
// Return the array of Quote objects.
return $tabQ;
}
}

@ -1,126 +1,112 @@
<?php
namespace Model;
use Entity\SourceEntity;
use Enum\TypeSourceEnum;
class SourceModel extends Model
{
/**
* Creates a new source with the provided title, date, and type.
*
* @param string $title The title of the source.
* @param string $date The date associated with the source.
* @param TypeSourceEnum $type The type of the source (e.g., Movie, Book, etc.).
*
* @return bool Returns true if the source was successfully created, false otherwise.
*/
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
{
// Create a new SourceEntity with the given title, date, and type.
// Note: The type is hardcoded as "Movie" in this implementation.
$q = new SourceEntity(-1, $title, $date, TypeSourceEnum::Movie);
// Use the gateway to insert the new source and return the result.
return $this->gateway->create($q);
$id = $this -> gateway -> getLastId();
$q = new SourceEntity($id,$title, $date, $type);
return $this -> gateway -> create($q);
}
/**
* Retrieves a source by its unique identifier.
*
* @param int $id_source The unique identifier of the source.
*
* @return SourceEntity|null Returns a SourceEntity object if found, or null if no source is found with the given ID.
*/
public function getSourceById(int $id_source) : ?SourceEntity
{
// Fetch the source by ID using the gateway's findById method.
$res = $this->gateway->findById($id_source);
// If a source is found, return a SourceEntity object.
if ($res) {
return new SourceEntity(
$res[0]["id_source"], // Source ID
$res[0]["title"], // Title of the source
$res[0]["dates"], // Date associated with the source
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
$res = $this -> gateway -> findById($id_source);
if ($res)
return new sourceEntity(
$res[0]["id_source"],
$res[0]["title"],
$res[0]["dates"],
TypeSourceEnum::Movie//from($res[0]["type"])
);
}
// Return null if no source is found.
return null;
}
/**
* Retrieves a source by its title.
*
* @param string $title The title of the source to search for.
*
* @return SourceEntity|null Returns a SourceEntity object if found, or null if no source is found with the given title.
*/
public function getSourceByTitle(string $title) : ?SourceEntity
{
// Fetch the source by title using the gateway's findByTitle method.
$res = $this->gateway->findByTitle($title);
// If a source is found, return a SourceEntity object.
if ($res) {
return new SourceEntity(
$res[0]["id_source"], // Source ID
$res[0]["title"], // Title of the source
$res[0]["dates"], // Date associated with the source
TypeSourceEnum::Movie // Hardcoded to "Movie" type; dynamic mapping could be considered
if ($res)
return new sourceEntity(
$res[0]["id_source"],
$res[0]["title"],
$res[0]["dates"],
TypeSourceEnum::Movie//from($res[0]["type"])
);
}
// Return null if no source is found.
return null;
}
/**
* Retrieves all sources from the database.
*
* @return SourceEntity[] Returns an array of SourceEntity objects representing all the sources.
*/
public function getAllSources() : array
public function getSourceByDate(string $date) : array
{
// Fetch all sources from the gateway's findAll method.
$res = $this->gateway->findAll();
$res = $this->gateway->findByDate($date);
$src = [];
foreach ($res as $sources) {
$src[] = new sourceEntity(
$sources["id_source"],
$sources["title"],
$sources["dates"],
TypeSourceEnum::from($sources["type"])
);
}
return $src;
}
// Initialize an empty array to store the SourceEntity objects.
public function getSourceByType(TypeSourceEnum $type) : array
{
$res = $this->gateway->findByType($type);
$src = [];
foreach ($res as $sources) {
$src[] = new sourceEntity(
$sources["id_source"],
$sources["title"],
$sources["dates"],
TypeSourceEnum::from($sources["type"])
);
}
return $src;
}
// Loop through the result and create a SourceEntity object for each source.
public function getAllSources() : array
{
$res = $this -> gateway -> findAll();
$src = [];
foreach ($res as $sources) {
$src[] = new SourceEntity(
$sources["id_source"], // Source ID
$sources["title"], // Title of the source
$sources["dates"], // Date associated with the source
TypeSourceEnum::Movie // Hardcoded to "Movie" type; you may consider dynamically mapping this
$sources["id_source"],
$sources["title"],
$sources["dates"],
TypeSourceEnum::Movie
//TypeSourceEnum::from($sources["type"])
);
}
// Return the array of SourceEntity objects.
return $src;
}
/**
* Checks if a source with the given name and type exists.
*
* @param string $name The name of the source to check.
* @param string $type The type of the source to check (e.g., Movie, Book, etc.).
*
* @return bool Returns true if the source exists, false otherwise.
*/
public function existSource(string $name, string $type) : bool
public function deleteSource(int $id_source) : bool
{
// Retrieve the source by title using the getSourceByTitle method.
$q = $this->getSourceByTitle($name);
return $this -> gateway -> delete($id_source);
}
// Check if the source exists and return the result.
return isset($q[0]);
public function updateSource(int $id_source, string $title, string $date) : bool
{
$q = $this -> getSourceById($id_source);
if ($q){
$q -> setTitle($title);
$q -> setDate($date);
return $this -> gateway -> update($q);
}
return false;
}
public function existSource(string $name, string $type) : bool{
$q = $this -> getSourceByTitle($name);
return isset($q);
}
}
?>

@ -8,55 +8,51 @@
class UserModel extends Model
{
/**
* Inserts a new user with the provided username, email, and password.
* The account is created with default settings (active and role 1).
*
* @param string $username The username for the new user.
* @param string $email The email address for the new user.
* @param string $passwd The password for the new user.
*
* @return bool Returns true if the user was successfully created, false otherwise.
*/
public function insertUser(string $username, string $email, string $passwd) : bool {
// Calls the gateway method to insert a new user with default settings.
return $this->gateway->insertUser($username, $email, $passwd, false, 1);
public function insertUser(string $username,string $email,string $passwd) : bool{
/*global $rep,$image;*/
return $this->gateway->insertUser( $username, $email, $passwd, false, 1);
}
/**
* Deletes a user by their ID.
*
* @param string $id The ID of the user to be deleted.
*
* @return bool Returns true if the user was successfully deleted, false otherwise.
*/
public function deleteUser(string $id) : bool {
// Calls the gateway method to delete the user by their ID.
public function deleteUser(string $id) : bool{
return $this->gateway->delete($id);
}
/**
* Retrieves the total number of users in the system.
*
* @return int The total number of users.
*/
public function getNumberOfUsers() : int {
// Calls the gateway method to get the number of users and returns the count.
// ===================== Get FUNCTION =====================
public function getNumberOfUsers() : int
{
return $this->gateway->getNumberOfUsers()[0]['count'] ?? 0;
}
/**
* Retrieves a user by their username.
*
* @param string $username The username of the user to retrieve.
*
* @return UserEntity|null Returns a UserEntity object if the user is found, or null if not.
*/
public function getUsername(string $username) : ?UserEntity {
// Fetches the user details using the gateway method findUsername.
// public function getFavoriteUser(string $id) : array{
// $res[0] = array();
// $data = $this->gateway->getFavorite($id);
// foreach ($data as $favoris) {
// $res[0][] = new Quote();
// }
// }
public function getDataUser(int $id) : ?UserEntity {
$res = $this->gateway->findDataUser($id);
if ($res)
return new UserEntity(
$res[0]['id_user'],
$res[0]['username'],
$res[0]['password'],
$res[0]['email'],
$res[0]['img'],
$res[0]['creation']
);
return null;
}
public function getUsername(string $username) : ?UserEntity
{
$res = $this->gateway->findUsername($username);
// If the user is found, return a UserEntity object with the user's details.
if ($res)
return new UserEntity(
$res[0]['id_user'],
@ -66,22 +62,12 @@
$res[0]['imgpath'],
$res[0]['creation']
);
// Return null if no user is found.
return null;
}
/**
* Retrieves a user by their email.
*
* @param string $email The email of the user to retrieve.
*
* @return UserEntity|null Returns a UserEntity object if the user is found, or null if not.
*/
public function getEmail(string $email) : ?UserEntity {
// Fetches the user details using the gateway method findEmail.
public function getEmail(string $email) : ?UserEntity
{
$res = $this->gateway->findEmail($email);
// If the user is found, return a UserEntity object with the user's details.
if ($res)
return new UserEntity(
$res[0]['id_user'],
@ -91,214 +77,115 @@
$res[0]['img'],
$res[0]['creation']
);
// Return null if no user is found.
return null;
}
/**
* Retrieves the user ID based on the username.
*
* @param string $username The username of the user.
*
* @return int The user ID.
*/
public function getIdByUsername(string $username) {
// Fetches the user ID using the gateway method getIdUser.
public function getIdByUsername(string $username){
$res = $this->gateway->getIdUser($username);
return $res[0]['id_user'];
}
/**
* Checks if a given username already exists.
*
* @param string $username The username to check.
*
* @return bool Returns true if the username exists, false otherwise.
*/
public function IsExisteUsername(string $username) : bool {
// Checks if the username exists using the gateway method.
public function getEmailWithUser(string $user){
$res = $this->gateway->emailWithUser($user);
return $res[0]['email'];
}
// ===================== Bool FUNCTION =====================
public function IsExisteUsername(string $username):bool{
return $this->gateway->IsExisteUsername($username);
}
/**
* Checks if a given email already exists.
*
* @param string $email The email to check.
*
* @return bool Returns true if the email exists, false otherwise.
*/
public function IsExisteEmail(string $email) : bool {
// Checks if the email exists using the gateway method.
public function IsExisteEmail(string $email):bool{
return $this->gateway->IsExisteEmail($email);
}
/**
* Verifies if the provided password matches the stored password hash for the given username.
*
* @param string $username The username for the user.
* @param string $passWd The password to verify.
*
* @return bool Returns true if the password is correct, false otherwise.
*/
public function isPassWd(string $username, string $passWd) : bool {
// Fetches the stored password hash for the username.
public function isPassWd(string $username, string $passWd): bool {
$hash = $this->gateway->getPasswordHash($username);
// Verifies the password using password_verify.
return $hash !== null && password_verify($passWd, $hash);
}
/**
* Checks if a quote is marked as a favorite by the current user.
*
* @param string|null $username The username of the user (can be null).
* @param int $idq The ID of the quote to check.
*
* @return bool Returns true if the quote is a favorite, false otherwise.
*/
public function isFavorite(?string $username, int $idq) : bool {
// If the user is not logged in (session is null), return false.
if ($_SESSION["user"] == NULL) {
public function isFavorite(?string $username, int $idq): bool {
if($_SESSION["user"] == NULL){
return false;
} else {
// Checks if the quote is in the user's favorites.
$res = $this->gateway->inFavorite($_SESSION["user"], $idq);
}
else{
$res = $this->gateway->inFavorite($_SESSION["user"],$idq);
return $res;
}
}
/**
* Updates the username for a user.
*
* @param string $username The current username.
* @param string $newUsername The new username to set.
*
* @return string Returns the new username if it was successfully updated, or the current username if the new one already exists.
*/
public function setUsername(string $username, string $newUsername) : string {
// If the new username already exists, return the current username.
if ($this->IsExisteUsername($newUsername)) {
return $username;
}
// Updates the username using the gateway method.
$res = $this->gateway->updateUsername($username, $newUsername);
// ===================== Set FUNCTION =====================
// If the update was successful, return the new username.
public function setUsername(string $username, string $newUsername): string {
if ($this->IsExisteUsername($newUsername)) {// Vérifier si le nouveau nom d'utilisateur existe déjà
return $username;// Retourne l'ancien nom d'utilisateur sans modification
}
$res = $this->gateway->updateUsername($username, $newUsername);// Sinon, mettre à jour le nom d'utilisateur
// Retourner le nouveau nom d'utilisateur après modification
if (!empty($res) && isset($res[0]['username'])) {
return $res[0]['username'];
}
// Return the original username if the update was unsuccessful.
return $username;
return $username; // En cas d'échec, retourne l'ancien nom d'utilisateur
}
/**
* Updates the email for a user.
*
* @param string $username The current username.
* @param string $newEmail The new email to set.
*
* @return string Returns the new email if it was successfully updated, or the current username if the new email already exists.
*/
public function setEmail(string $username, string $newEmail) {
// If the new email already exists, return the current username.
public function setEmail(string $username, string $newEmail){
if ($this->IsExisteEmail($newEmail)) {
return $username;
}
// Updates the email using the gateway method.
$res = $this->gateway->updateEmail($username, $newEmail);
$res = $this->gateway->updateEmail($username,$newEmail);
// If the update was successful, return the new email.
if (!empty($res) && isset($res[0]['email'])) {
return $res[0]['email'];
}
// Return the original username if the update was unsuccessful.
return $username;
return $username;// En cas d'échec, retourne l'ancien email
}
/**
* Updates the profile image for a user.
*
* @param string $username The username of the user.
* @param string $newImage The new image path to set.
*
* @return array Returns an array with the new image path.
*/
public function setImage(string $username, string $newImage) {
// Updates the image path using the gateway method.
$res = $this->gateway->updateImg($username, $newImage);
// Returns the updated image path.
public function setImage(string $username,string $newImage){
$res = $this->gateway->updateImg($username,$newImage);
$src[] = $res[0]['img'];
return $src;
}
/**
* Updates the password for a user.
*
* @param string $username The username of the user.
* @param string $newPassWd The new password to set.
*/
public function setPassWd(string $username, string $newPassWd) : void {
// Updates the password using the gateway method.
$res = $this->gateway->updatePasswd($username, $newPassWd);
public function setPassWd(string $username, string $newPassWd):void{
$res = $this->gateway->updatePasswd($username,$newPassWd);
}
/**
* Adds a quote to the user's favorites.
*
* @param string $username The username of the user.
* @param int $id The ID of the quote to add.
*/
public function addFavorite(string $username, int $id) {
// Adds the quote to the user's favorites.
$this->gateway->addFavorite($username, $id);
public function addFavorite(string $username, int $id){
$this->gateway->addFavorite($username,$id);
}
/**
* Removes a quote from the user's favorites.
*
* @param string $username The username of the user.
* @param int $id The ID of the quote to remove.
*/
public function supFavorite(string $username, int $id) {
// Removes the quote from the user's favorites.
$this->gateway->supFavorite($username, $id);
public function supFavorite(string $username, int $id){
$this->gateway->supFavorite($username,$id);
}
/**
* Deletes all comments made by the specified user.
*
* @param string $username The username of the user.
*/
public function deleteAllCommentary(string $username) {
// Deletes all comments made by the user.
// ===================== DELETE FUNCTION =====================
public function deleteAllCommentary(string $username){
$this->gateway->deleteAllCommentaryUser($username);
}
/**
* Deletes all favorite quotes of the specified user.
*
* @param string $username The username of the user.
*/
public function deleteAllFavorite(string $username) {
// Deletes all favorite quotes of the user.
public function deleteAllFavorite(string $username){
$this->gateway->deleteAllFavoriteUser($username);
}
/**
* Deletes the user's account.
*
* @param string $username The username of the user to delete.
*/
public function deleteAccount(string $username) {
// Deletes the user's account.
public function deleteAccount(string $username){
$this->gateway->deleteUser($username);
}
}
?>

@ -7,8 +7,8 @@ namespace Verification;
if($text==NULL){
return NULL;
}
$charInterdi=['|','/','\\','%','$','=','<','>','(',')'];
$chaineInterdi=["AND","OR","WHERE","FROM","SELECT"];
$charInterdi=['|','/','\\','%','$','=','<','>','(',')',';'];
$chaineInterdi=["AND","OR","WHERE","FROM","SELECT","DROP","DELETE","TABLE","Users"];
$textVerif="";
foreach( str_split($text,1) as $char){

@ -0,0 +1,16 @@
<?php
global $twig;
echo $twig->render('head.html.twig', [
'title' => "Quiz",
'style' => "public/styles/styleAccueilQuiz.css",
'scripts' => array("public/script/theme-toggle.js")
]);
echo $twig->render('bandeau.html.twig');
echo $twig->render('accueilQuiz.html.twig', [
'quizs' => $quizs
]);
?>

@ -14,6 +14,9 @@ echo $twig->render('bandeau.html.twig');
echo $twig->render('create.html.twig', [
'src' => $src,
'char' => $char
'char' => $char,
'content' => $_POST['content'],
'charId' => $charId,
'srcId' => $srcId
]);
?>

@ -8,11 +8,13 @@ echo $twig->render('head.html.twig', [
'scripts' => array("../public/script/theme-toggle-double-param.js")
]);
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo $twig->render('endQuiz.html.twig', ['score' => $score, 'nextquiz' => $id_quiz + 1])
echo $twig->render('endQuiz.html.twig',
['score' => $score,
'isNextQuiz' => $next,
'nb' => $nbQuestion]);
?>

@ -0,0 +1,17 @@
<?php
global $twig;
echo $twig->render('head.html.twig', [
'title' => "Quiz",
'style' => "public/styles/styleEndQuiz.css",
'scripts' => array("public/script/theme-toggle.js")
]);
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo $twig->render('endQuizRandom.html.twig',
['score' => $score
]);
?>

@ -1,5 +1,25 @@
<h1>
<?php
echo "ERREUR";
?>
</h1>
global $twig;
if(!isset($erreur[2])){
echo $twig->render('head.html.twig', [
'title' => "Accueil",
'style' => "public/styles/style.css",
'scripts' => array("public/script/theme-toggle.js")
]);
}
else{
echo $twig->render('head.html.twig', array(
'title' => "Quote",
'style' => "../public/styles/styleQuote.css",
'scripts' => array("../public/script/theme-toggle-double-param.js", "../public/script/copy.js")
));
}
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo $twig->render('erreur.html.twig',[
'numero' => $erreur[0],
'context' => $erreur[1],
]);

@ -1,16 +1,64 @@
<?php
global $twig;
// Paramètres de la pagination
$perPage = 30;
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($currentPage < 1) {
$currentPage = 1;
}
$totalItems = count($favorites);
$totalPages = ceil($totalItems / $perPage);
$offset = ($currentPage - 1) * $perPage;
$favoritesPaginated = array_slice($favorites, $offset, $perPage);
echo $twig->render('head.html.twig', [
'title' => "Favoris",
'style' => "public/styles/styleAccueil.css",
'title' => "Favoris",
'style' => "public/styles/styleAccueil.css",
'scripts' => array("public/script/theme-toggle.js")
]);
echo $twig->render('bandeau.html.twig');
echo $twig->render('quoteLittle.html.twig', [
'quotes' => $favorites,
'titre' => "Favoris"
]);
'quotes' => $favoritesPaginated,
'titre' => "Favoris"
]);
?>
<div class="pagination-container">
<button id="prev-page" <?php if($currentPage <= 1) echo "disabled"; ?>>Page précédente</button>
<select id="page-selector">
<?php for($page = 1; $page <= $totalPages; $page++): ?>
<option value="<?php echo $page; ?>" <?php if($page == $currentPage) echo "selected"; ?>>Page <?php echo $page; ?></option>
<?php endfor; ?>
</select>
<button id="next-page" <?php if($currentPage >= $totalPages) echo "disabled"; ?>>Page suivante</button>
<div class="spinner" id="spinner"></div>
</div>
<script>
document.getElementById('page-selector').addEventListener('change', function() {
document.getElementById('spinner').style.display = 'inline-block';
window.location.href = "?page=" + this.value;
});
document.getElementById('prev-page').addEventListener('click', function() {
var selector = document.getElementById('page-selector');
var newPage = parseInt(selector.value) - 1;
if(newPage >= 1) {
document.getElementById('spinner').style.display = 'inline-block';
window.location.href = "?page=" + newPage;
}
});
document.getElementById('next-page').addEventListener('click', function() {
var selector = document.getElementById('page-selector');
var newPage = parseInt(selector.value) + 1;
if(newPage <= <?php echo $totalPages; ?>) {
document.getElementById('spinner').style.display = 'inline-block';
window.location.href = "?page=" + newPage;
}
});
</script>

@ -1,17 +1,18 @@
<?php
global $twig;
echo $twig->render('head.html.twig', [
'title' => "Quiz",
'style' => "../public/styles/styleQuiz.css",
'scripts' => array("../public/script/theme-toggle-double-param.js")
]);
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo $twig->render('quiz.html.twig', ['idQuiz'=>$id , 'question' => $question,'id'=>$idquestion]);
?>
echo $twig->render('quiz.html.twig', [
'question' => $question,
'id'=>$idquestion,
'nb' => $num + 1,
'nbFinal' => $nbQuestion
]);

@ -0,0 +1,20 @@
<?php
global $twig;
echo $twig->render('head.html.twig', [
'title' => "Random Quiz",
'style' => "public/styles/styleQuiz.css",
'scripts' => array("public/script/theme-toggle.js")
]);
// Rendu du bandeau
echo $twig->render('bandeau.html.twig');
echo $twig->render('quizRandom.html.twig', [
'vie' => $vie,
'question' => $question,
'nb' => $no_question + 1
]);

@ -1,4 +1,5 @@
<?php
use Enum\TypeSourceEnum;
global $twig;
@ -17,5 +18,6 @@
'nbLike' => $q->getLike(),
'idQuote' => $q->getId(),
'com' => $c,
'type' => $q->getType()->name,
'fav' => $f));
?>

@ -0,0 +1,16 @@
<?php
global $twig;
echo $twig->render('head.html.twig', array(
'title' => "Recap Quote",
'style' => "public/styles/styleSubmitQuote.css",
'scripts' => array("public/script/theme-toggle.js")
));
echo $twig->render('bandeau.html.twig');
echo $twig -> render("recapSubmitQuote.html.twig", [
'content' => $recap["content"],
'character' => $recap["character"],
'source' => $recap["src"]
]);
?>

@ -2,25 +2,76 @@
global $twig;
// Paramètres de la pagination
$perPage = 30;
$currentPage = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($currentPage < 1) {
$currentPage = 1;
}
// Calcul du nombre total d'éléments et de pages
$totalItems = count($tq);
$totalPages = ceil($totalItems / $perPage);
// Découpage du tableau pour ne garder que les éléments de la page courante
$offset = ($currentPage - 1) * $perPage;
$quotesPaginated = array_slice($tq, $offset, $perPage);
echo $twig->render('head.html.twig', array(
'title' => "Quote",
'style' => "public/styles/styleSearch.css",
'title' => "Search",
'style' => "public/styles/styleSearch.css",
'scripts' => array("public/script/theme-toggle.js")
));
echo $twig->render('bandeau.html.twig');
echo $twig->render('filtre.html.twig',array(
'search'=>$search,
'type'=>$type,
echo $twig->render('filtre.html.twig', array(
'search' => $search,
'type' => $type,
));
echo $twig->render('quoteLittle.html.twig', [
'quotes' => $tq,
'titre' => "Résultats"
'quotes' => $quotesPaginated,
'titre' => "Résultats"
]);
?>
<div class="pagination-container">
<button id="prev-page" <?php if($currentPage <= 1) echo "disabled"; ?>>Page précédente</button>
<select id="page-selector">
<?php for($page = 1; $page <= $totalPages; $page++): ?>
<option value="<?php echo $page; ?>" <?php if($page == $currentPage) echo "selected"; ?>>Page <?php echo $page; ?></option>
<?php endfor; ?>
</select>
<button id="next-page" <?php if($currentPage >= $totalPages) echo "disabled"; ?>>Page suivante</button>
<div class="spinner" id="spinner"></div>
</div>
<script>
document.getElementById('page-selector').addEventListener('change', function() {
document.getElementById('spinner').style.display = 'inline-block';
window.location.href = "?page=" + this.value;
});
document.getElementById('prev-page').addEventListener('click', function() {
var selector = document.getElementById('page-selector');
var newPage = parseInt(selector.value) - 1;
if(newPage >= 1) {
document.getElementById('spinner').style.display = 'inline-block';
window.location.href = "?page=" + newPage;
}
});
document.getElementById('next-page').addEventListener('click', function() {
var selector = document.getElementById('page-selector');
var newPage = parseInt(selector.value) + 1;
if(newPage <= <?php echo $totalPages; ?>) {
document.getElementById('spinner').style.display = 'inline-block';
window.location.href = "?page=" + newPage;
}
});
</script>
<?php
echo "</div>";
//echo $twig->render('resultat.html.twig');
?>
?>

@ -0,0 +1,26 @@
<h2>Liste des Quiz</h2>
<div class="quiz-container">
<div class="quizCard">
<a href="{{ racine }}/randomQuiz" class="linkQuiz">
<img src="{{ racine }}/images/quizz.svg" alt="Image du quiz random">
<h3>Quiz random </h3>
</a>
</div>
{% for quiz in quizs %}
<div class="quizCard">
<a href="{{ racine }}/quiz/{{ quiz.id_quiz }}" class="linkQuiz">
<img src="{{ quiz.imgPath }}" alt="Image du quiz {{ quiz.title }}">
<h3>{{ quiz.title }} ({{ quiz.nb_quest }} questions)</h3>
</a>
</div>
{% else %}
<h3>Aucun quiz disponible pour le moment.</h3>
{% endfor %}
</div>
</body>
</html>

@ -1,8 +1,9 @@
<div class="header">
<div class="nav">
<a href="{{ racine }}/favorite"><img src="{{ racine }}/images/coeur.svg" alt="coeur" onmousedown="return false"></a>
<img class='theme-icon' id="theme-icon" src="{{ racine }}/images/dark.svg" alt="toggle theme" onmousedown="return false" onclick="toggleTheme()">
<a href="{{ racine }}/quiz/1"><img src="{{ racine }}/images/quizz.svg" alt="quizz" onmousedown="return false"></a>
<a href="{{ racine }}/accueilQuiz"><img src="{{ racine }}/images/quizz.svg" alt="quizz" onmousedown="return false"></a>
<a href="{{racine}}/submit" class="createQuote"><img src="{{ racine }}/images/Vector.svg" onmousedown="return false"></img></a>
</div>
<div class="logo">
@ -10,6 +11,7 @@
</div>
<div class="user">
<img class='theme-icon' id="theme-icon" src="{{ racine }}/images/dark.svg" alt="toggle theme" onmousedown="return false" onclick="toggleTheme()">
<a href="{{ racine }}/search"><img src="{{ racine }}/images/loupe.svg" alt="search" onmousedown="return false"></a>
<a class="iconUser" href="{{ racine }}/profil"><img src="{{ racine }}/images/user_dark.png" alt="user" onmousedown="return false"></a>
</div>

@ -1,11 +1,22 @@
<div class="creation">
<form class="add" method="post" action="{{racine}}/add">
<form class="add" method="post" action="{{racine}}/add" enctype="multipart/form-data">
{% if src == true and char == true %}
<input type="hidden" id="req" name="req" value="both"/>
<input type="hidden" id="content" name="content" value="{{ content }}"/>
{% elseif src == true %}
<input type="hidden" id="req" name="req" value="src"/>
<input type="hidden" id="character" name="character" value="{{ charId }}"/>
<input type="hidden" id="content" name="content" value="{{ content }}"/>
{% elseif char == true %}
<input type="hidden" id="req" name="req" value="src"/>
<input type="hidden" id="req" name="req" value="char"/>
<input type="hidden" id="src" name="src" value="{{ srcId }}"/>
<input type="hidden" id="content" name="content" value="{{ content }}"/>
{% endif %}
{% if src == true %}
<h1>Source</h1>
@ -15,16 +26,16 @@
<input type="number" id="date" name="date" min="1850" max="{{ "now"|date("Y") }}" required>
<label for="type">Type de source *</label>
<input type="radio" id="movie" name="type" value="Movie" checked>
<input type="radio" id="movie" name="type" value="movie" checked>
<label for="movie">Film</label><br>
<input type="radio" id="serie" name="type" value="Serie">
<input type="radio" id="serie" name="type" value="serie">
<label for="serie">Serie</label>
<input type="radio" id="vg" name="type" value="VideoGame">
<input type="radio" id="vg" name="type" value="video-game">
<label for="vg">Jeu Vidéo</label><br>
<input type="radio" id="anime" name="type" value="Anime">
<input type="radio" id="anime" name="type" value="anime">
<label for="anime">Anime</label>
{% endif %}
@ -34,7 +45,7 @@
<input type="text" class="champ" id="name" name="name" placeholder="Nom du personnage" required/>
<label for="name">Image du personnage *</label>
<input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg" required/>
<input type="file" id="avatar" name="avatar" accept="image/png, image/jpeg, imag/jpg" required/>
{% endif %}
<input type="submit" class="btn" value="Soumettre"/>

@ -1,10 +1,13 @@
<h1>Résultat</h1>
<div class="resultat">
<p> nombre de réponse juste : {{ score }}</p>
<p> nombre de réponse fausse : {{ 10 - score }}</p>
<a class="suiv" href="{{racine}}/quiz/{{ nextquiz }}" alt="quiz suivant">
<p> nombre de réponse fausse : {{ nb - score }}</p>
<p> pourcentage de réusite : {{ (100 * score) / nb }}%<p>
<a class="suiv" href="{{racine}}/accueilQuiz" alt="Retour selection quiz">
<img src="../images/suivant.png" />
</a>
</div>
</body>
</html>

@ -0,0 +1,12 @@
<h1>Résultat</h1>
<div class="resultat">
<p> nombre de réponse juste : {{ score }}</p>
<a class="suiv" href="{{racine}}/accueilQuiz" alt="Retour selection quiz">
<img src="images/suivant.png" />
</a>
</div>
</body>
</html>

@ -0,0 +1,4 @@
<h1 class='error'>Erreur</h1>
<p class="explanation">Erreur {{numero}} : {{context}}</p>
<body>
<html>

@ -1,9 +0,0 @@
<div class="citation-container suggestion">
<img src="{{ imagePath }}" alt="{{ movie }}" class="citation-image">
<div class="text-content">
<p class="quote">"{{ quote }}"</p>
<p class="movie">- {{ movie }}</p>
<p class="character">Personnage : {{ character }}</p>
<p class="year">Année : {{ year }}</p>
</div>
</div>

@ -1,3 +1,4 @@
<div class="content">
<form action="{{racine}}/search" method="post">
<div class="search-container">
<input type="search" placeholder="Recherche" id="filtre" name="search" value="{{ search }}"/>
@ -43,4 +44,5 @@
</div>
-->
</form>
</form>
</div>

@ -44,10 +44,6 @@
<img class="languageImage" src="{{ racine }}/images/drapeauFrance.png" onmousedown="return false"/>
</form>
<div class="createQuote">
<a {#href="{{racine}}/submit"#} class="createQuote">Ajouter une citation</a>
</div>
<div class="buttonSudmiteDiv">

@ -1,25 +1,25 @@
<h1>Quiz</h1>
<div class="quiz">
<h2> {{ question.question }} </h2>
{#<a id="timer"> 10 seconds left .. </a>#}
<form id="quizForm" method="POST" >
<div class="answers">
<button class="answer" name="answera" value="A-{{ id }}">
<button class="answer" name="answera" value="{{ question.answera }}-{{ id }}">
{{ question.answera }}
</button>
<button class="answer" name="answerb" value="B-{{ id }}">
<button class="answer" name="answerb" value="{{ question.answerb }}-{{ id }}">
{{ question.answerb }}
</button>
<button class="answer" name="answerc" value="C-{{ id }}">
<button class="answer" name="answerc" value="{{ question.answerc }}-{{ id }}">
{{ question.answerc }}
</button>
<button class="answer" name="answerd" value="D-{{ id }}">
<button class="answer" name="answerd" value="{{ question.answerd }}-{{ id }}">
{{ question.answerd }}
</button>
</div>
<input type="hidden" name="action" value="canswer">
</form>
<a id="timer">{{ nb }}/{{ nbFinal }}</a>
</div>
</body>
</html>

@ -0,0 +1,27 @@
<h1>Quiz Random</h1>
<div class="quiz">
<h2> {{ question.question }} </h2>
<h3>Vie restante : {{ vie }}</h3>
<form id="quizForm" method="POST" >
<div class="answers">
<button class="answer" name="answera" value="{{ question.answera }}">
{{ question.answera }}
</button>
<button class="answer" name="answerb" value="{{ question.answerb }}">
{{ question.answerb }}
</button>
<button class="answer" name="answerc" value="{{ question.answerc }}">
{{ question.answerc }}
</button>
<button class="answer" name="answerd" value="{{ question.answerd }}">
{{ question.answerd }}
</button>
</div>
<input type="hidden" name="canswer" value="{{ question.canswer }}">
</form>
<a id="timer">{{ nb }}/∞</a>
</div>
</body>
</html>

@ -19,7 +19,7 @@
<div class="part2">
<div class="info">
<ul class="infoQuote">
<li>- {{sourceName}}</li>
<li>- {{sourceName}} ({{type}})</li>
<li>- {{nameCarac}}</li>
<li>- {{dateSortie}}</li>
</ul>

@ -1,19 +1,4 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Wiki Fantasy : Submit Quote</title>
<link id="favicon" rel="icon" href="../../images/iconeSombre.ico"> <!-- Par défaut sombre -->
<link rel="stylesheet" href="../../public/styles/styleSubmitQuote.css">
<script defer src="../../public/script/theme-toggle.js"></script>
</head>
<body>
{% include "bandeau.html.twig" %}
<h1>▶ Your quote has been submitted successfully ◀</h1>
<h1>Votre citation a corectement été envoyé</h1>
<div>
@ -41,7 +26,7 @@
</div>
<div>
<button onclick="window.location.href='/';"> Revenir à l'acceuil</button>
<button onclick="window.location.href='{{racine}}/';"> Revenir à l'acceuil</button>
</div>
</div>

@ -43,8 +43,7 @@
<div id="contentField">
<p>Contenu *</p>
<textarea id="content" name="content" rows="5" cols="50" required>Ecrire une citation ...
</textarea>
<textarea id="content" name="content" rows="5" cols="50" required placeholder="écrire la citation..."></textarea>
</div>
</div>

Loading…
Cancel
Save