From f4df3e9b9df3d54ce58796f923da70ff7e566018 Mon Sep 17 00:00:00 2001 From: polo Date: Tue, 26 Aug 2025 01:15:33 +0200 Subject: =?UTF-8?q?s=C3=A9paration=20bloc=20/=20mise=20en=20page,=20bloc?= =?UTF-8?q?=20sp=C3=A9cial=20pour=20les=20actus,=20renommage=20de=20classe?= =?UTF-8?q?s,=20fichiers,=20etc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controller/ArticleController.php | 2 +- src/controller/PageManagementController.php | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/controller') diff --git a/src/controller/ArticleController.php b/src/controller/ArticleController.php index 3b39335..078754a 100644 --- a/src/controller/ArticleController.php +++ b/src/controller/ArticleController.php @@ -49,7 +49,7 @@ class ArticleController $date->setTimestamp($timestamp); $article = new Article($content, $date); // le "current" timestamp est obtenu par la BDD - $article_node = new Node('article', 'i' . (string)$timestamp, [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); + $article_node = new Node('post', 'i' . (string)$timestamp, [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); } $entityManager->persist($article_node); diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php index f84c528..50ce193 100644 --- a/src/controller/PageManagementController.php +++ b/src/controller/PageManagementController.php @@ -6,6 +6,7 @@ declare(strict_types=1); use App\Entity\Page; use App\Entity\Node; use App\Entity\NodeData; +use App\Entity\Presentation; //use App\Entity\Image; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\EntityManager; @@ -136,8 +137,7 @@ class PageManagementController $main = $director->getNode(); $position = count($main->getChildren()) + 1; // position dans la fraterie - $blocks = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php - if(!in_array($_POST["bloc_select"], $blocks, true)) // 3è param: contrôle du type + if(!in_array($_POST["bloc_select"], Blocks::getNameList(), true)) // 3è param: contrôle du type { header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); die; @@ -163,7 +163,7 @@ class PageManagementController $entityManager->persist($bulk_data[0]); } - $bloc = new Node( + $block = new Node( $_POST["bloc_select"], null, [], $position, @@ -171,9 +171,17 @@ class PageManagementController $page); $data = new NodeData( ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], - $bloc); + $block); - $entityManager->persist($bloc); + // valeurs par défaut + if($_POST["bloc_select"] === 'post_block'){ + $data->setPresentation($entityManager->find('App\Entity\Presentation', 1)); // pas génial l'utilisation de l'index dans la table + } + elseif($_POST["bloc_select"] === 'news_block'){ + $data->setPresentation($entityManager->find('App\Entity\Presentation', 2)); + } + + $entityManager->persist($block); $entityManager->persist($data); $entityManager->flush(); header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); -- cgit v1.2.3