From 0e5c6e26c46484fe075a88fe366b10a1d66a1e64 Mon Sep 17 00:00:00 2001 From: brongniart Date: Fri, 25 Oct 2024 15:33:47 +0200 Subject: [PATCH] controleur --- cache/b8/b8bf2b0d7583c567fbc28aec381ed411.php | 150 ++++++++++++++++++ config/config.php | 1 + src/Controleur/FrontControler.php | 27 +++- src/Controleur/VisitorControler.php | 30 ++-- vue/HeaderView.php | 28 ---- vue/quote.php | 29 ---- 6 files changed, 180 insertions(+), 85 deletions(-) create mode 100644 cache/b8/b8bf2b0d7583c567fbc28aec381ed411.php delete mode 100644 vue/HeaderView.php delete mode 100644 vue/quote.php diff --git a/cache/b8/b8bf2b0d7583c567fbc28aec381ed411.php b/cache/b8/b8bf2b0d7583c567fbc28aec381ed411.php new file mode 100644 index 0000000..164ff94 --- /dev/null +++ b/cache/b8/b8bf2b0d7583c567fbc28aec381ed411.php @@ -0,0 +1,150 @@ + + */ + 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 " + +
+ env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["srcImg"] ?? null), "html", null, true); + yield "\" alt=\""; + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["nameCarac"] ?? null), "html", null, true); + yield "\"> +

+ + "; + // line 7 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["quoteContent"] ?? null), "html", null, true); + yield " + +

+ +
+

+ "; + // line 23 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(($context["nbLike"] ?? null), "html", null, true); + yield " +

+
+
+
+ "; + // line 28 + if ((Twig\Extension\CoreExtension::length($this->env->getCharset(), ($context["comment"] ?? null)) > 0)) { + yield "
+ "; + // line 29 + $context['_parent'] = $context; + $context['_seq'] = CoreExtension::ensureTraversable(($context["comment"] ?? null)); + foreach ($context['_seq'] as $context["_key"] => $context["com"]) { + // line 30 + yield "

"; + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["com"], "user", [], "any", false, false, false, 30), "html", null, true); + yield "

+

"; + // line 31 + yield $this->env->getRuntime('Twig\Runtime\EscaperRuntime')->escape(CoreExtension::getAttribute($this->env, $this->source, $context["com"], "content", [], "any", false, false, false, 31), "html", null, true); + yield "

