summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpolo <ordipolo@gmx.fr>2025-04-13 13:30:31 +0200
committerpolo <ordipolo@gmx.fr>2025-04-13 13:30:31 +0200
commit75f2c543e7fe45c1a3dcea842650a5d13a0235f0 (patch)
tree82461287eac3ae23728a74a2b90d6f574f3ddb37
parent27bd4f380f76d5494fd9be81d3d0edac9a0aa2cc (diff)
downloadcms-75f2c543e7fe45c1a3dcea842650a5d13a0235f0.zip
menu et fil d'ariane gèrent le champ reachable dans page
-rw-r--r--public/css/nav.css15
-rw-r--r--src/model/Menu.php6
-rw-r--r--src/model/entities/Page.php7
-rw-r--r--src/view/BreadcrumbBuilder.php17
-rw-r--r--src/view/NavBuilder.php44
5 files changed, 48 insertions, 41 deletions
diff --git a/public/css/nav.css b/public/css/nav.css
index d51c58a..bff3896 100644
--- a/public/css/nav.css
+++ b/public/css/nav.css
@@ -48,14 +48,17 @@ ul
48 background-color: white; 48 background-color: white;
49 font-weight: bold; 49 font-weight: bold;
50} 50}
51.drop-down > p::after 51.drop-down > a > p::after
52{ 52{
53 content: ' ▼'; 53 content: ' ▼';
54 font-size: x-small; 54 font-size: x-small;
55} 55}
56 56
57.drop-down:hover > .sub-menu /* faire apparaître sub-menu */ 57/* faire apparaître sub-menu */
58{ 58.drop-down:hover > .sub-menu{
59 display: block;
60}
61.drop-right:hover > .sub-menu{
59 display: block; 62 display: block;
60} 63}
61.sub-menu 64.sub-menu
@@ -71,7 +74,7 @@ ul
71{ 74{
72 background-color: #ffff00; 75 background-color: #ffff00;
73} 76}
74.drop-down .sub-menu .drop-down > p:after /* bricolage? */ 77.drop-right > a > p:after
75{ 78{
76 content: " ▶"; 79 content: " ▶";
77 font-size: x-small; 80 font-size: x-small;
@@ -83,11 +86,11 @@ nav > ul > li > ul
83 position: absolute; /* retire du flux, positionnement par rapport à la fenêtre */ 86 position: absolute; /* retire du flux, positionnement par rapport à la fenêtre */
84} 87}
85/* élément du menu survolé, le positionnement relatif en fait la référence du positionnement suivant */ 88/* élément du menu survolé, le positionnement relatif en fait la référence du positionnement suivant */
86.drop-down .sub-menu .drop-down 89.drop-right
87{ 90{
88 position: relative; 91 position: relative;
89} 92}
90.drop-down .sub-menu .drop-down .sub-menu 93.drop-right .sub-menu
91{ 94{
92 position: absolute; /* positionnement par rapport au précédent "position" en CSS */ 95 position: absolute; /* positionnement par rapport au précédent "position" en CSS */
93 left: 100%; 96 left: 100%;
diff --git a/src/model/Menu.php b/src/model/Menu.php
index 624a0fc..403accf 100644
--- a/src/model/Menu.php
+++ b/src/model/Menu.php
@@ -20,12 +20,12 @@ class Menu extends Page
20 ->getResult(); // :array de Page 20 ->getResult(); // :array de Page
21 21
22 if(count($bulk_data) === 0){ 22 if(count($bulk_data) === 0){
23 makeStartPage($entityManager); 23 makeStartPage($entityManager); // => installation.php
24 } 24 }
25 25
26 foreach($bulk_data as $first_level_entries){ 26 foreach($bulk_data as $first_level_entries){
27 // génération du menu 27 // dans le menu
28 if($first_level_entries->getInMenu()){ 28 if($first_level_entries->isInMenu()){
29 $this->addChild($first_level_entries); 29 $this->addChild($first_level_entries);
30 } 30 }
31 // autres pages 31 // autres pages
diff --git a/src/model/entities/Page.php b/src/model/entities/Page.php
index fbf0f27..c40a297 100644
--- a/src/model/entities/Page.php
+++ b/src/model/entities/Page.php
@@ -73,7 +73,11 @@ class Page
73 { 73 {
74 return $this->end_of_path; 74 return $this->end_of_path;
75 } 75 }
76 public function getInMenu(): bool 76 public function isReachable(): bool
77 {
78 return $this->reachable;
79 }
80 public function isInMenu(): bool
77 { 81 {
78 return $this->in_menu; 82 return $this->in_menu;
79 } 83 }
@@ -112,7 +116,6 @@ class Page
112 { 116 {
113 for($i = 0; $i < $iteration - 1; $i++) 117 for($i = 0; $i < $iteration - 1; $i++)
114 { 118 {
115 //echo '<br>' . $this->children[$i]->getPosition() . ' - ' . $this->children[$i + 1]->getPosition();
116 if($this->children[$i]->getPosition() > $this->children[$i + 1]->getPosition()) 119 if($this->children[$i]->getPosition() > $this->children[$i + 1]->getPosition())
117 { 120 {
118 $tmp = $this->children[$i]; 121 $tmp = $this->children[$i];
diff --git a/src/view/BreadcrumbBuilder.php b/src/view/BreadcrumbBuilder.php
index f1fdddf..77f4c4c 100644
--- a/src/view/BreadcrumbBuilder.php
+++ b/src/view/BreadcrumbBuilder.php
@@ -7,10 +7,10 @@ class BreadcrumbBuilder extends AbstractBuilder
7{ 7{
8 public function __construct(Node $node) 8 public function __construct(Node $node)
9 { 9 {
10 $this->html = $this->breadcrumbHTML(false); 10 $this->html = $this->breadcrumbHTML();
11 } 11 }
12 12
13 private function breadcrumbHTML(bool $links = false): string 13 private function breadcrumbHTML(): string
14 { 14 {
15 $asset = 'assets/home.svg'; // => BDD? 15 $asset = 'assets/home.svg'; // => BDD?
16 $breadcrumb_array = Director::$page_path->getArray(); // tableau de Page 16 $breadcrumb_array = Director::$page_path->getArray(); // tableau de Page
@@ -23,21 +23,16 @@ class BreadcrumbBuilder extends AbstractBuilder
23 $html .= '<nav class="breadcrumb" aria-label="Breadcrumb">' . "\n"; 23 $html .= '<nav class="breadcrumb" aria-label="Breadcrumb">' . "\n";
24 $html .= '<a href="' . new URL . '"><img src="' . $asset . '"></a><span class="arrow"> →</span>' . "\n"; 24 $html .= '<a href="' . new URL . '"><img src="' . $asset . '"></a><span class="arrow"> →</span>' . "\n";
25 25
26 // partie intermédiaire 26 // partie intermédiaire (pas de lien sur le dernier élément)
27 for($i = 0; $i < ($nb_of_entries - 1); $i++) 27 for($i = 0; $i < ($nb_of_entries - 1); $i++)
28 { 28 {
29 // liens optionnels 29 // liens optionnels
30 if($links) 30 if($breadcrumb_array[$i]->isReachable())
31 { 31 {
32 $html .= '<a href="'; 32 $html .= '<a href="' . new URL(['page' => $breadcrumb_array[$i]->getPagePath()]) . '">';
33 for($j = 1; $j < $i; $j++) // chemin sans la fin
34 {
35 $html .= new URL(['page' => $breadcrumb_array[$i]->getPagePath()]);
36 }
37 $html .= '">';
38 } 33 }
39 $html .= '<span>' . $breadcrumb_array[$i]->getPageName() . '</span>'; 34 $html .= '<span>' . $breadcrumb_array[$i]->getPageName() . '</span>';
40 if($links) 35 if($breadcrumb_array[$i]->isReachable())
41 { 36 {
42 $html .= '</a>'; 37 $html .= '</a>';
43 } 38 }
diff --git a/src/view/NavBuilder.php b/src/view/NavBuilder.php
index e7254b1..2ef6bc8 100644
--- a/src/view/NavBuilder.php
+++ b/src/view/NavBuilder.php
@@ -22,20 +22,12 @@ class NavBuilder extends AbstractBuilder
22 22
23 foreach($nav_data->getChildren() as $data) 23 foreach($nav_data->getChildren() as $data)
24 { 24 {
25 $class = ''; 25 $li_class = '';
26 if(isset($current[$level]) && $data->getEndOfPath() === $current[$level]->getEndOfPath()){ 26 if(isset($current[$level]) && $data->getEndOfPath() === $current[$level]->getEndOfPath()){
27 $class = ' current'; 27 $li_class = 'current';
28 } 28 }
29 29
30 if(count($data->getChildren()) > 0) // titre de catégorie 30 if($data->isReachable())
31 {
32 $nav_html .= '<li class="drop-down'. $class . '"><p>' . $data->getPageName() . '</p><ul class="sub-menu">' . "\n";
33 $level++;
34 $nav_html .= $this->navMainHTML($data, $current);
35 $level--;
36 $nav_html .= '</ul></li>' . "\n";
37 }
38 else
39 { 31 {
40 $target = ''; 32 $target = '';
41 if(str_starts_with($data->getEndOfPath(), 'http')) // lien vers autre site 33 if(str_starts_with($data->getEndOfPath(), 'http')) // lien vers autre site
@@ -47,14 +39,28 @@ class NavBuilder extends AbstractBuilder
47 { 39 {
48 $link = new URL(['page' => $data->getPagePath()]); // $link = objet 40 $link = new URL(['page' => $data->getPagePath()]); // $link = objet
49 } 41 }
50 /*else 42 $nav_html .= '<a href="' . $link . '"' . $target . '>';
51 { 43 }
52 echo "else page d'accueil" . '<br>'; 44 else{
53 $link = new URL; // page d'accueil 45 $nav_html .= '<a>';
54 }*/
55
56 $nav_html .= '<a href="' . $link . '"' . $target . '><li class="'. $class . '"><p>' . $data->getPageName() . '</p></li></a>' . "\n";
57 } 46 }
47
48 if(count($data->getChildren()) > 0) // titre de catégorie
49 {
50 $li_class = $data->getParent() == null ? 'drop-down' : 'drop-right';
51
52 $nav_html .= '<li class="'. $li_class . '"><p>' . $data->getPageName() . '</p><ul class="sub-menu">' . "\n";
53 $level++;
54 $nav_html .= $this->navMainHTML($data, $current);
55 $level--;
56 $nav_html .= '</ul></li>' . "\n";
57 }
58 else
59 {
60 $nav_html .= '<li class="'. $li_class . '"><p>' . $data->getPageName() . '</p></li>' . "\n";
61 }
62
63 $nav_html .= "</a>\n";
58 } 64 }
59 return $nav_html; 65 return $nav_html;
60 } 66 }