diff --git a/config/.htaccess b/.htaccess similarity index 100% rename from config/.htaccess rename to .htaccess diff --git a/cache/44/4448d384ce5c0b36e3d5c422f47fbacf.php b/cache/44/4448d384ce5c0b36e3d5c422f47fbacf.php new file mode 100644 index 0000000..3823316 --- /dev/null +++ b/cache/44/4448d384ce5c0b36e3d5c422f47fbacf.php @@ -0,0 +1,115 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield "
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ S'inscrire ◀

+
+
+
+

Identifiant *

+ +
+ +
+

Email *

+ +
+ +
+

Mot de passe *

+ +
+ +
+

Confirmer mot de passe *

+ +
+ +
+

Image *

+ +
+ +
+ +
+
+
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "signin.html"; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "signin.html", "/home/www/lebeaulato/public_html/WF-Website/vue/templates/signin.html"); + } +} diff --git a/cache/f9/f92f69760ebb764380af0f11a2633512.php b/cache/f9/f92f69760ebb764380af0f11a2633512.php new file mode 100644 index 0000000..9f20119 --- /dev/null +++ b/cache/f9/f92f69760ebb764380af0f11a2633512.php @@ -0,0 +1,102 @@ + + */ + private array $macros = []; + + public function __construct(Environment $env) + { + parent::__construct($env); + + $this->source = $this->getSourceContext(); + + $this->parent = false; + + $this->blocks = [ + ]; + } + + protected function doDisplay(array $context, array $blocks = []): iterable + { + $macros = $this->macros; + // line 1 + yield "
+
+
+ \"coeur\" + \"toggle + \"quizz\" +
+
+ \"Logo\" +
+
+ \"user\" +
+
+
+

▶ Connexion ◀

+ +
+

Identifiant *

+ + +

Mot de passe *

+ + +
+

Vous n'avez pas de compte?

+ S'incrire +
+ + +
+ +
+ +
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "login.html"; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "login.html", "/home/www/lebeaulato/public_html/WF-Website/vue/templates/login.html"); + } +} diff --git a/config/config.php b/config/config.php index f7965e0..bfa17ed 100644 --- a/config/config.php +++ b/config/config.php @@ -18,8 +18,8 @@ $mdp = 'Ctvl-21122005'; $vues['erreur'] = 'vue/erreur.php'; $vues['accueil'] = 'vue/accueil.php'; $vues['quote'] = 'vue/quote.php'; -$vues['login'] = 'vue/login.html'; -$vues['signin'] = 'vue/signin.html'; +$vues['login'] = 'vue/login.php'; +$vues['signin'] = 'vue/signin.php'; $vues['quiz'] = 'vue/quiz.html'; diff --git a/index.php b/index.php index c5a1be9..5b3e0d1 100644 --- a/index.php +++ b/index.php @@ -16,10 +16,12 @@ $co = new \Gateway\Connection("pgsql:host=localhost;dbname={$base};", $login, $m //twig $loader = new \Twig\Loader\FilesystemLoader('vue/templates'); $twig = new \Twig\Environment($loader, [ - 'cache' => 'cache', + 'cache' => false, ]); -$cont = new Controleur\FrontControler(); +$twig->addGlobal('racine','/~kekentin/WF/WF-Website'); + +$cont = new Controleur\FrontControler($co); session_unset(); session_destroy(); diff --git a/public/script/theme-toggle.js b/public/script/theme-toggle.js index f651750..3954f9f 100644 --- a/public/script/theme-toggle.js +++ b/public/script/theme-toggle.js @@ -11,12 +11,12 @@ document.addEventListener("DOMContentLoaded", function() { if (currentTheme === 'light') { document.body.classList.remove('dark-mode'); document.body.classList.add('light-mode'); - themeIcon.src = '../images/light.svg'; // Affiche l'icône pour basculer vers le mode sombre - favicon.href = '../images/iconeClaire.ico'; // Favicon pour le mode clair + themeIcon.src = 'images/light.svg'; // Affiche l'icône pour basculer vers le mode sombre + favicon.href = 'images/iconeClaire.ico'; // Favicon pour le mode clair } else { document.body.classList.add('dark-mode'); - themeIcon.src = '../images/dark.svg'; // Affiche l'icône pour basculer vers le mode clair - favicon.href = '../images/iconeSombre.ico'; // Favicon pour le mode sombre + themeIcon.src = 'images/dark.svg'; // Affiche l'icône pour basculer vers le mode clair + favicon.href = 'images/iconeSombre.ico'; // Favicon pour le mode sombre } } else { console.error("Élément(s) manquant(s) : icône du thème ou favicon."); @@ -34,15 +34,15 @@ function toggleTheme() { // Si on est en mode sombre, on passe en mode clair body.classList.remove('dark-mode'); body.classList.add('light-mode'); - themeIcon.src = '../images/light.svg'; // Change vers le logo sombre - favicon.href = '../images/iconeClaire.ico'; // Favicon pour le mode clair + themeIcon.src = 'images/light.svg'; // Change vers le logo sombre + favicon.href = 'images/iconeClaire.ico'; // Favicon pour le mode clair localStorage.setItem('theme', 'light'); // Enregistre le thème clair dans localStorage } else { // Sinon, on repasse en mode sombre body.classList.remove('light-mode'); body.classList.add('dark-mode'); - themeIcon.src = '../images/dark.svg'; // Change vers le logo clair - favicon.href = '../images/iconeSombre.ico'; // Favicon pour le mode sombre + themeIcon.src = 'images/dark.svg'; // Change vers le logo clair + favicon.href = 'images/iconeSombre.ico'; // Favicon pour le mode sombre localStorage.setItem('theme', 'dark'); // Enregistre le thème sombre dans localStorage } } else { diff --git a/src/Controleur/FrontControler.php b/src/Controleur/FrontControler.php index 3dc128d..f9d30b4 100644 --- a/src/Controleur/FrontControler.php +++ b/src/Controleur/FrontControler.php @@ -11,7 +11,7 @@ Class FrontControler{ private Connection $co; - public function __construct(/*$co*/){ + public function __construct($co){ global $twig; @@ -23,8 +23,10 @@ Class FrontControler{ $dVueEreur = []; $router = new \AltoRouter(); + + $router->setBasePath('/~kemondejar/WF-Website'); - $router->map('GET', '/', 'VisitorControler'); + $router->map('GET', '/', 'VisitorControler','accueil'); /* 'i' => '[0-9]++' @@ -35,13 +37,11 @@ Class FrontControler{ '' => '[^/\.]++' */ - $router->map('GET|POST', '/quote/[i:idQuote]?', 'VisitorControler'); - $router->map('GET|POST', '/login', 'VisitorControler'); - $router->map('GET|POST', '/signin', 'VisitorControler'); - - $router->map('GET|POST', '/quiz', 'UserControler'); + $router->map('GET|POST', '/quote/[i:idQuote]?', 'VisitorControler','quote'); + $router->map('GET|POST', '/login', 'VisitorControler','login'); + $router->map('GET|POST', '/signin', 'VisitorControler','signin'); - $router->map('GET|POST', '/quiz/[i:id]?', 'QuizControler'); + $router->map('GET|POST', '/quiz/[i:id]?', 'QuizControler','quiz'); $match = $router->match(); @@ -54,30 +54,26 @@ Class FrontControler{ else{ $controller=$match['target'] ?? null; - $action = explode('/',$_SERVER['PHP_SELF']); - if(count($action)>2){ - $action=$action[2]; - } - else{ - $action='accueil'; - } + $action = $match['name']; + //Si existe, on l’appelle if(!$this->ifExisteAction($action)){ $dVueEreur[] = "Action introuvable"; $this->vueErreur($dVueEreur); } - if(!$this->verifDroit($action)){ + else if(!$this->verifDroit($action)){ $action='login'; $controller='VisitorControler'; } - - $controller = '\\Controleur\\' . $controller; - $controller = new $controller; - if (is_callable(array($controller, $action))) { - call_user_func_array(array($controller, $action), - array($match['params'])); + else { + $controller = '\\Controleur\\' . $controller; + $controller = new $controller($co); + if (is_callable(array($controller, $action))) { + call_user_func_array(array($controller, $action), + array($match['params'])); + } } } diff --git a/src/Controleur/QuizController.php b/src/Controleur/QuizControler.php similarity index 99% rename from src/Controleur/QuizController.php rename to src/Controleur/QuizControler.php index 3b81996..0e72f6d 100644 --- a/src/Controleur/QuizController.php +++ b/src/Controleur/QuizControler.php @@ -16,7 +16,7 @@ use Twig\Error\RuntimeError; use Twig\Error\SyntaxError; use Twig\Loader\FilesystemLoader; -class QuizController +class QuizControler { private int $no_question = 0; diff --git a/src/Controleur/VisitorControler.php b/src/Controleur/VisitorControler.php index e98fc79..bbf20a5 100644 --- a/src/Controleur/VisitorControler.php +++ b/src/Controleur/VisitorControler.php @@ -2,6 +2,7 @@ namespace Controleur; use Model\QuoteModel; use Gateway\Connection; +use Gateway\QuoteGateway; Class VisitorControler{ @@ -20,9 +21,8 @@ Class VisitorControler{ public function quote(array $arg){ global $vues; $id=$arg['idQuote'] ?? 1; - $q = $qMod->searchId($id); + $q = $this->qMod->searchId($id); //echo "{$id}"; - require_once $vues['quote']; } diff --git a/src/Entity/quoteEntity.php b/src/Entity/Quote.php similarity index 100% rename from src/Entity/quoteEntity.php rename to src/Entity/Quote.php diff --git a/src/Gateway/quoteGateway.php b/src/Gateway/QuoteGateway.php similarity index 95% rename from src/Gateway/quoteGateway.php rename to src/Gateway/QuoteGateway.php index 527bcdf..778e6e2 100644 --- a/src/Gateway/quoteGateway.php +++ b/src/Gateway/QuoteGateway.php @@ -1,7 +1,6 @@ con->executeQuery($query,array(':id' => array($id,PDO::PARAM_STR))); $result=$this->con->getResults(); return $result; diff --git a/src/Model/QuoteModel.php b/src/Model/QuoteModel.php new file mode 100644 index 0000000..e879b5e --- /dev/null +++ b/src/Model/QuoteModel.php @@ -0,0 +1,24 @@ +gateway = $gate; + } + + public function searchId(int $id): Quote{ + $res = $this->gateway->searchId($id); + var_dump($res); + 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"]); + } + } + +?> diff --git a/src/Model/quoteModel.php b/src/Model/quoteModel.php deleted file mode 100644 index 95867a1..0000000 --- a/src/Model/quoteModel.php +++ /dev/null @@ -1,20 +0,0 @@ -gateway = $gate; - } - - public function searchId(int $id): Quote{ - $res = $this->gate->searchId($id)[0]; - return new Quote($res["q.id_quote"],$res["q.content"],$res["c.caracter"],$res["c.img_path"],$res["s.title"],$res["s.date"],$res["q.like"],$res["q.language"]); - } - } - -?> diff --git a/vue/accueil.php b/vue/accueil.php index 9dc6686..5c6d764 100644 --- a/vue/accueil.php +++ b/vue/accueil.php @@ -1,17 +1,9 @@ false, - ]); - // + global $twig; echo $twig->render('head.html.twig', array( 'title' => "Accueil", - 'style' => "../../public/styles/styleAccueil.css", + 'style' => "public/styles/styleAccueil.css", )); echo $twig->render('bandeau.html.twig'); diff --git a/vue/login.php b/vue/login.php new file mode 100644 index 0000000..d1cf965 --- /dev/null +++ b/vue/login.php @@ -0,0 +1,12 @@ +render('head.html.twig', array( + 'title' => "Login", + 'style' => "../public/styles/styleLogin.css", + )); + + echo $twig->render('bandeau.html.twig'); + echo $twig->render('login.html'); +?> \ No newline at end of file diff --git a/vue/quote.php b/vue/quote.php index 8f853f9..8332bf2 100644 --- a/vue/quote.php +++ b/vue/quote.php @@ -1,20 +1,19 @@ render('head.html.twig', array( 'title' => "Quote", 'style' => "public/styles/styleQuote.css", )); - echo $twig->render('bandeau.html.twig'); echo $twig->render('quote.html', array( - 'srcImg' => $q->imgPath, - 'nameCarac' => $q->carac, - 'quoteContent' => $q->content, - 'sourceName' => $q->titleSrc, - 'dateSortie' => $q->dateSrc, - 'nbLike' => $q->like, + 'srcImg' => $q->getImgPath(), + 'nameCarac' => $q->getCarac(), + 'quoteContent' => $q->getContent(), + 'sourceName' => $q->getTitleSrc(), + 'dateSortie' => $q->getDateSrc(), + 'nbLike' => $q->getLike(), 'timeCode' =>"1h45", )); diff --git a/vue/signin.php b/vue/signin.php new file mode 100644 index 0000000..fd0b8d7 --- /dev/null +++ b/vue/signin.php @@ -0,0 +1,12 @@ +render('head.html.twig', array( + 'title' => "Sign in", + 'style' => "../public/styles/styleSignin.css", + )); + + echo $twig->render('bandeau.html.twig'); + echo $twig->render('signin.html'); +?> \ No newline at end of file diff --git a/vue/templates/bandeau.html.twig b/vue/templates/bandeau.html.twig index 4be6013..be606e7 100644 --- a/vue/templates/bandeau.html.twig +++ b/vue/templates/bandeau.html.twig @@ -1,14 +1,14 @@
- user + user
\ No newline at end of file diff --git a/vue/templates/head.html.twig b/vue/templates/head.html.twig index 5f5f2b7..31c1ef9 100644 --- a/vue/templates/head.html.twig +++ b/vue/templates/head.html.twig @@ -5,7 +5,7 @@ {{ title }} - - + + \ No newline at end of file diff --git a/vue/login.html b/vue/templates/login.html similarity index 72% rename from vue/login.html rename to vue/templates/login.html index 74328f6..5f7ad01 100644 --- a/vue/login.html +++ b/vue/templates/login.html @@ -1,15 +1,3 @@ - - - - - - - Wiki Fantasy : Connexion - - - - -