aboutsummaryrefslogtreecommitdiff
path: root/src/controller/PageManagementController.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/PageManagementController.php')
-rw-r--r--src/controller/PageManagementController.php65
1 files changed, 54 insertions, 11 deletions
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php
index 50ce193..4528810 100644
--- a/src/controller/PageManagementController.php
+++ b/src/controller/PageManagementController.php
@@ -39,7 +39,7 @@ class PageManagementController
39 } 39 }
40 } 40 }
41 $entityManager->flush(); 41 $entityManager->flush();
42 header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page'])); 42 header("Location: " . new URL(['page' => $page->getPagePath(), 'mode' => 'page_modif']));
43 die; 43 die;
44 } 44 }
45 45
@@ -104,7 +104,7 @@ class PageManagementController
104 $entityManager->flush(); 104 $entityManager->flush();
105 105
106 // page créée, direction la page en mode modification pour ajouter des blocs 106 // page créée, direction la page en mode modification pour ajouter des blocs
107 header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page'])); 107 header("Location: " . new URL(['page' => $page->getPagePath(), 'mode' => 'page_modif']));
108 die; 108 die;
109 } 109 }
110 110
@@ -146,10 +146,10 @@ class PageManagementController
146 if($_POST["bloc_select"] === 'calendar' || $_POST["bloc_select"] === 'form'){ 146 if($_POST["bloc_select"] === 'calendar' || $_POST["bloc_select"] === 'form'){
147 $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page 147 $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page
148 $bulk_data = $entityManager 148 $bulk_data = $entityManager
149 ->createQuery($dql) 149 ->createQuery($dql)
150 ->setParameter('page', $page) 150 ->setParameter('page', $page)
151 ->setParameter('name', 'head') 151 ->setParameter('name', 'head')
152 ->getResult(); 152 ->getResult();
153 153
154 if(count($bulk_data) != 1){ // 1 head par page 154 if(count($bulk_data) != 1){ // 1 head par page
155 header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found'])); 155 header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found']));
@@ -175,16 +175,20 @@ class PageManagementController
175 175
176 // valeurs par défaut 176 // valeurs par défaut
177 if($_POST["bloc_select"] === 'post_block'){ 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 178 $data->setPresentation(Presentation::findPresentation($entityManager, 'fullwidth')); // pas génial l'utilisation de l'index dans la table
179 } 179 }
180 elseif($_POST["bloc_select"] === 'news_block'){ 180 elseif($_POST["bloc_select"] === 'news_block'){
181 $data->setPresentation($entityManager->find('App\Entity\Presentation', 2)); 181 $data->setPresentation(Presentation::findPresentation($entityManager, 'grid'));
182 }
183 elseif($_POST["bloc_select"] === 'galery'){
184 $data->setPresentation(Presentation::findPresentation($entityManager, 'mosaic')); // mieux que carousel pour commencer
182 } 185 }
186 // else = null par défaut
183 187
184 $entityManager->persist($block); 188 $entityManager->persist($block);
185 $entityManager->persist($data); 189 $entityManager->persist($data);
186 $entityManager->flush(); 190 $entityManager->flush();
187 header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); 191 header("Location: " . new URL(['page' => $_GET['page'], 'mode' => 'page_modif']));
188 die; 192 die;
189 } 193 }
190 194
@@ -208,7 +212,8 @@ class PageManagementController
208 $entityManager->remove($bloc); // suppression en BDD 212 $entityManager->remove($bloc); // suppression en BDD
209 $entityManager->flush(); 213 $entityManager->flush();
210 } 214 }
211 header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); 215
216 header("Location: " . new URL(['page' => $_GET['page'], 'mode' => 'page_modif']));
212 die; 217 die;
213 } 218 }
214 219
@@ -235,7 +240,7 @@ class PageManagementController
235 static public function SwitchBlocsPositions(EntityManager $entityManager, array $json): void 240 static public function SwitchBlocsPositions(EntityManager $entityManager, array $json): void
236 { 241 {
237 if(isset($json['id1']) && is_int($json['id1']) && isset($json['id2']) && is_int($json['id2']) && isset($_GET['page'])){ 242 if(isset($json['id1']) && is_int($json['id1']) && isset($json['id2']) && is_int($json['id2']) && isset($_GET['page'])){
238 $director = new Director($entityManager, true); 243 $director = new Director($entityManager, true); // true pour $director->findItsChildren();
239 $director->findUniqueNodeByName('main'); 244 $director->findUniqueNodeByName('main');
240 $director->findItsChildren(); 245 $director->findItsChildren();
241 $main = $director->getNode(); 246 $main = $director->getNode();
@@ -269,4 +274,42 @@ class PageManagementController
269 } 274 }
270 die; 275 die;
271 } 276 }
277
278 static public function changePresentation(EntityManager $entityManager, array $json): void
279 {
280 if(isset($json['id']) && isset($json['presentation'])){
281 $director = new Director($entityManager, false);
282 $director->findNodeById($json['id']);
283
284 $presentation = Presentation::findPresentation($entityManager, $json['presentation']);
285 if($presentation !== null){
286 $director->getNode()->getNodeData()->setPresentation($presentation);
287
288 $entityManager->flush();
289 echo json_encode(['success' => true, 'presentation' => $json['presentation'], 'cols_min_width' => $director->getNode()->getNodeData()->getColsMinWidth()]);
290 }
291 else{
292 echo json_encode(['success' => false]);
293 }
294 }
295 else{
296 echo json_encode(['success' => false]);
297 }
298 die;
299 }
300 static public function changeColsMinWidth(EntityManager $entityManager, array $json): void
301 {
302 if(isset($json['id']) && isset($json['cols_min_width'])){
303 $director = new Director($entityManager, false);
304 $director->findNodeById($json['id']);
305 $director->getNode()->getNodeData()->setColsMinWidth((int)$json['cols_min_width']); // attention conversion?
306
307 $entityManager->flush();
308 echo json_encode(['success' => true, 'cols_min_width' => $json['cols_min_width']]);
309 }
310 else{
311 echo json_encode(['success' => false]);
312 }
313 die;
314 }
272} \ No newline at end of file 315} \ No newline at end of file