From f60a9d046088b3bad3e97ff568fc83fecc67ccde Mon Sep 17 00:00:00 2001 From: polo Date: Thu, 26 Jun 2025 11:11:24 +0200 Subject: =?UTF-8?q?ajout=20dans=20css=5Farray=20=C3=A0=20la=20cr=C3=A9atio?= =?UTF-8?q?n=20d'un=20bloc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/post.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/controller/post.php') diff --git a/src/controller/post.php b/src/controller/post.php index 3ba0656..7e6ed53 100644 --- a/src/controller/post.php +++ b/src/controller/post.php @@ -132,8 +132,32 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) $main = $director->getNode(); $position = count($main->getChildren()) + 1; // position dans la fraterie + $blocs_true_names = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php + if(!in_array($_POST["bloc_select"], $blocs_true_names, true)) // 3è param: contrôle du type + { + header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); + die; + } + + if($_POST["bloc_select"] === 'calendar'){ + $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page + $bulk_data = $entityManager + ->createQuery($dql) + ->setParameter('page', $page) + ->setParameter('name', 'head') + ->getResult(); + + if(count($bulk_data) != 1){ // 1 head par page + header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found'])); + die; + } + + $bulk_data[0]->addAttribute('css_array', 'calendar'); + $entityManager->persist($bulk_data[0]); + } + $bloc = new Node( - trim(htmlspecialchars($_POST["bloc_select"])), + $_POST["bloc_select"], null, [], $position, $main, -- cgit v1.2.3