summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-04-21 20:36:10 +0200
committerpolo <ordipolo@gmx.fr>2025-04-21 20:36:10 +0200
commiteb3e1eb8c8365d3b3d1d39f24314ba420255afc2 (patch)
tree5e3d747b0e4d5e747052e9afed76f3a0f0986379 /src
parentca3949aca0c7c1af476c8eec93b4920d5aff21ec (diff)
downloadcms-eb3e1eb8c8365d3b3d1d39f24314ba420255afc2.zip
page menu et chemin, partie1
Diffstat (limited to 'src')
-rw-r--r--src/controller/Director.php2
-rw-r--r--src/controller/ajax.php44
-rw-r--r--src/controller/installation.php10
-rw-r--r--src/controller/password.php2
-rw-r--r--src/model/Position.php63
-rw-r--r--src/model/entities/Node.php33
-rw-r--r--src/model/entities/Page.php38
-rw-r--r--src/view/FooterBuilder.php2
-rw-r--r--src/view/HeaderBuilder.php2
-rw-r--r--src/view/MenuBuilder.php88
-rw-r--r--src/view/NavBuilder.php9
-rw-r--r--src/view/templates/header.php2
-rw-r--r--src/view/templates/menu.php15
13 files changed, 254 insertions, 56 deletions
diff --git a/src/controller/Director.php b/src/controller/Director.php
index b7be9b8..a2528ed 100644
--- a/src/controller/Director.php
+++ b/src/controller/Director.php
@@ -11,7 +11,7 @@ class Director
11{ 11{
12 private EntityManager $entityManager; 12 private EntityManager $entityManager;
13 static public Menu $menu_data; // pour NavBuilder 13 static public Menu $menu_data; // pour NavBuilder
14 static public Path $page_path; // pour BreadcrumbBuilder 14 static public ?Path $page_path = null; // pour $current dans NavBuilder et pour BreadcrumbBuilder
15 private Page $page; 15 private Page $page;
16 private Node $node; 16 private Node $node;
17 private Node $article; 17 private Node $article;
diff --git a/src/controller/ajax.php b/src/controller/ajax.php
index a4b61e4..c774bf3 100644
--- a/src/controller/ajax.php
+++ b/src/controller/ajax.php
@@ -6,7 +6,7 @@ declare(strict_types=1);
6use App\Entity\Article; 6use App\Entity\Article;
7use App\Entity\Node; 7use App\Entity\Node;
8 8
9// détection des requêtes de tinymce 9// détection des requêtes de tinymce ou touchant aux articles
10if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) 10if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action']))
11{ 11{
12 // récupération des données 12 // récupération des données
@@ -204,6 +204,48 @@ if(strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false && isset($_
204 die; 204 die;
205} 205}
206 206
207if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit']))
208{
209 // récupération des données
210 $data = file_get_contents('php://input');
211 $json = json_decode($data, true);
212
213 if($_GET['menu_edit'] === 'switch_positions' && isset($json['id1']) && isset($json['id2']))
214 {
215 //$menu = new Menu($entityManager);
216 Director::$menu_data = new Menu($entityManager);
217
218 $id1 = $json['id1'];
219 $id2 = $json['id2'];
220
221 // vérifier qu'ils ont le même parent
222 $page1 = Director::$menu_data->findPageById((int)$id1);
223 $page2 = Director::$menu_data->findPageById((int)$id2);
224
225 // double le contrôle fait en JS
226 if($page1->getParent() === $page2->getParent()) // comparaison stricte d'objet (même instance du parent?)
227 {
228 // inversion
229 $tmp = $page1->getPosition();
230 $page1->setPosition($page2->getPosition());
231 $page2->setPosition($tmp);
232 Director::$menu_data->sortChildren(true); // modifie tableau children
233 $entityManager->flush();
234
235 // menu utilisant les nouvelles données
236 //Director::$page_path = new Path();
237 $nav_builder = new NavBuilder(); // builder appelé sans envoi du noeud correspondant
238
239 echo json_encode(['success' => true, 'path1' => '', 'path2' => '', 'nav' => $nav_builder->render()]);
240 }
241 else{
242 echo json_encode(['success' => false]);
243 }
244
245 die;
246 }
247}
248
207// détection des requêtes de type XHR, pas d'utilité pour l'instant 249// détection des requêtes de type XHR, pas d'utilité pour l'instant
208/*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ 250/*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){
209 echo "requête XHR reçue par le serveur"; 251 echo "requête XHR reçue par le serveur";
diff --git a/src/controller/installation.php b/src/controller/installation.php
index c2b38fd..ff168eb 100644
--- a/src/controller/installation.php
+++ b/src/controller/installation.php
@@ -80,9 +80,9 @@ function makeStartPage(EntityManager $entityManager){
80 $accueil = new Page('Accueil', 'accueil', true, true, 1, NULL); 80 $accueil = new Page('Accueil', 'accueil', true, true, 1, NULL);
81 $connection = new Page('Connexion', 'connexion', true, false, NULL, NULL); 81 $connection = new Page('Connexion', 'connexion', true, false, NULL, NULL);
82 $article = new Page('Article', 'article', true, false, NULL, NULL); 82 $article = new Page('Article', 'article', true, false, NULL, NULL);
83 $menu_paths = new Page("Menu et chemins", 'menu_chemins', true, false, NULL, NULL);
83 $edit_page = new Page("Modification d'une page", 'modif_page', true, false, NULL, NULL); 84 $edit_page = new Page("Modification d'une page", 'modif_page', true, false, NULL, NULL);
84 $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, NULL, NULL); 85 $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, NULL, NULL);
85 $edit_paths = new Page("Menu et chemins", 'menu_chemins', true, false, NULL, NULL);
86 86
87 /* -- table node -- */ 87 /* -- table node -- */
88 // paramètres: name_node, article_timestamp, attributes, position, parent, page, article 88 // paramètres: name_node, article_timestamp, attributes, position, parent, page, article
@@ -95,6 +95,8 @@ function makeStartPage(EntityManager $entityManager){
95 $head_login = new Node('head', NULL, ["stop" => true, 'css_array' => ['body', 'head', 'nav', 'main'], 'js_array' => ['main']], 1, NULL, $connection, NULL); 95 $head_login = new Node('head', NULL, ["stop" => true, 'css_array' => ['body', 'head', 'nav', 'main'], 'js_array' => ['main']], 1, NULL, $connection, NULL);
96 $login = new Node('login', NULL, [], 1, $main, $connection, NULL); 96 $login = new Node('login', NULL, [], 1, $main, $connection, NULL);
97 $head_article = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'foot'], 'js_array' => ['main']], 1, NULL, $article, NULL); 97 $head_article = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'foot'], 'js_array' => ['main']], 1, NULL, $article, NULL);
98 $head_edit_menu = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'menu'], 'js_array' => ['main']], 1, NULL, $menu_paths, NULL);
99 $edit_menu = new Node('menu', NULL, [], 1, $main, $menu_paths, NULL);
98 100
99 /* -- table image -- */ 101 /* -- table image -- */
100 // paramètres: file_name, file_path, file_path_mini, mime_type, alt 102 // paramètres: file_name, file_path, file_path_mini, mime_type, alt
@@ -111,13 +113,14 @@ function makeStartPage(EntityManager $entityManager){
111 $footer_data = new NodeData(["adresse" => "17, rue Raymonde Folgoas Guillou, 29120 Pont-l’Abbé", "contact_nom" => "Les Nageurs Bigoudens", "e_mail" => "nb.secretariat@orange.fr", "logo_footer" => "assets/logo-nb-et-ffn.png"], $footer); 113 $footer_data = new NodeData(["adresse" => "17, rue Raymonde Folgoas Guillou, 29120 Pont-l’Abbé", "contact_nom" => "Les Nageurs Bigoudens", "e_mail" => "nb.secretariat@orange.fr", "logo_footer" => "assets/logo-nb-et-ffn.png"], $footer);
112 $head_login_data = new NodeData(["description" => "Connexion", "title" => "Connexion"], $head_login, new ArrayCollection([$favicon])); 114 $head_login_data = new NodeData(["description" => "Connexion", "title" => "Connexion"], $head_login, new ArrayCollection([$favicon]));
113 $head_article_data = new NodeData(["description" => "", "title" => ""], $head_article, new ArrayCollection([$favicon])); 115 $head_article_data = new NodeData(["description" => "", "title" => ""], $head_article, new ArrayCollection([$favicon]));
116 $head_edit_menu_data = new NodeData(["description" => "Menu et chemins", "title" => "Menu et chemins"], $head_edit_menu, new ArrayCollection([$favicon]));
114 117
115 $entityManager->persist($accueil); 118 $entityManager->persist($accueil);
116 $entityManager->persist($connection); 119 $entityManager->persist($connection);
117 $entityManager->persist($article); 120 $entityManager->persist($article);
121 $entityManager->persist($menu_paths);
118 $entityManager->persist($edit_page); 122 $entityManager->persist($edit_page);
119 $entityManager->persist($new_page); 123 $entityManager->persist($new_page);
120 $entityManager->persist($edit_paths);
121 $entityManager->persist($head_accueil); 124 $entityManager->persist($head_accueil);
122 $entityManager->persist($header); 125 $entityManager->persist($header);
123 $entityManager->persist($nav); 126 $entityManager->persist($nav);
@@ -127,6 +130,8 @@ function makeStartPage(EntityManager $entityManager){
127 $entityManager->persist($head_login); 130 $entityManager->persist($head_login);
128 $entityManager->persist($login); 131 $entityManager->persist($login);
129 $entityManager->persist($head_article); 132 $entityManager->persist($head_article);
133 $entityManager->persist($head_edit_menu);
134 $entityManager->persist($edit_menu);
130 $entityManager->persist($favicon); 135 $entityManager->persist($favicon);
131 $entityManager->persist($logo); 136 $entityManager->persist($logo);
132 $entityManager->persist($facebook); 137 $entityManager->persist($facebook);
@@ -137,6 +142,7 @@ function makeStartPage(EntityManager $entityManager){
137 $entityManager->persist($footer_data); 142 $entityManager->persist($footer_data);
138 $entityManager->persist($head_login_data); 143 $entityManager->persist($head_login_data);
139 $entityManager->persist($head_article_data); 144 $entityManager->persist($head_article_data);
145 $entityManager->persist($head_edit_menu_data);
140 $entityManager->flush(); 146 $entityManager->flush();
141 147
142 header('Location: ' . new URL); 148 header('Location: ' . new URL);
diff --git a/src/controller/password.php b/src/controller/password.php
index 47db637..66a617a 100644
--- a/src/controller/password.php
+++ b/src/controller/password.php
@@ -307,7 +307,7 @@ function getUser(string $login, EntityManager $entityManager): ?User
307} 307}
308 308
309 309
310function disconnect(EntityManager $entityManager) 310function disconnect()
311{ 311{
312 // nettoyage complet 312 // nettoyage complet
313 $_SESSION = []; // mémoire vive 313 $_SESSION = []; // mémoire vive
diff --git a/src/model/Position.php b/src/model/Position.php
new file mode 100644
index 0000000..74d173a
--- /dev/null
+++ b/src/model/Position.php
@@ -0,0 +1,63 @@
1<?php
2// src/modele/Position.php
3//
4// pour Node et Page
5
6declare(strict_types=1);
7
8trait Position
9{
10 public function sortChildren(bool $reposition = false): void
11 {
12 // ordre du tableau des enfants
13 // inefficace quand des noeuds ont la même position
14
15 // tri par insertion avant affichage
16 for($i = 1; $i < count($this->children); $i++)
17 {
18 $tmp = $this->children[$i];
19 $j = $i - 1;
20
21 // Déplacez les éléments du tableau qui sont plus grands que la clé
22 // à une position devant leur position actuelle
23 while ($j >= 0 && $this->children[$j]->getPosition() > $tmp->getPosition()) {
24 $this->children[$j + 1] = $this->children[$j];
25 $j = $j - 1;
26 }
27 $this->children[$j + 1] = $tmp;
28 }
29
30 foreach ($this->children as $child) {
31 if (count($child->children) > 0) {
32 $child->sortChildren($reposition);
33 }
34 }
35
36 // nouvelles positions (tableau $children => BDD)
37 if($reposition){
38 $i = 1;
39 foreach($this->children as $child){
40 $child->setPosition($i);
41 $i++;
42 }
43 }
44 }
45
46 /*private function sortChildren(): void
47 {
48 $iteration = count($this->children);
49 while($iteration > 1)
50 {
51 for($i = 0; $i < $iteration - 1; $i++)
52 {
53 if($this->children[$i]->getPosition() > $this->children[$i + 1]->getPosition())
54 {
55 $tmp = $this->children[$i];
56 $this->children[$i] = $this->children[$i + 1];
57 $this->children[$i + 1] = $tmp;
58 }
59 }
60 $iteration--;
61 }
62 }*/
63} \ No newline at end of file
diff --git a/src/model/entities/Node.php b/src/model/entities/Node.php
index a52a7e6..103163b 100644
--- a/src/model/entities/Node.php
+++ b/src/model/entities/Node.php
@@ -12,6 +12,8 @@ use Doctrine\ORM\Mapping as ORM;
12#[ORM\Table(name: TABLE_PREFIX . "node")] 12#[ORM\Table(name: TABLE_PREFIX . "node")]
13class Node 13class Node
14{ 14{
15 use \Position;
16
15 #[ORM\Id] 17 #[ORM\Id]
16 #[ORM\GeneratedValue] 18 #[ORM\GeneratedValue]
17 #[ORM\Column(type: "integer")] 19 #[ORM\Column(type: "integer")]
@@ -135,36 +137,7 @@ class Node
135 $this->children[] = $child; 137 $this->children[] = $child;
136 $this->sortChildren(false); 138 $this->sortChildren(false);
137 } 139 }
138 // utiliser $position pour afficher les éléments dans l'ordre 140
139 public function sortChildren(bool $reposition = false): void
140 {
141 // ordre du tableau des enfants
142 // inefficace quand des noeuds ont la même position
143
144 // tri par insertion
145 for($i = 1; $i < count($this->children); $i++)
146 {
147 $tmp = $this->children[$i];
148 $j = $i - 1;
149
150 // Déplacez les éléments du tableau qui sont plus grands que la clé
151 // à une position devant leur position actuelle
152 while ($j >= 0 && $this->children[$j]->getPosition() > $tmp->getPosition()) {
153 $this->children[$j + 1] = $this->children[$j];
154 $j = $j - 1;
155 }
156 $this->children[$j + 1] = $tmp;
157 }
158
159 // nouvelles positions
160 if($reposition){
161 $i = 1;
162 foreach($this->children as $child){
163 $child->setPosition($i);
164 $i++;
165 }
166 }
167 }
168 public function removeChild(self $child): void 141 public function removeChild(self $child): void
169 { 142 {
170 foreach($this->children as $key => $object){ 143 foreach($this->children as $key => $object){
diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php
index c40a297..c30305c 100644
--- a/src/model/entities/Page.php
+++ b/src/model/entities/Page.php
@@ -13,6 +13,8 @@ use Doctrine\Common\Collections\ArrayCollection;
13#[ORM\Table(name: TABLE_PREFIX . "page")] 13#[ORM\Table(name: TABLE_PREFIX . "page")]
14class Page 14class Page
15{ 15{
16 use \Position;
17
16 #[ORM\Id] 18 #[ORM\Id]
17 #[ORM\GeneratedValue] 19 #[ORM\GeneratedValue]
18 #[ORM\Column(type: "integer")] 20 #[ORM\Column(type: "integer")]
@@ -56,11 +58,11 @@ class Page
56 $this->children = new ArrayCollection(); 58 $this->children = new ArrayCollection();
57 } 59 }
58 60
59 // getters 61 // getters/setters
60 /*public function getId(): int 62 public function getId(): int
61 { 63 {
62 return $this->id_page; 64 return $this->id_page;
63 }*/ 65 }
64 public function getPageName(): string 66 public function getPageName(): string
65 { 67 {
66 return $this->name_page; 68 return $this->name_page;
@@ -85,6 +87,10 @@ class Page
85 { 87 {
86 return $this->position; 88 return $this->position;
87 } 89 }
90 public function setPosition(int $position): void
91 {
92 $this->position = $position;
93 }
88 public function getParent(): ?Page 94 public function getParent(): ?Page
89 { 95 {
90 return $this->parent; 96 return $this->parent;
@@ -105,25 +111,23 @@ class Page
105 public function addChild(self $child): void 111 public function addChild(self $child): void
106 { 112 {
107 $this->children[] = $child; 113 $this->children[] = $child;
108 $this->sortChildren(); 114 $this->sortChildren(false);
109 } 115 }
110 116
111 // utiliser $position pour afficher les éléments dans l'ordre 117 public function findPageById(int $id): ?Page
112 private function sortChildren(): void
113 { 118 {
114 $iteration = count($this->children); 119 $target = null;
115 while($iteration > 1) 120 foreach($this->children as $page){
116 { 121 if($page->getId() === $id){
117 for($i = 0; $i < $iteration - 1; $i++) 122 return $page;
118 { 123 }
119 if($this->children[$i]->getPosition() > $this->children[$i + 1]->getPosition()) 124 if(count($page->getChildren()) > 0){
120 { 125 $target = $page->findPageById($id);
121 $tmp = $this->children[$i]; 126 if($target !== null){
122 $this->children[$i] = $this->children[$i + 1]; 127 return $target;
123 $this->children[$i + 1] = $tmp;
124 } 128 }
125 } 129 }
126 $iteration--;
127 } 130 }
131 return $target;
128 } 132 }
129} 133}
diff --git a/src/view/FooterBuilder.php b/src/view/FooterBuilder.php
index 49da71c..5a7748f 100644
--- a/src/view/FooterBuilder.php
+++ b/src/view/FooterBuilder.php
@@ -29,7 +29,7 @@ class FooterBuilder extends AbstractBuilder
29 $empty_admin_zone = 'empty_admin_zone'; 29 $empty_admin_zone = 'empty_admin_zone';
30 $link_edit_page = new URL(['page' => CURRENT_PAGE, 'action' => 'modif_page']); 30 $link_edit_page = new URL(['page' => CURRENT_PAGE, 'action' => 'modif_page']);
31 $link_new_page = new URL(['from' => CURRENT_PAGE, 'page' => 'nouvelle_page']); 31 $link_new_page = new URL(['from' => CURRENT_PAGE, 'page' => 'nouvelle_page']);
32 $link_change_paths = new URL(['from' => CURRENT_PAGE, 'page' => 'menu_chemins']); 32 $link_change_paths = new URL(['page' => 'menu_chemins']);
33 33
34 $link_change_password = new URL(['from' => CURRENT_PAGE, 'action' => 'modif_mdp']); 34 $link_change_password = new URL(['from' => CURRENT_PAGE, 'action' => 'modif_mdp']);
35 isset($_GET['id']) ? $link_change_password->addParams(['id' => $_GET['id']]) : ''; 35 isset($_GET['id']) ? $link_change_password->addParams(['id' => $_GET['id']]) : '';
diff --git a/src/view/HeaderBuilder.php b/src/view/HeaderBuilder.php
index eef2663..28aae13 100644
--- a/src/view/HeaderBuilder.php
+++ b/src/view/HeaderBuilder.php
@@ -16,7 +16,9 @@ class HeaderBuilder extends AbstractBuilder
16 { 16 {
17 if($child->getName() === 'nav'){ 17 if($child->getName() === 'nav'){
18 $this->nav = $child; 18 $this->nav = $child;
19 // actuellement le noeud nav ne contient aucune info utile et l'envoyer à NavBuilder est inutile
19 $nav_builder = new NavBuilder($this->nav); 20 $nav_builder = new NavBuilder($this->nav);
21
20 $nav = $nav_builder->render(); 22 $nav = $nav_builder->render();
21 } 23 }
22 elseif($child->getName() === 'breadcrumb'){ 24 elseif($child->getName() === 'breadcrumb'){
diff --git a/src/view/MenuBuilder.php b/src/view/MenuBuilder.php
new file mode 100644
index 0000000..0fcfbe5
--- /dev/null
+++ b/src/view/MenuBuilder.php
@@ -0,0 +1,88 @@
1<?php
2// src/view/MenuBuilder.php
3//
4// page Menu et chemins en mode admin
5
6use App\Entity\Node;
7use App\Entity\Page;
8
9class MenuBuilder extends AbstractBuilder
10{
11 private int $margin_left_multiplier = 29;
12
13 public function __construct(Node $node)
14 {
15 parent::__construct($node);
16 $viewFile = self::VIEWS_PATH . $node->getName() . '.php';
17
18 if(file_exists($viewFile))
19 {
20 /*if(!empty($node->getNodeData()->getData()))
21 {
22 extract($node->getNodeData()->getData());
23 }*/
24
25 // ajouter un article
26 $new_article = '';
27 if($_SESSION['admin'])
28 {
29 $this->unfoldMenu(Director::$menu_data, 0 - $this->margin_left_multiplier);
30 }
31 else{
32 header('Location: ' . new URL);
33 die;
34 }
35
36 ob_start();
37 require $viewFile;
38 $this->html = ob_get_clean(); // pas de concaténation ici, on écrase
39 }
40 }
41
42 private function unfoldMenu(Page $menu, int $margin_left): void
43 {
44 $margin_left += $this->margin_left_multiplier;
45 $this->html .= '<div class="level">' . "\n";
46
47 foreach($menu->getChildren() as $entry)
48 {
49 $div_style = 'margin-left: ' . $margin_left . 'px;';
50 $checked = $entry->IsInMenu() ? 'checked' : '';
51 $this->html .= '<div id="' . $entry->getId() . '" style="' . $div_style . '">
52 <img class="move_entry_icon" onclick="" src="assets/arrow-left.svg">
53 <img class="move_entry_icon" onclick="" src="assets/arrow-right.svg">
54 <img class="move_entry_icon" onclick="switchMenuPositions(' . $entry->getId() . ', \'up\')" src="assets/arrow-up.svg">
55 <img class="move_entry_icon" onclick="switchMenuPositions(' . $entry->getId() . ', \'down\')" src="assets/arrow-down.svg">
56 <span class="menu_entry_checkbox">
57 <input type="checkbox" ' . $checked . ' onclick="checkMenuEntry(' . $entry->getId() . ')">
58 </span>
59 <button>' . $entry->getPageName() . '</button>';
60
61 if(str_starts_with($entry->getEndOfPath(), 'http')){
62 $this->html .= '<span id="edit-i..."><img class="move_entry_icon" src="assets/edit.svg" onclick="openEditor(\'i...\')"></span>
63 <i>' . $entry->getEndOfPath() . '</i>
64 <span id="delete-i..."><img class="move_entry_icon" src="assets/delete-bin.svg" onclick="delete(\'i...\')"></span>';
65 }
66 else{
67 $this->html .= '<i>' . $entry->getPagePath() . '</i>';
68 }
69
70
71 // supprimer me label "visible" et griser le texte et bouton en JS à la place
72
73 /*
74 => flèche gauche: position = position du parent + 1, parent = grand-parent, recalculer les positions
75 => flèche droite: position = nombre d'éléments de la fraterie + 1, l'élément précédent devient le parent
76 => flèches haut et bas: inversement de position, comme pour les noeuds, mais dans la table page
77 => checkbox: in_menu ^= 1
78 */
79
80 if(count($entry->getChildren()) > 0){
81 $this->unfoldMenu($entry, $margin_left);
82 }
83 $this->html .= '</div>' . "\n";
84 }
85 $this->html .= "</div>\n";
86 $margin_left -= $this->margin_left_multiplier;
87 }
88} \ No newline at end of file
diff --git a/src/view/NavBuilder.php b/src/view/NavBuilder.php
index 603fcfa..2718569 100644
--- a/src/view/NavBuilder.php
+++ b/src/view/NavBuilder.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2// src/view/NavBuilder.php 2// src/view/NavBuilder.php
3//
4// menu principal
3 5
4declare(strict_types=1); 6declare(strict_types=1);
5 7
@@ -8,10 +10,13 @@ use App\Entity\Page;
8 10
9class NavBuilder extends AbstractBuilder 11class NavBuilder extends AbstractBuilder
10{ 12{
11 public function __construct(Node $node) 13 public function __construct(Node $node = null)
12 { 14 {
13 $this->html .= '<nav class="nav_main"><ul>'; 15 $this->html .= '<nav class="nav_main"><ul>';
14 $this->html .= $this->navMainHTML(Director::$menu_data, Director::$page_path->getArray()); 16 $this->html .= $this->navMainHTML(
17 Director::$menu_data,
18 // param nullable, ça retire une dépendance stricte entre NavBuilder et Director
19 Director::$page_path != null ? Director::$page_path->getArray() : []);
15 $this->html .= '</ul></nav>'; 20 $this->html .= '</ul></nav>';
16 } 21 }
17 22
diff --git a/src/view/templates/header.php b/src/view/templates/header.php
index 0bf4396..4b633a6 100644
--- a/src/view/templates/header.php
+++ b/src/view/templates/header.php
@@ -1,7 +1,7 @@
1<body> 1<body>
2 <div> 2 <div>
3 <header> 3 <header>
4 <div class="empty_nav_zone"> 4 <div id="nav_zone">
5 <?= $nav ?> 5 <?= $nav ?>
6 </div> 6 </div>
7 7
diff --git a/src/view/templates/menu.php b/src/view/templates/menu.php
new file mode 100644
index 0000000..a7f318e
--- /dev/null
+++ b/src/view/templates/menu.php
@@ -0,0 +1,15 @@
1<section class="menu">
2 <h3>Menu et chemins</h3>
3 <aside>
4 <p><img src="assets/arrow-left.svg"> remonter dans l'arbre</p>
5 <p><img src="assets/arrow-right.svg"> devenir une branche de l'élément précédent</p>
6 <p><img src="assets/arrow-up.svg"><img src="assets/arrow-down.svg"> déplacer la branche parmi celles de même niveau</p>
7 <p><input type="checkbox" checked>afficher/cacher</p>
8 </aside>
9<?= $this->html ?>
10 <div class="new_entry_buttons">
11 <p>Ajouter une nouvelle entrée dans le menu?</p>
12 <button id="new-i..." onclick="openEditor('i...')"><img class="action_icon" src="assets/edit.svg">avec une URL</button>
13 ...sinon cliquer sur Nouvelle page<img src="assets/arrow-down.svg">dans la barre jaune
14 </div>
15</section> \ No newline at end of file