diff options
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 |