From 959527bb712fcd05351d8b4b52ff17786baad454 Mon Sep 17 00:00:00 2001 From: polo Date: Sun, 26 Oct 2025 22:48:49 +0100 Subject: =?UTF-8?q?modification=20du=20nom=20et=20plus=20seulement=20de=20?= =?UTF-8?q?l'URL=20des=20entr=C3=A9es=20"URL"=20du=20menu,=20header/footer?= =?UTF-8?q?:=20renommage=20de=20classes=20et=20input=20absents=20du=20HTML?= =?UTF-8?q?=20sans=20=C3=AAtre=20admin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/MenuAndPathsController.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/controller/MenuAndPathsController.php') diff --git a/src/controller/MenuAndPathsController.php b/src/controller/MenuAndPathsController.php index a32b210..6bb098f 100644 --- a/src/controller/MenuAndPathsController.php +++ b/src/controller/MenuAndPathsController.php @@ -42,21 +42,30 @@ class MenuAndPathsController die; } - static public function editUrlEntry(EntityManager $entityManager, array $json): void + // on pourrait utiliser FormValidation ici + static public function editUrl(EntityManager $entityManager, array $json): void { - $url_input = trim($json['url_input']); // faire htmlspecialchars à l'affichage + $url_data = trim($json['input_data']); // garder htmlspecialchars pour l'affichage $page = $entityManager->find('App\Entity\Page', $json['id']); if(!$page){ echo json_encode(['success' => false, 'message' => "id invalide"]); } - elseif(!filter_var($url_input, FILTER_VALIDATE_URL) || !str_starts_with($url_input, 'http')){ + elseif(!in_array($json['field'], ['url_name', 'url_content'])){ + echo json_encode(['success' => false, 'message' => "champ invalide"]); + } + elseif($json['field'] === 'url_content' && (!filter_var($url_data, FILTER_VALIDATE_URL) || !str_starts_with($url_data, 'http'))){ echo json_encode(['success' => false, 'message' => "la chaîne envoyée n'est pas une URL valide"]); } else{ - $page->setEndOfPath($url_input); + if($json['field'] === 'url_name'){ + $page->setPageName($url_data); + } + elseif($json['field'] === 'url_content'){ + $page->setEndOfPath($url_data); + } $entityManager->flush(); - echo json_encode(['success' => true, 'url_input' => $url_input]); + echo json_encode(['success' => true, 'url_data' => $url_data]); } die; } -- cgit v1.2.3