diff options
| author | polo <ordipolo@gmx.fr> | 2025-04-13 13:30:31 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-04-13 13:30:31 +0200 |
| commit | 75f2c543e7fe45c1a3dcea842650a5d13a0235f0 (patch) | |
| tree | 82461287eac3ae23728a74a2b90d6f574f3ddb37 /src | |
| parent | 27bd4f380f76d5494fd9be81d3d0edac9a0aa2cc (diff) | |
| download | cms-75f2c543e7fe45c1a3dcea842650a5d13a0235f0.tar.gz cms-75f2c543e7fe45c1a3dcea842650a5d13a0235f0.tar.bz2 cms-75f2c543e7fe45c1a3dcea842650a5d13a0235f0.zip | |
menu et fil d'ariane gèrent le champ reachable dans page
Diffstat (limited to 'src')
| -rw-r--r-- | src/model/Menu.php | 6 | ||||
| -rw-r--r-- | src/model/entities/Page.php | 7 | ||||
| -rw-r--r-- | src/view/BreadcrumbBuilder.php | 17 | ||||
| -rw-r--r-- | src/view/NavBuilder.php | 44 |
4 files changed, 39 insertions, 35 deletions
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 | } |
