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 | |
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')
-rw-r--r-- | src/view/MenuBuilder.php | 30 | ||||
-rw-r--r-- | src/view/NavBuilder.php | 2 | ||||
-rw-r--r-- | src/view/templates/menu.php | 11 |
3 files changed, 25 insertions, 18 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>'; |
diff --git a/src/view/NavBuilder.php b/src/view/NavBuilder.php index a9cf49c..2cbdef9 100644 --- a/src/view/NavBuilder.php +++ b/src/view/NavBuilder.php | |||
@@ -38,7 +38,7 @@ class NavBuilder extends AbstractBuilder | |||
38 | { | 38 | { |
39 | if(str_starts_with($data->getEndOfPath(), 'http')) // lien vers autre site | 39 | if(str_starts_with($data->getEndOfPath(), 'http')) // lien vers autre site |
40 | { | 40 | { |
41 | $link .= '<a href="' . $data->getEndOfPath() . '" target="_blank">'; | 41 | $link .= '<a href="' . htmlspecialchars($data->getEndOfPath()) . '" target="_blank">'; |
42 | } | 42 | } |
43 | elseif($data->getEndOfPath() != '') // lien relatif | 43 | elseif($data->getEndOfPath() != '') // lien relatif |
44 | { | 44 | { |
diff --git a/src/view/templates/menu.php b/src/view/templates/menu.php index 55c9ff9..d78c665 100644 --- a/src/view/templates/menu.php +++ b/src/view/templates/menu.php | |||
@@ -2,18 +2,18 @@ | |||
2 | <section class="menu"> | 2 | <section class="menu"> |
3 | <h3>Menu et chemins</h3> | 3 | <h3>Menu et chemins</h3> |
4 | <div class="new_page_button"> | 4 | <div class="new_page_button"> |
5 | <p >Créer une <a href="<?= new URL(['page' => 'nouvelle_page']) ?>"><button style="color: #ff1d04;">Nouvelle page</button></a>.</p> | 5 | <p>Créer une <a href="<?= new URL(['page' => 'nouvelle_page']) ?>"><button style="color: #ff1d04;">Nouvelle page</button></a>.</p> |
6 | </div> | 6 | </div> |
7 | <div class="url_form_zone"> | 7 | <div class="url_form_zone"> |
8 | <p>Ajouter au menu un lien vers un site web quelconque avec le formulaire ci-dessous:</p> | 8 | <p>Créer une entrée dans le menu avec une adresse vers un site quelconque:</p> |
9 | <form method="post" action="<?= new URL(['from' => 'menu_chemins']) ?>"> | 9 | <form method="post" action="<?= new URL(['from' => 'menu_chemins']) ?>"> |
10 | <p> | 10 | <p> |
11 | <label for="label_input">Nom:</label> | 11 | <label for="label_input">Nom dans le menu:</label> |
12 | <input id="label_input" type="text" name="label_input"> | 12 | <input id="label_input" type="text" name="label_input"> |
13 | </p> | 13 | </p> |
14 | <p> | 14 | <p> |
15 | <label for="url_input">Adresse URL:</label> | 15 | <label for="url_input">Adresse (collez votre lien):</label> |
16 | <input id="url_input" type="url" name="url_input"> | 16 | <input id="url_input" type="url" name="url_input" placeholder="http://"> |
17 | </p> | 17 | </p> |
18 | <p> | 18 | <p> |
19 | <label>Placer le lien juste après cette entrée:</label> | 19 | <label>Placer le lien juste après cette entrée:</label> |
@@ -38,5 +38,4 @@ | |||
38 | <div id="menu_edit_buttons"> | 38 | <div id="menu_edit_buttons"> |
39 | <?= $this->html ?> | 39 | <?= $this->html ?> |
40 | </div> | 40 | </div> |
41 | |||
42 | </section> \ No newline at end of file | 41 | </section> \ No newline at end of file |