aboutsummaryrefslogtreecommitdiff
path: root/src/controller
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2026-07-02 00:01:31 +0200
committerpolo <ordipolo@gmx.fr>2026-07-02 00:01:31 +0200
commit0fa852ee4e9c3060ba7fc0daf4b08a44ea151f7f (patch)
treeaa41e7a0a2e41649dea66114e73a26574a042b85 /src/controller
parent9021dc699874c46b72dcbe019ec1a4408fbf6d70 (diff)
downloadcms-0fa852ee4e9c3060ba7fc0daf4b08a44ea151f7f.tar.gz
cms-0fa852ee4e9c3060ba7fc0daf4b08a44ea151f7f.tar.bz2
cms-0fa852ee4e9c3060ba7fc0daf4b08a44ea151f7f.zip
entité Presentation, MAJ filtre ViewController::SPECIAL_PAGES, table node_data non allégée pour l'instant
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/ArticleController.php7
-rw-r--r--src/controller/PageManagementController.php12
-rw-r--r--src/controller/ViewController.php7
3 files changed, 17 insertions, 9 deletions
diff --git a/src/controller/ArticleController.php b/src/controller/ArticleController.php
index 7019f5c..0ddb0e1 100644
--- a/src/controller/ArticleController.php
+++ b/src/controller/ArticleController.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
5 5
6use App\Entity\Node; 6use App\Entity\Node;
7use App\Entity\Article; 7use App\Entity\Article;
8use App\Entity\Presentation;
8use Doctrine\ORM\EntityManager; 9use Doctrine\ORM\EntityManager;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpFoundation\Response; 11use Symfony\Component\HttpFoundation\Response;
@@ -21,7 +22,7 @@ class ArticleController
21 $model->findNodeById($id); 22 $model->findNodeById($id);
22 $parent_block = $model->getNode(); 23 $parent_block = $model->getNode();
23 24
24 if(Blocks::hasPresentation($parent_block->getName())){ 25 if(Presentation::hasPresentation($parent_block->getName())){
25 $get_articles_return = $model->getNextArticles($parent_block, $request); 26 $get_articles_return = $model->getNextArticles($parent_block, $request);
26 $bulk_data = $get_articles_return[0]; 27 $bulk_data = $get_articles_return[0];
27 28
@@ -44,11 +45,11 @@ class ArticleController
44 return new JsonResponse(['success' => true, 'html' => $html, 'truncated' => $get_articles_return[1]]); 45 return new JsonResponse(['success' => true, 'html' => $html, 'truncated' => $get_articles_return[1]]);
45 } 46 }
46 else{ 47 else{
47 return new JsonResponse(['success' => false, 'error' => 'server side error']); 48 return new JsonResponse(['success' => false, 'error' => 'server side error'], JsonResponse::HTTP_INTERNAL_SERVER_ERROR);
48 } 49 }
49 } 50 }
50 else{ 51 else{
51 return new JsonResponse(['success' => false, 'error' => 'bad parameters']); 52 return new JsonResponse(['success' => false, 'error' => 'bad parameters'], JsonResponse::HTTP_BAD_REQUEST);
52 } 53 }
53 } 54 }
54 55
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php
index c575077..bfad474 100644
--- a/src/controller/PageManagementController.php
+++ b/src/controller/PageManagementController.php
@@ -7,6 +7,7 @@ use App\Entity\Page;
7use App\Entity\Node; 7use App\Entity\Node;
8use App\Entity\NodeData; 8use App\Entity\NodeData;
9use App\Entity\EmailForm; 9use App\Entity\EmailForm;
10use App\Entity\Presentation;
10//use App\Entity\Image; 11//use App\Entity\Image;
11use Doctrine\ORM\EntityManager; 12use Doctrine\ORM\EntityManager;
12use Symfony\Component\HttpFoundation\InputBag; 13use Symfony\Component\HttpFoundation\InputBag;
@@ -131,7 +132,7 @@ class PageManagementController
131 $main = $model->getNode(); 132 $main = $model->getNode();
132 $position = count($main->getChildren()) + 1; // position dans la fraterie 133 $position = count($main->getChildren()) + 1; // position dans la fraterie
133 134
134 if(!in_array($request->request->get("bloc_select"), array_keys(Blocks::$blocks), true)){ // 3è param: contrôle du type 135 if(!in_array($request->request->get("bloc_select"), array_keys(Presentation::$blocks), true)){ // 3è param: contrôle du type
135 // utiliser une flash error 136 // utiliser une flash error
136 return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'error' => 'bad_bloc_type'])); 137 return new RedirectResponse((string)new URL(['page' => $request->query->get('page'), 'error' => 'bad_bloc_type']));
137 } 138 }
@@ -146,7 +147,12 @@ class PageManagementController
146 147
147 $block = new Node($request->request->get("bloc_select"), $position, $main, $page); 148 $block = new Node($request->request->get("bloc_select"), $position, $main, $page);
148 149
149 $DataClass = $request->request->get("bloc_select") === 'form' ? EmailForm::class : NodeData::class; // cas particulier avec bloc 'email_form' 150 $DataClass = match($request->request->get("bloc_select")){
151 'form' => EmailForm::class,
152 'post_block', 'news_block' => Presentation::class,
153 'calendar' => NodeData::class,
154 default => throw new InvalidArgumentException("Erreur: type de bloc inconnu"),
155 };
150 $data = new $DataClass(['title' => trim(htmlspecialchars($request->request->get("bloc_title")))], $block); 156 $data = new $DataClass(['title' => trim(htmlspecialchars($request->request->get("bloc_title")))], $block);
151 157
152 // valeurs par défaut 158 // valeurs par défaut
@@ -305,7 +311,7 @@ class PageManagementController
305 $model = new Model($entityManager); 311 $model = new Model($entityManager);
306 $model->findNodeById($json['id']); 312 $model->findNodeById($json['id']);
307 313
308 if(in_array($json['presentation'], array_keys(Blocks::$presentations))){ 314 if(in_array($json['presentation'], array_keys(Presentation::$presentations))){
309 $model->getNode()->getNodeData()->setPresentation($json['presentation']); 315 $model->getNode()->getNodeData()->setPresentation($json['presentation']);
310 $entityManager->flush(); 316 $entityManager->flush();
311 317
diff --git a/src/controller/ViewController.php b/src/controller/ViewController.php
index 43db6a6..d1aaee7 100644
--- a/src/controller/ViewController.php
+++ b/src/controller/ViewController.php
@@ -8,8 +8,9 @@ use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 8use Symfony\Component\HttpFoundation\Response;
9use Symfony\Component\HttpFoundation\RedirectResponse; 9use Symfony\Component\HttpFoundation\RedirectResponse;
10 10
11class ViewController 11class ViewController{
12{ 12 const SPECIAL_PAGES = ['article', 'new_page', 'menu_paths', 'user_edit', 'connection', 'emails', 'maintenance'];
13
13 static function getWebPage(EntityManager $entityManager, Request $request): Response 14 static function getWebPage(EntityManager $entityManager, Request $request): Response
14 { 15 {
15 /* 1/ 1er contrôle des paramètres */ 16 /* 1/ 1er contrôle des paramètres */
@@ -17,7 +18,7 @@ class ViewController
17 // mode modification d'une page 18 // mode modification d'une page
18 if(IS_ADMIN 19 if(IS_ADMIN
19 && $request->query->has('mode') && $request->query->get('mode') === 'page_modif' 20 && $request->query->has('mode') && $request->query->get('mode') === 'page_modif'
20 && !in_array(CURRENT_PAGE, ['article', 'new_page', 'menu_paths', 'user_edit', 'connection'])) 21 && !in_array(CURRENT_PAGE, self::SPECIAL_PAGES))
21 { 22 {
22 MainBuilder::$modif_mode = true; 23 MainBuilder::$modif_mode = true;
23 } 24 }