aboutsummaryrefslogtreecommitdiff
path: root/src/controller
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-11-01 23:35:25 +0100
committerpolo <ordipolo@gmx.fr>2025-11-01 23:35:25 +0100
commit3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7 (patch)
tree9bab7aeff8c16b3dca39a2326eea87b911d83050 /src/controller
parent34d4b26dc3984fc2cca8226dbd43db3945697cc6 (diff)
downloadcms-3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7.tar.gz
cms-3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7.tar.bz2
cms-3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7.zip
renommage pour mes yeux
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/MenuAndPathsController.php32
-rw-r--r--src/controller/PageManagementController.php12
2 files changed, 22 insertions, 22 deletions
diff --git a/src/controller/MenuAndPathsController.php b/src/controller/MenuAndPathsController.php
index 6bb098f..4d37f3d 100644
--- a/src/controller/MenuAndPathsController.php
+++ b/src/controller/MenuAndPathsController.php
@@ -10,8 +10,8 @@ class MenuAndPathsController
10{ 10{
11 static public function newUrlMenuEntry(EntityManager $entityManager): void 11 static public function newUrlMenuEntry(EntityManager $entityManager): void
12 { 12 {
13 Model::$menu_data = new Menu($entityManager); 13 Model::$menu = new Menu($entityManager);
14 $previous_page = Model::$menu_data->findPageById((int)$_POST["location"]); // (int) à cause de declare(strict_types=1); 14 $previous_page = Model::$menu->findPageById((int)$_POST["location"]); // (int) à cause de declare(strict_types=1);
15 $parent = $previous_page->getParent(); 15 $parent = $previous_page->getParent();
16 16
17 $url_input = trim($_POST["url_input"]); // faire htmlspecialchars à l'affichage 17 $url_input = trim($_POST["url_input"]); // faire htmlspecialchars à l'affichage
@@ -31,7 +31,7 @@ class MenuAndPathsController
31 // addChild l'ajoute à la fin du tableau "children" puis on trie 31 // addChild l'ajoute à la fin du tableau "children" puis on trie
32 // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position 32 // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position
33 if(!$parent){ 33 if(!$parent){
34 $parent = Model::$menu_data; 34 $parent = Model::$menu;
35 } 35 }
36 $parent->addChild($page); // true pour réindexer les positions en BDD 36 $parent->addChild($page); // true pour réindexer les positions en BDD
37 $parent->reindexPositions(); 37 $parent->reindexPositions();
@@ -72,11 +72,11 @@ class MenuAndPathsController
72 72
73 static public function deleteUrlMenuEntry(EntityManager $entityManager): void 73 static public function deleteUrlMenuEntry(EntityManager $entityManager): void
74 { 74 {
75 Model::$menu_data = new Menu($entityManager); 75 Model::$menu = new Menu($entityManager);
76 $page = Model::$menu_data->findPageById((int)$_POST["delete"]); 76 $page = Model::$menu->findPageById((int)$_POST["delete"]);
77 $parent = $page->getParent(); 77 $parent = $page->getParent();
78 if($parent == null){ 78 if($parent == null){
79 $parent = Model::$menu_data; 79 $parent = Model::$menu;
80 } 80 }
81 81
82 $parent->removeChild($page); // suppression de $children avant de trier 82 $parent->removeChild($page); // suppression de $children avant de trier
@@ -91,7 +91,7 @@ class MenuAndPathsController
91 static public function MoveOneLevelUp(EntityManager $entityManager, array $json): void 91 static public function MoveOneLevelUp(EntityManager $entityManager, array $json): void
92 { 92 {
93 $id = $json['id']; 93 $id = $json['id'];
94 $page = Model::$menu_data->findPageById((int)$id); 94 $page = Model::$menu->findPageById((int)$id);
95 95
96 $parent = $page->getParent(); // peut être null 96 $parent = $page->getParent(); // peut être null
97 if($parent === null){ 97 if($parent === null){
@@ -103,12 +103,12 @@ class MenuAndPathsController
103 else{ 103 else{
104 $page->setPosition($parent->getPosition() + 1); // nouvelle position 104 $page->setPosition($parent->getPosition() + 1); // nouvelle position
105 105
106 // 2ème niveau: le parent devient $menu_data, puis null après tri 106 // 2ème niveau: le parent devient $menu, puis null après tri
107 if($parent->getParent() === null){ 107 if($parent->getParent() === null){
108 // connexion dans les deux sens 108 // connexion dans les deux sens
109 $page->setParent(Model::$menu_data); // => pour la persistance 109 $page->setParent(Model::$menu); // => pour la persistance
110 110
111 //Model::$menu_data->addChild($page); // => pour sortChildren 111 //Model::$menu->addChild($page); // => pour sortChildren
112 $page->getParent()->addChild($page); // => pour sortChildren 112 $page->getParent()->addChild($page); // => pour sortChildren
113 $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères 113 $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères
114 $page->setParent(null); 114 $page->setParent(null);
@@ -138,11 +138,11 @@ class MenuAndPathsController
138 static public function MoveOneLevelDown(EntityManager $entityManager, array $json): void 138 static public function MoveOneLevelDown(EntityManager $entityManager, array $json): void
139 { 139 {
140 $id = $json['id']; 140 $id = $json['id'];
141 $page = Model::$menu_data->findPageById((int)$id); 141 $page = Model::$menu->findPageById((int)$id);
142 142
143 $parent = $page->getParent(); // peut être null 143 $parent = $page->getParent(); // peut être null
144 if($parent == null){ 144 if($parent == null){
145 $parent = Model::$menu_data; 145 $parent = Model::$menu;
146 } 146 }
147 147
148 // BDD 148 // BDD
@@ -175,8 +175,8 @@ class MenuAndPathsController
175 $id2 = $json['id2']; 175 $id2 = $json['id2'];
176 176
177 // vérifier qu'ils ont le même parent 177 // vérifier qu'ils ont le même parent
178 $page1 = Model::$menu_data->findPageById((int)$id1); 178 $page1 = Model::$menu->findPageById((int)$id1);
179 $page2 = Model::$menu_data->findPageById((int)$id2); 179 $page2 = Model::$menu->findPageById((int)$id2);
180 180
181 // double le contrôle fait en JS 181 // double le contrôle fait en JS
182 if($page1->getParent() === $page2->getParent()) // comparaison stricte d'objet (même instance du parent?) 182 if($page1->getParent() === $page2->getParent()) // comparaison stricte d'objet (même instance du parent?)
@@ -185,7 +185,7 @@ class MenuAndPathsController
185 $tmp = $page1->getPosition(); 185 $tmp = $page1->getPosition();
186 $page1->setPosition($page2->getPosition()); 186 $page1->setPosition($page2->getPosition());
187 $page2->setPosition($tmp); 187 $page2->setPosition($tmp);
188 Model::$menu_data->sortChildren(true); // modifie tableau children 188 Model::$menu->sortChildren(true); // modifie tableau children
189 $entityManager->flush(); 189 $entityManager->flush();
190 190
191 // nouveau menu 191 // nouveau menu
@@ -203,7 +203,7 @@ class MenuAndPathsController
203 $id = $json['id']; 203 $id = $json['id'];
204 $checked = $json['checked']; 204 $checked = $json['checked'];
205 205
206 $page = Model::$menu_data->findPageById((int)$id); 206 $page = Model::$menu->findPageById((int)$id);
207 if($page->isHidden() === $checked){ 207 if($page->isHidden() === $checked){
208 $page->setHidden(!$checked); 208 $page->setHidden(!$checked);
209 $entityManager->flush(); 209 $entityManager->flush();
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php
index 7697864..45c6027 100644
--- a/src/controller/PageManagementController.php
+++ b/src/controller/PageManagementController.php
@@ -25,7 +25,7 @@ class PageManagementController
25 25
26 static public function updatePageMenuPath(EntityManager $entityManager): void 26 static public function updatePageMenuPath(EntityManager $entityManager): void
27 { 27 {
28 Model::$menu_data = new Menu($entityManager); 28 Model::$menu = new Menu($entityManager);
29 Model::$page_path = new Path(); 29 Model::$page_path = new Path();
30 $page = Model::$page_path->getLast(); 30 $page = Model::$page_path->getLast();
31 $path = htmlspecialchars($_POST['page_menu_path']); 31 $path = htmlspecialchars($_POST['page_menu_path']);
@@ -33,7 +33,7 @@ class PageManagementController
33 // mise en snake_case: filtre caractères non-alphanumériques, minuscule, doublons d'underscore, trim des underscores 33 // mise en snake_case: filtre caractères non-alphanumériques, minuscule, doublons d'underscore, trim des underscores
34 $path = trim(preg_replace('/_+/', '_', strtolower(preg_replace('/[^a-zA-Z0-9]/', '_', $path))), '_'); 34 $path = trim(preg_replace('/_+/', '_', strtolower(preg_replace('/[^a-zA-Z0-9]/', '_', $path))), '_');
35 $page->setEndOfPath($path); 35 $page->setEndOfPath($path);
36 foreach(Model::$menu_data->getChildren() as $child){ 36 foreach(Model::$menu->getChildren() as $child){
37 if($child->getEndOfPath() === Model::$page_path->getArray()[0]->getEndOfPath()){ 37 if($child->getEndOfPath() === Model::$page_path->getArray()[0]->getEndOfPath()){
38 $child->fillChildrenPagePath(); // MAJ de $page_path 38 $child->fillChildrenPagePath(); // MAJ de $page_path
39 } 39 }
@@ -55,8 +55,8 @@ class PageManagementController
55 static public function newPage(EntityManager $entityManager, array $post): void 55 static public function newPage(EntityManager $entityManager, array $post): void
56 { 56 {
57 // titre et chemin 57 // titre et chemin
58 Model::$menu_data = new Menu($entityManager); 58 Model::$menu = new Menu($entityManager);
59 $previous_page = Model::$menu_data->findPageById((int)$post["page_location"]); // (int) à cause de declare(strict_types=1); 59 $previous_page = Model::$menu->findPageById((int)$post["page_location"]); // (int) à cause de declare(strict_types=1);
60 $parent = $previous_page->getParent(); 60 $parent = $previous_page->getParent();
61 61
62 $page = new Page( 62 $page = new Page(
@@ -71,7 +71,7 @@ class PageManagementController
71 // addChild l'ajoute à la fin du tableau "children" puis on trie 71 // addChild l'ajoute à la fin du tableau "children" puis on trie
72 // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position 72 // exemple avec 2 comme position demandée: 1 2 3 4 2 devient 1 2 3 4 5 et la nouvelle entrée sera en 3è position
73 if($parent == null){ 73 if($parent == null){
74 $parent = Model::$menu_data; 74 $parent = Model::$menu;
75 } 75 }
76 $parent->addChild($page); 76 $parent->addChild($page);
77 $parent->reindexPositions(); 77 $parent->reindexPositions();
@@ -109,7 +109,7 @@ class PageManagementController
109 static public function addBloc(EntityManager $entityManager): void 109 static public function addBloc(EntityManager $entityManager): void
110 { 110 {
111 $model = new Model($entityManager); 111 $model = new Model($entityManager);
112 $model->makeMenuAndPaths(); // on a besoin de page_path qui dépend de menu_data 112 $model->makeMenuAndPaths(); // on a besoin de page_path qui dépend de menu
113 $page = Model::$page_path->getLast(); 113 $page = Model::$page_path->getLast();
114 $model->findUniqueNodeByName('main'); 114 $model->findUniqueNodeByName('main');
115 $model->findItsChildren(); 115 $model->findItsChildren();