modifCitation #25

Merged
kevin.mondejar merged 16 commits from modifCitation into master 3 months ago

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

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

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

Binary file not shown.

@ -1,25 +1,31 @@
/* @import url('https://fonts.googleapis.com/css2?family=Lemon&display=swap'); */ /* @import url('https://fonts.googleapis.com/css2?family=Lemon&display=swap'); */
@import url(./styleScroll.css); @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 { :root {
--main-dark-background-color: #120B1D; --main-dark-background-color: #120B1D;
--main-dark-text-color : #ffffff; --main-dark-text-color : #ffffff;
--main-dark-gradient : linear-gradient(45deg, #4a148c, #7b1fa2); --main-dark-gradient : linear-gradient(45deg, #4a148c, #7b1fa2);
--main-dark-other-color : #000000; --main-dark-other-color : #000000;
--main-light-background-color: #cccccc; --main-light-background-color: #ffffff;
/*--main-light-background-color: #ffffff;*/ --main-light-text-color : #000000;
--main-light-text-color : #000; /*--main-light-gradient : linear-gradient(90deg, #46BE73, #BAEBF6);*/
--main-light-gradient : linear-gradient(90deg, #46BE73, #BAEBF6); /*--main-light-gradient : linear-gradient(90deg, #AAB9CF, #BDD4E7);*/
/*--main-light-gradient : linear-gradient(-90deg, #f3e0f7, #dd9aff);*/ --main-light-gradient : #84e4a9;
/*--main-light-gradient : linear-gradient(45deg, #73CFF6, #DE95CA);*/
--main-light-other-color : #46BE73; --main-light-other-color : #46BE73;
/*--main-light-other-color : #f8eaff;*/ /* --main-light-gradient : #94d3ac;
/*--main-light-other-color : #d2d2d8;*/ --main-light-other-color : #75b48d; */
}
*{
font-family: "roboto condensed", sans-serif;
font-weight: 600;
} }
/* Général */ /* Général */
body{ body{
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
margin : 0%; margin : 0%;
} }
@ -62,7 +68,7 @@ body.dark-mode .header{
/* Light mode */ /* Light mode */
body.light-mode{ body.light-mode{
background-color: var(--main-light-background-color); background-image: url("../../images/chaos.png");
color: var(--main-light-text-color); 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 { .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 */ /* écran par défaut */
@ -171,6 +177,18 @@ body{
height : 7vh; height : 7vh;
} }
.error{
display:block;
margin-top: 30vh;
text-align: center;
font-size: 5em;
}
.explanation{
text-align: center;
font-size: 3em;
}
/* écran tablette*/ /* écran tablette*/
@media (max-width: 834px) or (max-aspect-ratio : 1/1){ @media (max-width: 834px) or (max-aspect-ratio : 1/1){

@ -0,0 +1,42 @@
@import url(./style.css); /* Import de style.css */
h2{
text-align: center;
font-size: 2em;
margin-top: 2em;
margin-bottom: 2em;
}
.quizCard {
background: var(--main-dark-gradient);
border-radius: 15px;
padding: 1em;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.quizCard img {
border-radius: 15px 15px 0 0;
width: 100%;
height: auto;
}
.quizCard h3 {
margin: 1em 0 0;
font-size: 1.5em;
text-align: center;
}
.quizCard ul {
display: flex;
justify-content: center;
list-style: none;
padding: 0;
margin: 1em 0 0;
}
.quizCard ul li {
margin: 0 0.5em;
}

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

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

@ -34,7 +34,7 @@ body.dark-mode .imgModify{
body.light-mode .inputPasswd{ body.light-mode .inputPasswd{
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
margin-top: 2%; margin-top: 2%;
color: black; color: black;
} }
@ -77,7 +77,7 @@ body.light-mode .login{
body.light-mode .inputPasswd{ body.light-mode .inputPasswd{
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
margin-top: 2%; margin-top: 2%;
color: black; color: black;
} }
@ -90,7 +90,7 @@ body.light-mode .saveButtonPasswd {
/* ====== ECRAN DEFAUT ====== */ /* ====== ECRAN DEFAUT ====== */
h1{ h1{
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
text-align: center; text-align: center;
font-size: 35px; font-size: 35px;
} }
@ -99,7 +99,7 @@ p{
margin-top: 4%; margin-top: 4%;
margin-bottom: 2%; margin-bottom: 2%;
font-size: 20px; font-size: 20px;
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
} }
::backdrop { ::backdrop {
@ -110,10 +110,9 @@ p{
height: 60%; height: 60%;
font-size: 15px; font-size: 15px;
text-align: center; text-align: center;
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
border: 15px solid; border: 15px solid;
border-radius: 20px; border-radius: 20px;
} }
@ -132,7 +131,7 @@ p{
} }
.buttonSudmite{ .buttonSudmite{
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
border: none; border: none;
padding: 2%; padding: 2%;
border-radius: 25px; border-radius: 25px;
@ -146,7 +145,7 @@ p{
font-size: 15px; font-size: 15px;
text-align: center; text-align: center;
padding-top: 1%; padding-top: 1%;
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
} }
.login{ .login{
@ -172,7 +171,7 @@ p{
border-radius: 25px; border-radius: 25px;
border: none; border: none;
font-size: 15px; 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 { body.dark-mode .buttonSudmite {
background: linear-gradient(90deg, #6100ff 0%, #1b0048 100%); background: linear-gradient(90deg, #6100ff 0%, #1b0048 100%);
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
border: none; border: none;
color: white; color: white;
padding: 10px 20px; padding: 10px 20px;
@ -50,7 +50,7 @@ body.light-mode .answer {
/* ====== ECRAN DEFAUT ====== */ /* ====== ECRAN DEFAUT ====== */
h1, h2, p { h1, h2, p {
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
text-align: center; text-align: center;
} }

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

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

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

@ -25,7 +25,7 @@ body.light-mode #box{
/* ====== ECRAN DEFAULT ====== */ /* ====== ECRAN DEFAULT ====== */
h1, h2{ h1, h2{
font-family: "Lemon", serif; font-family: "roboto condensed", sans-serif;
text-align: center; text-align: center;
} }

@ -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,11 @@ Class FrontControler{
global $twig,$racine; global $twig,$racine;
$this->listAction = ['visitor' => array('accueil','search','quote','login','signin','validlogin','validsignin'), $this->listAction = ['visitor' => array('accueil','search','quote','login','signin','validlogin','validsignin'),
<<<<<<< HEAD
'user' => array('quiz','commentary','logout','addComment','favorite','profil','addFav','supFav','changedata', 'submit', 'validsubmit', 'add', 'accueilQuiz'),
=======
'user' => array('quiz','commentary','logout','addComment','favorite','profil','addFav','supFav','changedata', 'submit', 'validsubmit', 'add','deleteAccount'), 'user' => array('quiz','commentary','logout','addComment','favorite','profil','addFav','supFav','changedata', 'submit', 'validsubmit', 'add','deleteAccount'),
>>>>>>> origin/master
'admin' => array('null')]; 'admin' => array('null')];
$dVueEreur = []; $dVueEreur = [];
@ -52,16 +56,19 @@ Class FrontControler{
$router->map('GET|POST', '/supFav/[i:id]', 'UserControler','supFav'); $router->map('GET|POST', '/supFav/[i:id]', 'UserControler','supFav');
$router->map('GET|POST', '/changedata', 'UserControler','changedata'); $router->map('GET|POST', '/changedata', 'UserControler','changedata');
$router->map('GET|POST', '/submit', 'UserControler', 'submit'); $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', '/add', 'UserControler', 'add');
$router->map('GET|POST', '/accueilQuiz', 'UserControler', 'accueilQuiz');
$router->map('GET|POST', '/error', 'VisitorControler','error');
$router->map('GET|POST', '/deleteAccount', 'UserControler', 'deleteAccount'); $router->map('GET|POST', '/deleteAccount', 'UserControler', 'deleteAccount');
$match = $router->match(); $match = $router->match();
$action = NULL; $action = NULL;
if(!$match){ if(!$match){
$dVueEreur[] = "Requête introuvable"; $dVueEreur = [404,"Page inconue"];
$this->vueErreur($dVueEreur); $this->vueErreur($dVueEreur);
} }
else{ else{
@ -71,7 +78,7 @@ Class FrontControler{
//Si existe, on lappelle //Si existe, on lappelle
if(!$this->ifExisteAction($action)){ if(!$this->ifExisteAction($action)){
$dVueEreur[] = "Action introuvable"; $dVueEreur = [404,"Action inconue"];
$this->vueErreur($dVueEreur); $this->vueErreur($dVueEreur);
} }
@ -112,9 +119,8 @@ Class FrontControler{
return false; return false;
} }
private function vueErreur(array $dVueErreur){ private function vueErreur(array $erreur){
global $vues; global $vues;
echo "{$dVueErreur[0]}";
require_once $vues['erreur']; require_once $vues['erreur'];
} }

@ -29,20 +29,29 @@ class UserControler {
private CommentaryModel $cMod; private CommentaryModel $cMod;
private UserModel $uMod; private UserModel $uMod;
private QuoteModel $qMod; private QuoteModel $qMod;
private QuestionModel $mdl;
private CharacterModel $caMod; private CharacterModel $caMod;
private SourceModel $srcMod; private SourceModel $srcMod;
private QuestionModel $questMod;
private ImageModel $iMod; private ImageModel $iMod;
private QuizModel $quizModel;
public function __construct() { public function __construct() {
global $co; global $co;
$this->cMod = new CommentaryModel(new CommentaryGateway($co)); $this->cMod = new CommentaryModel(new CommentaryGateway($co));
$this->uMod = new UserModel(new UserGateway($co)); $this->uMod = new UserModel(new UserGateway($co));
$this->qMod = new QuoteModel(new QuoteGateway($co)); $this->qMod = new QuoteModel(new QuoteGateway($co));
$this -> mdl = new QuestionModel(new QuestionGateway($co)); $this -> questMod = new QuestionModel(new QuestionGateway($co));
$this -> caMod = new CharacterModel(new CharacterGateway($co)); $this -> caMod = new CharacterModel(new CharacterGateway($co));
$this->srcMod = new SourceModel(new SourceGateway($co)); $this->srcMod = new SourceModel(new SourceGateway($co));
$this->iMod = new ImageModel(new ImageGateway($co)); $this->iMod = new ImageModel(new ImageGateway($co));
$this->quizModel = new QuizModel(new QuizGateway($co));
}
public function accueilQuiz() {
global $vues;
$quizs = $this->quizModel->listQuiz();
require_once $vues['accueilQuiz'];
} }
public function profil() { public function profil() {
@ -145,10 +154,12 @@ class UserControler {
$gw = new QuizGateway($co); $gw = new QuizGateway($co);
$mdl = new QuizModel($gw); $mdl = new QuizModel($gw);
$nbQuestion = $this->getNumberOfQuestion($id_quiz);
if ($mdl->getQuiz($id_quiz + 1)){ if ($mdl->getQuiz($id_quiz + 1)){
$next = true;
require_once $vues['endQuiz']; require_once $vues['endQuiz'];
} }
$next = false;
require_once $vues['endQuiz']; require_once $vues['endQuiz'];
} }
@ -174,7 +185,7 @@ class UserControler {
$answer = explode('-', $answerd)[0]; $answer = explode('-', $answerd)[0];
$id = (int) explode('-', $answerd)[1]; $id = (int) explode('-', $answerd)[1];
} }
$res = $this->mdl->getQuestion($id); $res = $this->questMod->getQuestion($id);
return $answer == $res->getCanswer(); return $answer == $res->getCanswer();
} }
@ -195,11 +206,20 @@ class UserControler {
$q = $this->GetQuestion($id); $q = $this->GetQuestion($id);
$question = $q[$num] ?? $q[0]; $question = $q[$num] ?? $q[0];
$idquestion = $question->getIdQuestion(); $idquestion = $question->getIdQuestion();
$nbQuestion = $this->getNumberOfQuestion($id);
require_once $vues['quiz']; require_once $vues['quiz'];
//echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]); //echo $twig->render('quiz.html.twig', ['question' => $question,'id'=>$idquestion]);
} }
public function getQuiz(int $id) : QuizModel
{
global $co;
$gw = new QuizGateway($co);
$mdl = new QuizModel($gw);
return $mdl->getQuiz($id);
}
public function getNumberOfQuestion(int $id) : int{ public function getNumberOfQuestion(int $id) : int{
global $co; global $co;
@ -333,46 +353,24 @@ class UserControler {
* @throws RuntimeError * @throws RuntimeError
* @throws LoaderError * @throws LoaderError
*/ */
public function toSubmit() : ?array{
public function toSubmit(string $content,string $character, string $source)
{
global $co; global $co;
if ($_POST) if ($_POST)
{ {
$content = $_POST['content'] ?? null;
$character = $_POST['character'] ?? null;
$source = $_POST['src'] ?? null;
//$img = $_POST['img'] ?? null;
$errors = [null, null]; $errors = [null, null];
$gw = new CharacterGateway($co); $nameSrc = $this->srcMod->getSourceById($source)->getTitle();
$mdl = new CharacterModel($gw); $nameChar = $this->caMod->getCharacterById($character)->getName();
$character = $mdl -> getCharacterById($character);
$gw = new SourceGateway($co);
$mdl = new SourceModel($gw);
$source = $mdl -> getSourceById($source);
if (!$character) if (!$character)
$errors[0] = "Personnage inexistant"; $errors[0] = "Personnage inexistant";
if (!$source) if (!$source)
$errors[1] = "Source inexistante"; $errors[1] = "Source inexistante";
if ($errors[0] || $errors[1]) $this -> qMod -> addQuote($content,'fr',$character,$source,$this->uMod->getIdByUsername(Verification::VerifChar($_SESSION['user'])));
{ $this -> recapSubmitQuote(array('content' => $content, 'src' => $nameSrc, 'character' => $nameChar));
global $twig;
$this->submit();
exit();
}
$gw = new QuoteGateway($co);
$mdl = new QuoteModel($gw);
//$mdl -> insert4User($content, '/imgPath', 'fr', $this -> getIdOfUser(), $source->getIdSource(), $character->getIdCharacter());
return [$content, $_POST['character'], $_POST['src']];
} }
return null;
} }
/** /**
@ -386,6 +384,8 @@ class UserControler {
global $vues; global $vues;
$src = true; $src = true;
$char = true; $char = true;
$srcId = null;
$charId = null;
require_once $vues['create']; require_once $vues['create'];
exit(); exit();
} }
@ -393,6 +393,8 @@ class UserControler {
global $vues; global $vues;
$src = true; $src = true;
$char = false; $char = false;
$srcId = null;
$charId = $_POST['character'];
require_once $vues['create']; require_once $vues['create'];
exit(); exit();
} }
@ -400,32 +402,25 @@ class UserControler {
global $vues; global $vues;
$src = false; $src = false;
$char = true; $char = true;
$srcId = $_POST['src'];
$charId = null;
require_once $vues['create']; require_once $vues['create'];
exit(); exit();
} }
if($_POST) $recap = $this -> toSubmit($_POST['content'],$_POST['character'],$_POST['src']);
$recap = $this -> toSubmit();
if ($recap)
{
$this -> recapSubmitQuote($recap);
}
} }
public function recapSubmitQuote(array $recap){
global $vues;
require_once($vues["recap"]);
}
// ===================== SUBMIT QUOTE FUNCTION =====================
/** // ===================== SUBMIT QUOTE FUNCTION =====================
* @throws RuntimeError
* @throws SyntaxError
* @throws LoaderError
*/
public function recapSubmitQuote(?array $recap) : void{
global $twig;
echo $twig -> render("recapSubmitQuote.html.twig", ['content' => $recap[0], 'character' => $recap[1], 'source' => $recap[2]]);
}
public function getIdOfUser() : ?int{ public function getIdOfUser() : ?int
{
if (isset($_SESSION['user'])) if (isset($_SESSION['user']))
{ {
global $co; global $co;
@ -439,17 +434,18 @@ class UserControler {
public function add(){ public function add(){
global $vues; global $vues, $repImg;
var_dump($_POST);
$error = []; $error = [];
$src = false;
$char = false;
var_dump($_FILES);
if($_POST['req'] == "both"){ if($_POST['req'] == "both"){
$src = true; $src = true;
$char = true; $char = true;
} }
elseif($_POST['req'] == "src"){
$src = true; if($_POST['req'] == "src" or $src == true){
$char = false; $type = array("movie","serie","video-game","anime");
$type = array("Movie","Serie","VideoGame","Anime");
if(Verification::verifNotNull($_POST["titre"])){ if(Verification::verifNotNull($_POST["titre"])){
$_POST["titre"] = Verification::verifChar($_POST["titre"]); $_POST["titre"] = Verification::verifChar($_POST["titre"]);
if($this->srcMod->existSource($_POST["titre"],$_POST["type"])){ if($this->srcMod->existSource($_POST["titre"],$_POST["type"])){
@ -460,8 +456,6 @@ class UserControler {
$error[] = "Le titre doit être définit"; $error[] = "Le titre doit être définit";
} }
if(Verification::verifNotNull($_POST["date"])){ if(Verification::verifNotNull($_POST["date"])){
$src = true;
$char = false;
$_POST["date"] = Verification::verifChar($_POST["date"]); $_POST["date"] = Verification::verifChar($_POST["date"]);
if(intval($_POST["date"],10) < 1850 or intval($_POST["date"],10) > date( "Y", time() )){ if(intval($_POST["date"],10) < 1850 or intval($_POST["date"],10) > date( "Y", time() )){
$error[] = "La date est invalide"; $error[] = "La date est invalide";
@ -480,30 +474,85 @@ class UserControler {
$error[] = "Le type doit être définit"; $error[] = "Le type doit être définit";
} }
} }
elseif($_POST['req'] == "char"){
$src = false;
$char = true;
if(Verification::verifNotNull($_POST[""])){
if($_POST['req'] == "char" or $char == true){
if(Verification::verifNotNull($_POST["name"])){
$_POST["name"] = Verification::verifChar($_POST["name"]);
}
else{
$error[] = "Le nom doit être définit";
}
// upload de la photo
if (isset($_FILES['avatar'])) {
$tabExtension = explode('.', $_FILES['avatar']['name']);
$extension = strtolower(end($tabExtension));
$extensions = ['jpg', 'png', 'jpeg'];
if(in_array($extension, $extensions)){
move_uploaded_file($_FILES['avatar']['tmp_name'], $repImg.$_FILES['avatar']['name']);
$filePath = $repImg.$_FILES['avatar']['name'];
}
else{
$error[] = "Mauvaise extension";
exit();
}
} }
else{
$error[] = "Aucune photo";
}
} }
if($error == []){ if($error == []){
$recap['content'] = $_POST['content'];
if($_POST['req'] == "both"){ if($_POST['req'] == "both"){
$this->srcMod->createSource($_POST["titre"], $_POST["date"], TypeSourceEnum::from($_POST["type"]));
$idImg = $this->iMod->createImgModelWithoutId($filePath);
$this->caMod->createCharacterWithoutId($_POST["name"], $idImg);
$idC = $this-> caMod -> getCharacterByName($_POST["name"])->getIdCharacter();
$idS = $this -> srcMod -> getSourceByTitle($_POST["titre"])->getIdSource();
} }
elseif($_POST['req'] == "src"){ elseif($_POST['req'] == "src"){
$this->srcMod->createSource($_POST["titre"], $_POST["date"], $_POST["type"]); $this->srcMod->createSource($_POST["titre"], $_POST["date"], TypeSourceEnum::from($_POST["type"]));
$idC = Verification::VerifChar($_POST["character"]);
$idS = $this -> srcMod -> getSourceByTitle($_POST["titre"])->getIdSource();
} }
elseif($_POST['req'] == "char"){ elseif($_POST['req'] == "char"){
$idImg = $this->iMod->createImgModelWithoutId($filePath);
$this->caMod->createCharacterWithoutId($_POST["name"], $idImg);
$idC = $this-> caMod -> getCharacterByName($_POST["name"])->getIdCharacter();
$idS = Verification::VerifChar($_POST["src"]);
} }
$this -> toSubmit(Verification::VerifChar($_POST["content"]),$idC,$idS);
} }
else{ else{
require_once($vues["create"]); require_once($vues["create"]);
var_dump($error);
} }
} }
// Quiz aléatoire
// argument = Langue / type question / type reponse
public function quizAleatoire(){
global $vues;
if(!isset($_POST["nbVie"])){
$vie = 3;
}
$question = $questMod->getRandomQuestion([$_POST["questionType"],$_POST["awnserType"]],$_POST["langue"]);
addTab($question);
if($question == null){
$erreur = [501,"Erreur serveur lors de l'obtention de la question"];
$require_once($vues["erreur"]);
}
else{
$require_once($vues['quiz']);
}
}
public function questionSuivantAleatoire(){
}
// ===================== DELETE ACCOUNT FUNCTION ===================== // ===================== DELETE ACCOUNT FUNCTION =====================

@ -56,10 +56,21 @@ Class VisitorControler {
public function quote(array $arg){ public function quote(array $arg){
global $vues; global $vues;
$id= $arg['idQuote'] ?? 1; $id= $arg['idQuote'] ?? 1;
if($id > 999999999){
$erreur = [404,"Citation inexistante pour le moment",'../'];
require_once($vues['erreur']);
exit();
}
$f = $this->uMod->isFavorite($_SESSION["user"],$id); $f = $this->uMod->isFavorite($_SESSION["user"],$id);
$q = $this->qMod->searchId($id); $q = $this->qMod->searchId($id);
$c = $this->cMod->getComment($id); $c = $this->cMod->getComment($id);
require_once $vues['quote']; if($q->getContent() != 'NULL'){
require_once $vues['quote'];
}
else{
$erreur = [404,"Citation inexistante pour le moment","../"];
require_once($vues['erreur']);
}
} }
public function favorite() { public function favorite() {

@ -49,8 +49,4 @@ class QuizEntity
{ {
$this->nb_questions = $nb_questions; $this->nb_questions = $nb_questions;
} }
} }

@ -1,6 +1,8 @@
<?php <?php
namespace Entity; namespace Entity;
use Enum\TypeSourceEnum;
class Quote{ class Quote{
private int $id; private int $id;
@ -11,6 +13,7 @@
private string $dateSrc; private string $dateSrc;
private int $like; private int $like;
private string $langue; private string $langue;
private TypeSourceEnum $type;
/** /**
* @param int $id * @param int $id
@ -22,7 +25,7 @@
* @param int $like * @param int $like
* @param string $langue * @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->id = $id;
$this->content = $content; $this->content = $content;
@ -32,6 +35,7 @@
$this->dateSrc = $dateSrc; $this->dateSrc = $dateSrc;
$this->like = $like; $this->like = $like;
$this->langue = $langue; $this->langue = $langue;
$this->type = $type;
} }
/** /**
@ -162,7 +166,13 @@
$this->langue = $langue; $this->langue = $langue;
} }
public function getType(): TypeSourceEnum{
return $this->type;
}
public function setType(TypeSourceEnum $type){
$this->type = $type;
}
} }
?> ?>

@ -6,4 +6,14 @@ enum TypeSourceEnum : string {
case VideoGame = 'video-game'; case VideoGame = 'video-game';
case Anime = 'anime'; case Anime = 'anime';
case Serie = 'serie'; 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 );
}
} }

@ -18,7 +18,7 @@ class CharacterGateway extends Gateway
return $this -> co -> executeQuery($query, [ return $this -> co -> executeQuery($query, [
'id_caracter' => array($id_character, PDO::PARAM_INT), 'id_caracter' => array($id_character, PDO::PARAM_INT),
'caracter' => array($name, PDO::PARAM_STR), 'caracter' => array($name, PDO::PARAM_STR),
'id_img' => array($img_char, PDO::PARAM_STR) 'id_img' => array($img_char, PDO::PARAM_INT)
]); ]);
} }
@ -61,8 +61,24 @@ class CharacterGateway extends Gateway
return $this -> co -> executeQuery($query, [ return $this -> co -> executeQuery($query, [
"id_c" => array($id_char, PDO::PARAM_INT), "id_c" => array($id_char, PDO::PARAM_INT),
"caracter" => array($name, PDO::PARAM_STR), "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;
}
} }

@ -65,4 +65,19 @@ class ImageGateway extends Gateway
'img_path' => array($imgPath, PDO::PARAM_STR) '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;
}
} }

@ -98,4 +98,8 @@ class QuestionGateway extends Gateway
return $this -> co -> getResults(); return $this -> co -> getResults();
} }
public function getQuestionQuoteSrc(string $l) : array{
}
} }

@ -36,7 +36,7 @@ class QuizGateway extends Gateway
public function findAll() : array public function findAll() : array
{ {
$query = "SELECT * FROM Quiz"; $query = "SELECT id_quiz, title, imgPath FROM Quiz q JOIN Image i on q.img = i.id_img";
$this -> co -> executeQuery($query); $this -> co -> executeQuery($query);
return $this -> co -> getResults(); return $this -> co -> getResults();
} }

@ -151,23 +151,38 @@ Class QuoteGateway extends Gateway{
return ($this -> co ->getResults())[0]['id']; return ($this -> co ->getResults())[0]['id'];
} }
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character) : bool public function addQuote(string $content, string $lang, int $idChar, int $idSrc, int $idUsr){
{ $id = $this->getLastId();
$query = " $query = "INSERT INTO Quote Values (:id,:content,0,:lang,false,'',:charac,:src,:user);";
INSERT INTO Quote (id_quote, content, langue, reason, id_source, id_caracter, id_user_verif, img_path) try {
VALUES (:id, :content, :langage, :reason, :source, :character, :user, :img_path) $this->co->executeQuery($query,[
"; ':id' => [$id,PDO::PARAM_INT],
':content' => [$content,PDO::PARAM_STR],
return $this->co->executeQuery($query, [ ':lang' => [$lang,PDO::PARAM_STR],
':id' => array($this->autoincrement(), PDO::PARAM_INT), ':charac' => [$idChar,PDO::PARAM_INT],
':content' => array($content, PDO::PARAM_STR), ':src' => [$idSrc,PDO::PARAM_INT],
':img_path' => array($img_path, PDO::PARAM_STR), ':user' => [$idUsr,PDO::PARAM_INT],
':langage' => array($langage, PDO::PARAM_STR), ]);
':user' => array($user, PDO::PARAM_INT), }
':reason' => array('À vérifier', PDO::PARAM_STR), catch (PDOException $e){
':source' => array($source, PDO::PARAM_STR), $error['501'] = 'Erreur lors de la création de la citation';
':character' => array($character, PDO::PARAM_STR) 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;
} }
//======================== PARTI ADMIN ======================== //======================== PARTI ADMIN ========================

@ -10,10 +10,11 @@ class SourceGateway extends Gateway{
{ {
$query = " $query = "
INSERT INTO Source INSERT INTO Source
VALUES( :title, :date) VALUES(:id, :title, :date)
"; ";
return $this -> co -> executeQuery($query, [ return $this -> co -> executeQuery($query, [
"id" => array($s->getIdSource(), PDO::PARAM_INT),
"title" => array($s->getTitle(), PDO::PARAM_STR), "title" => array($s->getTitle(), PDO::PARAM_STR),
"date" => array($s->getDate(), PDO::PARAM_STR), "date" => array($s->getDate(), PDO::PARAM_STR),
#"type" => array($s->getType(), PDO::PARAM_STR) #"type" => array($s->getType(), PDO::PARAM_STR)
@ -81,4 +82,19 @@ class SourceGateway extends Gateway{
]); ]);
} }
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;
}
} }

@ -9,11 +9,17 @@ use Gateway\Gateway;
class CharacterModel extends Model class CharacterModel extends Model
{ {
public function createCharacter(int $id_character, string $name , string $img_char) : bool public function createCharacter(int $id_character, string $name , int $img_char) : bool
{ {
return $this -> gateway -> create($id_character, $name, $img_char); return $this -> gateway -> create($id_character, $name, $img_char);
} }
public function createCharacterWithoutId(string $name , int $img_char) : bool
{
$id_character = $this -> gateway -> getLastId();
return $this -> gateway -> create($id_character, $name, $img_char);
}
public function getCharacterById(int $id_character) : ?CharacterEntity public function getCharacterById(int $id_character) : ?CharacterEntity
{ {
$c = $this -> gateway -> findById($id_character); $c = $this -> gateway -> findById($id_character);
@ -72,7 +78,7 @@ class CharacterModel extends Model
return $this -> gateway -> delete($id_character); return $this -> gateway -> delete($id_character);
} }
public function updateCharacter(int $id_character, string $name, string $img_char) : bool public function updateCharacter(int $id_character, string $name, int $img_char) : bool
{ {
return $this -> gateway -> update($id_character, $name, $img_char); return $this -> gateway -> update($id_character, $name, $img_char);
} }

@ -13,6 +13,13 @@ class ImageModel extends Model
return $this -> gateway -> createImgGateway($idImg, $imgPath); return $this -> gateway -> createImgGateway($idImg, $imgPath);
} }
public function createImgModelWithoutId (string $imgPath) : int
{
$idImg = $this->gateway ->getLastId() ;
$this -> gateway -> createImgGateway($idImg, $imgPath, false);
return $idImg;
}
public function getImgById(int $idImg) : ?ImageEntity public function getImgById(int $idImg) : ?ImageEntity
{ {
$res = $this -> gateway -> findImgById($idImg); $res = $this -> gateway -> findImgById($idImg);

@ -79,4 +79,39 @@ class QuestionModel extends Model
); );
return null; 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;
}
}
} }

@ -30,20 +30,8 @@ class QuizModel extends Model{
return $this -> gateway -> delete($id_quiz); return $this -> gateway -> delete($id_quiz);
} }
public function getAllQuiz() : array public function listQuiz() : array
{ {
$q = $this -> gateway -> findAll();
$quizzes = [];
foreach ($q as $quiz) {
$quizzes[] = new quizEntity(
$quiz['id_quiz'],
$quiz['nb_questions']
);
}
return $quizzes;
} }
} }

@ -3,6 +3,7 @@
use Entity\Quote; use Entity\Quote;
use Gateway\QuoteGateway; use Gateway\QuoteGateway;
use Gateway\Gateway; use Gateway\Gateway;
use Enum\TypeSourceEnum;
class QuoteModel extends Model class QuoteModel extends Model
{ {
@ -12,7 +13,7 @@
if( count($res) == 0) if( count($res) == 0)
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default"); return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default");
else 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"]); 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);
} }
public function getSuggest(int $numpage, string $language):array{ public function getSuggest(int $numpage, string $language):array{
@ -21,7 +22,7 @@
foreach($res as $q ){ foreach($res as $q ){
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"]; $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"]) ; $tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
} }
return $tabQ; return $tabQ;
} }
@ -29,10 +30,10 @@
public function getQuoteOfTheDay(string $language):Quote{ public function getQuoteOfTheDay(string $language):Quote{
$res = $this->gateway->getQuoteOfTheDay($language); $res = $this->gateway->getQuoteOfTheDay($language);
if( count($res) == 0) if( count($res) == 0)
return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default"); return new Quote(-1,"NULL","NULL","NULL","NULL","NULL",0,"Default",TypeSourceEnum::Movie);
else else
$res["content"] = (strlen($res["content"]) > 153) ? substr($res["content"],0,150).'...' : $res["content"]; $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"]) ; return new Quote($res["id_quote"],$res["content"],$res["caracter"],$res["imgpath"],$res["title"],$res["dates"],$res["likes"],$res["langue"],TypeSourceEnum::Movie) ;
} }
public function getFavorites(string $userId): array { public function getFavorites(string $userId): array {
@ -41,16 +42,14 @@
foreach($res as $q ){ foreach($res as $q ){
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"]; $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"]) ; $tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
} }
return $tabQ; return $tabQ;
} }
public function insert4User(string $content, string $img_path, string $langage, int $user, int $source, int $character) : bool public function addQuote(string $content, string $lang, int $idChar, int $idSrc, int $idUsr){
{ $this -> gateway -> addQuote($content,$lang,$idChar,$idSrc,$idUsr);
return $this->gateway->insert4User($content, $img_path, $langage, $user, $source, $character);
} }
} }
?> ?>

@ -3,6 +3,7 @@
use Entity\Quote; use Entity\Quote;
use Gateway\QuoteGateway; use Gateway\QuoteGateway;
use Gateway\Gateway; use Gateway\Gateway;
use Enum\TypeSourceEnum;
class SearchModel extends Model class SearchModel extends Model
{ {
@ -14,7 +15,7 @@
foreach($res as $q ){ foreach($res as $q ){
$q["content"] = (strlen($q["content"]) > 153) ? substr($q["content"],0,150).'...' : $q["content"]; $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"]) ; $tabQ[]= new Quote($q["id_quote"],$q["content"],$q["caracter"],$q["imgpath"],$q["title"],$q["dates"],$q["likes"],$q["langue"],TypeSourceEnum::Movie) ;
} }
return $tabQ; return $tabQ;
} }

@ -8,8 +8,8 @@ class SourceModel extends Model
public function createSource(string $title, string $date, TypeSourceEnum $type) : bool public function createSource(string $title, string $date, TypeSourceEnum $type) : bool
{ {
$q = new SourceEntity(-1,$title, $date, TypeSourceEnum::Movie/*$type*/); $id = $this -> gateway -> getLastId();
$q = new SourceEntity($id,$title, $date, $type);
return $this -> gateway -> create($q); return $this -> gateway -> create($q);
} }
@ -106,7 +106,7 @@ class SourceModel extends Model
public function existSource(string $name, string $type) : bool{ public function existSource(string $name, string $type) : bool{
$q = $this -> getSourceByTitle($name); $q = $this -> getSourceByTitle($name);
return isset($q[0]); return isset($q);
} }
} }

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

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

@ -12,7 +12,11 @@ echo $twig->render('head.html.twig', [
// Rendu du bandeau // Rendu du bandeau
echo $twig->render('bandeau.html.twig'); 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,
'nextquiz' => $id_quiz + 1,
'nb' => $nbQuestion]);
?> ?>

@ -1,5 +1,25 @@
<h1>
<?php <?php
echo "ERREUR"; global $twig;
?>
</h1> 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,17 +1,15 @@
<?php <?php
global $twig; global $twig;
echo $twig->render('head.html.twig', [ echo $twig->render('head.html.twig', [
'title' => "Quiz", 'title' => "Quiz",
'style' => "../public/styles/styleQuiz.css", 'style' => "../public/styles/styleQuiz.css",
'scripts' => array("../public/script/theme-toggle-double-param.js") 'scripts' => array("../public/script/theme-toggle-double-param.js")
]); ]);
// Rendu du bandeau // Rendu du bandeau
echo $twig->render('bandeau.html.twig'); echo $twig->render('bandeau.html.twig');
echo $twig->render('quiz.html.twig', ['idQuiz'=>$id , 'question' => $question,'id'=>$idquestion]); echo $twig->render('quiz.html.twig', [
?> 'quizList' => $quizs
]);

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

@ -3,7 +3,7 @@
global $twig; global $twig;
echo $twig->render('head.html.twig', array( echo $twig->render('head.html.twig', array(
'title' => "Quote", 'title' => "Search",
'style' => "public/styles/styleSearch.css", 'style' => "public/styles/styleSearch.css",
'scripts' => array("public/script/theme-toggle.js") 'scripts' => array("public/script/theme-toggle.js")
)); ));

@ -0,0 +1,17 @@
<h2>Liste des Quiz</h2>
<ul>
{% for quiz in quizList %}
<li>
<div class="quizCard">
<a href="{{ racine }}/quote/{{ quizIds.id_quiz }}">
<img src="{{ quizIds.image }}" alt="Image du quiz {{ quiz.title }}">
<h3>{{ quizIds.title }}</h3>
</a>
</div>
</li>
{% else %}
<li>Aucun quiz disponible pour le moment.</li>
{% endfor %}
</ul>
</body>
</html>

@ -2,7 +2,7 @@
<div class="nav"> <div class="nav">
<a href="{{ racine }}/favorite"><img src="{{ racine }}/images/coeur.svg" alt="coeur" onmousedown="return false"></a> <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()"> <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>
</div> </div>
<div class="logo"> <div class="logo">

@ -1,11 +1,22 @@
<div class="creation"> <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 %} {% if src == true and char == true %}
<input type="hidden" id="req" name="req" value="both"/> <input type="hidden" id="req" name="req" value="both"/>
<input type="hidden" id="content" name="content" value="{{ content }}"/>
{% elseif src == true %} {% elseif src == true %}
<input type="hidden" id="req" name="req" value="src"/> <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 %} {% 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 %} {% endif %}
{% if src == true %} {% if src == true %}
<h1>Source</h1> <h1>Source</h1>
@ -15,16 +26,16 @@
<input type="number" id="date" name="date" min="1850" max="{{ "now"|date("Y") }}" required> <input type="number" id="date" name="date" min="1850" max="{{ "now"|date("Y") }}" required>
<label for="type">Type de source *</label> <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> <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> <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> <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> <label for="anime">Anime</label>
{% endif %} {% endif %}
@ -34,7 +45,7 @@
<input type="text" class="champ" id="name" name="name" placeholder="Nom du personnage" required/> <input type="text" class="champ" id="name" name="name" placeholder="Nom du personnage" required/>
<label for="name">Image du personnage *</label> <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 %} {% endif %}
<input type="submit" class="btn" value="Soumettre"/> <input type="submit" class="btn" value="Soumettre"/>

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

@ -46,7 +46,7 @@
</form> </form>
<div class="createQuote"> <div class="createQuote">
<a {#href="{{racine}}/submit"#} class="createQuote">Ajouter une citation</a> <a href="{{racine}}/submit" class="createQuote">Ajouter une citation</a>
</div> </div>

@ -1,7 +1,6 @@
<h1>Quiz</h1> <h1>Quiz</h1>
<div class="quiz"> <div class="quiz">
<h2> {{ question.question }} </h2> <h2> {{ question.question }} </h2>
{#<a id="timer"> 10 seconds left .. </a>#}
<form id="quizForm" method="POST" > <form id="quizForm" method="POST" >
<div class="answers"> <div class="answers">
@ -20,6 +19,7 @@
</div> </div>
<input type="hidden" name="action" value="canswer"> <input type="hidden" name="action" value="canswer">
</form> </form>
<a id="timer">{{ nb }}/{{ nbFinal }}</a>
</div> </div>
</body> </body>
</html> </html>

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

@ -1,19 +1,4 @@
<!DOCTYPE html> <h1>Votre citation a corectement été envoyé</h1>
<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>
<div> <div>
@ -41,7 +26,7 @@
</div> </div>
<div> <div>
<button onclick="window.location.href='/';"> Revenir à l'acceuil</button> <button onclick="window.location.href='{{racine}}/';"> Revenir à l'acceuil</button>
</div> </div>
</div> </div>

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

Loading…
Cancel
Save