From f27cca08ff786ceff1870147f6d6bad14d71117f Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 23 Oct 2026 00:47:32 +0200 Subject: =?UTF-8?q?dossiers=20avec=20majuscule,=20namespace=20pour=20toute?= =?UTF-8?q?s=20les=20classes,=20autoload=20psr-4,=20UserDataService::creat?= =?UTF-8?q?eZip=20d=C3=A9plac=C3=A9=20dans=20Backup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/View/MenuBuilder.php | 101 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/View/MenuBuilder.php (limited to 'src/View/MenuBuilder.php') diff --git a/src/View/MenuBuilder.php b/src/View/MenuBuilder.php new file mode 100644 index 0000000..f14cea7 --- /dev/null +++ b/src/View/MenuBuilder.php @@ -0,0 +1,101 @@ +getName() . '.php'; + + if(file_exists($viewFile)) + { + if(IS_ADMIN){ + $this->unfoldMenu(Model::$menu); + + if($template){ + $this->unfoldOptions(Model::$menu); + } + } + else{ + header('Location: ' . new URL); + die; + } + + // si faux, n'utilise pas le template + if($template){ + ob_start(); + require $viewFile; // insertion de $this->html généré par unfoldMenu + $this->html = ob_get_clean(); // pas de concaténation .= cette fois on écrase + } + } + } + + private function unfoldMenu(Page $page): void + { + $this->html .= '
' . "\n"; + + foreach($page->getChildren() as $entry) + { + $checked = $entry->isHidden() ? '' : 'checked'; + $this->html .= '
+ + + + + + + '; + + // entrées URL: bouton poubelle + nom du lien + adresse + if(str_starts_with($entry->getEndOfPath(), 'http')){ + $this->html .= '
+ + +
+ + + + + + + + '; + } + else{ + $this->html .= ' + ' . $entry->getPagePath() . ''; + } + + if(count($entry->getChildren()) > 0){ + $this->unfoldMenu($entry); + } + $this->html .= '
' . "\n"; + } + $this->html .= "
\n"; + } + + private function unfoldOptions(Page $page): void + { + foreach($page->getChildren() as $entry){ + $this->options .= '\n"; + if(count($entry->getChildren()) > 0){ + $this->unfoldOptions($entry); + } + } + } +} \ No newline at end of file -- cgit v1.2.3