diff options
Diffstat (limited to 'src/controller/ajax.php')
-rw-r--r-- | src/controller/ajax.php | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index c774bf3..9d1cc42 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
@@ -209,12 +209,10 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | |||
209 | // récupération des données | 209 | // récupération des données |
210 | $data = file_get_contents('php://input'); | 210 | $data = file_get_contents('php://input'); |
211 | $json = json_decode($data, true); | 211 | $json = json_decode($data, true); |
212 | Director::$menu_data = new Menu($entityManager); | ||
212 | 213 | ||
213 | if($_GET['menu_edit'] === 'switch_positions' && isset($json['id1']) && isset($json['id2'])) | 214 | if($_GET['menu_edit'] === 'switch_positions' && isset($json['id1']) && isset($json['id2'])) |
214 | { | 215 | { |
215 | //$menu = new Menu($entityManager); | ||
216 | Director::$menu_data = new Menu($entityManager); | ||
217 | |||
218 | $id1 = $json['id1']; | 216 | $id1 = $json['id1']; |
219 | $id2 = $json['id2']; | 217 | $id2 = $json['id2']; |
220 | 218 | ||
@@ -232,11 +230,9 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | |||
232 | Director::$menu_data->sortChildren(true); // modifie tableau children | 230 | Director::$menu_data->sortChildren(true); // modifie tableau children |
233 | $entityManager->flush(); | 231 | $entityManager->flush(); |
234 | 232 | ||
235 | // menu utilisant les nouvelles données | 233 | // nouveau menu |
236 | //Director::$page_path = new Path(); | 234 | $nav_builder = new NavBuilder(); |
237 | $nav_builder = new NavBuilder(); // builder appelé sans envoi du noeud correspondant | 235 | echo json_encode(['success' => true, 'nav' => $nav_builder->render()]); |
238 | |||
239 | echo json_encode(['success' => true, 'path1' => '', 'path2' => '', 'nav' => $nav_builder->render()]); | ||
240 | } | 236 | } |
241 | else{ | 237 | else{ |
242 | echo json_encode(['success' => false]); | 238 | echo json_encode(['success' => false]); |
@@ -244,9 +240,29 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | |||
244 | 240 | ||
245 | die; | 241 | die; |
246 | } | 242 | } |
243 | |||
244 | if($_GET['menu_edit'] === 'displayInMenu' && isset($json['id']) && isset($json['checked'])) | ||
245 | { | ||
246 | $id = $json['id']; | ||
247 | $checked = $json['checked']; | ||
248 | |||
249 | $page = Director::$menu_data->findPageById((int)$id); | ||
250 | if($page->isHidden() === $checked){ | ||
251 | $page->setHidden(!$checked); | ||
252 | $entityManager->flush(); | ||
253 | |||
254 | // nouveau menu | ||
255 | $nav_builder = new NavBuilder(); | ||
256 | echo json_encode(['success' => true, 'nav' => $nav_builder->render()]); | ||
257 | } | ||
258 | else{ | ||
259 | echo json_encode(['success' => false]); | ||
260 | } | ||
261 | die; | ||
262 | } | ||
247 | } | 263 | } |
248 | 264 | ||
249 | // détection des requêtes de type XHR, pas d'utilité pour l'instant | 265 | // détection des requêtes de type XHR?, pas d'utilité pour l'instant |
250 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ | 266 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ |
251 | echo "requête XHR reçue par le serveur"; | 267 | echo "requête XHR reçue par le serveur"; |
252 | die; | 268 | die; |