aboutsummaryrefslogtreecommitdiff
path: root/src
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
parent34d4b26dc3984fc2cca8226dbd43db3945697cc6 (diff)
downloadcms-3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7.tar.gz
cms-3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7.tar.bz2
cms-3fb48f4bf19b5e5d73607509c0d15a4f8864e1b7.zip
renommage pour mes yeux
Diffstat (limited to 'src')
-rw-r--r--src/controller/MenuAndPathsController.php32
-rw-r--r--src/controller/PageManagementController.php12
-rw-r--r--src/model/Model.php4
-rw-r--r--src/model/Path.php2
-rw-r--r--src/router.php2
-rw-r--r--src/view/MenuBuilder.php4
-rw-r--r--src/view/NavBuilder.php4
-rw-r--r--src/view/NewPageBuilder.php2
8 files changed, 31 insertions, 31 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();
diff --git a/src/model/Model.php b/src/model/Model.php
index eeba8b2..b650183 100644
--- a/src/model/Model.php
+++ b/src/model/Model.php
@@ -15,7 +15,7 @@ use Symfony\Component\HttpFoundation\Request;
15class Model 15class Model
16{ 16{
17 private EntityManager $entityManager; 17 private EntityManager $entityManager;
18 static public Menu $menu_data; // pour NavBuilder 18 static public Menu $menu; // pour NavBuilder
19 static public ?Path $page_path = null; // pour $current dans NavBuilder et pour BreadcrumbBuilder 19 static public ?Path $page_path = null; // pour $current dans NavBuilder et pour BreadcrumbBuilder
20 private Page $page; 20 private Page $page;
21 private ?Node $node; 21 private ?Node $node;
@@ -31,7 +31,7 @@ class Model
31 // couper Model en deux classes NodeModel et PageModel? 31 // couper Model en deux classes NodeModel et PageModel?
32 public function makeMenuAndPaths(): void // lit la table "page" 32 public function makeMenuAndPaths(): void // lit la table "page"
33 { 33 {
34 self::$menu_data = new Menu($this->entityManager); 34 self::$menu = new Menu($this->entityManager);
35 self::$page_path = new Path(); 35 self::$page_path = new Path();
36 $this->page = self::$page_path->getLast(); 36 $this->page = self::$page_path->getLast();
37 } 37 }
diff --git a/src/model/Path.php b/src/model/Path.php
index bf9653e..8ef9100 100644
--- a/src/model/Path.php
+++ b/src/model/Path.php
@@ -17,7 +17,7 @@ class Path extends Page
17 $path_array = explode('/', CURRENT_PAGE); 17 $path_array = explode('/', CURRENT_PAGE);
18 try{ 18 try{
19 // parcourir le menu de haut en bas pour obtenir un ou plusieurs objets Page 19 // parcourir le menu de haut en bas pour obtenir un ou plusieurs objets Page
20 $this->findPage(Model::$menu_data, $path_array); // remplit $this->current_page 20 $this->findPage(Model::$menu, $path_array); // remplit $this->current_page
21 } 21 }
22 catch(Exception $e){} 22 catch(Exception $e){}
23 } 23 }
diff --git a/src/router.php b/src/router.php
index 2ba3b88..42ccaed 100644
--- a/src/router.php
+++ b/src/router.php
@@ -153,7 +153,7 @@ elseif($request->getMethod() === 'POST'){
153 elseif(isset($_GET['menu_edit'])) 153 elseif(isset($_GET['menu_edit']))
154 { 154 {
155 // ne suit pas la règle, faire ça dans un contrôleur? 155 // ne suit pas la règle, faire ça dans un contrôleur?
156 Model::$menu_data = new Menu($entityManager); // récupération des données 156 Model::$menu = new Menu($entityManager); // récupération des données
157 157
158 // flèche gauche <=: position = position du parent + 1, parent = grand-parent, recalculer les positions 158 // flèche gauche <=: position = position du parent + 1, parent = grand-parent, recalculer les positions
159 if($_GET['menu_edit'] === 'move_one_level_up' && isset($json['id'])){ 159 if($_GET['menu_edit'] === 'move_one_level_up' && isset($json['id'])){
diff --git a/src/view/MenuBuilder.php b/src/view/MenuBuilder.php
index e9bc4bc..dbbe3e7 100644
--- a/src/view/MenuBuilder.php
+++ b/src/view/MenuBuilder.php
@@ -21,10 +21,10 @@ class MenuBuilder extends AbstractBuilder
21 if(file_exists($viewFile)) 21 if(file_exists($viewFile))
22 { 22 {
23 if($_SESSION['admin']){ 23 if($_SESSION['admin']){
24 $this->unfoldMenu(Model::$menu_data); 24 $this->unfoldMenu(Model::$menu);
25 25
26 if($template){ 26 if($template){
27 $this->unfoldOptions(Model::$menu_data); 27 $this->unfoldOptions(Model::$menu);
28 } 28 }
29 } 29 }
30 else{ 30 else{
diff --git a/src/view/NavBuilder.php b/src/view/NavBuilder.php
index 2cded67..03b4c97 100644
--- a/src/view/NavBuilder.php
+++ b/src/view/NavBuilder.php
@@ -13,9 +13,9 @@ class NavBuilder extends AbstractBuilder
13 public function __construct(Node $node = null) 13 public function __construct(Node $node = null)
14 { 14 {
15 $this->html .= '<nav class="nav_main"><ul>'; 15 $this->html .= '<nav class="nav_main"><ul>';
16 if(count(Model::$menu_data->getChildren()) > 1){ 16 if(count(Model::$menu->getChildren()) > 1){
17 $this->html .= $this->navMainHTML( 17 $this->html .= $this->navMainHTML(
18 Model::$menu_data, // Menu étend Page 18 Model::$menu, // Menu étend Page
19 Model::$page_path != null ? Model::$page_path->getArray() : []); // param nullable, ça retire une dépendance stricte entre NavBuilder et Model 19 Model::$page_path != null ? Model::$page_path->getArray() : []); // param nullable, ça retire une dépendance stricte entre NavBuilder et Model
20 } 20 }
21 $this->html .= '</ul></nav>'; 21 $this->html .= '</ul></nav>';
diff --git a/src/view/NewPageBuilder.php b/src/view/NewPageBuilder.php
index 7bf8628..d519a22 100644
--- a/src/view/NewPageBuilder.php
+++ b/src/view/NewPageBuilder.php
@@ -25,7 +25,7 @@ class NewPageBuilder extends AbstractBuilder
25 extract($node->getNodeData()->getData()); 25 extract($node->getNodeData()->getData());
26 }*/ 26 }*/
27 27
28 $this->unfoldOptions(Model::$menu_data); 28 $this->unfoldOptions(Model::$menu);
29 29
30 ob_start(); 30 ob_start();
31 require $viewFile; // insertion de $this->html généré par unfoldMenu 31 require $viewFile; // insertion de $this->html généré par unfoldMenu