summaryrefslogtreecommitdiff
path: root/src/controller/ajax.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/ajax.php')
-rw-r--r--src/controller/ajax.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/controller/ajax.php b/src/controller/ajax.php
index a6786d9..a64c39b 100644
--- a/src/controller/ajax.php
+++ b/src/controller/ajax.php
@@ -378,7 +378,43 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['bloc_edit']))
378 } 378 }
379 die; 379 die;
380 } 380 }
381 // inversion des positions de deux blocs
382 elseif($_GET['bloc_edit'] === 'switch_blocs_positions')
383 {
384 if(isset($json['id1']) && is_int($json['id1']) && isset($json['id2']) && is_int($json['id2']) && isset($_GET['page'])){
385 $director = new Director($entityManager, true);
386 $director->findUniqueNodeByName('main');
387 $director->findItsChildren();
388 $main = $director->getNode();
389 $main->sortChildren(true); // régénère les positions avant inversion
390
391 $bloc1; $bloc2;
392 foreach($main->getChildren() as $child){
393 if($child->getId() === $json['id1']){
394 $bloc1 = $child;
395 break;
396 }
397 }
398 foreach($main->getChildren() as $child){
399 if($child->getId() === $json['id2']){
400 $bloc2 = $child;
401 break;
402 }
403 }
381 404
405 // inversion
406 $tmp = $bloc1->getPosition();
407 $bloc1->setPosition($bloc2->getPosition());
408 $bloc2->setPosition($tmp);
409
410 $entityManager->flush();
411 echo json_encode(['success' => true]);
412 }
413 else{
414 echo json_encode(['success' => false]);
415 }
416 die;
417 }
382} 418}
383 419
384 420