diff options
Diffstat (limited to 'src/controller/ajax.php')
| -rw-r--r-- | src/controller/ajax.php | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index a20bd87..a6786d9 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
| @@ -35,7 +35,8 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 35 | if($id[0] === 'n') | 35 | if($id[0] === 'n') |
| 36 | { | 36 | { |
| 37 | $section_id = (int)substr($id, 1); // id du bloc <section> | 37 | $section_id = (int)substr($id, 1); // id du bloc <section> |
| 38 | $director->makeSectionNode($section_id); | 38 | $director->findNodeById($section_id); |
| 39 | $director->makeSectionNode(); | ||
| 39 | $node = $director->getNode(); // = <section> | 40 | $node = $director->getNode(); // = <section> |
| 40 | 41 | ||
| 41 | if(is_array($content)){ | 42 | if(is_array($content)){ |
| @@ -205,6 +206,8 @@ if(strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false && isset($_ | |||
| 205 | die; | 206 | die; |
| 206 | } | 207 | } |
| 207 | 208 | ||
| 209 | |||
| 210 | /* -- page Menu et chemins -- */ | ||
| 208 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | 211 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) |
| 209 | { | 212 | { |
| 210 | // récupération des données | 213 | // récupération des données |
| @@ -347,7 +350,39 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | |||
| 347 | } | 350 | } |
| 348 | } | 351 | } |
| 349 | 352 | ||
| 350 | // détection des requêtes de type XHR?, pas d'utilité pour l'instant | 353 | |
| 354 | /* -- mode Modification d'une page -- */ | ||
| 355 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['bloc_edit'])) | ||
| 356 | { | ||
| 357 | // récupération des données | ||
| 358 | $data = file_get_contents('php://input'); | ||
| 359 | $json = json_decode($data, true); | ||
| 360 | |||
| 361 | // renommage d'un bloc | ||
| 362 | if($_GET['bloc_edit'] === 'rename_page_bloc') | ||
| 363 | { | ||
| 364 | if(isset($json['bloc_title']) && $json['bloc_title'] !== null && isset($json['bloc_id']) && is_int($json['bloc_id'])){ | ||
| 365 | $director = new Director($entityManager); | ||
| 366 | $director->findNodeById($json['bloc_id']); | ||
| 367 | |||
| 368 | // le titre (du JSON en BDD) est récupéré sous forme de tableau, modifié et renvoyé | ||
| 369 | $data = $director->getNode()->getNodeData()->getData(); | ||
| 370 | $data['title'] = htmlspecialchars($json['bloc_title']); | ||
| 371 | $director->getNode()->getNodeData()->setData($data); | ||
| 372 | |||
| 373 | $entityManager->flush(); | ||
| 374 | echo json_encode(['success' => true, 'title' => $data['title']]); | ||
| 375 | } | ||
| 376 | else{ | ||
| 377 | echo json_encode(['success' => false]); | ||
| 378 | } | ||
| 379 | die; | ||
| 380 | } | ||
| 381 | |||
| 382 | } | ||
| 383 | |||
| 384 | |||
| 385 | // détection des requêtes de type XHR?, pas d'utilité à priori | ||
| 351 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ | 386 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ |
| 352 | echo "requête XHR reçue par le serveur"; | 387 | echo "requête XHR reçue par le serveur"; |
| 353 | die; | 388 | die; |
