diff options
Diffstat (limited to 'src/controller')
-rw-r--r-- | src/controller/ArticleController.php | 2 | ||||
-rw-r--r-- | src/controller/PageManagementController.php | 18 |
2 files changed, 14 insertions, 6 deletions
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 | |||
49 | $date->setTimestamp($timestamp); | 49 | $date->setTimestamp($timestamp); |
50 | 50 | ||
51 | $article = new Article($content, $date); // le "current" timestamp est obtenu par la BDD | 51 | $article = new Article($content, $date); // le "current" timestamp est obtenu par la BDD |
52 | $article_node = new Node('article', 'i' . (string)$timestamp, [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); | 52 | $article_node = new Node('post', 'i' . (string)$timestamp, [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); |
53 | } | 53 | } |
54 | 54 | ||
55 | $entityManager->persist($article_node); | 55 | $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); | |||
6 | use App\Entity\Page; | 6 | use App\Entity\Page; |
7 | use App\Entity\Node; | 7 | use App\Entity\Node; |
8 | use App\Entity\NodeData; | 8 | use App\Entity\NodeData; |
9 | use App\Entity\Presentation; | ||
9 | //use App\Entity\Image; | 10 | //use App\Entity\Image; |
10 | use Doctrine\Common\Collections\ArrayCollection; | 11 | use Doctrine\Common\Collections\ArrayCollection; |
11 | use Doctrine\ORM\EntityManager; | 12 | use Doctrine\ORM\EntityManager; |
@@ -136,8 +137,7 @@ class PageManagementController | |||
136 | $main = $director->getNode(); | 137 | $main = $director->getNode(); |
137 | $position = count($main->getChildren()) + 1; // position dans la fraterie | 138 | $position = count($main->getChildren()) + 1; // position dans la fraterie |
138 | 139 | ||
139 | $blocks = ['blog', 'grid', 'calendar', 'galery', 'form']; // même liste dans FormBuilder.php | 140 | if(!in_array($_POST["bloc_select"], Blocks::getNameList(), true)) // 3è param: contrôle du type |
140 | if(!in_array($_POST["bloc_select"], $blocks, true)) // 3è param: contrôle du type | ||
141 | { | 141 | { |
142 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); | 142 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'bad_bloc_type'])); |
143 | die; | 143 | die; |
@@ -163,7 +163,7 @@ class PageManagementController | |||
163 | $entityManager->persist($bulk_data[0]); | 163 | $entityManager->persist($bulk_data[0]); |
164 | } | 164 | } |
165 | 165 | ||
166 | $bloc = new Node( | 166 | $block = new Node( |
167 | $_POST["bloc_select"], | 167 | $_POST["bloc_select"], |
168 | null, [], | 168 | null, [], |
169 | $position, | 169 | $position, |
@@ -171,9 +171,17 @@ class PageManagementController | |||
171 | $page); | 171 | $page); |
172 | $data = new NodeData( | 172 | $data = new NodeData( |
173 | ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], | 173 | ['title' => trim(htmlspecialchars($_POST["bloc_title"]))], |
174 | $bloc); | 174 | $block); |
175 | 175 | ||
176 | $entityManager->persist($bloc); | 176 | // valeurs par défaut |
177 | if($_POST["bloc_select"] === 'post_block'){ | ||
178 | $data->setPresentation($entityManager->find('App\Entity\Presentation', 1)); // pas génial l'utilisation de l'index dans la table | ||
179 | } | ||
180 | elseif($_POST["bloc_select"] === 'news_block'){ | ||
181 | $data->setPresentation($entityManager->find('App\Entity\Presentation', 2)); | ||
182 | } | ||
183 | |||
184 | $entityManager->persist($block); | ||
177 | $entityManager->persist($data); | 185 | $entityManager->persist($data); |
178 | $entityManager->flush(); | 186 | $entityManager->flush(); |
179 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | 187 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); |