diff options
author | polo <ordipolo@gmx.fr> | 2025-09-10 01:02:36 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2025-09-10 01:02:36 +0200 |
commit | efd79d15adef2a27347c25ebb19754e9937f9715 (patch) | |
tree | 6114ec988ef4dfd7cdf2e2ca07cc9762f8fec4c3 /src/view/MenuBuilder.php | |
parent | 5e41bea598ff38b3c520b69fd92ee3412e716df2 (diff) | |
download | cms-efd79d15adef2a27347c25ebb19754e9937f9715.zip |
modification d'une URL page Menu et chemin, htmlspecialchars sur les URL du menu à l'affichage
Diffstat (limited to 'src/view/MenuBuilder.php')
-rw-r--r-- | src/view/MenuBuilder.php | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/view/MenuBuilder.php b/src/view/MenuBuilder.php index 9d4dda1..bc64e30 100644 --- a/src/view/MenuBuilder.php +++ b/src/view/MenuBuilder.php | |||
@@ -13,18 +13,13 @@ class MenuBuilder extends AbstractBuilder | |||
13 | //private int $margin_left_multiplier = 29; | 13 | //private int $margin_left_multiplier = 29; |
14 | private string $options = ''; | 14 | private string $options = ''; |
15 | 15 | ||
16 | public function __construct(Node $node = null, bool $template = true) | 16 | public function __construct(Node $node, bool $template = true) |
17 | { | 17 | { |
18 | //parent::__construct($node); | 18 | // impossible de me rappeler pourquoi j'ai écrit ce test sur $node, pourquoi $node serait null? |
19 | $viewFile = $node === null ? self::VIEWS_PATH . 'menu.php' : self::VIEWS_PATH . $node->getName() . '.php'; | 19 | $viewFile = $node === null ? self::VIEWS_PATH . 'menu.php' : self::VIEWS_PATH . $node->getName() . '.php'; |
20 | 20 | ||
21 | if(file_exists($viewFile)) | 21 | if(file_exists($viewFile)) |
22 | { | 22 | { |
23 | /*if(!empty($node->getNodeData()->getData())) | ||
24 | { | ||
25 | extract($node->getNodeData()->getData()); | ||
26 | }*/ | ||
27 | |||
28 | if($_SESSION['admin']){ | 23 | if($_SESSION['admin']){ |
29 | $this->unfoldMenu(Director::$menu_data); | 24 | $this->unfoldMenu(Director::$menu_data); |
30 | 25 | ||
@@ -63,13 +58,26 @@ class MenuBuilder extends AbstractBuilder | |||
63 | </span> | 58 | </span> |
64 | <button>' . $entry->getPageName() . '</button>'; | 59 | <button>' . $entry->getPageName() . '</button>'; |
65 | 60 | ||
61 | // seul la modification des URL est possible pour l'instant, les noms des entrées de menu attendront | ||
66 | if(str_starts_with($entry->getEndOfPath(), 'http')){ | 62 | if(str_starts_with($entry->getEndOfPath(), 'http')){ |
67 | $this->html .= '<span id="edit-i' . $entry->getId() . '"><img class="move_entry_icon" src="assets/edit.svg" onclick="editUrlEntry(' . $entry->getId() . ')"></span> | 63 | $this->html .= '<form style="display: inline;" id="delete-i' . $entry->getId() . '" method="post" action="' . new URL(['from' => 'menu_chemins']) . '"> |
68 | <i class="url">' . $entry->getEndOfPath() . '</i> | ||
69 | <form style="display: inline;" id="delete-i' . $entry->getId() . '" method="post" action="' . new URL(['from' => 'menu_chemins']) . '"> | ||
70 | <input type="hidden" name="delete" value="' . $entry->getId() . '"> | 64 | <input type="hidden" name="delete" value="' . $entry->getId() . '"> |
71 | <input type="image" class="move_entry_icon" src="assets/delete-bin.svg" alt="delete link button" onclick="return confirm(\'Voulez-vous vraiment supprimer cette entrée?\');"> | 65 | <input type="image" class="move_entry_icon" src="assets/delete-bin.svg" alt="delete link button" onclick="return confirm(\'Voulez-vous vraiment supprimer cette entrée?\');"> |
72 | </form>'; | 66 | </form> |
67 | <span class="url"> | ||
68 | <input type="url" value="' . htmlspecialchars($entry->getEndOfPath()) . '"> | ||
69 | <img class="move_entry_icon" src="assets/save.svg" onclick="editUrlEntry(' . $entry->getId() . ')"> | ||
70 | </span>'; | ||
71 | |||
72 | // code à recycler pour pouvoir modifier le nom de l'entrée de menu correspondant aux liens | ||
73 | /*$this->html .= '<span id="cancel-i' . $entry->getId() . '"> | ||
74 | <input type="hidden" name="cancel" value="' . $entry->getId() . '"> | ||
75 | <button class="hidden" onclick="cancelUrlEntry(' . $entry->getId() . ')">Annuler</button> | ||
76 | </span> | ||
77 | <span id="submit-i' . $entry->getId() . '"> | ||
78 | <input type="hidden" name="submit" value="' . $entry->getId() . '"> | ||
79 | <input type="submit" class="hidden" onclick="submitUrlEntry(' . $entry->getId() . ')"> | ||
80 | </span>';*/ | ||
73 | } | 81 | } |
74 | else{ | 82 | else{ |
75 | $this->html .= '<i class="path">' . $entry->getPagePath() . '</i>'; | 83 | $this->html .= '<i class="path">' . $entry->getPagePath() . '</i>'; |