+ "; + } + $_parent = $context['_parent']; + unset($context['_seq'], $context['_key'], $context['com'], $context['_parent']); + $context = array_intersect_key($context, $_parent) + $_parent; + // line 32 + yield "
+ "; + } + // line 34 + yield "
+ +"; + yield from []; + } + + /** + * @codeCoverageIgnore + */ + public function getTemplateName(): string + { + return "quote.html"; + } + + /** + * @codeCoverageIgnore + */ + public function isTraitable(): bool + { + return false; + } + + /** + * @codeCoverageIgnore + */ + public function getDebugInfo(): array + { + return array ( 116 => 34, 112 => 32, 104 => 31, 99 => 30, 95 => 29, 91 => 28, 83 => 23, 75 => 18, 69 => 15, 63 => 12, 55 => 7, 47 => 4, 42 => 1,); + } + + public function getSourceContext(): Source + { + return new Source("", "quote.html", "/home/www/kekentin/public_html/WF/WF-Website/vue/templates/quote.html"); + } +} diff --git a/config/config.php b/config/config.php index 044d3ec..3caadec 100644 --- a/config/config.php +++ b/config/config.php @@ -16,6 +16,7 @@ $mdp = ''; //Vues $vues['erreur'] = 'vue/erreur.php'; $vues['accueil'] = 'vue/accueil.php'; +$vues['quote'] = 'vue/quote.php'; //Style css $style['accueil'] = 'public/styles/styleAccueil.css'; diff --git a/src/Controleur/FrontControler.php b/src/Controleur/FrontControler.php index 6c4eac5..40d8f9c 100644 --- a/src/Controleur/FrontControler.php +++ b/src/Controleur/FrontControler.php @@ -3,20 +3,23 @@ namespace Controleur; Class FrontControler{ - private $listAction = ['visitor' => array('accueil','search','quote','login','singin'), - 'user' => array('quiz','commentary','favorite','logout'), - 'admin' => array()]; + private $listAction; private string $role = 'visitor'; public function __construct(){ global $twig; + $this->listAction = ['visitor' => array('accueil','search','quote','login','singin'), + 'user' => array('quiz','commentary','favorite','logout'), + 'admin' => array('null')]; + $dVueEreur = []; $router = new \AltoRouter(); $router->map('GET', '/', 'VisitorControler'); + /* 'i' => '[0-9]++' 'a' => '[0-9A-Za-z]++' @@ -25,11 +28,11 @@ Class FrontControler{ '**' => '.++' '' => '[^/\.]++' */ - $router->map('GET|POST', '/quote/[a:action]?', 'VisitorControler'); - $match = $router->match(); + $router->map('GET|POST', '/quote/[i:arg]?', 'VisitorControler'); - $action = array(); + $match = $router->match(); + $action = NULL; if(!$match){ $dVueEreur[] = "Requette introuvable"; @@ -40,7 +43,11 @@ Class FrontControler{ $action=$match['params']['action'] ?? 'accueil'; //Si existe, on l’appelle - + if(!$this->ifExisteAction($action)){ + $dVueEreur[] = "Action introuvable"; + $this->vueErreur($dVueEreur); + } + $controller = '\\Controleur\\' . $controller; $controller = new $controller; if (is_callable(array($controller, $action))) { @@ -54,7 +61,11 @@ Class FrontControler{ } private function ifExisteAction(string $action):bool { - if( in_array($action , $listAction['admin']) || in_array($action , $listAction['user']) || in_array($action , $listAction['visiteur'])) return true; + if( in_array($action , $this->listAction['admin']) || + in_array($action , $this->listAction['user']) || + in_array($action , $this->listAction['visitor']) ) { + return true; + } return false; } diff --git a/src/Controleur/VisitorControler.php b/src/Controleur/VisitorControler.php index 0a5c928..9b95b4c 100644 --- a/src/Controleur/VisitorControler.php +++ b/src/Controleur/VisitorControler.php @@ -4,30 +4,20 @@ namespace Controleur; Class VisitorControler{ public function __construct(){ - global $vues; - require_once $vues['accueil']; - } - - - - - private function ifExisteAction(string $action):bool { - if( in_array($action , $listAction['visiteur'])) return true; - - return false; + $action = explode('/',$_SERVER['PHP_SELF']); + var_dump( $action[2]); } - private function verifDroit(string $action):bool { - if( in_array($action , $listAction['admin']) && $role == 'admin') return true; - elseif( in_array($action , $listAction['user']) && ($role == 'admin' || $role == 'user') ) return true; - elseif(in_array($action , $listAction['visitor']) && ($role == 'admin'|| $role == 'user'|| $role == 'visitor')) return true; - return false; + public function accueil(){ + global $vues; + require_once $vues['accueil']; } - private function vueErreur(array $dVueErreur){ + public function quote(array $arg){ global $vues; - echo "{$dVueErreur[0]}"; - require_once $vues['erreur']; + foreach( $arg as $i){ + echo "{$i}"; + } + require_once $vues['quote']; } - } diff --git a/vue/HeaderView.php b/vue/HeaderView.php deleted file mode 100644 index 8bd414e..0000000 --- a/vue/HeaderView.php +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - Wiki Fantasy - - - - - - -
-
- - -
- user -
-
-
diff --git a/vue/quote.php b/vue/quote.php deleted file mode 100644 index 8c2adf0..0000000 --- a/vue/quote.php +++ /dev/null @@ -1,29 +0,0 @@ - false, - ]); - // - - echo $twig->render('quote.html', array( - 'srcImg' => "../default.jpg", - 'nameCarac' => "default", - 'quoteContent' => "je test la page", - 'sourceName' => "une source", - 'dateSortie' => "1999", - 'nbLike' => "0", - 'comment'=> array( - array( - 'user'=>'toto', - 'content'=>'12345674fkjgvhgtfoidshfziutgfos' - ), - array( - 'user'=> 'tata', - 'content'=>'azertyuiopqsdfghjklmwxcvbn' - ) -))); -?> \ No newline at end of file