diff options
Diffstat (limited to 'src/view/NavBuilder.php')
-rw-r--r-- | src/view/NavBuilder.php | 44 |
1 files changed, 25 insertions, 19 deletions
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 | } |