From d2bdfa7d0f746f060090a9e8c8ad6e376b5a1480 Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 9 May 2025 01:02:23 +0200 Subject: =?UTF-8?q?mode=20modif=20page=20termin=C3=A9!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/ajax.php | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/controller/ajax.php') 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'])) } die; } + // inversion des positions de deux blocs + elseif($_GET['bloc_edit'] === 'switch_blocs_positions') + { + if(isset($json['id1']) && is_int($json['id1']) && isset($json['id2']) && is_int($json['id2']) && isset($_GET['page'])){ + $director = new Director($entityManager, true); + $director->findUniqueNodeByName('main'); + $director->findItsChildren(); + $main = $director->getNode(); + $main->sortChildren(true); // régénère les positions avant inversion + + $bloc1; $bloc2; + foreach($main->getChildren() as $child){ + if($child->getId() === $json['id1']){ + $bloc1 = $child; + break; + } + } + foreach($main->getChildren() as $child){ + if($child->getId() === $json['id2']){ + $bloc2 = $child; + break; + } + } + // inversion + $tmp = $bloc1->getPosition(); + $bloc1->setPosition($bloc2->getPosition()); + $bloc2->setPosition($tmp); + + $entityManager->flush(); + echo json_encode(['success' => true]); + } + else{ + echo json_encode(['success' => false]); + } + die; + } } -- cgit v1.2.3