diff options
| author | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-10-23 00:47:32 +0200 |
| commit | f27cca08ff786ceff1870147f6d6bad14d71117f (patch) | |
| tree | d36597a72025313d6faf4ed228755fa267ebe2f6 | |
| parent | c7309f900ef05bd5cb313110ec159b761af394ec (diff) | |
| download | cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.gz cms-f27cca08ff786ceff1870147f6d6bad14d71117f.tar.bz2 cms-f27cca08ff786ceff1870147f6d6bad14d71117f.zip | |
dossiers avec majuscule, namespace pour toutes les classes, autoload psr-4, UserDataService::createZip déplacé dans Backup
| -rw-r--r-- | bin/copy_directory.php | 6 | ||||
| -rw-r--r-- | bin/cron.php | 7 | ||||
| -rwxr-xr-x | bin/doctrine | 7 | ||||
| -rwxr-xr-x | bin/mysqldump.php | 5 | ||||
| -rwxr-xr-x | bin/restore_db.php | 5 | ||||
| -rw-r--r-- | composer.json | 7 | ||||
| -rw-r--r-- | public/index.php | 10 | ||||
| -rw-r--r-- | src/Controller/ArticleController.php (renamed from src/controller/ArticleController.php) | 23 | ||||
| -rw-r--r-- | src/Controller/CalendarController.php (renamed from src/controller/CalendarController.php) | 19 | ||||
| -rw-r--r-- | src/Controller/ContactFormController.php (renamed from src/controller/ContactFormController.php) | 9 | ||||
| -rw-r--r-- | src/Controller/FileUploadController.php (renamed from src/controller/FileUploadController.php) | 7 | ||||
| -rw-r--r-- | src/Controller/HeadFootController.php (renamed from src/controller/HeadFootController.php) | 11 | ||||
| -rw-r--r-- | src/Controller/ImageUploadController.php (renamed from src/controller/ImageUploadController.php) | 17 | ||||
| -rw-r--r-- | src/Controller/MaintenanceController.php (renamed from src/controller/MaintenanceController.php) | 31 | ||||
| -rw-r--r-- | src/Controller/MenuAndPathsController.php (renamed from src/controller/MenuAndPathsController.php) | 11 | ||||
| -rw-r--r-- | src/Controller/PageManagementController.php (renamed from src/controller/PageManagementController.php) | 22 | ||||
| -rw-r--r-- | src/Controller/UserController.php (renamed from src/controller/UserController.php) | 13 | ||||
| -rw-r--r-- | src/Controller/ViewController.php (renamed from src/controller/ViewController.php) | 9 | ||||
| -rw-r--r-- | src/Model/DatabaseSettingUp.php (renamed from src/model/DatabaseSettingUp.php) | 6 | ||||
| -rw-r--r-- | src/Model/Entity/AppMetadata.php (renamed from src/model/entities/AppMetadata.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Article.php (renamed from src/model/entities/Article.php) | 4 | ||||
| -rw-r--r-- | src/Model/Entity/Asset.php (renamed from src/model/entities/Asset.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/AssetEmployment.php (renamed from src/model/entities/AssetEmployment.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Email.php (renamed from src/model/entities/Email.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/EmailForm.php (renamed from src/model/entities/EmailForm.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Event.php (renamed from src/model/entities/Event.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Image.php (renamed from src/model/entities/Image.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Log.php (renamed from src/model/entities/Log.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Node.php (renamed from src/model/entities/Node.php) | 5 | ||||
| -rw-r--r-- | src/Model/Entity/NodeData.php (renamed from src/model/entities/NodeData.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/Page.php (renamed from src/model/entities/Page.php) | 5 | ||||
| -rw-r--r-- | src/Model/Entity/Presentation.php (renamed from src/model/entities/Presentation.php) | 2 | ||||
| -rw-r--r-- | src/Model/Entity/User.php (renamed from src/model/entities/User.php) | 2 | ||||
| -rw-r--r-- | src/Model/EventDTO.php (renamed from src/model/EventDTO.php) | 4 | ||||
| -rw-r--r-- | src/Model/Menu.php (renamed from src/model/Menu.php) | 6 | ||||
| -rw-r--r-- | src/Model/Model.php (renamed from src/model/Model.php) | 10 | ||||
| -rw-r--r-- | src/Model/Path.php (renamed from src/model/Path.php) | 14 | ||||
| -rw-r--r-- | src/Model/Position.php (renamed from src/model/Position.php) | 4 | ||||
| -rw-r--r-- | src/Model/doctrine-bootstrap.php (renamed from src/model/doctrine-bootstrap.php) | 7 | ||||
| -rw-r--r-- | src/Service/Backup.php (renamed from src/service/Backup.php) | 51 | ||||
| -rw-r--r-- | src/Service/Captcha.php (renamed from src/service/Captcha.php) | 4 | ||||
| -rw-r--r-- | src/Service/Config.php (renamed from src/service/Config.php) | 4 | ||||
| -rw-r--r-- | src/Service/EmailService.php (renamed from src/service/EmailService.php) | 6 | ||||
| -rw-r--r-- | src/Service/FormValidation.php (renamed from src/service/FormValidation.php) | 6 | ||||
| -rw-r--r-- | src/Service/Installation.php (renamed from src/service/Installation.php) | 12 | ||||
| -rw-r--r-- | src/Service/Router.php (renamed from src/service/Router.php) | 21 | ||||
| -rw-r--r-- | src/Service/Security.php (renamed from src/service/Security.php) | 4 | ||||
| -rw-r--r-- | src/Service/URL.php (renamed from src/service/URL.php) | 6 | ||||
| -rw-r--r-- | src/Service/User.php (renamed from src/service/User.php) | 4 | ||||
| -rw-r--r-- | src/Service/session.php (renamed from src/service/session.php) | 6 | ||||
| -rw-r--r-- | src/View/AbstractBuilder.php (renamed from src/view/AbstractBuilder.php) | 12 | ||||
| -rw-r--r-- | src/View/BreadcrumbBuilder.php (renamed from src/view/BreadcrumbBuilder.php) | 11 | ||||
| -rw-r--r-- | src/View/CalendarBuilder.php (renamed from src/view/CalendarBuilder.php) | 4 | ||||
| -rw-r--r-- | src/View/FooterBuilder.php (renamed from src/view/FooterBuilder.php) | 7 | ||||
| -rw-r--r-- | src/View/FormBuilder.php (renamed from src/view/FormBuilder.php) | 11 | ||||
| -rw-r--r-- | src/View/GaleryBuilder.php (renamed from src/view/GaleryBuilder.php) | 4 | ||||
| -rw-r--r-- | src/View/HeadBuilder.php (renamed from src/view/HeadBuilder.php) | 5 | ||||
| -rw-r--r-- | src/View/HeaderBuilder.php (renamed from src/view/HeaderBuilder.php) | 16 | ||||
| -rw-r--r-- | src/View/LoginBuilder.php (renamed from src/view/LoginBuilder.php) | 6 | ||||
| -rw-r--r-- | src/View/MainBuilder.php (renamed from src/view/MainBuilder.php) | 10 | ||||
| -rw-r--r-- | src/View/MaintenanceBuilder.php (renamed from src/view/MaintenanceBuilder.php) | 7 | ||||
| -rw-r--r-- | src/View/MenuBuilder.php (renamed from src/view/MenuBuilder.php) | 6 | ||||
| -rw-r--r-- | src/View/NavBuilder.php (renamed from src/view/NavBuilder.php) | 10 | ||||
| -rw-r--r-- | src/View/NewBuilder.php (renamed from src/view/NewBuilder.php) | 7 | ||||
| -rw-r--r-- | src/View/NewPageBuilder.php (renamed from src/view/NewPageBuilder.php) | 8 | ||||
| -rw-r--r-- | src/View/NewsBlockBuilder.php (renamed from src/view/NewsBlockBuilder.php) | 5 | ||||
| -rw-r--r-- | src/View/PostBlockBuilder.php (renamed from src/view/PostBlockBuilder.php) | 4 | ||||
| -rw-r--r-- | src/View/PostBuilder.php (renamed from src/view/PostBuilder.php) | 5 | ||||
| -rw-r--r-- | src/View/ShowEmailsBuilder.php (renamed from src/view/ShowEmailsBuilder.php) | 6 | ||||
| -rw-r--r-- | src/View/UserEditBuilder.php (renamed from src/view/UserEditBuilder.php) | 12 | ||||
| -rw-r--r-- | src/View/ViewDirector.php (renamed from src/view/ViewDirector.php) | 4 | ||||
| -rw-r--r-- | src/View/templates/calendar.php (renamed from src/view/templates/calendar.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/footer.php (renamed from src/view/templates/footer.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/form.php (renamed from src/view/templates/form.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/form_admin.php (renamed from src/view/templates/form_admin.php) | 1 | ||||
| -rw-r--r-- | src/View/templates/galery.php (renamed from src/view/templates/galery.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/head.php (renamed from src/view/templates/head.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/header.php (renamed from src/view/templates/header.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/login.php (renamed from src/view/templates/login.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/maintenance.php (renamed from src/view/templates/maintenance.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/menu.php (renamed from src/view/templates/menu.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/modify_block.php (renamed from src/view/templates/modify_block.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/modify_page.php (renamed from src/view/templates/modify_page.php) | 6 | ||||
| -rw-r--r-- | src/View/templates/new.php (renamed from src/view/templates/new.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/new_page.php (renamed from src/view/templates/new_page.php) | 5 | ||||
| -rw-r--r-- | src/View/templates/news_block.php (renamed from src/view/templates/news_block.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/post.php (renamed from src/view/templates/post.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/post_block.php (renamed from src/view/templates/post_block.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/show_emails.php (renamed from src/view/templates/show_emails.php) | 0 | ||||
| -rw-r--r-- | src/View/templates/user_create.php (renamed from src/view/templates/user_create.php) | 1 | ||||
| -rw-r--r-- | src/View/templates/user_edit.php (renamed from src/view/templates/user_edit.php) | 0 | ||||
| -rw-r--r-- | src/service/UserDataService.php | 46 |
92 files changed, 448 insertions, 231 deletions
diff --git a/bin/copy_directory.php b/bin/copy_directory.php index 20e4821..0e0afe1 100644 --- a/bin/copy_directory.php +++ b/bin/copy_directory.php | |||
| @@ -15,9 +15,9 @@ function copyDirectory(string $source, string $destination): void | |||
| 15 | mkdir($destination, 0755, true); | 15 | mkdir($destination, 0755, true); |
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | $iterator = new RecursiveIteratorIterator( | 18 | $iterator = new \RecursiveIteratorIterator( |
| 19 | new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS), | 19 | new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS), |
| 20 | RecursiveIteratorIterator::SELF_FIRST | 20 | \RecursiveIteratorIterator::SELF_FIRST |
| 21 | ); | 21 | ); |
| 22 | 22 | ||
| 23 | foreach($iterator as $item){ | 23 | foreach($iterator as $item){ |
diff --git a/bin/cron.php b/bin/cron.php index 5e158a4..14bb460 100644 --- a/bin/cron.php +++ b/bin/cron.php | |||
| @@ -4,9 +4,12 @@ | |||
| 4 | 4 | ||
| 5 | declare(strict_types=1); | 5 | declare(strict_types=1); |
| 6 | 6 | ||
| 7 | use App\Service\Config; | ||
| 8 | use App\Service\EmailService; | ||
| 9 | |||
| 7 | chdir(dirname(__FILE__)); // = /chemin/du/site/bin = même niveau que public/ | 10 | chdir(dirname(__FILE__)); // = /chemin/du/site/bin = même niveau que public/ |
| 8 | require('../src/Config.php'); | 11 | require('../src/Service/Config.php'); |
| 9 | Config::load('../config/config.ini'); | 12 | Config::load('../config/config.ini'); |
| 10 | require '../src/model/doctrine-bootstrap.php'; | 13 | require '../src/Model/doctrine-bootstrap.php'; |
| 11 | 14 | ||
| 12 | EmailService::cleanEmails($entityManager); \ No newline at end of file | 15 | EmailService::cleanEmails($entityManager); \ No newline at end of file |
diff --git a/bin/doctrine b/bin/doctrine index 8cfd5d0..e92490c 100755 --- a/bin/doctrine +++ b/bin/doctrine | |||
| @@ -4,14 +4,15 @@ | |||
| 4 | 4 | ||
| 5 | use Doctrine\ORM\Tools\Console\ConsoleRunner; | 5 | use Doctrine\ORM\Tools\Console\ConsoleRunner; |
| 6 | use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; | 6 | use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider; |
| 7 | use App\Service\Config; | ||
| 7 | 8 | ||
| 8 | chdir(dirname(__FILE__)); // pour être au même niveau que l'appli dans /public | 9 | chdir(dirname(__FILE__)); // pour être au même niveau que l'appli dans /public |
| 9 | 10 | ||
| 10 | require('../src/service/Config.php'); | 11 | require('../src/Service/Config.php'); |
| 11 | Config::load('../config/config.ini'); | 12 | Config::load('../config/config.ini'); |
| 12 | 13 | ||
| 13 | require '../src/model/doctrine-bootstrap.php'; // relatif | 14 | require '../src/Model/doctrine-bootstrap.php'; // relatif |
| 14 | //require __DIR__ . '/../src/model/doctrine-bootstrap.php'; // absolu | 15 | //require __DIR__ . '/../src/Model/doctrine-bootstrap.php'; // absolu |
| 15 | 16 | ||
| 16 | ConsoleRunner::run( | 17 | ConsoleRunner::run( |
| 17 | new SingleManagerProvider($entityManager) | 18 | new SingleManagerProvider($entityManager) |
diff --git a/bin/mysqldump.php b/bin/mysqldump.php index 7d8e960..3a63da9 100755 --- a/bin/mysqldump.php +++ b/bin/mysqldump.php | |||
| @@ -4,10 +4,13 @@ | |||
| 4 | 4 | ||
| 5 | declare(strict_types=1); | 5 | declare(strict_types=1); |
| 6 | 6 | ||
| 7 | use App\Service\Config; | ||
| 8 | use App\Service\Backup; | ||
| 9 | |||
| 7 | chdir(dirname(__FILE__)); | 10 | chdir(dirname(__FILE__)); |
| 8 | require "../vendor/autoload.php"; | 11 | require "../vendor/autoload.php"; |
| 9 | Config::load('../config/config.ini'); | 12 | Config::load('../config/config.ini'); |
| 10 | require '../src/model/doctrine-bootstrap.php'; | 13 | require '../src/Model/doctrine-bootstrap.php'; |
| 11 | 14 | ||
| 12 | $file_name = Backup::mySQLdump($entityManager, 'console'); // créer un nouveau backup | 15 | $file_name = Backup::mySQLdump($entityManager, 'console'); // créer un nouveau backup |
| 13 | echo "Un backup a été créé:\n" . realpath($file_name) . "\n"; \ No newline at end of file | 16 | echo "Un backup a été créé:\n" . realpath($file_name) . "\n"; \ No newline at end of file |
diff --git a/bin/restore_db.php b/bin/restore_db.php index c54aaa9..3fcddc1 100755 --- a/bin/restore_db.php +++ b/bin/restore_db.php | |||
| @@ -4,6 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | declare(strict_types=1); | 5 | declare(strict_types=1); |
| 6 | 6 | ||
| 7 | use App\Service\Config; | ||
| 8 | use App\Service\Backup; | ||
| 9 | |||
| 7 | if($argc === 2){ | 10 | if($argc === 2){ |
| 8 | if(pathinfo($argv[1])['extension'] !== 'sql'){ | 11 | if(pathinfo($argv[1])['extension'] !== 'sql'){ |
| 9 | try{ | 12 | try{ |
| @@ -21,7 +24,7 @@ if($argc === 2){ | |||
| 21 | chdir(dirname(__FILE__)); // /chemin/absolu/bin/restore_db.php | 24 | chdir(dirname(__FILE__)); // /chemin/absolu/bin/restore_db.php |
| 22 | require "../vendor/autoload.php"; | 25 | require "../vendor/autoload.php"; |
| 23 | Config::load('../config/config.ini'); | 26 | Config::load('../config/config.ini'); |
| 24 | require '../src/model/doctrine-bootstrap.php'; | 27 | require '../src/Model/doctrine-bootstrap.php'; |
| 25 | 28 | ||
| 26 | // backup sur le système de fichiers en paramètre | 29 | // backup sur le système de fichiers en paramètre |
| 27 | if($argc === 2){ | 30 | if($argc === 2){ |
diff --git a/composer.json b/composer.json index 1978a0e..8c38f28 100644 --- a/composer.json +++ b/composer.json | |||
| @@ -36,6 +36,9 @@ | |||
| 36 | } | 36 | } |
| 37 | ], | 37 | ], |
| 38 | "autoload": { | 38 | "autoload": { |
| 39 | "classmap": ["src/"] | 39 | "psr-4": { |
| 40 | } | 40 | "App\\Entity\\": "src/Model/Entity/", |
| 41 | "App\\": "src/" | ||
| 42 | } | ||
| 43 | } | ||
| 41 | } | 44 | } |
diff --git a/public/index.php b/public/index.php index 19011d1..6032dfd 100644 --- a/public/index.php +++ b/public/index.php | |||
| @@ -14,7 +14,11 @@ | |||
| 14 | declare(strict_types=1); | 14 | declare(strict_types=1); |
| 15 | 15 | ||
| 16 | use Symfony\Component\HttpFoundation\Request; | 16 | use Symfony\Component\HttpFoundation\Request; |
| 17 | 17 | use App\Model\DatabaseSettingUp; | |
| 18 | use App\Service\Config; | ||
| 19 | use App\Service\URL; | ||
| 20 | use App\Service\Installation; | ||
| 21 | use App\Service\Router; | ||
| 18 | 22 | ||
| 19 | /* -- partie 1: prétraitement -- | 23 | /* -- partie 1: prétraitement -- |
| 20 | code à exécuter pour toutes requêtes */ | 24 | code à exécuter pour toutes requêtes */ |
| @@ -31,10 +35,10 @@ URL::setPort(Config::$port); | |||
| 31 | URL::setHost($_SERVER['HTTP_HOST'] . Config::$index_path); | 35 | URL::setHost($_SERVER['HTTP_HOST'] . Config::$index_path); |
| 32 | 36 | ||
| 33 | // $entityManager | 37 | // $entityManager |
| 34 | require '../src/model/doctrine-bootstrap.php'; // isDevMode est sur "true", DSN à adapter | 38 | require '../src/Model/doctrine-bootstrap.php'; // isDevMode est sur "true", DSN à adapter |
| 35 | 39 | ||
| 36 | // session | 40 | // session |
| 37 | require('../src/service/session.php'); | 41 | require('../src/Service/session.php'); |
| 38 | startSession($entityManager); | 42 | startSession($entityManager); |
| 39 | 43 | ||
| 40 | // tests de bon fonctionnement | 44 | // tests de bon fonctionnement |
diff --git a/src/controller/ArticleController.php b/src/Controller/ArticleController.php index 0ddb0e1..075e3b4 100644 --- a/src/controller/ArticleController.php +++ b/src/Controller/ArticleController.php | |||
| @@ -1,16 +1,21 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/ArticleController.php | 2 | // src/Controller/ArticleController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\Node; | 6 | namespace App\Controller; |
| 7 | use App\Entity\Article; | 7 | |
| 8 | use App\Entity\Presentation; | ||
| 9 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 10 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
| 11 | use Symfony\Component\HttpFoundation\Response; | 10 | use Symfony\Component\HttpFoundation\Response; |
| 12 | use Symfony\Component\HttpFoundation\JsonResponse; | 11 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 13 | use Symfony\Component\HttpFoundation\RedirectResponse; | 12 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 13 | use App\Entity\Node; | ||
| 14 | use App\Entity\Article; | ||
| 15 | use App\Entity\Presentation; | ||
| 16 | use App\Model\Model; | ||
| 17 | use App\Service\URL; | ||
| 18 | use App\Service\Security; | ||
| 14 | 19 | ||
| 15 | class ArticleController | 20 | class ArticleController |
| 16 | { | 21 | { |
| @@ -27,10 +32,10 @@ class ArticleController | |||
| 27 | $bulk_data = $get_articles_return[0]; | 32 | $bulk_data = $get_articles_return[0]; |
| 28 | 33 | ||
| 29 | if($parent_block->getName() === 'post_block'){ | 34 | if($parent_block->getName() === 'post_block'){ |
| 30 | $builder_name = 'PostBuilder'; | 35 | $builder_name = 'App\View\PostBuilder'; |
| 31 | } | 36 | } |
| 32 | elseif($parent_block->getName() === 'news_block'){ | 37 | elseif($parent_block->getName() === 'news_block'){ |
| 33 | $builder_name = 'NewBuilder'; | 38 | $builder_name = 'App\View\NewBuilder'; |
| 34 | } | 39 | } |
| 35 | else{ | 40 | else{ |
| 36 | return new JsonResponse(['success' => false, 'error' => 'server side error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR); | 41 | return new JsonResponse(['success' => false, 'error' => 'server side error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR); |
| @@ -176,7 +181,7 @@ class ArticleController | |||
| 176 | $entityManager->flush(); | 181 | $entityManager->flush(); |
| 177 | $params = ['true', 'Article supprimé avec succès']; | 182 | $params = ['true', 'Article supprimé avec succès']; |
| 178 | } | 183 | } |
| 179 | catch(Exception $e){ | 184 | catch(\Exception $e){ |
| 180 | $params = ['false', 'Erreur 500 ' . $e->getMessage()]; | 185 | $params = ['false', 'Erreur 500 ' . $e->getMessage()]; |
| 181 | } | 186 | } |
| 182 | } | 187 | } |
| @@ -193,7 +198,7 @@ class ArticleController | |||
| 193 | } | 198 | } |
| 194 | else{ | 199 | else{ |
| 195 | // cas inaccesible | 200 | // cas inaccesible |
| 196 | throw new Exception('la méthode deleteArticle ne peut être appelée de cette manière'); | 201 | throw new \Exception('la méthode deleteArticle ne peut être appelée de cette manière'); |
| 197 | } | 202 | } |
| 198 | } | 203 | } |
| 199 | 204 | ||
| @@ -226,7 +231,7 @@ class ArticleController | |||
| 226 | static public function dateSubmit(EntityManager $entityManager, array $json): JsonResponse | 231 | static public function dateSubmit(EntityManager $entityManager, array $json): JsonResponse |
| 227 | { | 232 | { |
| 228 | $id = substr($json['id'], 1); | 233 | $id = substr($json['id'], 1); |
| 229 | $date = new DateTime($json['date']); | 234 | $date = new \DateTime($json['date']); |
| 230 | 235 | ||
| 231 | $model = new Model($entityManager); | 236 | $model = new Model($entityManager); |
| 232 | $model->makeArticleNode($id); | 237 | $model->makeArticleNode($id); |
diff --git a/src/controller/CalendarController.php b/src/Controller/CalendarController.php index 1a62afa..679ff8a 100644 --- a/src/controller/CalendarController.php +++ b/src/Controller/CalendarController.php | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // /src/controller/CalendarController.php | 2 | // /src/Controller/CalendarController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 6 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 7 | use App\Entity\Event; | ||
| 8 | use Symfony\Component\HttpFoundation\JsonResponse; | 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 10 | use App\Entity\Event; | ||
| 11 | use App\Model\EventDTO; | ||
| 9 | 12 | ||
| 10 | class CalendarController | 13 | class CalendarController |
| 11 | { | 14 | { |
| @@ -13,10 +16,10 @@ class CalendarController | |||
| 13 | { | 16 | { |
| 14 | // bornes début et fin du calendrier affiché à l'heure locale | 17 | // bornes début et fin du calendrier affiché à l'heure locale |
| 15 | // noter que la vue "planning" est similaire à la vue "semaine" | 18 | // noter que la vue "planning" est similaire à la vue "semaine" |
| 16 | $start = new DateTime($_GET['start']); | 19 | $start = new \DateTime($_GET['start']); |
| 17 | $end = new DateTime($_GET['end']); | 20 | $end = new \DateTime($_GET['end']); |
| 18 | $start->setTimezone(new DateTimeZone('UTC')); | 21 | $start->setTimezone(new \DateTimeZone('UTC')); |
| 19 | $end->setTimezone(new DateTimeZone('UTC')); | 22 | $end->setTimezone(new \DateTimeZone('UTC')); |
| 20 | 23 | ||
| 21 | // affichage format ISO à l'heure UTC | 24 | // affichage format ISO à l'heure UTC |
| 22 | //$date->format('Y-m-d\TH:i:s\Z'); | 25 | //$date->format('Y-m-d\TH:i:s\Z'); |
| @@ -42,7 +45,7 @@ class CalendarController | |||
| 42 | try{ | 45 | try{ |
| 43 | $event = new Event($json); | 46 | $event = new Event($json); |
| 44 | } | 47 | } |
| 45 | catch(InvalidArgumentException $e){ | 48 | catch(\InvalidArgumentException $e){ |
| 46 | return new JsonResponse(['success' => false, 'error' => $e->getMessage()], JsonResponse::HTTP_BAD_REQUEST); // code 400 | 49 | return new JsonResponse(['success' => false, 'error' => $e->getMessage()], JsonResponse::HTTP_BAD_REQUEST); // code 400 |
| 47 | } | 50 | } |
| 48 | $entityManager->persist($event); | 51 | $entityManager->persist($event); |
| @@ -56,7 +59,7 @@ class CalendarController | |||
| 56 | try{ | 59 | try{ |
| 57 | $event->securedUpdateFromJSON($json); | 60 | $event->securedUpdateFromJSON($json); |
| 58 | } | 61 | } |
| 59 | catch(InvalidArgumentException $e){ | 62 | catch(\InvalidArgumentException $e){ |
| 60 | return new JsonResponse(['success' => false, 'error' => $e->getMessage()], JsonResponse::HTTP_BAD_REQUEST); // code 400 | 63 | return new JsonResponse(['success' => false, 'error' => $e->getMessage()], JsonResponse::HTTP_BAD_REQUEST); // code 400 |
| 61 | } | 64 | } |
| 62 | $entityManager->flush(); | 65 | $entityManager->flush(); |
diff --git a/src/controller/ContactFormController.php b/src/Controller/ContactFormController.php index 82e9b17..56ef402 100644 --- a/src/controller/ContactFormController.php +++ b/src/Controller/ContactFormController.php | |||
| @@ -1,12 +1,17 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/ContactFormController.php | 2 | // src/Controller/ContactFormController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 8 | use Symfony\Component\HttpFoundation\JsonResponse; | ||
| 6 | use Doctrine\ORM\EntityManager; | 9 | use Doctrine\ORM\EntityManager; |
| 7 | use App\Entity\EmailForm; | 10 | use App\Entity\EmailForm; |
| 8 | use App\Entity\Email; | 11 | use App\Entity\Email; |
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; | 12 | use App\Service\EmailService; |
| 13 | use App\Service\FormValidation; | ||
| 14 | use App\Service\ValidationStrategy; | ||
| 10 | 15 | ||
| 11 | class ContactFormController | 16 | class ContactFormController |
| 12 | { | 17 | { |
diff --git a/src/controller/FileUploadController.php b/src/Controller/FileUploadController.php index 3cd5e6b..4627017 100644 --- a/src/controller/FileUploadController.php +++ b/src/Controller/FileUploadController.php | |||
| @@ -1,9 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/FileUploadController.php | 2 | // src/Controller/FileUploadController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 6 | use Symfony\Component\HttpFoundation\JsonResponse; | 8 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 9 | use App\Service\Security; | ||
| 7 | 10 | ||
| 8 | class FileUploadController | 11 | class FileUploadController |
| 9 | { | 12 | { |
| @@ -24,7 +27,7 @@ class FileUploadController | |||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | // 3/ objet $finfo valide (dépend du paramètre FILEINFO_MIME_TYPE) | 29 | // 3/ objet $finfo valide (dépend du paramètre FILEINFO_MIME_TYPE) |
| 27 | $finfo = new finfo(FILEINFO_MIME_TYPE); | 30 | $finfo = new \finfo(FILEINFO_MIME_TYPE); |
| 28 | if($finfo === false){ | 31 | if($finfo === false){ |
| 29 | return false; | 32 | return false; |
| 30 | } | 33 | } |
diff --git a/src/controller/HeadFootController.php b/src/Controller/HeadFootController.php index 72487d8..e39c07b 100644 --- a/src/controller/HeadFootController.php +++ b/src/Controller/HeadFootController.php | |||
| @@ -1,13 +1,18 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/HeadFootController.php | 2 | // src/Controller/HeadFootController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 8 | use Doctrine\ORM\EntityManager; | ||
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; | ||
| 6 | use App\Entity\NodeData; | 10 | use App\Entity\NodeData; |
| 7 | use App\Entity\Asset; | 11 | use App\Entity\Asset; |
| 8 | use App\Entity\AssetEmployment; | 12 | use App\Entity\AssetEmployment; |
| 9 | use Doctrine\ORM\EntityManager; | 13 | use App\Model\Model; |
| 10 | use Symfony\Component\HttpFoundation\JsonResponse; | 14 | use App\Controller\ImageUploadController; |
| 15 | use App\Service\Security; | ||
| 11 | 16 | ||
| 12 | class HeadFootController | 17 | class HeadFootController |
| 13 | { | 18 | { |
diff --git a/src/controller/ImageUploadController.php b/src/Controller/ImageUploadController.php index af9a553..4ca9f48 100644 --- a/src/controller/ImageUploadController.php +++ b/src/Controller/ImageUploadController.php | |||
| @@ -1,9 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/ImageUploadController.php | 2 | // src/Controller/ImageUploadController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 6 | use Symfony\Component\HttpFoundation\JsonResponse; | 8 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 9 | use App\Service\Security; | ||
| 7 | 10 | ||
| 8 | class ImageUploadController | 11 | class ImageUploadController |
| 9 | { | 12 | { |
| @@ -13,7 +16,7 @@ class ImageUploadController | |||
| 13 | { | 16 | { |
| 14 | $format = strtolower(pathinfo($local_path)['extension']); | 17 | $format = strtolower(pathinfo($local_path)['extension']); |
| 15 | try{ | 18 | try{ |
| 16 | $imagick = new Imagick(); | 19 | $imagick = new \Imagick(); |
| 17 | $imagick->readImageBlob($image_data); | 20 | $imagick->readImageBlob($image_data); |
| 18 | $imagick->stripImage(); // nettoyage métadonnées | 21 | $imagick->stripImage(); // nettoyage métadonnées |
| 19 | //$imagick->setImageFormat($format); // inutile, writeImage force la conversion | 22 | //$imagick->setImageFormat($format); // inutile, writeImage force la conversion |
| @@ -22,19 +25,19 @@ class ImageUploadController | |||
| 22 | switch($format){ | 25 | switch($format){ |
| 23 | case 'jpeg': // particularité du switch, si 'jpeg' le test de 'jpg' est ignoré et on va jusqu'au break | 26 | case 'jpeg': // particularité du switch, si 'jpeg' le test de 'jpg' est ignoré et on va jusqu'au break |
| 24 | case 'jpg': | 27 | case 'jpg': |
| 25 | $imagick->setImageCompression(Imagick::COMPRESSION_JPEG); | 28 | $imagick->setImageCompression(\Imagick::COMPRESSION_JPEG); |
| 26 | $imagick->setImageCompressionQuality(85); | 29 | $imagick->setImageCompressionQuality(85); |
| 27 | break; | 30 | break; |
| 28 | case 'webp': | 31 | case 'webp': |
| 29 | $imagick->setImageCompression(Imagick::COMPRESSION_WEBP); | 32 | $imagick->setImageCompression(\Imagick::COMPRESSION_WEBP); |
| 30 | $imagick->setImageCompressionQuality(85); | 33 | $imagick->setImageCompressionQuality(85); |
| 31 | break; | 34 | break; |
| 32 | case 'png': | 35 | case 'png': |
| 33 | $imagick->setImageCompression(Imagick::COMPRESSION_ZIP); | 36 | $imagick->setImageCompression(\Imagick::COMPRESSION_ZIP); |
| 34 | $imagick->setImageCompressionQuality(7); // 9 est sans perte | 37 | $imagick->setImageCompressionQuality(7); // 9 est sans perte |
| 35 | break; | 38 | break; |
| 36 | case 'tiff': | 39 | case 'tiff': |
| 37 | $imagick->setImageCompression(Imagick::COMPRESSION_LZW); // LZW est sans perte | 40 | $imagick->setImageCompression(\Imagick::COMPRESSION_LZW); // LZW est sans perte |
| 38 | break; | 41 | break; |
| 39 | } | 42 | } |
| 40 | 43 | ||
| @@ -46,7 +49,7 @@ class ImageUploadController | |||
| 46 | $imagick->destroy(); | 49 | $imagick->destroy(); |
| 47 | return true; | 50 | return true; |
| 48 | } | 51 | } |
| 49 | catch(Exception $e){ | 52 | catch(\Exception $e){ |
| 50 | return false; | 53 | return false; |
| 51 | } | 54 | } |
| 52 | } | 55 | } |
diff --git a/src/controller/MaintenanceController.php b/src/Controller/MaintenanceController.php index 5b67fa8..d3be2a1 100644 --- a/src/controller/MaintenanceController.php +++ b/src/Controller/MaintenanceController.php | |||
| @@ -1,15 +1,20 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/MaintenanceController.php | 2 | // src/Controller/MaintenanceController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use Doctrine\ORM\EntityManager; | 6 | namespace App\Controller; |
| 7 | use App\Entity\log; | 7 | |
| 8 | use Symfony\Component\HttpFoundation\Request; | 8 | use Symfony\Component\HttpFoundation\Request; |
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; | 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 10 | use Symfony\Component\HttpFoundation\BinaryFileResponse; | 10 | use Symfony\Component\HttpFoundation\BinaryFileResponse; |
| 11 | use Symfony\Component\HttpFoundation\ResponseHeaderBag; | 11 | use Symfony\Component\HttpFoundation\ResponseHeaderBag; |
| 12 | use Symfony\Component\HttpFoundation\RedirectResponse; | 12 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 13 | use Doctrine\ORM\EntityManager; | ||
| 14 | use App\Entity\log; | ||
| 15 | use App\Service\Backup; | ||
| 16 | use App\Service\URL; | ||
| 17 | use App\Service\Config; | ||
| 13 | 18 | ||
| 14 | class MaintenanceController | 19 | class MaintenanceController |
| 15 | { | 20 | { |
| @@ -46,7 +51,7 @@ class MaintenanceController | |||
| 46 | $entityManager->getConnection()->executeStatement("TRUNCATE TABLE {$table}"); // SQL donné à DBAL | 51 | $entityManager->getConnection()->executeStatement("TRUNCATE TABLE {$table}"); // SQL donné à DBAL |
| 47 | return new JsonResponse(['success' => true]); | 52 | return new JsonResponse(['success' => true]); |
| 48 | } | 53 | } |
| 49 | catch(Exception $e){ | 54 | catch(\Exception $e){ |
| 50 | return new JsonResponse(['success' => false, 'error' => $e->getMessage()]); | 55 | return new JsonResponse(['success' => false, 'error' => $e->getMessage()]); |
| 51 | } | 56 | } |
| 52 | } | 57 | } |
| @@ -62,7 +67,7 @@ class MaintenanceController | |||
| 62 | $backup_list = Backup::getBackupList(); | 67 | $backup_list = Backup::getBackupList(); |
| 63 | $nb = count($backup_list); | 68 | $nb = count($backup_list); |
| 64 | if($nb <= 0){ // improbable, les dossiers devraient déjà avoir été créés | 69 | if($nb <= 0){ // improbable, les dossiers devraient déjà avoir été créés |
| 65 | throw new RuntimeException("Le serveur a rencontré une erreur: aucun backup n'est disponible et ce n'est pas normal."); | 70 | throw new \RuntimeException("Le serveur a rencontré une erreur: aucun backup n'est disponible et ce n'est pas normal."); |
| 66 | } | 71 | } |
| 67 | } | 72 | } |
| 68 | 73 | ||
| @@ -70,7 +75,7 @@ class MaintenanceController | |||
| 70 | $response = new BinaryFileResponse($file_path); | 75 | $response = new BinaryFileResponse($file_path); |
| 71 | $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); // ne pas essayer de l'afficher dans le navigateur | 76 | $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); // ne pas essayer de l'afficher dans le navigateur |
| 72 | } | 77 | } |
| 73 | catch(RuntimeException $e){ | 78 | catch(\RuntimeException $e){ |
| 74 | $_SESSION['flash_message'] = $e->getMessage(); | 79 | $_SESSION['flash_message'] = $e->getMessage(); |
| 75 | $response = new RedirectResponse((string) new URL(['page' => 'maintenance'])); | 80 | $response = new RedirectResponse((string) new URL(['page' => 'maintenance'])); |
| 76 | } | 81 | } |
| @@ -79,11 +84,11 @@ class MaintenanceController | |||
| 79 | static public function getAllMedia(): BinaryFileResponse|RedirectResponse | 84 | static public function getAllMedia(): BinaryFileResponse|RedirectResponse |
| 80 | { | 85 | { |
| 81 | try{ | 86 | try{ |
| 82 | $file_path = '../var/' . UserDataService::createZip('all_media.zip', ['user_data/assets', 'user_data/images', 'user_data/media']); | 87 | $file_path = '../var/' . Backup::createZip('all_media.zip', ['user_data/assets', 'user_data/images', 'user_data/media']); |
| 83 | $response = new BinaryFileResponse($file_path); | 88 | $response = new BinaryFileResponse($file_path); |
| 84 | $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); // ne pas essayer de l'afficher dans le navigateur | 89 | $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); // ne pas essayer de l'afficher dans le navigateur |
| 85 | } | 90 | } |
| 86 | catch(RuntimeException $e){ | 91 | catch(\RuntimeException $e){ |
| 87 | $_SESSION['flash_message'] = $e->getMessage(); | 92 | $_SESSION['flash_message'] = $e->getMessage(); |
| 88 | $response = new RedirectResponse((string) new URL(['page' => 'maintenance'])); | 93 | $response = new RedirectResponse((string) new URL(['page' => 'maintenance'])); |
| 89 | } | 94 | } |
| @@ -101,13 +106,13 @@ class MaintenanceController | |||
| 101 | 106 | ||
| 102 | try{ | 107 | try{ |
| 103 | if(pathinfo($selected_file)['extension'] !== 'sql'){ // pas censé se produire en fait | 108 | if(pathinfo($selected_file)['extension'] !== 'sql'){ // pas censé se produire en fait |
| 104 | throw new Exception("charger un fichier au format SQL"); | 109 | throw new \Exception("charger un fichier au format SQL"); |
| 105 | } | 110 | } |
| 106 | Backup::restoreDatabase($entityManager, $selected_file, ['user']); | 111 | Backup::restoreDatabase($entityManager, $selected_file, ['user']); |
| 107 | 112 | ||
| 108 | $_SESSION['flash_message'] = "La base de données a été restaurée avec succès !!"; | 113 | $_SESSION['flash_message'] = "La base de données a été restaurée avec succès !!"; |
| 109 | } | 114 | } |
| 110 | catch(Exception $e){ | 115 | catch(\Exception $e){ |
| 111 | $_SESSION['flash_message'] = "Une erreur s'est produite: " . $e->getMessage(); | 116 | $_SESSION['flash_message'] = "Une erreur s'est produite: " . $e->getMessage(); |
| 112 | } | 117 | } |
| 113 | 118 | ||
| @@ -117,7 +122,7 @@ class MaintenanceController | |||
| 117 | static public function downloadSQL(EntityManager $entityManager, Request $request): RedirectResponse | 122 | static public function downloadSQL(EntityManager $entityManager, Request $request): RedirectResponse |
| 118 | { | 123 | { |
| 119 | $uploaded_file = $request->files->get('uploaded_sql'); | 124 | $uploaded_file = $request->files->get('uploaded_sql'); |
| 120 | $date = new DateTime; | 125 | $date = new \DateTime; |
| 121 | $server_place = Config::$database . '_' . $date->format('Y-m-d') . '_uploaded.sql'; | 126 | $server_place = Config::$database . '_' . $date->format('Y-m-d') . '_uploaded.sql'; |
| 122 | $url = new URL; | 127 | $url = new URL; |
| 123 | if($request->query->has('from')){ | 128 | if($request->query->has('from')){ |
| @@ -126,7 +131,7 @@ class MaintenanceController | |||
| 126 | 131 | ||
| 127 | try{ | 132 | try{ |
| 128 | if(pathinfo($uploaded_file->getClientOriginalName())['extension'] !== 'sql'){ | 133 | if(pathinfo($uploaded_file->getClientOriginalName())['extension'] !== 'sql'){ |
| 129 | throw new Exception("Charger un fichier au format SQL"); | 134 | throw new \Exception("Charger un fichier au format SQL"); |
| 130 | } | 135 | } |
| 131 | //echo $uploaded_file->getSize(); // à garder de côté au cas où | 136 | //echo $uploaded_file->getSize(); // à garder de côté au cas où |
| 132 | 137 | ||
| @@ -138,7 +143,7 @@ class MaintenanceController | |||
| 138 | 143 | ||
| 139 | $_SESSION['flash_message'] = "La base de données a été restaurée avec succès !!"; | 144 | $_SESSION['flash_message'] = "La base de données a été restaurée avec succès !!"; |
| 140 | } | 145 | } |
| 141 | catch(Exception $e){ | 146 | catch(\Exception $e){ |
| 142 | $_SESSION['flash_message'] = "Une erreur s'est produite: " . $e->getMessage(); | 147 | $_SESSION['flash_message'] = "Une erreur s'est produite: " . $e->getMessage(); |
| 143 | } | 148 | } |
| 144 | 149 | ||
diff --git a/src/controller/MenuAndPathsController.php b/src/Controller/MenuAndPathsController.php index 9bd6ad1..1916f06 100644 --- a/src/controller/MenuAndPathsController.php +++ b/src/Controller/MenuAndPathsController.php | |||
| @@ -1,12 +1,19 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/MenuAndPathsController.php | 2 | // src/Controller/MenuAndPathsController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\Page; | 6 | namespace App\Controller; |
| 7 | |||
| 7 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 8 | use Symfony\Component\HttpFoundation\JsonResponse; | 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 9 | use Symfony\Component\HttpFoundation\RedirectResponse; | 10 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 11 | use App\Entity\Page; | ||
| 12 | use App\Model\Menu; | ||
| 13 | use App\Model\Model; | ||
| 14 | use App\Service\URL; | ||
| 15 | use App\View\NavBuilder; | ||
| 16 | use App\View\MenuBuilder; | ||
| 10 | 17 | ||
| 11 | class MenuAndPathsController | 18 | class MenuAndPathsController |
| 12 | { | 19 | { |
diff --git a/src/controller/PageManagementController.php b/src/Controller/PageManagementController.php index 11aab09..02e6e6a 100644 --- a/src/controller/PageManagementController.php +++ b/src/Controller/PageManagementController.php | |||
| @@ -1,19 +1,25 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/PageManagementController.php | 2 | // src/Controller/PageManagementController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 8 | use Doctrine\ORM\EntityManager; | ||
| 9 | use Symfony\Component\HttpFoundation\InputBag; | ||
| 10 | use Symfony\Component\HttpFoundation\JsonResponse; | ||
| 11 | use Symfony\Component\HttpFoundation\RedirectResponse; | ||
| 12 | use Symfony\Component\HttpFoundation\Request; | ||
| 6 | use App\Entity\Page; | 13 | use App\Entity\Page; |
| 7 | use App\Entity\Node; | 14 | use App\Entity\Node; |
| 8 | use App\Entity\NodeData; | 15 | use App\Entity\NodeData; |
| 9 | use App\Entity\EmailForm; | 16 | use App\Entity\EmailForm; |
| 10 | use App\Entity\Presentation; | 17 | use App\Entity\Presentation; |
| 11 | //use App\Entity\Image; | 18 | //use App\Entity\Image; |
| 12 | use Doctrine\ORM\EntityManager; | 19 | use App\Model\Model; |
| 13 | use Symfony\Component\HttpFoundation\InputBag; | 20 | use App\Model\Menu; |
| 14 | use Symfony\Component\HttpFoundation\JsonResponse; | 21 | use App\Model\Path; |
| 15 | use Symfony\Component\HttpFoundation\RedirectResponse; | 22 | use App\Service\URL; |
| 16 | use Symfony\Component\HttpFoundation\Request; | ||
| 17 | 23 | ||
| 18 | class PageManagementController | 24 | class PageManagementController |
| 19 | { | 25 | { |
| @@ -151,7 +157,7 @@ class PageManagementController | |||
| 151 | 'form' => EmailForm::class, | 157 | 'form' => EmailForm::class, |
| 152 | 'post_block', 'news_block' => Presentation::class, | 158 | 'post_block', 'news_block' => Presentation::class, |
| 153 | 'calendar' => NodeData::class, | 159 | 'calendar' => NodeData::class, |
| 154 | default => throw new InvalidArgumentException("Erreur: type de bloc inconnu"), | 160 | default => throw new \InvalidArgumentException("Erreur: type de bloc inconnu"), |
| 155 | }; | 161 | }; |
| 156 | $data = new $DataClass(['title' => trim(htmlspecialchars($request->request->get("bloc_title")))], $block); | 162 | $data = new $DataClass(['title' => trim(htmlspecialchars($request->request->get("bloc_title")))], $block); |
| 157 | 163 | ||
| @@ -214,7 +220,7 @@ class PageManagementController | |||
| 214 | try{ | 220 | try{ |
| 215 | $entityManager->flush(); | 221 | $entityManager->flush(); |
| 216 | } | 222 | } |
| 217 | catch(Exception $e){ | 223 | catch(\Exception $e){ |
| 218 | // utiliser une flash error | 224 | // utiliser une flash error |
| 219 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'mode' => 'page_modif', 'error' => $e->getMessage()])); | 225 | return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'mode' => 'page_modif', 'error' => $e->getMessage()])); |
| 220 | } | 226 | } |
diff --git a/src/controller/UserController.php b/src/Controller/UserController.php index b68421f..812a2da 100644 --- a/src/controller/UserController.php +++ b/src/Controller/UserController.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/UserController.php | 2 | // src/Controller/UserController.php |
| 3 | // | 3 | // |
| 4 | /* actuellement un fourre-tout de méthodes en rapport avec les utilisateurs | 4 | /* actuellement un fourre-tout de méthodes en rapport avec les utilisateurs |
| 5 | pour l'améliorer on pourrait appliquer le principe de reponsabilité unique | 5 | pour l'améliorer on pourrait appliquer le principe de reponsabilité unique |
| @@ -13,10 +13,17 @@ Auth (connexion, deconnexion), User (infos, choix photo), Account (créer, suppr | |||
| 13 | 13 | ||
| 14 | declare(strict_types=1); | 14 | declare(strict_types=1); |
| 15 | 15 | ||
| 16 | namespace App\Controller; | ||
| 17 | |||
| 18 | use Symfony\Component\HttpFoundation\RedirectResponse; | ||
| 16 | use Doctrine\ORM\EntityManager; | 19 | use Doctrine\ORM\EntityManager; |
| 17 | use App\Entity\User; | 20 | use App\Entity\User; |
| 18 | use App\Entity\Log; | 21 | use App\Entity\Log; |
| 19 | use Symfony\Component\HttpFoundation\RedirectResponse; | 22 | use App\Service\FormValidation; |
| 23 | use App\Service\ValidationStrategy; | ||
| 24 | use App\Service\URL; | ||
| 25 | use App\Service\Backup; | ||
| 26 | use App\Service\EmailService; | ||
| 20 | 27 | ||
| 21 | class UserController | 28 | class UserController |
| 22 | { | 29 | { |
| @@ -80,7 +87,7 @@ class UserController | |||
| 80 | Backup::mySQLdump($entityManager, 'auto'); // créer un nouveau backup, sauf si les dossiers nécessaires sont encore à créer | 87 | Backup::mySQLdump($entityManager, 'auto'); // créer un nouveau backup, sauf si les dossiers nécessaires sont encore à créer |
| 81 | } | 88 | } |
| 82 | } | 89 | } |
| 83 | catch(RuntimeException $e){ | 90 | catch(\RuntimeException $e){ |
| 84 | echo '<script>window.error_message = "' . $e->getMessage() . '";</script>'; | 91 | echo '<script>window.error_message = "' . $e->getMessage() . '";</script>'; |
| 85 | } | 92 | } |
| 86 | 93 | ||
diff --git a/src/controller/ViewController.php b/src/Controller/ViewController.php index d1aaee7..1f13861 100644 --- a/src/controller/ViewController.php +++ b/src/Controller/ViewController.php | |||
| @@ -1,12 +1,19 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/controller/ViewController.php | 2 | // src/Controller/ViewController.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Controller; | ||
| 7 | |||
| 6 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 7 | use Symfony\Component\HttpFoundation\Request; | 9 | use Symfony\Component\HttpFoundation\Request; |
| 8 | use Symfony\Component\HttpFoundation\Response; | 10 | use Symfony\Component\HttpFoundation\Response; |
| 9 | use Symfony\Component\HttpFoundation\RedirectResponse; | 11 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 12 | use App\Model\Model; | ||
| 13 | use App\View\ViewDirector; | ||
| 14 | use App\View\MainBuilder; | ||
| 15 | use App\View\NewBuilder; | ||
| 16 | use App\Service\URL; | ||
| 10 | 17 | ||
| 11 | class ViewController{ | 18 | class ViewController{ |
| 12 | const SPECIAL_PAGES = ['article', 'new_page', 'menu_paths', 'user_edit', 'connection', 'emails', 'maintenance']; | 19 | const SPECIAL_PAGES = ['article', 'new_page', 'menu_paths', 'user_edit', 'connection', 'emails', 'maintenance']; |
diff --git a/src/model/DatabaseSettingUp.php b/src/Model/DatabaseSettingUp.php index 4086d5a..725eaed 100644 --- a/src/model/DatabaseSettingUp.php +++ b/src/Model/DatabaseSettingUp.php | |||
| @@ -1,13 +1,15 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/DatabaseSettingUp.php | 2 | // src/Model/DatabaseSettingUp.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Model; | ||
| 7 | |||
| 8 | use Doctrine\ORM\EntityManager; | ||
| 6 | use App\Entity\AppMetadata; | 9 | use App\Entity\AppMetadata; |
| 7 | use App\Entity\Page; | 10 | use App\Entity\Page; |
| 8 | use App\Entity\Node; | 11 | use App\Entity\Node; |
| 9 | use App\Entity\NodeData; | 12 | use App\Entity\NodeData; |
| 10 | use Doctrine\ORM\EntityManager; | ||
| 11 | 13 | ||
| 12 | /* création d'un site minimal avec une page d'accueil à la toute 1ère visite du site, ne doit surtout pas être exécutée une seconde fois */ | 14 | /* création d'un site minimal avec une page d'accueil à la toute 1ère visite du site, ne doit surtout pas être exécutée une seconde fois */ |
| 13 | class DatabaseSettingUp | 15 | class DatabaseSettingUp |
diff --git a/src/model/entities/AppMetadata.php b/src/Model/Entity/AppMetadata.php index ae42ad9..b7d6923 100644 --- a/src/model/entities/AppMetadata.php +++ b/src/Model/Entity/AppMetadata.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/AppMetadata.php | 2 | // src/Model/Entity/AppMetadata.php |
| 3 | 3 | ||
| 4 | // comme dans AppMode, prévoir d'ajouter des champs "since" et "by" (qui a changé quoi quel jour?) | 4 | // comme dans AppMode, prévoir d'ajouter des champs "since" et "by" (qui a changé quoi quel jour?) |
| 5 | 5 | ||
diff --git a/src/model/entities/Article.php b/src/Model/Entity/Article.php index b9cb4bb..588ebd6 100644 --- a/src/model/entities/Article.php +++ b/src/Model/Entity/Article.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Article.php | 2 | // src/Model/Entity/Article.php |
| 3 | // | 3 | // |
| 4 | // entité commune pour les "post" (articles simples) et les "news" (complexes avec titre, aperçu et contenu) | 4 | // entité commune pour les "post" (articles simples) et les "news" (complexes avec titre, aperçu et contenu) |
| 5 | 5 | ||
| @@ -41,7 +41,7 @@ class Article | |||
| 41 | )] | 41 | )] |
| 42 | private Collection $images; | 42 | private Collection $images; |
| 43 | 43 | ||
| 44 | public function __construct(string $content, \DateTime $date_time = null, string $title = '', string $preview = '') | 44 | public function __construct(string $content, ?\DateTime $date_time = null, string $title = '', string $preview = '') |
| 45 | { | 45 | { |
| 46 | $this->date_time = $date_time; | 46 | $this->date_time = $date_time; |
| 47 | $this->title = $title; | 47 | $this->title = $title; |
diff --git a/src/model/entities/Asset.php b/src/Model/Entity/Asset.php index d76ba08..51e21fe 100644 --- a/src/model/entities/Asset.php +++ b/src/Model/Entity/Asset.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Asset.php | 2 | // src/Model/Entity/Asset.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/AssetEmployment.php b/src/Model/Entity/AssetEmployment.php index 04bbd9a..e608af0 100644 --- a/src/model/entities/AssetEmployment.php +++ b/src/Model/Entity/AssetEmployment.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/NodeDataAsset.php | 2 | // src/Model/Entity/NodeDataAsset.php |
| 3 | // | 3 | // |
| 4 | // entité intermédiaire 3 colonnes conçue selon le principe "slot <=> ressource unique" (paires node_data/role uniques) | 4 | // entité intermédiaire 3 colonnes conçue selon le principe "slot <=> ressource unique" (paires node_data/role uniques) |
| 5 | // doctrine gère mal les clés primaires triples, j'ai donc choisi une clé primaire double node_data_id/role | 5 | // doctrine gère mal les clés primaires triples, j'ai donc choisi une clé primaire double node_data_id/role |
diff --git a/src/model/entities/Email.php b/src/Model/Entity/Email.php index 60fcc1f..8ad66fd 100644 --- a/src/model/entities/Email.php +++ b/src/Model/Entity/Email.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Email.php | 2 | // src/Model/Entity/Email.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/EmailForm.php b/src/Model/Entity/EmailForm.php index 0dcdeec..5c54b86 100644 --- a/src/model/entities/EmailForm.php +++ b/src/Model/Entity/EmailForm.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/EmailForm.php | 2 | // src/Model/Entity/EmailForm.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/Event.php b/src/Model/Entity/Event.php index ae0d396..3b81da7 100644 --- a/src/model/entities/Event.php +++ b/src/Model/Entity/Event.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Event.php | 2 | // src/Model/Entity/Event.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/Image.php b/src/Model/Entity/Image.php index 2ee379a..06230ce 100644 --- a/src/model/entities/Image.php +++ b/src/Model/Entity/Image.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Image.php | 2 | // src/Model/Entity/Image.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/Log.php b/src/Model/Entity/Log.php index 222b8db..b1cc168 100644 --- a/src/model/entities/Log.php +++ b/src/Model/Entity/Log.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Log.php | 2 | // src/Model/Entity/Log.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/Node.php b/src/Model/Entity/Node.php index 7932efc..07666c3 100644 --- a/src/model/entities/Node.php +++ b/src/Model/Entity/Node.php | |||
| @@ -1,17 +1,18 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Node.php | 2 | // src/Model/Entity/Node.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Entity; | 6 | namespace App\Entity; |
| 7 | 7 | ||
| 8 | use Doctrine\ORM\Mapping as ORM; | 8 | use Doctrine\ORM\Mapping as ORM; |
| 9 | use App\Model\Position; | ||
| 9 | 10 | ||
| 10 | #[ORM\Entity] | 11 | #[ORM\Entity] |
| 11 | #[ORM\Table(name: TABLE_PREFIX . "node")] | 12 | #[ORM\Table(name: TABLE_PREFIX . "node")] |
| 12 | class Node | 13 | class Node |
| 13 | { | 14 | { |
| 14 | use \Position; | 15 | use Position; |
| 15 | 16 | ||
| 16 | #[ORM\Id] | 17 | #[ORM\Id] |
| 17 | #[ORM\GeneratedValue] | 18 | #[ORM\GeneratedValue] |
diff --git a/src/model/entities/NodeData.php b/src/Model/Entity/NodeData.php index 1646c92..d81628d 100644 --- a/src/model/entities/NodeData.php +++ b/src/Model/Entity/NodeData.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/NodeData.php | 2 | // src/Model/Entity/NodeData.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/Page.php b/src/Model/Entity/Page.php index 8d3dd40..7cca3dc 100644 --- a/src/model/entities/Page.php +++ b/src/Model/Entity/Page.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Page.php | 2 | // src/Model/Entity/Page.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| @@ -8,12 +8,13 @@ namespace App\Entity; | |||
| 8 | use Doctrine\ORM\Mapping as ORM; | 8 | use Doctrine\ORM\Mapping as ORM; |
| 9 | use Doctrine\Common\Collections\Collection; | 9 | use Doctrine\Common\Collections\Collection; |
| 10 | use Doctrine\Common\Collections\ArrayCollection; | 10 | use Doctrine\Common\Collections\ArrayCollection; |
| 11 | use App\Model\Position; | ||
| 11 | 12 | ||
| 12 | #[ORM\Entity] | 13 | #[ORM\Entity] |
| 13 | #[ORM\Table(name: TABLE_PREFIX . "page")] | 14 | #[ORM\Table(name: TABLE_PREFIX . "page")] |
| 14 | class Page | 15 | class Page |
| 15 | { | 16 | { |
| 16 | use \Position; | 17 | use Position; |
| 17 | 18 | ||
| 18 | #[ORM\Id] | 19 | #[ORM\Id] |
| 19 | #[ORM\GeneratedValue] | 20 | #[ORM\GeneratedValue] |
diff --git a/src/model/entities/Presentation.php b/src/Model/Entity/Presentation.php index d66bf24..f5e3502 100644 --- a/src/model/entities/Presentation.php +++ b/src/Model/Entity/Presentation.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/Presentation.php | 2 | // src/Model/Entity/Presentation.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/entities/User.php b/src/Model/Entity/User.php index 36bc4db..461a5bc 100644 --- a/src/model/entities/User.php +++ b/src/Model/Entity/User.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/entities/User.php | 2 | // src/Model/Entity/User.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
diff --git a/src/model/EventDTO.php b/src/Model/EventDTO.php index 6dd3722..b65176c 100644 --- a/src/model/EventDTO.php +++ b/src/Model/EventDTO.php | |||
| @@ -1,11 +1,13 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/EventDTO.php | 2 | // src/Model/EventDTO.php |
| 3 | // | 3 | // |
| 4 | // classe de données JSONifiable compatible avec fullcalendar | 4 | // classe de données JSONifiable compatible avec fullcalendar |
| 5 | // servira éventuellement pour l'import/export de fichiers .ics | 5 | // servira éventuellement pour l'import/export de fichiers .ics |
| 6 | 6 | ||
| 7 | declare(strict_types=1); | 7 | declare(strict_types=1); |
| 8 | 8 | ||
| 9 | namespace App\Model; | ||
| 10 | |||
| 9 | use App\Entity\Event; | 11 | use App\Entity\Event; |
| 10 | 12 | ||
| 11 | class EventDTO | 13 | class EventDTO |
diff --git a/src/model/Menu.php b/src/Model/Menu.php index d277259..6b08950 100644 --- a/src/model/Menu.php +++ b/src/Model/Menu.php | |||
| @@ -1,11 +1,13 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/Menu.php | 2 | // src/Model/Menu.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Model; | ||
| 7 | |||
| 6 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 7 | use App\Entity\Page; | ||
| 8 | use Doctrine\Common\Collections\ArrayCollection; | 9 | use Doctrine\Common\Collections\ArrayCollection; |
| 10 | use App\Entity\Page; | ||
| 9 | 11 | ||
| 10 | class Menu extends Page | 12 | class Menu extends Page |
| 11 | { | 13 | { |
diff --git a/src/model/Model.php b/src/Model/Model.php index 15ff12a..fa8f764 100644 --- a/src/model/Model.php +++ b/src/Model/Model.php | |||
| @@ -1,17 +1,21 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/Model.php | 2 | // src/Model/Model.php |
| 3 | // | 3 | // |
| 4 | // à l'occaz, faire des classes métiers: NodeModel = celle-ci | 4 | // à l'occaz, faire des classes métiers: NodeModel = celle-ci |
| 5 | // puis PageModel, puis éventuellement UserModel, EmailModel (le calendrier a déjà EventDTO) | 5 | // puis PageModel, puis éventuellement UserModel, EmailModel (le calendrier a déjà EventDTO) |
| 6 | 6 | ||
| 7 | declare(strict_types=1); | 7 | declare(strict_types=1); |
| 8 | 8 | ||
| 9 | namespace App\Model; | ||
| 10 | |||
| 9 | use Doctrine\ORM\EntityManager; | 11 | use Doctrine\ORM\EntityManager; |
| 12 | use Doctrine\ORM\QueryBuilder; | ||
| 13 | use Symfony\Component\HttpFoundation\Request; | ||
| 10 | use App\Entity\Page; | 14 | use App\Entity\Page; |
| 11 | use App\Entity\Node; | 15 | use App\Entity\Node; |
| 12 | use App\Entity\Presentation; | 16 | use App\Entity\Presentation; |
| 13 | use Doctrine\ORM\QueryBuilder; | 17 | use App\Model\Menu; |
| 14 | use Symfony\Component\HttpFoundation\Request; | 18 | use App\Model\Path; |
| 15 | 19 | ||
| 16 | class Model | 20 | class Model |
| 17 | { | 21 | { |
diff --git a/src/model/Path.php b/src/Model/Path.php index 4303952..91eb2ff 100644 --- a/src/model/Path.php +++ b/src/Model/Path.php | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/Path.php | 2 | // src/Model/Path.php |
| 3 | // | 3 | // |
| 4 | // attention, cette classe dépend de src/model/Menu.php | 4 | // attention, cette classe dépend de src/model/Menu.php |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | use Doctrine\ORM\EntityManager; | 8 | namespace App\Model; |
| 9 | |||
| 9 | use App\Entity\Page; | 10 | use App\Entity\Page; |
| 11 | use App\Model\Model; | ||
| 12 | use App\Model\Menu; | ||
| 13 | use App\Service\URL; | ||
| 10 | 14 | ||
| 11 | class Path extends Page | 15 | class Path extends Page |
| 12 | { | 16 | { |
| @@ -19,7 +23,7 @@ class Path extends Page | |||
| 19 | // parcourir le menu de haut en bas pour obtenir un ou plusieurs objets Page | 23 | // parcourir le menu de haut en bas pour obtenir un ou plusieurs objets Page |
| 20 | $this->findPage(Model::$menu, $path_array); // remplit $this->current_page | 24 | $this->findPage(Model::$menu, $path_array); // remplit $this->current_page |
| 21 | } | 25 | } |
| 22 | catch(Exception $e){} | 26 | catch(\Exception $e){} |
| 23 | } | 27 | } |
| 24 | 28 | ||
| 25 | // produit un tableau de Page en comparant le chemin demandé avec les données dans Menu | 29 | // produit un tableau de Page en comparant le chemin demandé avec les données dans Menu |
| @@ -32,7 +36,7 @@ class Path extends Page | |||
| 32 | foreach($menu->getOtherPages() as $page){ | 36 | foreach($menu->getOtherPages() as $page){ |
| 33 | if($path_array[0] === $page->getEndOfPath()){ | 37 | if($path_array[0] === $page->getEndOfPath()){ |
| 34 | $this->current_page[] = $page; | 38 | $this->current_page[] = $page; |
| 35 | throw new Exception(); | 39 | throw new \Exception(); |
| 36 | } | 40 | } |
| 37 | } | 41 | } |
| 38 | } | 42 | } |
| @@ -45,7 +49,7 @@ class Path extends Page | |||
| 45 | $this->findPage($page, $path_array); | 49 | $this->findPage($page, $path_array); |
| 46 | } | 50 | } |
| 47 | else{ | 51 | else{ |
| 48 | throw new Exception(); // sortir de tous les findPage() en même temps | 52 | throw new \Exception(); // sortir de tous les findPage() en même temps |
| 49 | } | 53 | } |
| 50 | } | 54 | } |
| 51 | } | 55 | } |
diff --git a/src/model/Position.php b/src/Model/Position.php index fdba271..7799cdf 100644 --- a/src/model/Position.php +++ b/src/Model/Position.php | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/modele/Position.php | 2 | // src/Model/Position.php |
| 3 | // | 3 | // |
| 4 | // pour Node et Page | 4 | // pour Node et Page |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\Model; | ||
| 9 | |||
| 8 | trait Position | 10 | trait Position |
| 9 | { | 11 | { |
| 10 | // tri par insertion du tableau des enfants | 12 | // tri par insertion du tableau des enfants |
diff --git a/src/model/doctrine-bootstrap.php b/src/Model/doctrine-bootstrap.php index 127f72f..13db87f 100644 --- a/src/model/doctrine-bootstrap.php +++ b/src/Model/doctrine-bootstrap.php | |||
| @@ -1,18 +1,19 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/model/doctrine-bootstrap.php | 2 | // src/Model/doctrine-bootstrap.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use Doctrine\ORM\ORMSetup; | 6 | use Doctrine\ORM\ORMSetup; |
| 7 | use Doctrine\DBAL\DriverManager; | 7 | use Doctrine\DBAL\DriverManager; |
| 8 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 9 | use App\Service\Config; | ||
| 9 | 10 | ||
| 10 | require_once "../vendor/autoload.php"; | 11 | //require_once "../vendor/autoload.php"; |
| 11 | 12 | ||
| 12 | // Create a simple "default" Doctrine ORM configuration for Attributes | 13 | // Create a simple "default" Doctrine ORM configuration for Attributes |
| 13 | $config = ORMSetup::createAttributeMetadataConfiguration( | 14 | $config = ORMSetup::createAttributeMetadataConfiguration( |
| 14 | //paths: array(__DIR__.'/entities'), | 15 | //paths: array(__DIR__.'/entities'), |
| 15 | paths: array('../src/model/entities'), | 16 | paths: array('../src/Model/Entity'), |
| 16 | isDevMode: true, | 17 | isDevMode: true, |
| 17 | // true: cache en mémoire vive | 18 | // true: cache en mémoire vive |
| 18 | // false: utilisation de APCu ou redis ou memcache | 19 | // false: utilisation de APCu ou redis ou memcache |
diff --git a/src/service/Backup.php b/src/Service/Backup.php index 2ee69c1..546e81e 100644 --- a/src/service/Backup.php +++ b/src/Service/Backup.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/Backup.php | 2 | // src/Service/Backup.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Service; | ||
| 7 | |||
| 6 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 7 | use Symfony\Component\Process\Process; // protection injection dans le shell | 9 | use Symfony\Component\Process\Process; // protection injection dans le shell |
| 8 | 10 | ||
| @@ -13,7 +15,7 @@ class Backup | |||
| 13 | 15 | ||
| 14 | static public function mySQLdump(EntityManager $entityManager, string $type): string | 16 | static public function mySQLdump(EntityManager $entityManager, string $type): string |
| 15 | { | 17 | { |
| 16 | $date = new DateTime; | 18 | $date = new \DateTime; |
| 17 | $file_path = self::$backup_dir . '/' . Config::$database . '_' . $date->format('Y-m-d') . '_' . $type . '.sql'; | 19 | $file_path = self::$backup_dir . '/' . Config::$database . '_' . $date->format('Y-m-d') . '_' . $type . '.sql'; |
| 18 | 20 | ||
| 19 | // les versions de mysql sont comme ci: 8.0.36 | 21 | // les versions de mysql sont comme ci: 8.0.36 |
| @@ -77,7 +79,7 @@ class Backup | |||
| 77 | { | 79 | { |
| 78 | $files = scandir(Backup::$backup_dir); // affiche un warning si échoue (à cacher en prod) | 80 | $files = scandir(Backup::$backup_dir); // affiche un warning si échoue (à cacher en prod) |
| 79 | if(!$files){ | 81 | if(!$files){ |
| 80 | throw new RuntimeException("Le serveur a rencontré une erreur:<br>Accès aux backups impossible faute de permissions."); | 82 | throw new \RuntimeException("Le serveur a rencontré une erreur:<br>Accès aux backups impossible faute de permissions."); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | $backup_array = []; | 85 | $backup_array = []; |
| @@ -105,7 +107,7 @@ class Backup | |||
| 105 | $list_by_database[$exploded[0]][] = $file; | 107 | $list_by_database[$exploded[0]][] = $file; |
| 106 | } | 108 | } |
| 107 | 109 | ||
| 108 | $date = new DateTime; | 110 | $date = new \DateTime; |
| 109 | foreach($sorted_files as $db_name => $from_one_database){ | 111 | foreach($sorted_files as $db_name => $from_one_database){ |
| 110 | // on garde une "quantité à garder" par BDD | 112 | // on garde une "quantité à garder" par BDD |
| 111 | if(count($from_one_database) > self::$amount_to_keep){ | 113 | if(count($from_one_database) > self::$amount_to_keep){ |
| @@ -159,7 +161,7 @@ class Backup | |||
| 159 | static public function restoreDatabase(EntityManager $entityManager, string $file_name, array $exclusion_list = []): void | 161 | static public function restoreDatabase(EntityManager $entityManager, string $file_name, array $exclusion_list = []): void |
| 160 | { | 162 | { |
| 161 | // création d'un backup de sécurité non écrasable | 163 | // création d'un backup de sécurité non écrasable |
| 162 | $date = new DateTime; | 164 | $date = new \DateTime; |
| 163 | if(!file_exists(self::$backup_dir . '/' . Config::$database . '_' . $date->format('Y-m-d') . '_before-restore.sql')){ | 165 | if(!file_exists(self::$backup_dir . '/' . Config::$database . '_' . $date->format('Y-m-d') . '_before-restore.sql')){ |
| 164 | Backup::mySQLdump($entityManager, 'before-restore'); | 166 | Backup::mySQLdump($entityManager, 'before-restore'); |
| 165 | } | 167 | } |
| @@ -220,7 +222,7 @@ class Backup | |||
| 220 | foreach($tables as $key => $elem){ | 222 | foreach($tables as $key => $elem){ |
| 221 | foreach($exclusion_list as $excluded){ | 223 | foreach($exclusion_list as $excluded){ |
| 222 | if(!is_string($excluded)){ // cas pas du tout censé arriver! | 224 | if(!is_string($excluded)){ // cas pas du tout censé arriver! |
| 223 | throw new LogicException("Un nom de table doit etre une chaîne de caractères."); | 225 | throw new \LogicException("Un nom de table doit etre une chaîne de caractères."); |
| 224 | } | 226 | } |
| 225 | if($elem === TABLE_PREFIX . $excluded){ | 227 | if($elem === TABLE_PREFIX . $excluded){ |
| 226 | unset($tables[$key]); | 228 | unset($tables[$key]); |
| @@ -230,4 +232,41 @@ class Backup | |||
| 230 | } | 232 | } |
| 231 | return $tables; | 233 | return $tables; |
| 232 | } | 234 | } |
| 235 | |||
| 236 | static public function createZip(string $zip_name, array $source_directories, array $pattern_to_target_in_user_data = []): string | ||
| 237 | { | ||
| 238 | $file_path = '../var/' . $zip_name; | ||
| 239 | $Zip = new \ZipArchive(); | ||
| 240 | |||
| 241 | if($Zip->open($file_path, \ZipArchive::CREATE | \ZipArchive::OVERWRITE) !== TRUE){ // ou ZipArchive::FL_OVERWRITE, à comparer à ZipArchive::OVERWRITE | ||
| 242 | throw new \RuntimeException("Création ou ouverture du fichier demandé impossible à cause d'une erreur de permissions sur le serveur."); | ||
| 243 | } | ||
| 244 | |||
| 245 | // recherche récursive dans les dossiers dans $source_directories, c'est comme le paramètre "-r" dans la console | ||
| 246 | $counter = 0; | ||
| 247 | foreach($source_directories as $path){ | ||
| 248 | $directory = new \RecursiveDirectoryIterator($path); | ||
| 249 | $iterator = new \RecursiveIteratorIterator($directory); | ||
| 250 | |||
| 251 | foreach($iterator as $info){ | ||
| 252 | if($info->getFilename() != "." && $info->getFilename() != ".." && $info->getFilename() != '.htaccess'){ // chemins inutiles . et .. et le .htaccess | ||
| 253 | $Zip->addGlob($info->getPathname(), 0, array('')); | ||
| 254 | $counter++; | ||
| 255 | } | ||
| 256 | } | ||
| 257 | } | ||
| 258 | // recherche à la racine avec des pattern de noms de fichiers (optionnel) | ||
| 259 | foreach($pattern_to_target_in_user_data as $one_pattern){ | ||
| 260 | $Zip->addGlob($one_pattern, 0, array('')); | ||
| 261 | } | ||
| 262 | |||
| 263 | $Zip->close(); | ||
| 264 | if($counter > 0){ | ||
| 265 | //chmod($file_path, 0666); | ||
| 266 | return $zip_name; | ||
| 267 | } | ||
| 268 | else{ | ||
| 269 | throw new \RuntimeException("Téléchargement des fichiers impossible, aucun fichier n'a été trouvé sur le serveur."); | ||
| 270 | } | ||
| 271 | } | ||
| 233 | } \ No newline at end of file | 272 | } \ No newline at end of file |
diff --git a/src/service/Captcha.php b/src/Service/Captcha.php index d57f912..28c7f71 100644 --- a/src/service/Captcha.php +++ b/src/Service/Captcha.php | |||
| @@ -1,11 +1,13 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/Captcha.php | 2 | // src/Service/Captcha.php |
| 3 | // | 3 | // |
| 4 | // la solution est stockée dans une unique variable $_SESSION['captcha'] | 4 | // la solution est stockée dans une unique variable $_SESSION['captcha'] |
| 5 | // => on pourrait appliquer le pattern "singleton" (justification = le captcha devient une sorte de ressource partagée) | 5 | // => on pourrait appliquer le pattern "singleton" (justification = le captcha devient une sorte de ressource partagée) |
| 6 | 6 | ||
| 7 | declare(strict_types=1); | 7 | declare(strict_types=1); |
| 8 | 8 | ||
| 9 | namespace App\Service; | ||
| 10 | |||
| 9 | class Captcha | 11 | class Captcha |
| 10 | { | 12 | { |
| 11 | private int $a; | 13 | private int $a; |
diff --git a/src/service/Config.php b/src/Service/Config.php index 7077e01..fc4d127 100644 --- a/src/service/Config.php +++ b/src/Service/Config.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/Config.php | 2 | // src/Service/Config.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Service; | ||
| 7 | |||
| 6 | class Config | 8 | class Config |
| 7 | { | 9 | { |
| 8 | // BDD | 10 | // BDD |
diff --git a/src/service/EmailService.php b/src/Service/EmailService.php index 1579bdb..38b4cf8 100644 --- a/src/service/EmailService.php +++ b/src/Service/EmailService.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/EmailService.php | 2 | // src/Service/EmailService.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Service; | ||
| 7 | |||
| 6 | use PHPMailer\PHPMailer\PHPMailer; | 8 | use PHPMailer\PHPMailer\PHPMailer; |
| 7 | //use PHPMailer\PHPMailer\Exception; | 9 | //use PHPMailer\PHPMailer\Exception; |
| 8 | use Doctrine\ORM\EntityManager; | 10 | use Doctrine\ORM\EntityManager; |
| @@ -77,7 +79,7 @@ class EmailService | |||
| 77 | 79 | ||
| 78 | return true; | 80 | return true; |
| 79 | } | 81 | } |
| 80 | catch(Exception $e){ | 82 | catch(\Exception $e){ |
| 81 | echo "Le message n'a pas pu être envoyé. Erreur : {$e} <br> {$mail->ErrorInfo}"; | 83 | echo "Le message n'a pas pu être envoyé. Erreur : {$e} <br> {$mail->ErrorInfo}"; |
| 82 | return false; | 84 | return false; |
| 83 | } | 85 | } |
diff --git a/src/service/FormValidation.php b/src/Service/FormValidation.php index 9d0b838..d91aa12 100644 --- a/src/service/FormValidation.php +++ b/src/Service/FormValidation.php | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/FormValidation.php | 2 | // src/Service/FormValidation.php |
| 3 | // | 3 | // |
| 4 | // pattern strategy simplifié, permet évolution future vers le vrai pattern | 4 | // pattern strategy simplifié, permet évolution future vers le vrai pattern |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\Service; | ||
| 9 | |||
| 8 | // classe spéciale permettant de bénéficier du typage de classe au lieu de passer une chaîne à FormValidation | 10 | // classe spéciale permettant de bénéficier du typage de classe au lieu de passer une chaîne à FormValidation |
| 9 | enum ValidationStrategy { | 11 | enum ValidationStrategy { |
| 10 | // bloc formulaire de contact | 12 | // bloc formulaire de contact |
| @@ -32,7 +34,7 @@ enum ValidationStrategy { | |||
| 32 | class FormValidation | 34 | class FormValidation |
| 33 | { | 35 | { |
| 34 | private array $data; // tableau associatif (probablement $_POST) | 36 | private array $data; // tableau associatif (probablement $_POST) |
| 35 | private Closure $callStrategy; | 37 | private \Closure $callStrategy; |
| 36 | private ?string $error; | 38 | private ?string $error; |
| 37 | 39 | ||
| 38 | public function __construct(array $data, ValidationStrategy $strategy){ | 40 | public function __construct(array $data, ValidationStrategy $strategy){ |
diff --git a/src/service/Installation.php b/src/Service/Installation.php index f7de2cf..ed9f20a 100644 --- a/src/service/Installation.php +++ b/src/Service/Installation.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/Installation.php | 2 | // src/Service/Installation.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Service; | ||
| 7 | |||
| 6 | class Installation | 8 | class Installation |
| 7 | { | 9 | { |
| 8 | static public function phpDependancies(): void | 10 | static public function phpDependancies(): void |
| @@ -16,7 +18,7 @@ class Installation | |||
| 16 | $flag = true; | 18 | $flag = true; |
| 17 | } | 19 | } |
| 18 | } | 20 | } |
| 19 | if(!class_exists(DOMDocument::class)){ // théoriquement plus fiable que extension_loaded() | 21 | if(!class_exists(\DOMDocument::class)){ // théoriquement plus fiable que extension_loaded() |
| 20 | echo("<p>L'extension <b>dom</b> est manquante.</p>"); | 22 | echo("<p>L'extension <b>dom</b> est manquante.</p>"); |
| 21 | $flag = true; | 23 | $flag = true; |
| 22 | } | 24 | } |
| @@ -45,7 +47,7 @@ class Installation | |||
| 45 | mkdir('user_data/'); | 47 | mkdir('user_data/'); |
| 46 | chmod('user_data/', $droits_dossiers); | 48 | chmod('user_data/', $droits_dossiers); |
| 47 | } | 49 | } |
| 48 | catch(Exception $e){ | 50 | catch(\Exception $e){ |
| 49 | echo '<p style="color: red;">Le dossier public/user_data introuvable et le serveur n\'a pas la permission de le créer.<br> | 51 | echo '<p style="color: red;">Le dossier public/user_data introuvable et le serveur n\'a pas la permission de le créer.<br> |
| 50 | Pour faire ça bien:<br>sudo -u "serveur web" mkdir /chemin/du/site/public/user_data</p>'; | 52 | Pour faire ça bien:<br>sudo -u "serveur web" mkdir /chemin/du/site/public/user_data</p>'; |
| 51 | echo $e; | 53 | echo $e; |
| @@ -57,7 +59,7 @@ class Installation | |||
| 57 | mkdir('../var'); | 59 | mkdir('../var'); |
| 58 | chmod('../var', $droits_dossiers); | 60 | chmod('../var', $droits_dossiers); |
| 59 | } | 61 | } |
| 60 | catch(Exception $e){ | 62 | catch(\Exception $e){ |
| 61 | echo $e; | 63 | echo $e; |
| 62 | $flag = true; | 64 | $flag = true; |
| 63 | } | 65 | } |
| @@ -67,7 +69,7 @@ class Installation | |||
| 67 | mkdir('../var/backups'); | 69 | mkdir('../var/backups'); |
| 68 | chmod('../var/backups', $droits_dossiers); // autoriser à la fois le serveur et les scripts dans bin/ | 70 | chmod('../var/backups', $droits_dossiers); // autoriser à la fois le serveur et les scripts dans bin/ |
| 69 | } | 71 | } |
| 70 | catch(Exception $e){ | 72 | catch(\Exception $e){ |
| 71 | echo $e; | 73 | echo $e; |
| 72 | $flag = true; | 74 | $flag = true; |
| 73 | } | 75 | } |
diff --git a/src/service/Router.php b/src/Service/Router.php index 28a6c39..98cecc5 100644 --- a/src/service/Router.php +++ b/src/Service/Router.php | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/router.php | 2 | // src/Service/Router.php |
| 3 | // | 3 | // |
| 4 | /* fonctionnement: | 4 | /* fonctionnement: |
| 5 | => 1er test, méthode http GET? POST? | 5 | => 1er test, méthode http GET? POST? |
| @@ -22,11 +22,28 @@ StreamedResponse(function () {echo "ligne 1\n";echo "ligne 2\n";}) gros fichier | |||
| 22 | 22 | ||
| 23 | declare(strict_types=1); | 23 | declare(strict_types=1); |
| 24 | 24 | ||
| 25 | namespace App\Service; | ||
| 26 | |||
| 25 | use Symfony\Component\HttpFoundation\Request; | 27 | use Symfony\Component\HttpFoundation\Request; |
| 26 | use Doctrine\ORM\EntityManager; | 28 | use Doctrine\ORM\EntityManager; |
| 27 | use Symfony\Component\HttpFoundation\JsonResponse; | 29 | use Symfony\Component\HttpFoundation\JsonResponse; |
| 28 | use Symfony\Component\HttpFoundation\RedirectResponse; | 30 | use Symfony\Component\HttpFoundation\RedirectResponse; |
| 29 | use Symfony\Component\HttpFoundation\Response; | 31 | use Symfony\Component\HttpFoundation\Response; |
| 32 | use App\Service\User; | ||
| 33 | use App\View\AbstractBuilder; | ||
| 34 | use App\Model\Model; | ||
| 35 | use App\Model\Menu; | ||
| 36 | use App\Controller\UserController; | ||
| 37 | use App\Controller\ArticleController; | ||
| 38 | use App\Controller\CalendarController; | ||
| 39 | use App\Controller\MaintenanceController; | ||
| 40 | use App\Controller\ViewController; | ||
| 41 | use App\Controller\ContactFormController; | ||
| 42 | use App\Controller\ImageUploadController; | ||
| 43 | use App\Controller\HeadFootController; | ||
| 44 | use App\Controller\MenuAndPathsController; | ||
| 45 | use App\Controller\PageManagementController; | ||
| 46 | use App\Controller\FileUploadController; | ||
| 30 | 47 | ||
| 31 | class Router{ | 48 | class Router{ |
| 32 | private Request $request; | 49 | private Request $request; |
| @@ -277,7 +294,7 @@ class Router{ | |||
| 277 | /* -- page Maintenance -- */ | 294 | /* -- page Maintenance -- */ |
| 278 | elseif($this->request->query->get('action') === 'restore_database' && $this->request->request->get('hidden') === '' | 295 | elseif($this->request->query->get('action') === 'restore_database' && $this->request->request->get('hidden') === '' |
| 279 | && $this->request->files->has('uploaded_sql')){ | 296 | && $this->request->files->has('uploaded_sql')){ |
| 280 | return MaintenanceController::downloadSQL($entityManager, $request); | 297 | return MaintenanceController::downloadSQL($this->entityManager, $this->request); |
| 281 | } | 298 | } |
| 282 | else{ | 299 | else{ |
| 283 | // choix ici entre répondre en JSON ou par une redirection, choix du JSON pour pouvoir passer un message | 300 | // choix ici entre répondre en JSON ou par une redirection, choix du JSON pour pouvoir passer un message |
diff --git a/src/service/Security.php b/src/Service/Security.php index 356f4f4..0fbd8b7 100644 --- a/src/service/Security.php +++ b/src/Service/Security.php | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/Security.php | 2 | // src/Service/Security.php |
| 3 | // | 3 | // |
| 4 | // htmlawed nettoie les entrées de l'utilisateur, en particulier le html de l'éditeur | 4 | // htmlawed nettoie les entrées de l'utilisateur, en particulier le html de l'éditeur |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\Service; | ||
| 9 | |||
| 8 | class Security | 10 | class Security |
| 9 | { | 11 | { |
| 10 | private static $configHtmLawed = array( | 12 | private static $configHtmLawed = array( |
diff --git a/src/service/URL.php b/src/Service/URL.php index 5bd2594..035f572 100644 --- a/src/service/URL.php +++ b/src/Service/URL.php | |||
| @@ -1,9 +1,11 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/URL.php | 2 | // src/Service/URL.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | class URL implements Stringable | 6 | namespace App\Service; |
| 7 | |||
| 8 | class URL implements \Stringable | ||
| 7 | { | 9 | { |
| 8 | static private string $protocol = 'http://'; | 10 | static private string $protocol = 'http://'; |
| 9 | static private string $host = ''; | 11 | static private string $host = ''; |
diff --git a/src/service/User.php b/src/Service/User.php index bd17dce..bd4c315 100644 --- a/src/service/User.php +++ b/src/Service/User.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/User.php | 2 | // src/Service/User.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\Service; | ||
| 7 | |||
| 6 | use Doctrine\ORM\EntityManager; | 8 | use Doctrine\ORM\EntityManager; |
| 7 | 9 | ||
| 8 | class User{ | 10 | class User{ |
diff --git a/src/service/session.php b/src/Service/session.php index 24023e9..39c6ba2 100644 --- a/src/service/session.php +++ b/src/Service/session.php | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/service/session.php | 2 | // src/Service/session.php |
| 3 | 3 | ||
| 4 | // à voir si c'est mieux avec: | 4 | // à voir si c'est mieux avec: |
| 5 | //use Symfony\Component\HttpFoundation\Session\Session; | 5 | //use Symfony\Component\HttpFoundation\Session\Session; |
| 6 | 6 | ||
| 7 | // note: session_regenerate_id(true) se trouve dans UserController::connect | 7 | // note: session_regenerate_id(true) se trouve dans UserController::connect |
| 8 | 8 | ||
| 9 | declare(strict_types=1); | ||
| 10 | |||
| 9 | use Doctrine\ORM\EntityManager; | 11 | use Doctrine\ORM\EntityManager; |
| 12 | use App\Service\URL; | ||
| 13 | use App\Controller\UserController; | ||
| 10 | 14 | ||
| 11 | function startSession(EntityManager $entityManager): void | 15 | function startSession(EntityManager $entityManager): void |
| 12 | { | 16 | { |
diff --git a/src/view/AbstractBuilder.php b/src/View/AbstractBuilder.php index b9a1d7f..170e871 100644 --- a/src/view/AbstractBuilder.php +++ b/src/View/AbstractBuilder.php | |||
| @@ -1,13 +1,16 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/AbstractBuilder.php | 2 | // src/View/AbstractBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 9 | use App\Model\Model; | ||
| 7 | 10 | ||
| 8 | abstract class AbstractBuilder | 11 | abstract class AbstractBuilder |
| 9 | { | 12 | { |
| 10 | const VIEWS_PATH = '../src/view/templates/'; | 13 | const VIEWS_PATH = '../src/View/templates/'; |
| 11 | protected string $html = ''; | 14 | protected string $html = ''; |
| 12 | protected int $id_node; | 15 | protected int $id_node; |
| 13 | 16 | ||
| @@ -20,7 +23,8 @@ abstract class AbstractBuilder | |||
| 20 | { | 23 | { |
| 21 | foreach($node->getChildren() as $child_node) | 24 | foreach($node->getChildren() as $child_node) |
| 22 | { | 25 | { |
| 23 | $builder_name = $this->snakeToPascalCase($child_node->getName()) . 'Builder'; | 26 | // le double \\ permet de ne pas échapper la quote |
| 27 | $builder_name = 'App\View\\' . $this->snakeToPascalCase($child_node->getName()) . 'Builder'; | ||
| 24 | $builder = new $builder_name($child_node); | 28 | $builder = new $builder_name($child_node); |
| 25 | $this->html .= $builder->render(); | 29 | $this->html .= $builder->render(); |
| 26 | 30 | ||
| @@ -64,7 +68,7 @@ abstract class AbstractBuilder | |||
| 64 | 68 | ||
| 65 | // modification des attributs | 69 | // modification des attributs |
| 66 | if(!empty($attributes)){ | 70 | if(!empty($attributes)){ |
| 67 | $dom = new DOMDocument(); | 71 | $dom = new \DOMDocument(); |
| 68 | $dom->loadXML($svg); | 72 | $dom->loadXML($svg); |
| 69 | $svg_elem = $dom->documentElement; | 73 | $svg_elem = $dom->documentElement; |
| 70 | foreach($attributes as $key => $value){ | 74 | foreach($attributes as $key => $value){ |
diff --git a/src/view/BreadcrumbBuilder.php b/src/View/BreadcrumbBuilder.php index 2655551..81df0eb 100644 --- a/src/view/BreadcrumbBuilder.php +++ b/src/View/BreadcrumbBuilder.php | |||
| @@ -1,14 +1,17 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/BreadcrumbBuilder.php | 2 | // src/View/BreadcrumbBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | use App\Entity\Node; | 6 | namespace App\View; |
| 7 | |||
| 8 | //use App\Entity\Node; | ||
| 9 | use App\Model\Model; | ||
| 10 | use App\Service\URL; | ||
| 7 | 11 | ||
| 8 | class BreadcrumbBuilder extends AbstractBuilder | 12 | class BreadcrumbBuilder extends AbstractBuilder |
| 9 | { | 13 | { |
| 10 | public function __construct(Node $node) | 14 | public function __construct(/*Node $node*/){ |
| 11 | { | ||
| 12 | $this->html = $this->breadcrumbHTML(); | 15 | $this->html = $this->breadcrumbHTML(); |
| 13 | } | 16 | } |
| 14 | 17 | ||
diff --git a/src/view/CalendarBuilder.php b/src/View/CalendarBuilder.php index 0c0006d..34b1952 100644 --- a/src/view/CalendarBuilder.php +++ b/src/View/CalendarBuilder.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/CalendarBuilder.php | 2 | // src/View/CalendarBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 7 | 9 | ||
| 8 | class CalendarBuilder extends AbstractBuilder | 10 | class CalendarBuilder extends AbstractBuilder |
diff --git a/src/view/FooterBuilder.php b/src/View/FooterBuilder.php index bb99c13..72a571d 100644 --- a/src/view/FooterBuilder.php +++ b/src/View/FooterBuilder.php | |||
| @@ -1,10 +1,15 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/FooterBuilder.php | 2 | // src/View/FooterBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 7 | use App\Entity\Asset; | 9 | use App\Entity\Asset; |
| 10 | use App\Controller\ViewController; | ||
| 11 | use App\Model\Model; | ||
| 12 | use App\Service\URL; | ||
| 8 | 13 | ||
| 9 | class FooterBuilder extends AbstractBuilder | 14 | class FooterBuilder extends AbstractBuilder |
| 10 | { | 15 | { |
diff --git a/src/view/FormBuilder.php b/src/View/FormBuilder.php index 9a900ce..df5687d 100644 --- a/src/view/FormBuilder.php +++ b/src/View/FormBuilder.php | |||
| @@ -1,9 +1,14 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/FormBuilder.php | 2 | // src/View/FormBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 9 | use App\Entity\Email; | ||
| 10 | use App\Service\Captcha; | ||
| 11 | use App\Service\Config; | ||
| 7 | 12 | ||
| 8 | class FormBuilder extends AbstractBuilder | 13 | class FormBuilder extends AbstractBuilder |
| 9 | { | 14 | { |
| @@ -28,8 +33,8 @@ class FormBuilder extends AbstractBuilder | |||
| 28 | $smtp_username = $smtp_username ?? Config::$smtp_username; | 33 | $smtp_username = $smtp_username ?? Config::$smtp_username; |
| 29 | $email_dest = $email_dest ?? Config::$email_dest; | 34 | $email_dest = $email_dest ?? Config::$email_dest; |
| 30 | $keep_emails = (bool)($keep_emails ?? false); // (bool) est inutile mais plus clair | 35 | $keep_emails = (bool)($keep_emails ?? false); // (bool) est inutile mais plus clair |
| 31 | $retention_period = $this->getRetentionPeriod($retention_period ?? null, App\Entity\Email::DEFAULT_RETENTION_PERIOD); | 36 | $retention_period = $this->getRetentionPeriod($retention_period ?? null, Email::DEFAULT_RETENTION_PERIOD); |
| 32 | $retention_period_sensible = $this->getRetentionPeriod($retention_period_sensible ?? null, App\Entity\Email::DEFAULT_RETENTION_PERIOD_SENSITIVE); | 37 | $retention_period_sensible = $this->getRetentionPeriod($retention_period_sensible ?? null, Email::DEFAULT_RETENTION_PERIOD_SENSITIVE); |
| 33 | 38 | ||
| 34 | $admin_content = ''; | 39 | $admin_content = ''; |
| 35 | if(IS_ADMIN){ | 40 | if(IS_ADMIN){ |
diff --git a/src/view/GaleryBuilder.php b/src/View/GaleryBuilder.php index 019a2c7..436cc36 100644 --- a/src/view/GaleryBuilder.php +++ b/src/View/GaleryBuilder.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/GaleryBuilder.php | 2 | // src/View/GaleryBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 7 | 9 | ||
| 8 | class GaleryBuilder extends AbstractBuilder | 10 | class GaleryBuilder extends AbstractBuilder |
diff --git a/src/view/HeadBuilder.php b/src/View/HeadBuilder.php index 9cb0650..4d63457 100644 --- a/src/view/HeadBuilder.php +++ b/src/View/HeadBuilder.php | |||
| @@ -1,10 +1,13 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/HeadBuilder.php | 2 | // src/View/HeadBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Asset; | 8 | use App\Entity\Asset; |
| 7 | use App\Entity\Node; | 9 | use App\Entity\Node; |
| 10 | use App\Model\Model; | ||
| 8 | 11 | ||
| 9 | class HeadBuilder extends AbstractBuilder | 12 | class HeadBuilder extends AbstractBuilder |
| 10 | { | 13 | { |
diff --git a/src/view/HeaderBuilder.php b/src/View/HeaderBuilder.php index bfd5963..14f5ffa 100644 --- a/src/view/HeaderBuilder.php +++ b/src/View/HeaderBuilder.php | |||
| @@ -1,16 +1,18 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/HeaderBuilder.php | 2 | // src/View/HeaderBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 7 | use App\Entity\NodeData; | 9 | use App\Entity\NodeData; |
| 8 | use App\Entity\Asset; | 10 | use App\Entity\Asset; |
| 9 | 11 | ||
| 10 | class HeaderBuilder extends AbstractBuilder | 12 | class HeaderBuilder extends AbstractBuilder |
| 11 | { | 13 | { |
| 12 | private ?Node $nav = null; | 14 | //private ?Node $nav = null; |
| 13 | private ?Node $breadcrumb = null; | 15 | //private ?Node $breadcrumb = null; |
| 14 | const ICON_PATH = 'icons/'; | 16 | const ICON_PATH = 'icons/'; |
| 15 | 17 | ||
| 16 | public function __construct(Node $node) | 18 | public function __construct(Node $node) |
| @@ -20,15 +22,15 @@ class HeaderBuilder extends AbstractBuilder | |||
| 20 | foreach($children as $child) | 22 | foreach($children as $child) |
| 21 | { | 23 | { |
| 22 | if($child->getName() === 'nav'){ | 24 | if($child->getName() === 'nav'){ |
| 23 | $this->nav = $child; | 25 | //$this->nav = $child; |
| 24 | // actuellement le noeud nav ne contient aucune info utile et l'envoyer à NavBuilder est inutile | 26 | // actuellement le noeud nav ne contient aucune info utile et l'envoyer à NavBuilder est inutile |
| 25 | $nav_builder = new NavBuilder($this->nav); | 27 | $nav_builder = new NavBuilder(/*$this->nav*/); |
| 26 | 28 | ||
| 27 | $nav = $nav_builder->render(); | 29 | $nav = $nav_builder->render(); |
| 28 | } | 30 | } |
| 29 | elseif($child->getName() === 'breadcrumb'){ | 31 | elseif($child->getName() === 'breadcrumb'){ |
| 30 | $this->breadcrumb = $child; | 32 | //$this->breadcrumb = $child; |
| 31 | $breadcrumb_builder = new BreadcrumbBuilder($this->breadcrumb); | 33 | $breadcrumb_builder = new BreadcrumbBuilder(/*$this->breadcrumb*/); |
| 32 | $breadcrumb = $breadcrumb_builder->render(); | 34 | $breadcrumb = $breadcrumb_builder->render(); |
| 33 | } | 35 | } |
| 34 | } | 36 | } |
diff --git a/src/view/LoginBuilder.php b/src/View/LoginBuilder.php index 479398c..3a303b0 100644 --- a/src/view/LoginBuilder.php +++ b/src/View/LoginBuilder.php | |||
| @@ -1,9 +1,13 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/LoginBuilder.php | 2 | // src/View/LoginBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 9 | use App\Service\URL; | ||
| 10 | use App\Service\Captcha; | ||
| 7 | 11 | ||
| 8 | class LoginBuilder extends AbstractBuilder | 12 | class LoginBuilder extends AbstractBuilder |
| 9 | { | 13 | { |
diff --git a/src/view/MainBuilder.php b/src/View/MainBuilder.php index 1df5846..b5b9b00 100644 --- a/src/view/MainBuilder.php +++ b/src/View/MainBuilder.php | |||
| @@ -1,11 +1,15 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/MainBuilder.php | 2 | // src/View/MainBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Article; | 8 | use App\Entity\Article; |
| 7 | use App\Entity\Node; | 9 | use App\Entity\Node; |
| 8 | use App\Entity\Presentation; | 10 | use App\Entity\Presentation; |
| 11 | use App\Model\Model; | ||
| 12 | use App\Service\URL; | ||
| 9 | 13 | ||
| 10 | class MainBuilder extends AbstractBuilder | 14 | class MainBuilder extends AbstractBuilder |
| 11 | { | 15 | { |
| @@ -33,8 +37,8 @@ class MainBuilder extends AbstractBuilder | |||
| 33 | else{ | 37 | else{ |
| 34 | $new = $node->getAdoptedChild(); | 38 | $new = $node->getAdoptedChild(); |
| 35 | } | 39 | } |
| 36 | //$builder_name = $this->snakeToPascalCase($new->getName()) . 'Builder'; | 40 | //$builder_name = 'App\View\\' . $this->snakeToPascalCase($new->getName()) . 'Builder'; |
| 37 | $builder_name = 'NewBuilder'; | 41 | $builder_name = 'App\View\NewBuilder'; |
| 38 | $builder = new $builder_name($new); | 42 | $builder = new $builder_name($new); |
| 39 | $this->html .= $builder->render(); | 43 | $this->html .= $builder->render(); |
| 40 | } | 44 | } |
diff --git a/src/view/MaintenanceBuilder.php b/src/View/MaintenanceBuilder.php index 5ed1ce2..13d391c 100644 --- a/src/view/MaintenanceBuilder.php +++ b/src/View/MaintenanceBuilder.php | |||
| @@ -1,9 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/MaintenanceBuilder.php | 2 | // src/View/MaintenanceBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 9 | use App\Service\Backup; | ||
| 7 | 10 | ||
| 8 | class MaintenanceBuilder extends AbstractBuilder | 11 | class MaintenanceBuilder extends AbstractBuilder |
| 9 | { | 12 | { |
| @@ -14,7 +17,7 @@ class MaintenanceBuilder extends AbstractBuilder | |||
| 14 | try{ | 17 | try{ |
| 15 | $backup_array = Backup::getBackupList(); | 18 | $backup_array = Backup::getBackupList(); |
| 16 | } | 19 | } |
| 17 | catch(RuntimeException $e){ | 20 | catch(\RuntimeException $e){ |
| 18 | $backup_array = []; | 21 | $backup_array = []; |
| 19 | $_SESSION['flash_message'] = $e->getMessage(); // peut écraser une flash error déjà dans $_SESSION['flash_message'] | 22 | $_SESSION['flash_message'] = $e->getMessage(); // peut écraser une flash error déjà dans $_SESSION['flash_message'] |
| 20 | } | 23 | } |
diff --git a/src/view/MenuBuilder.php b/src/View/MenuBuilder.php index 0395dfa..f14cea7 100644 --- a/src/view/MenuBuilder.php +++ b/src/View/MenuBuilder.php | |||
| @@ -1,12 +1,16 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/MenuBuilder.php | 2 | // src/View/MenuBuilder.php |
| 3 | // | 3 | // |
| 4 | // page Menu et chemins en mode admin, fonctionne avec menu.js | 4 | // page Menu et chemins en mode admin, fonctionne avec menu.js |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\View; | ||
| 9 | |||
| 8 | use App\Entity\Node; | 10 | use App\Entity\Node; |
| 9 | use App\Entity\Page; | 11 | use App\Entity\Page; |
| 12 | use App\Model\Model; | ||
| 13 | use App\Service\URL; | ||
| 10 | 14 | ||
| 11 | class MenuBuilder extends AbstractBuilder | 15 | class MenuBuilder extends AbstractBuilder |
| 12 | { | 16 | { |
diff --git a/src/view/NavBuilder.php b/src/View/NavBuilder.php index 6caefbc..2e3cdbd 100644 --- a/src/view/NavBuilder.php +++ b/src/View/NavBuilder.php | |||
| @@ -1,16 +1,20 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/NavBuilder.php | 2 | // src/View/NavBuilder.php |
| 3 | // | 3 | // |
| 4 | // menu principal | 4 | // menu principal |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | use App\Entity\Node; | 8 | namespace App\View; |
| 9 | |||
| 10 | //use App\Entity\Node; | ||
| 9 | use App\Entity\Page; | 11 | use App\Entity\Page; |
| 12 | use App\Model\Model; | ||
| 13 | use App\Service\URL; | ||
| 10 | 14 | ||
| 11 | class NavBuilder extends AbstractBuilder | 15 | class NavBuilder extends AbstractBuilder |
| 12 | { | 16 | { |
| 13 | public function __construct(Node $node = null) | 17 | public function __construct(/*?Node $node = null*/) |
| 14 | { | 18 | { |
| 15 | $this->html .= '<nav class="nav_main"><ul>'; | 19 | $this->html .= '<nav class="nav_main"><ul>'; |
| 16 | if(count(Model::$menu->getChildren()) > 1 || !Model::$menu->getChildren()[0]->getChildren()->isEmpty()){ | 20 | if(count(Model::$menu->getChildren()) > 1 || !Model::$menu->getChildren()[0]->getChildren()->isEmpty()){ |
diff --git a/src/view/NewBuilder.php b/src/View/NewBuilder.php index 7459cc8..598bb1c 100644 --- a/src/view/NewBuilder.php +++ b/src/View/NewBuilder.php | |||
| @@ -1,9 +1,14 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/NewBuilder.php | 2 | // src/View/NewBuilder.php |
| 3 | // | ||
| 4 | // new = nouvelle (du journal) | ||
| 3 | 5 | ||
| 4 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 5 | 7 | ||
| 8 | namespace App\View; | ||
| 9 | |||
| 6 | use App\Entity\Node; | 10 | use App\Entity\Node; |
| 11 | use App\Service\URL; | ||
| 7 | 12 | ||
| 8 | class NewBuilder extends AbstractBuilder | 13 | class NewBuilder extends AbstractBuilder |
| 9 | { | 14 | { |
diff --git a/src/view/NewPageBuilder.php b/src/View/NewPageBuilder.php index 0a3a137..578a098 100644 --- a/src/view/NewPageBuilder.php +++ b/src/View/NewPageBuilder.php | |||
| @@ -1,19 +1,23 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/NewPageBuilder.php | 2 | // src/View/NewPageBuilder.php |
| 3 | // | 3 | // |
| 4 | // page Nouvelle page en mode admin, fonctionne avec new_page.js | 4 | // page Nouvelle page en mode admin, fonctionne avec new_page.js |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\View; | ||
| 9 | |||
| 8 | use App\Entity\Node; | 10 | use App\Entity\Node; |
| 9 | use App\Entity\Page; | 11 | use App\Entity\Page; |
| 12 | use App\Model\Model; | ||
| 13 | use App\Service\URL; | ||
| 10 | 14 | ||
| 11 | class NewPageBuilder extends AbstractBuilder | 15 | class NewPageBuilder extends AbstractBuilder |
| 12 | { | 16 | { |
| 13 | //private int $margin_left_multiplier = 29; | 17 | //private int $margin_left_multiplier = 29; |
| 14 | private string $options = ''; | 18 | private string $options = ''; |
| 15 | 19 | ||
| 16 | public function __construct(Node $node = null) | 20 | public function __construct(Node $node) |
| 17 | { | 21 | { |
| 18 | //parent::__construct($node); | 22 | //parent::__construct($node); |
| 19 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; | 23 | $viewFile = self::VIEWS_PATH . $node->getName() . '.php'; |
diff --git a/src/view/NewsBlockBuilder.php b/src/View/NewsBlockBuilder.php index f1fe12b..6b3aba5 100644 --- a/src/view/NewsBlockBuilder.php +++ b/src/View/NewsBlockBuilder.php | |||
| @@ -1,9 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/NewsBlockBuilder.php | 2 | // src/View/NewsBlockBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 9 | use App\Service\URL; | ||
| 7 | 10 | ||
| 8 | class NewsBlockBuilder extends AbstractBuilder | 11 | class NewsBlockBuilder extends AbstractBuilder |
| 9 | { | 12 | { |
diff --git a/src/view/PostBlockBuilder.php b/src/View/PostBlockBuilder.php index c6094e8..850364a 100644 --- a/src/view/PostBlockBuilder.php +++ b/src/View/PostBlockBuilder.php | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/PostBlockBuilder.php | 2 | // src/View/PostBlockBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 7 | 9 | ||
| 8 | class PostBlockBuilder extends AbstractBuilder | 10 | class PostBlockBuilder extends AbstractBuilder |
diff --git a/src/view/PostBuilder.php b/src/View/PostBuilder.php index e0bf985..ade7304 100644 --- a/src/view/PostBuilder.php +++ b/src/View/PostBuilder.php | |||
| @@ -1,9 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/PostBuilder.php | 2 | // src/View/PostBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 9 | use App\Service\URL; | ||
| 7 | 10 | ||
| 8 | class PostBuilder extends AbstractBuilder | 11 | class PostBuilder extends AbstractBuilder |
| 9 | { | 12 | { |
diff --git a/src/view/ShowEmailsBuilder.php b/src/View/ShowEmailsBuilder.php index e88b349..b02174d 100644 --- a/src/view/ShowEmailsBuilder.php +++ b/src/View/ShowEmailsBuilder.php | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/ShowEmailsBuilder.php | 2 | // src/View/ShowEmailsBuilder.php |
| 3 | 3 | ||
| 4 | declare(strict_types=1); | 4 | declare(strict_types=1); |
| 5 | 5 | ||
| 6 | namespace App\View; | ||
| 7 | |||
| 6 | use App\Entity\Node; | 8 | use App\Entity\Node; |
| 7 | use App\Entity\Page; | 9 | use App\Service\URL; |
| 8 | 10 | ||
| 9 | class ShowEmailsBuilder extends AbstractBuilder | 11 | class ShowEmailsBuilder extends AbstractBuilder |
| 10 | { | 12 | { |
diff --git a/src/view/UserEditBuilder.php b/src/View/UserEditBuilder.php index 0a347d4..4a9fd90 100644 --- a/src/view/UserEditBuilder.php +++ b/src/View/UserEditBuilder.php | |||
| @@ -1,19 +1,21 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/UserEditBuilder.php | 2 | // src/View/UserEditBuilder.php |
| 3 | // | 3 | // |
| 4 | // fonctionne avec UserController | 4 | // fonctionne avec UserController |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\View; | ||
| 9 | |||
| 8 | use App\Entity\Node; | 10 | use App\Entity\Node; |
| 11 | use App\Service\URL; | ||
| 12 | use App\Service\Captcha; | ||
| 9 | 13 | ||
| 10 | class UserEditBuilder extends AbstractBuilder | 14 | class UserEditBuilder extends AbstractBuilder |
| 11 | { | 15 | { |
| 12 | public function __construct(Node $node) | 16 | public function __construct(Node $node){ |
| 13 | { | ||
| 14 | // pour éviter les arnaques | 17 | // pour éviter les arnaques |
| 15 | if(!IS_ADMIN) | 18 | if(!IS_ADMIN){ |
| 16 | { | ||
| 17 | header('Location: ' . new URL); | 19 | header('Location: ' . new URL); |
| 18 | die; | 20 | die; |
| 19 | } | 21 | } |
diff --git a/src/view/ViewDirector.php b/src/View/ViewDirector.php index c1a38b8..af35179 100644 --- a/src/view/ViewDirector.php +++ b/src/View/ViewDirector.php | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/ViewDirector.php | 2 | // src/View/ViewDirector.php |
| 3 | // | 3 | // |
| 4 | // génère le HTML avec des Builder | 4 | // génère le HTML avec des Builder |
| 5 | 5 | ||
| 6 | declare(strict_types=1); | 6 | declare(strict_types=1); |
| 7 | 7 | ||
| 8 | namespace App\View; | ||
| 9 | |||
| 8 | use App\Entity\Node; | 10 | use App\Entity\Node; |
| 9 | 11 | ||
| 10 | class ViewDirector extends AbstractBuilder // ViewDirector est le premier Builder | 12 | class ViewDirector extends AbstractBuilder // ViewDirector est le premier Builder |
diff --git a/src/view/templates/calendar.php b/src/View/templates/calendar.php index 18f68f2..fd920fd 100644 --- a/src/view/templates/calendar.php +++ b/src/View/templates/calendar.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\View\HeadBuilder; | ||
| 4 | ?> | ||
| 2 | <section class="calendar" id="<?= $this->id_node ?>"> | 5 | <section class="calendar" id="<?= $this->id_node ?>"> |
| 3 | <?= HeadBuilder::insertJS('fullcalendar/index.global.min') ?> | 6 | <?= HeadBuilder::insertJS('fullcalendar/index.global.min') ?> |
| 4 | <?= HeadBuilder::insertJS('fullcalendar/fr.global.min') ?> | 7 | <?= HeadBuilder::insertJS('fullcalendar/fr.global.min') ?> |
diff --git a/src/view/templates/footer.php b/src/View/templates/footer.php index 6450e21..cd8bd0a 100644 --- a/src/view/templates/footer.php +++ b/src/View/templates/footer.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Service\URL; | ||
| 4 | ?> | ||
| 2 | <footer> | 5 | <footer> |
| 3 | <?= $breadcrumb ?> | 6 | <?= $breadcrumb ?> |
| 4 | <div class="data"> | 7 | <div class="data"> |
diff --git a/src/view/templates/form.php b/src/View/templates/form.php index 384bde9..384bde9 100644 --- a/src/view/templates/form.php +++ b/src/View/templates/form.php | |||
diff --git a/src/view/templates/form_admin.php b/src/View/templates/form_admin.php index d745656..47bca38 100644 --- a/src/view/templates/form_admin.php +++ b/src/View/templates/form_admin.php | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/view/templates/form_params.php | 2 | // src/view/templates/form_params.php |
| 3 | declare(strict_types=1); | 3 | declare(strict_types=1); |
| 4 | use App\Service\URL; | ||
| 4 | // note: l'id ici n'est pas celui du noeud bloc mais celui de l'entrée dans node_data correspondante | 5 | // note: l'id ici n'est pas celui du noeud bloc mais celui de l'entrée dans node_data correspondante |
| 5 | ?> | 6 | ?> |
| 6 | <div class="admin_form"> | 7 | <div class="admin_form"> |
diff --git a/src/view/templates/galery.php b/src/View/templates/galery.php index 97f8cd8..97f8cd8 100644 --- a/src/view/templates/galery.php +++ b/src/View/templates/galery.php | |||
diff --git a/src/view/templates/head.php b/src/View/templates/head.php index bce0a19..bce0a19 100644 --- a/src/view/templates/head.php +++ b/src/View/templates/head.php | |||
diff --git a/src/view/templates/header.php b/src/View/templates/header.php index 400c7c0..08bc478 100644 --- a/src/view/templates/header.php +++ b/src/View/templates/header.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Service\URL; | ||
| 4 | ?> | ||
| 2 | <body> | 5 | <body> |
| 3 | <div> | 6 | <div> |
| 4 | <header style="background-image: url('<?= $header_background ?? '' ?>');"> | 7 | <header style="background-image: url('<?= $header_background ?? '' ?>');"> |
diff --git a/src/view/templates/login.php b/src/View/templates/login.php index 3257690..3257690 100644 --- a/src/view/templates/login.php +++ b/src/View/templates/login.php | |||
diff --git a/src/view/templates/maintenance.php b/src/View/templates/maintenance.php index 61d5146..5a8a46d 100644 --- a/src/view/templates/maintenance.php +++ b/src/View/templates/maintenance.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Service\URL; | ||
| 4 | ?> | ||
| 2 | <section class="maintenance"> | 5 | <section class="maintenance"> |
| 3 | <h3>Maintenance du site</h3> | 6 | <h3>Maintenance du site</h3> |
| 4 | <div class="basic_div"> | 7 | <div class="basic_div"> |
diff --git a/src/view/templates/menu.php b/src/View/templates/menu.php index ccfb518..5a15fdb 100644 --- a/src/view/templates/menu.php +++ b/src/View/templates/menu.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Service\URL; | ||
| 4 | ?> | ||
| 2 | <section class="menu"> | 5 | <section class="menu"> |
| 3 | <h3>Menu et chemins</h3> | 6 | <h3>Menu et chemins</h3> |
| 4 | <div class="new_page_button"> | 7 | <div class="new_page_button"> |
diff --git a/src/view/templates/modify_block.php b/src/View/templates/modify_block.php index e966ee3..bb5abd3 100644 --- a/src/view/templates/modify_block.php +++ b/src/View/templates/modify_block.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Service\URL; | ||
| 4 | ?> | ||
| 2 | <div class="modify_one_block" id="bloc_edit_<?= $child_node->getId() ?>"> | 5 | <div class="modify_one_block" id="bloc_edit_<?= $child_node->getId() ?>"> |
| 3 | <div class="block_options"> | 6 | <div class="block_options"> |
| 4 | <label for="bloc_rename_<?= $child_node->getId() ?>">Type <b><?= App\Entity\Presentation::BLOCKS[$child_node->getName()] ?? '<i>erreur base de données</i>' ?></b> | 7 | <label for="bloc_rename_<?= $child_node->getId() ?>">Type <b><?= App\Entity\Presentation::BLOCKS[$child_node->getName()] ?? '<i>erreur base de données</i>' ?></b> |
diff --git a/src/view/templates/modify_page.php b/src/View/templates/modify_page.php index d32179c..773277b 100644 --- a/src/view/templates/modify_page.php +++ b/src/View/templates/modify_page.php | |||
| @@ -1,4 +1,8 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Model\Model; | ||
| 4 | use App\Service\URL; | ||
| 5 | ?> | ||
| 2 | <section class="page_modification"> | 6 | <section class="page_modification"> |
| 3 | <h3>Modification de la page</h3> | 7 | <h3>Modification de la page</h3> |
| 4 | <div class="edit_page_zone"> | 8 | <div class="edit_page_zone"> |
diff --git a/src/view/templates/new.php b/src/View/templates/new.php index 30b244f..30b244f 100644 --- a/src/view/templates/new.php +++ b/src/View/templates/new.php | |||
diff --git a/src/view/templates/new_page.php b/src/View/templates/new_page.php index 7bf4c01..535d88d 100644 --- a/src/view/templates/new_page.php +++ b/src/View/templates/new_page.php | |||
| @@ -1,4 +1,7 @@ | |||
| 1 | <?php declare(strict_types=1); ?> | 1 | <?php |
| 2 | declare(strict_types=1); | ||
| 3 | use App\Service\URL; | ||
| 4 | ?> | ||
| 2 | <section class="new_page"> | 5 | <section class="new_page"> |
| 3 | <h3>Création d'une nouvelle page</h3> | 6 | <h3>Création d'une nouvelle page</h3> |
| 4 | <div class="form_zone"> | 7 | <div class="form_zone"> |
diff --git a/src/view/templates/news_block.php b/src/View/templates/news_block.php index 43dbe01..43dbe01 100644 --- a/src/view/templates/news_block.php +++ b/src/View/templates/news_block.php | |||
diff --git a/src/view/templates/post.php b/src/View/templates/post.php index d0d01b2..d0d01b2 100644 --- a/src/view/templates/post.php +++ b/src/View/templates/post.php | |||
diff --git a/src/view/templates/post_block.php b/src/View/templates/post_block.php index 43dbe01..43dbe01 100644 --- a/src/view/templates/post_block.php +++ b/src/View/templates/post_block.php | |||
diff --git a/src/view/templates/show_emails.php b/src/View/templates/show_emails.php index f561dc7..f561dc7 100644 --- a/src/view/templates/show_emails.php +++ b/src/View/templates/show_emails.php | |||
diff --git a/src/view/templates/user_create.php b/src/View/templates/user_create.php index 870b904..662d9ac 100644 --- a/src/view/templates/user_create.php +++ b/src/View/templates/user_create.php | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | declare(strict_types=1); | 2 | declare(strict_types=1); |
| 3 | use App\Service\Captcha; | ||
| 3 | 4 | ||
| 4 | $error_messages = [ | 5 | $error_messages = [ |
| 5 | 'error_non_valid_captcha' => 'Erreur au test anti-robot, veuillez saisir un nombre entier.', | 6 | 'error_non_valid_captcha' => 'Erreur au test anti-robot, veuillez saisir un nombre entier.', |
diff --git a/src/view/templates/user_edit.php b/src/View/templates/user_edit.php index 9191e7d..9191e7d 100644 --- a/src/view/templates/user_edit.php +++ b/src/View/templates/user_edit.php | |||
diff --git a/src/service/UserDataService.php b/src/service/UserDataService.php deleted file mode 100644 index e0156e2..0000000 --- a/src/service/UserDataService.php +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | // src/service/UserDataService.php | ||
| 3 | |||
| 4 | declare(strict_types=1); | ||
| 5 | |||
| 6 | class UserDataService | ||
| 7 | { | ||
| 8 | static private string $var = '../var'; | ||
| 9 | |||
| 10 | static public function createZip(string $zip_name, array $source_directories, array $pattern_to_target_in_user_data = []): string | ||
| 11 | { | ||
| 12 | $file_path = self::$var . '/' . $zip_name; | ||
| 13 | $Zip = new ZipArchive(); | ||
| 14 | |||
| 15 | if($Zip->open($file_path, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== TRUE){ // ou ZipArchive::FL_OVERWRITE, à comparer à ZipArchive::OVERWRITE | ||
| 16 | throw new RuntimeException("Création ou ouverture du fichier demandé impossible à cause d'une erreur de permissions sur le serveur."); | ||
| 17 | } | ||
| 18 | |||
| 19 | // recherche récursive dans les dossiers dans $source_directories, c'est comme le paramètre "-r" dans la console | ||
| 20 | $counter = 0; | ||
| 21 | foreach($source_directories as $path){ | ||
| 22 | $directory = new RecursiveDirectoryIterator($path); | ||
| 23 | $iterator = new RecursiveIteratorIterator($directory); | ||
| 24 | |||
| 25 | foreach($iterator as $info){ | ||
| 26 | if($info->getFilename() != "." && $info->getFilename() != ".." && $info->getFilename() != '.htaccess'){ // chemins inutiles . et .. et le .htaccess | ||
| 27 | $Zip->addGlob($info->getPathname(), 0, array('')); | ||
| 28 | $counter++; | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | // recherche à la racine avec des pattern de noms de fichiers (optionnel) | ||
| 33 | foreach($pattern_to_target_in_user_data as $one_pattern){ | ||
| 34 | $Zip->addGlob($one_pattern, 0, array('')); | ||
| 35 | } | ||
| 36 | |||
| 37 | $Zip->close(); | ||
| 38 | if($counter > 0){ | ||
| 39 | //chmod($file_path, 0666); | ||
| 40 | return $zip_name; | ||
| 41 | } | ||
| 42 | else{ | ||
| 43 | throw new RuntimeException("Téléchargement des fichiers impossible, aucun fichier n'a été trouvé sur le serveur."); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } \ No newline at end of file | ||
