summaryrefslogtreecommitdiff
path: root/src/controller/post.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/post.php')
-rw-r--r--src/controller/post.php30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/controller/post.php b/src/controller/post.php
index d437423..631c4ad 100644
--- a/src/controller/post.php
+++ b/src/controller/post.php
@@ -13,9 +13,30 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
13 if($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded') 13 if($_SERVER['CONTENT_TYPE'] === 'application/x-www-form-urlencoded')
14 { 14 {
15 /* -- mode Modification d'une page -- */ 15 /* -- mode Modification d'une page -- */
16 if(isset($_POST['page_menu_path']) && $_POST['page_menu_path'] !== null
17 && isset($_POST['page_id']) && $_POST['page_id'] !== null
18 && isset($_POST['page_name_path_hidden']) && $_POST['page_name_path_hidden'] === '')
19 {
20 $director = new Director($entityManager, true);
21 $page = Director::$page_path->getLast();
22 //$page = $entityManager->find('App\Entity\Page', $_POST['page_id']);
23 $path = htmlspecialchars($_POST['page_menu_path']);
16 24
25 // mise en snake_case: filtre caractères non-alphanumériques, minuscule, doublons d'underscore, trim des underscores
26 $path = trim(preg_replace('/_+/', '_', strtolower(preg_replace('/[^a-zA-Z0-9]/', '_', $path))), '_');
27 $page->setEndOfPath($path);
28 foreach(Director::$menu_data->getChildren() as $child){
29 if($child->getEndOfPath() === Director::$page_path->getArray()[0]->getEndOfPath()){
30 $child->fillChildrenPagePath(); // MAJ de $page_path
31 }
32 }
33 $entityManager->flush();
34 header("Location: " . new URL(['page' => $page->getPagePath(), 'action' => 'modif_page']));
35 die;
36 }
17 // ajout d'un bloc dans une page 37 // ajout d'un bloc dans une page
18 if(isset($_POST['bloc_title']) && $_POST['bloc_title'] !== null && isset($_POST['bloc_select']) && $_POST['bloc_select'] !== null 38 elseif(isset($_POST['bloc_title']) && $_POST['bloc_title'] !== null
39 && isset($_POST['bloc_select']) && $_POST['bloc_select'] !== null
19 && isset($_POST['bloc_title_hidden']) && $_POST['bloc_title_hidden'] === '') // contrôle anti-robot avec input hidden 40 && isset($_POST['bloc_title_hidden']) && $_POST['bloc_title_hidden'] === '') // contrôle anti-robot avec input hidden
20 { 41 {
21 $director = new Director($entityManager, true); // on a besoin de page_path qui dépend de menu_data 42 $director = new Director($entityManager, true); // on a besoin de page_path qui dépend de menu_data
@@ -39,6 +60,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
39 $entityManager->persist($data); 60 $entityManager->persist($data);
40 $entityManager->flush(); 61 $entityManager->flush();
41 header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); 62 header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page']));
63 die;
42 } 64 }
43 // suppression d'un bloc de page 65 // suppression d'un bloc de page
44 elseif(isset($_POST['delete_bloc_id']) && $_POST['delete_bloc_id'] !== null 66 elseif(isset($_POST['delete_bloc_id']) && $_POST['delete_bloc_id'] !== null
@@ -62,8 +84,9 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
62 $entityManager->remove($bloc); // suppression en BDD 84 $entityManager->remove($bloc); // suppression en BDD
63 $entityManager->flush(); 85 $entityManager->flush();
64 header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); 86 header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page']));
87 die;
65 } 88 }
66 89
67 90
68 /* -- page Menu et chemins -- */ 91 /* -- page Menu et chemins -- */
69 92
@@ -91,6 +114,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
91 $entityManager->persist($page); 114 $entityManager->persist($page);
92 $entityManager->flush(); 115 $entityManager->flush();
93 header("Location: " . new URL(['page' => $_GET['from']])); 116 header("Location: " . new URL(['page' => $_GET['from']]));
117 die;
94 } 118 }
95 // suppression d'une entrée de menu avec une URL 119 // suppression d'une entrée de menu avec une URL
96 elseif(isset($_POST['delete']) && isset($_POST['x']) && isset($_POST['y'])){ // 2 params x et y sont là parce qu'on a cliqué sur une image 120 elseif(isset($_POST['delete']) && isset($_POST['x']) && isset($_POST['y'])){ // 2 params x et y sont là parce qu'on a cliqué sur une image
@@ -107,9 +131,11 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true)
107 $entityManager->remove($page); // suppression en BDD 131 $entityManager->remove($page); // suppression en BDD
108 $entityManager->flush(); 132 $entityManager->flush();
109 header("Location: " . new URL(['page' => $_GET['from']])); 133 header("Location: " . new URL(['page' => $_GET['from']]));
134 die;
110 } 135 }
111 else{ 136 else{
112 header("Location: " . new URL(['error' => 'paramètres inconnus'])); 137 header("Location: " . new URL(['error' => 'paramètres inconnus']));
138 die;
113 } 139 }
114 } 140 }
115 141