diff options
| author | polo <ordipolo@gmx.fr> | 2025-08-26 20:34:38 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-08-26 20:34:38 +0200 |
| commit | 6c28cf85e1b5921e4fb77be230651bc22e83b801 (patch) | |
| tree | f42e38a5a389a0b3960ed9d085998aee668be3aa /src/router.php | |
| parent | fdbc0d2c6366019249d19ed387df877eda90b320 (diff) | |
| download | cms-6c28cf85e1b5921e4fb77be230651bc22e83b801.tar.gz cms-6c28cf85e1b5921e4fb77be230651bc22e83b801.tar.bz2 cms-6c28cf85e1b5921e4fb77be230651bc22e83b801.zip | |
redirections correctes et bouton supprimer page article, ArticleController::deleteArticle renvoie une Response
Diffstat (limited to 'src/router.php')
| -rw-r--r-- | src/router.php | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/router.php b/src/router.php index eddd199..8aa0aa9 100644 --- a/src/router.php +++ b/src/router.php | |||
| @@ -13,7 +13,6 @@ $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' requête AJAX xhs, non uti | |||
| 13 | 13 | ||
| 14 | declare(strict_types=1); | 14 | declare(strict_types=1); |
| 15 | 15 | ||
| 16 | |||
| 17 | if($_SERVER['REQUEST_METHOD'] === 'GET'){ | 16 | if($_SERVER['REQUEST_METHOD'] === 'GET'){ |
| 18 | // table "user" vide | 17 | // table "user" vide |
| 19 | if(!UserController::existUsers($entityManager)){ | 18 | if(!UserController::existUsers($entityManager)){ |
| @@ -95,9 +94,10 @@ elseif($_SERVER['REQUEST_METHOD'] === 'POST'){ | |||
| 95 | { | 94 | { |
| 96 | ArticleController::editorSubmit($entityManager, $json); | 95 | ArticleController::editorSubmit($entityManager, $json); |
| 97 | } | 96 | } |
| 98 | elseif($_GET['action'] === 'delete_article' && isset($json['id'])) | 97 | elseif($_GET['action'] === 'delete_article' && isset($json['id'])){ |
| 99 | { | 98 | $response = ArticleController::deleteArticle($entityManager, $json); // version AJAX |
| 100 | ArticleController::deleteArticle($entityManager, $json); | 99 | $response->send(); |
| 100 | die; | ||
| 101 | } | 101 | } |
| 102 | // inversion de la position de deux noeuds | 102 | // inversion de la position de deux noeuds |
| 103 | elseif($_GET['action'] === 'switch_positions' && isset($json['id1']) && isset($json['id2'])) | 103 | elseif($_GET['action'] === 'switch_positions' && isset($json['id1']) && isset($json['id2'])) |
| @@ -214,8 +214,19 @@ elseif($_SERVER['REQUEST_METHOD'] === 'POST'){ | |||
| 214 | /* -- envoi formulaire HTML -- */ | 214 | /* -- envoi formulaire HTML -- */ |
| 215 | elseif($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') | 215 | elseif($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') |
| 216 | { | 216 | { |
| 217 | if($_GET['action'] === 'delete_article' && isset($_GET['id'])){ | ||
| 218 | $response = json_decode(ArticleController::deleteArticle($entityManager, $_GET)->getContent(), true); // version formulaire | ||
| 219 | $url = new URL; | ||
| 220 | if(isset($_GET['from'])){ | ||
| 221 | $url->addParams(['page' => $_GET['from']]); | ||
| 222 | } | ||
| 223 | $url->addParams(['success' => $response['success'], 'message' => $response['message']]); | ||
| 224 | header('Location: ' . $url); | ||
| 225 | die; | ||
| 226 | } | ||
| 227 | |||
| 217 | /* -- nouvelle page -- */ | 228 | /* -- nouvelle page -- */ |
| 218 | if(isset($_POST['page_name']) && $_POST['page_name'] !== null | 229 | elseif(isset($_POST['page_name']) && $_POST['page_name'] !== null |
| 219 | && isset($_POST['page_name_path']) && $_POST['page_name_path'] !== null | 230 | && isset($_POST['page_name_path']) && $_POST['page_name_path'] !== null |
| 220 | && isset($_POST['page_location']) && $_POST['page_location'] !== null | 231 | && isset($_POST['page_location']) && $_POST['page_location'] !== null |
| 221 | && isset($_POST['page_description']) && $_POST['page_description'] !== null | 232 | && isset($_POST['page_description']) && $_POST['page_description'] !== null |
