From 83050073175d08ff98f01943666364ce520e222b Mon Sep 17 00:00:00 2001 From: Emmanuel ROY Date: Mon, 9 Sep 2019 22:37:17 +0200 Subject: [PATCH] =?UTF-8?q?Application=20nettoy=C3=A9,=20Ajout=20de=20la?= =?UTF-8?q?=20lib=20composer=20hybridauth/hybridauth=20TODO:=20integrer=20?= =?UTF-8?q?hybrid=20auth=20sur=20une=20page=20simple=20d'authentification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- .idea/MVC---Objet.iml | 5 ++-- .idea/php.xml | 1 + README.md | 17 ++++++------ application/class/Application.php | 1 + application/class/Controlleur.php | 4 +-- application/class/Url.php | 11 +++++--- application/class/Vue.php | 21 ++++++++------- application/include/vues/accueil.phtml | 2 -- application/include/vues/error.phtml | 1 - .../include/vues/layout/body.blade.php | 13 +++++++++ application/include/vues/syf43.phtml | 1 - .../include/vues/system/layout.blade.php | 14 ---------- .../include/vues/system/system.blade.php | 9 +++++++ .../{templating => view}/accueil.blade.php | 2 +- .../vues/{templating => view}/error.blade.php | 0 .../vues/{templating => view}/syf43.blade.php | 0 .../layout/include/standard/body.phtml | 4 --- .../include/standard/bottom-javascript.phtml | 2 -- .../layout/include/standard/footer.phtml | 5 ---- .../layout/include/standard/head.phtml | 20 -------------- .../layout/include/standard/header.phtml | 7 ----- .../layout/include/standard/top-css.phtml | 2 -- application/layout/standard.phtml | 27 ------------------- .../modules/setup/syf43.twig.class.php | 21 --------------- composer.json | 3 ++- public/index.php | 4 +-- 27 files changed, 61 insertions(+), 138 deletions(-) delete mode 100644 application/include/vues/accueil.phtml delete mode 100644 application/include/vues/error.phtml create mode 100644 application/include/vues/layout/body.blade.php delete mode 100644 application/include/vues/syf43.phtml delete mode 100644 application/include/vues/system/layout.blade.php create mode 100644 application/include/vues/system/system.blade.php rename application/include/vues/{templating => view}/accueil.blade.php (92%) rename application/include/vues/{templating => view}/error.blade.php (100%) rename application/include/vues/{templating => view}/syf43.blade.php (100%) delete mode 100644 application/layout/include/standard/body.phtml delete mode 100644 application/layout/include/standard/bottom-javascript.phtml delete mode 100644 application/layout/include/standard/footer.phtml delete mode 100644 application/layout/include/standard/head.phtml delete mode 100644 application/layout/include/standard/header.phtml delete mode 100644 application/layout/include/standard/top-css.phtml delete mode 100644 application/layout/standard.phtml delete mode 100644 application/modules/setup/syf43.twig.class.php diff --git a/.gitignore b/.gitignore index 0c591a7..e5edce0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ vendor -cache +application/include/vues/cache/* /composer.lock diff --git a/.idea/MVC---Objet.iml b/.idea/MVC---Objet.iml index 5ebfe3f..6ec0a77 100644 --- a/.idea/MVC---Objet.iml +++ b/.idea/MVC---Objet.iml @@ -2,9 +2,10 @@ - - + + + diff --git a/.idea/php.xml b/.idea/php.xml index a0a82de..c3ead44 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -11,6 +11,7 @@ + diff --git a/README.md b/README.md index 88da6bb..25f89e7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# MVC - en Programmation Orienté Objet +# Modular Symfony Application --- -Cette architecture MVC Objet est composée d'un layout HTML5 Standard +Cette architecture MVC Objet est composée d'un layout Blade (Laravel) Les urls d'accès sont de type www.domain.tld/page/varname1/varvalue1/varname2/varvalue2/ ... @@ -10,7 +10,7 @@ Afin de créer une nouvelle page vous devez instancier trois fichiers contenant "application > include > controlleurs > mapage.php" contenant: > les commandes permettant de gérer un formulaire > un ou plusieurs accès à la base de données -> les variables ainsi instanciées permettent l'affichage dans la vue +> les variables instanciées dans $templateData permettent l'affichage dans la vue blade "application > include > modeles > mapage.model" contenant >les variables spécifiques à la page de l'application exemple: @@ -19,10 +19,9 @@ name : le nom de mapage description : ma description pour les moteur de recherche params : paramètre(s) supplémentaire(s) ``` +"application > include > vues > view > mapage.blade.php contenant +> le layout blade a instancier -"application > include > vues > mapage.phtml" contenant ->les blocs html qui seront affichés dans le layout standard - -Je ne peut que vous proposer de regarder dans le dossier layout afin de comprendre comment cela est affiché! - -pour le reste, c'est a vous de voir, mais c'est une architecture fonctionnelle à 2.5 vitesses +pour les modules symfony, c'est un peu plus compliqué il faut instancier ces trois précédents fichiers en faisant appel la class Modular, +ne pas oublier de référencer le module dans le dossier modules > setup > registre.model +et faire correspondre le nom du dossier avec le registre, ici l'exemple est syf43. \ No newline at end of file diff --git a/application/class/Application.php b/application/class/Application.php index e2ea8fb..d758a9b 100644 --- a/application/class/Application.php +++ b/application/class/Application.php @@ -17,6 +17,7 @@ class Application public function launch(){ $controlleur = new Controlleur($this); + //si la page n'est un controlleur d'action alors on affiche l'écran if(!$this->url->page['control']) { print($controlleur->vue->ecran); } diff --git a/application/class/Controlleur.php b/application/class/Controlleur.php index b58d18d..2c98b3a 100644 --- a/application/class/Controlleur.php +++ b/application/class/Controlleur.php @@ -18,8 +18,8 @@ class Controlleur{ $url_params = $application->url->page['params']; require TRAITEMENT_PATH . DIRECTORY_SEPARATOR . $application->url->page['name'] . '.php'; } else { - $this->modele = new modele($application->url->page); - $this->vue = new vue($this); + $this->modele = new Modele($application->url->page); + $this->vue = new Vue($this); } } diff --git a/application/class/Url.php b/application/class/Url.php index 5b39ccd..32f7269 100644 --- a/application/class/Url.php +++ b/application/class/Url.php @@ -10,8 +10,10 @@ class Url public function __construct(){ + //on créé le registre des modules symfony $this->registre = new \MVC\Classe\ModularRegister(); + //définition des parametres de base $page = array(); $page['name'] = 'accueil'; $page['description'] = ""; @@ -42,18 +44,19 @@ class Url } - //vérification du nombre de parametres: s'il n'existe pas autant de clé que - // de valeurs on sort de la fonction et on renvoie une page d'erreur. + //vérification du nombre de parametres: $numParts = count($urlParts); - + //s'il n'existe pas autant de clé que de valeurs, ce peut ^etre un module symfony if ( $numParts%2 != 0 ) { + //si un module symfony n'est pas reférencé avec le nom de la page, on renvoi un erreur if( !in_array($page['name'], $this->registre->getIndex()) ){ $page['name'] = 'error'; $page['params'] = array(); $this->page = $page; return; } - }else if ( $numParts != 0 ){ + //cas d'utilisation normal : il existe autant de clé que de valeurs + } else if ( $numParts != 0 ) { $values = array(); $keys = array(); foreach( $urlParts as $key => $value ){ diff --git a/application/class/Vue.php b/application/class/Vue.php index 95f8ec8..eead4eb 100644 --- a/application/class/Vue.php +++ b/application/class/Vue.php @@ -15,24 +15,25 @@ class Vue{ $templateData = array(); extract( $baseControlleur->modele->page ); - //print_r($name); - ob_start(); + + //l'inclusion du controlleur doit renvoyer le tableau $templateData require CONTROLLER_PATH.DIRECTORY_SEPARATOR.$name.'.php'; $paths = new \SplPriorityQueue; + $paths->insert(VIEW_PATH.DIRECTORY_SEPARATOR."system", 100); - $paths->insert(VIEW_PATH.DIRECTORY_SEPARATOR."templating", 200); - //$paths->insert('path/to/theme', 300); + $paths->insert(VIEW_PATH.DIRECTORY_SEPARATOR."layout", 200); + $paths->insert(VIEW_PATH.DIRECTORY_SEPARATOR."view", 300); + $renderer = new \Windwalker\Renderer\BladeRenderer($paths, array('cache_path' => VIEW_PATH.DIRECTORY_SEPARATOR."cache")); + + //de base on ajoute les parametres du .model et ceux provenant de l'url + foreach($baseControlleur->modele->page as $key => $value){ + $templateData[$key] = $value; + } echo $renderer->render( $name , $templateData); - - /*require VIEW_PATH.DIRECTORY_SEPARATOR.$name.'.phtml'; - $this->block_body = ob_get_clean(); - - ob_start(); - require LAYOUT_PATH.DIRECTORY_SEPARATOR."standard.phtml";*/ $this->ecran = ob_get_clean(); } diff --git a/application/include/vues/accueil.phtml b/application/include/vues/accueil.phtml deleted file mode 100644 index e62bf6f..0000000 --- a/application/include/vues/accueil.phtml +++ /dev/null @@ -1,2 +0,0 @@ -

Accueil

-

\ No newline at end of file diff --git a/application/include/vues/error.phtml b/application/include/vues/error.phtml deleted file mode 100644 index ba6deab..0000000 --- a/application/include/vues/error.phtml +++ /dev/null @@ -1 +0,0 @@ -

ERREUR poo_v1

diff --git a/application/include/vues/layout/body.blade.php b/application/include/vues/layout/body.blade.php new file mode 100644 index 0000000..47174b9 --- /dev/null +++ b/application/include/vues/layout/body.blade.php @@ -0,0 +1,13 @@ +@extends('system') + +@section('body') + + @section('sidebar') + This is the master sidebar. + @show + +
+ @yield('content') +
+ +@endsection \ No newline at end of file diff --git a/application/include/vues/syf43.phtml b/application/include/vues/syf43.phtml deleted file mode 100644 index 8a1b49e..0000000 --- a/application/include/vues/syf43.phtml +++ /dev/null @@ -1 +0,0 @@ -load(); ?> \ No newline at end of file diff --git a/application/include/vues/system/layout.blade.php b/application/include/vues/system/layout.blade.php deleted file mode 100644 index 79c0d37..0000000 --- a/application/include/vues/system/layout.blade.php +++ /dev/null @@ -1,14 +0,0 @@ - - - App Name - - -@section('sidebar') - This is the master sidebar. -@show - -
- @yield('content') -
- - \ No newline at end of file diff --git a/application/include/vues/system/system.blade.php b/application/include/vues/system/system.blade.php new file mode 100644 index 0000000..b5be8c9 --- /dev/null +++ b/application/include/vues/system/system.blade.php @@ -0,0 +1,9 @@ + + + {{$page_title}} + + + +@yield('body') + + \ No newline at end of file diff --git a/application/include/vues/templating/accueil.blade.php b/application/include/vues/view/accueil.blade.php similarity index 92% rename from application/include/vues/templating/accueil.blade.php rename to application/include/vues/view/accueil.blade.php index 66b54f6..6620966 100644 --- a/application/include/vues/templating/accueil.blade.php +++ b/application/include/vues/view/accueil.blade.php @@ -1,4 +1,4 @@ -@extends('layout') +@extends('body') @section('sidebar') @parent diff --git a/application/include/vues/templating/error.blade.php b/application/include/vues/view/error.blade.php similarity index 100% rename from application/include/vues/templating/error.blade.php rename to application/include/vues/view/error.blade.php diff --git a/application/include/vues/templating/syf43.blade.php b/application/include/vues/view/syf43.blade.php similarity index 100% rename from application/include/vues/templating/syf43.blade.php rename to application/include/vues/view/syf43.blade.php diff --git a/application/layout/include/standard/body.phtml b/application/layout/include/standard/body.phtml deleted file mode 100644 index c395c5e..0000000 --- a/application/layout/include/standard/body.phtml +++ /dev/null @@ -1,4 +0,0 @@ - -
- block_body ?> -
diff --git a/application/layout/include/standard/bottom-javascript.phtml b/application/layout/include/standard/bottom-javascript.phtml deleted file mode 100644 index 44ef3b7..0000000 --- a/application/layout/include/standard/bottom-javascript.phtml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/application/layout/include/standard/footer.phtml b/application/layout/include/standard/footer.phtml deleted file mode 100644 index a141992..0000000 --- a/application/layout/include/standard/footer.phtml +++ /dev/null @@ -1,5 +0,0 @@ -
- - Follow Me on Github - -
\ No newline at end of file diff --git a/application/layout/include/standard/head.phtml b/application/layout/include/standard/head.phtml deleted file mode 100644 index 5797b16..0000000 --- a/application/layout/include/standard/head.phtml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - <?php echo $page_title; ?> - - - - - - - - - - - - diff --git a/application/layout/include/standard/header.phtml b/application/layout/include/standard/header.phtml deleted file mode 100644 index b300a45..0000000 --- a/application/layout/include/standard/header.phtml +++ /dev/null @@ -1,7 +0,0 @@ -
-

Menu Experiments

- -
diff --git a/application/layout/include/standard/top-css.phtml b/application/layout/include/standard/top-css.phtml deleted file mode 100644 index 76be61c..0000000 --- a/application/layout/include/standard/top-css.phtml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/application/layout/standard.phtml b/application/layout/standard.phtml deleted file mode 100644 index ee2f2ce..0000000 --- a/application/layout/standard.phtml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - -
- -
- - - - - - - - - diff --git a/application/modules/setup/syf43.twig.class.php b/application/modules/setup/syf43.twig.class.php deleted file mode 100644 index 3a4f60a..0000000 --- a/application/modules/setup/syf43.twig.class.php +++ /dev/null @@ -1,21 +0,0 @@ -launch(); +$poo_v5 = new \MVC\Classe\Application(); +$poo_v5->launch();