From 5fc1a655e0271b583f3caa009524ea9d99a8bd3e Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 29 Apr 2025 00:27:06 +0200 Subject: page menu et chemins, partie4 --- public/css/foot.css | 15 ++++++++ public/css/menu.css | 64 ++++++++++++++++++++++++++++------ public/js/menu.js | 11 ++++++ src/controller/post.php | 84 +++------------------------------------------ src/view/FooterBuilder.php | 2 +- src/view/MenuBuilder.php | 25 +++++++++++--- src/view/templates/menu.php | 43 +++++++++++++++++------ 7 files changed, 138 insertions(+), 106 deletions(-) diff --git a/public/css/foot.css b/public/css/foot.css index 91f67ab..038d33b 100644 --- a/public/css/foot.css +++ b/public/css/foot.css @@ -6,6 +6,7 @@ footer background-color: #B7E9FE; /*width: 1200px;*/ margin: auto; + padding: 0 20px; } footer > div @@ -72,6 +73,20 @@ footer > div { max-width: 288px; } +@media screen and (max-width: 1000px) +{ + .footer .contact + { + width: 70px; + } +} +@media screen and (max-width: 800px) +{ + footer > div + { + flex-direction: column; + } +} .breadcrumb a { diff --git a/public/css/menu.css b/public/css/menu.css index 5016610..a338666 100644 --- a/public/css/menu.css +++ b/public/css/menu.css @@ -8,32 +8,56 @@ { margin-left: 29px; } +.menu .new_page_button +{ + background-color: white; + padding: 10px; +} .menu img { width: 20px; - vertical-align: middle; } -.menu form +/*.menu form { display: inline; +}*/ +.menu p +{ + margin: 5px; } -/* explications pour l'utiisateur */ +/* explications pour l'utilisateur */ .menu aside { - display: flex; - flex-wrap: wrap; background-color: white; padding: 10px; + margin-top: 10px; } -.menu aside p +.menu aside .controls_explanations +{ + display: flex; + flex-wrap: wrap; +} +.menu aside .controls_explanations p { - margin: 5px; font-size: smaller; } +.menu aside img +{ + vertical-align: bottom; +} .menu aside input { pointer-events: none; /* case non clicable, sauf action au clavier... */ + vertical-align: bottom; +} +.menu #location, .menu input[type=submit] +{ + color: #ff1d04; + font-size: medium; + border-radius: 4px; + background-color: white; + border: lightgrey 2px outset; } .menu button @@ -54,7 +78,7 @@ input vertical-align: middle; border: 2px #e3f3ff solid; } -.move_entry_icon:hover +.menu #location:hover, .menu input[type=submit]:hover, .move_entry_icon:hover { background-color: #ffff00; border-radius: 4px; @@ -62,15 +86,35 @@ input cursor: pointer; } -.menu .new_entry_buttons +.menu form +{ + padding: 10px; + background-color: #f0f0f0f0; +} +.menu .url_form_zone { background-color: white; padding: 10px; margin-top: 10px; } -.menu .new_entry_buttons p +/*.menu .url_form_zone div +{ + display: flex; +}*/ +.menu .url_form_zone label +{ + text-wrap: nowrap; + margin-right: 5px; +} +.menu .url_form_zone #url_input +{ + width: 100%; +} +.menu .url_form_zone p { margin: 5px; + display: flex; + align-items: center; } @media screen and (min-width: 80rem) { diff --git a/public/js/menu.js b/public/js/menu.js index a864597..ac6d35e 100644 --- a/public/js/menu.js +++ b/public/js/menu.js @@ -237,4 +237,15 @@ function checkMenuEntry(page_id){ .catch(error => { console.error('Erreur:', error); }); +} + + +function editUrlEntry(page_id){ + const selected_div = document.getElementById(page_id); + console.log(selected_div.id); +} + +function deleteUrlEntry(page_id){ + const selected_div = document.getElementById(page_id); + console.log(selected_div.id); } \ No newline at end of file diff --git a/src/controller/post.php b/src/controller/post.php index 8924686..66de5a0 100644 --- a/src/controller/post.php +++ b/src/controller/post.php @@ -5,89 +5,13 @@ declare(strict_types=1); if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) { - /* -- requêtes non AJAX -- */ - // page Menu et chemin - /*if(isset($_POST['menu_edit_post']) && isset($_POST['id'])) - { - // <= flèche gauche: le parent devient le grand-parent position = position du parent + 1, recalculer les positions des enfants restants - if($_POST['menu_edit_post'] == 'move_one_level_up'){ - Director::$menu_data = new Menu($entityManager); - $page = Director::$menu_data->findPageById((int)$_POST['id']); - - $parent = $page->getParent(); // peut être null - if($parent === null){ - // 1er niveau: ne rien faire - header('Location: ' . new URL(['page' => 'menu_chemins'])); - die; - } - else{ - $page->setPosition($parent->getPosition() + 1); // nouvelle position - - // 2ème niveau: le parent devient $menu_data, puis null après tri - if($parent->getParent() === null){ - // connexion dans les deux sens - $page->setParent(Director::$menu_data); // => pour la persistance - Director::$menu_data->addChild($page); // => pour sortChildren - - //Director::$menu_data->sortChildren(true); // positions décaléees des nouveaux petits frères - $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères - - $page->setParent(null); - } - // 3ème niveau et plus - else{ - $page->setParent($parent->getParent()); // nouveau parent - $page->getParent()->sortChildren(true); // positions décaléees des nouveaux petits frères - } - //$parent->sortChildren(true); // positions des enfants restants, inutile si la fonction est récursive? - echo $page->getPosition(); - //die; - } - $entityManager->flush(); - - header('Location: ' . new URL(['page' => 'menu_chemins'])); - die; - } - // => flèche droite: l'élément précédent devient le parent, position = nombre d'éléments de la fraterie + 1 - elseif($_POST['menu_edit_post'] == 'move_one_level_down') - { - Director::$menu_data = new Menu($entityManager); - $page = Director::$menu_data->findPageById((int)$_POST['id']); - - $parent = $page->getParent(); // peut être null - if($parent == null){ - $parent = Director::$menu_data; - } - - $parent->sortChildren(true); // trie et réindexe par sécurité: 1, 2, 3... - if($page->getPosition() > 1){ - foreach($parent->getChildren() as $child){ - echo $child->getPageName(); - if($child->getPosition() === $page->getPosition() - 1){ - $page->setParent($child); - break; - } - } - $page->setPosition(count($page->getParent()->getChildren()) + 1); - } - $entityManager->flush(); - - header('Location: ' . new URL(['page' => 'menu_chemins'])); - die; - } - else{ - // you talking to me? - die; - } - }*/ - - /* -- requêtes AJAX -- */ - require '../src/controller/ajax.php'; - - // formulaires HTML + /* -- formulaires HTML -- */ /*if(isset($_POST['from']) // page d'où vient la requête && isset($_POST)) // données { echo "requête envoyée en validant un formulaire"; }*/ + + /* -- requêtes AJAX -- */ + require '../src/controller/ajax.php'; } diff --git a/src/view/FooterBuilder.php b/src/view/FooterBuilder.php index 5a7748f..7abdb90 100644 --- a/src/view/FooterBuilder.php +++ b/src/view/FooterBuilder.php @@ -28,7 +28,7 @@ class FooterBuilder extends AbstractBuilder $div_admin = 'logged_in'; $empty_admin_zone = 'empty_admin_zone'; $link_edit_page = new URL(['page' => CURRENT_PAGE, 'action' => 'modif_page']); - $link_new_page = new URL(['from' => CURRENT_PAGE, 'page' => 'nouvelle_page']); + $link_new_page = new URL(['page' => 'nouvelle_page']); $link_change_paths = new URL(['page' => 'menu_chemins']); $link_change_password = new URL(['from' => CURRENT_PAGE, 'action' => 'modif_mdp']); diff --git a/src/view/MenuBuilder.php b/src/view/MenuBuilder.php index 42c9273..5331c08 100644 --- a/src/view/MenuBuilder.php +++ b/src/view/MenuBuilder.php @@ -9,6 +9,7 @@ use App\Entity\Page; class MenuBuilder extends AbstractBuilder { //private int $margin_left_multiplier = 29; + private string $options = ''; public function __construct(Node $node = null, bool $template = true) { @@ -23,7 +24,11 @@ class MenuBuilder extends AbstractBuilder }*/ if($_SESSION['admin']){ - $this->unfoldMenu(Director::$menu_data/*, 0 - $this->margin_left_multiplier*/); + $this->unfoldMenu(Director::$menu_data); + + if($template){ + $this->unfoldOptions(Director::$menu_data); + } } else{ header('Location: ' . new URL); @@ -39,11 +44,11 @@ class MenuBuilder extends AbstractBuilder } } - private function unfoldMenu(Page $menu): void + private function unfoldMenu(Page $page): void { $this->html .= '
' . "\n"; - foreach($menu->getChildren() as $entry) + foreach($page->getChildren() as $entry) { $checked = $entry->isHidden() ? '' : 'checked'; $this->html .= '
@@ -57,9 +62,9 @@ class MenuBuilder extends AbstractBuilder '; if(str_starts_with($entry->getEndOfPath(), 'http')){ - $this->html .= ' + $this->html .= ' ' . $entry->getEndOfPath() . ' - '; + '; } else{ $this->html .= '' . $entry->getPagePath() . ''; @@ -72,4 +77,14 @@ class MenuBuilder extends AbstractBuilder } $this->html .= "
\n"; } + + private function unfoldOptions(Page $page): void + { + foreach($page->getChildren() as $entry){ + $this->options .= '