diff options
Diffstat (limited to 'src/controller/PageManagementController.php')
-rw-r--r-- | src/controller/PageManagementController.php | 38 |
1 files changed, 6 insertions, 32 deletions
diff --git a/src/controller/PageManagementController.php b/src/controller/PageManagementController.php index 9dce952..c45f3f3 100644 --- a/src/controller/PageManagementController.php +++ b/src/controller/PageManagementController.php | |||
@@ -68,6 +68,8 @@ class PageManagementController | |||
68 | true, true, false, | 68 | true, true, false, |
69 | $previous_page->getPosition(), | 69 | $previous_page->getPosition(), |
70 | $parent); // peut et DOIT être null si on est au 1er niveau | 70 | $parent); // peut et DOIT être null si on est au 1er niveau |
71 | $page->useDefaultCSS(); | ||
72 | $page->useDefaultJS(); | ||
71 | 73 | ||
72 | // on a donné à la nouvelle entrée la même position qu'à la précédente, | 74 | // on a donné à la nouvelle entrée la même position qu'à la précédente, |
73 | // addChild l'ajoute à la fin du tableau "children" puis on trie | 75 | // addChild l'ajoute à la fin du tableau "children" puis on trie |
@@ -80,24 +82,7 @@ class PageManagementController | |||
80 | 82 | ||
81 | $page->setPagePath(ltrim($parent->getPagePath() . '/' . $page->getEndOfPath(), '/')); | 83 | $page->setPagePath(ltrim($parent->getPagePath() . '/' . $page->getEndOfPath(), '/')); |
82 | 84 | ||
83 | // noeud "head" | ||
84 | $node = new Node('head', [], | ||
85 | 1, // position d'un head = 1 | ||
86 | null, // pas de parent | ||
87 | $page); | ||
88 | $node->useDefaultAttributes(); // fichiers CSS et JS | ||
89 | |||
90 | $data = new NodeData([], $node); | ||
91 | |||
92 | $bulk_data = $entityManager | ||
93 | ->createQuery('SELECT n FROM App\Entity\Image n WHERE n.file_name LIKE :name') | ||
94 | ->setParameter('name', '%favicon%') | ||
95 | ->getResult(); | ||
96 | $data->setImages(new ArrayCollection($bulk_data)); | ||
97 | |||
98 | $entityManager->persist($page); | 85 | $entityManager->persist($page); |
99 | $entityManager->persist($node); | ||
100 | $entityManager->persist($data); | ||
101 | $entityManager->flush(); | 86 | $entityManager->flush(); |
102 | 87 | ||
103 | // page créée, direction la page en mode modification pour ajouter des blocs | 88 | // page créée, direction la page en mode modification pour ajouter des blocs |
@@ -142,26 +127,15 @@ class PageManagementController | |||
142 | } | 127 | } |
143 | 128 | ||
144 | if($_POST["bloc_select"] === 'calendar' || $_POST["bloc_select"] === 'form'){ | 129 | if($_POST["bloc_select"] === 'calendar' || $_POST["bloc_select"] === 'form'){ |
145 | $dql = 'SELECT n FROM App\Entity\Node n WHERE n.page = :page AND n.name_node = :name'; // noeud 'head' de la page | 130 | $page->setCSS(array_merge($page->getCSS(), [$_POST["bloc_select"]])); |
146 | $bulk_data = $entityManager | ||
147 | ->createQuery($dql) | ||
148 | ->setParameter('page', $page) | ||
149 | ->setParameter('name', 'head') | ||
150 | ->getResult(); | ||
151 | |||
152 | if(count($bulk_data) != 1){ // 1 head par page | ||
153 | header("Location: " . new URL(['page' => $_GET['page'], 'error' => 'head_node_not_found'])); | ||
154 | die; | ||
155 | } | ||
156 | 131 | ||
157 | $bulk_data[0]->addAttribute('css_array', $_POST["bloc_select"]); | ||
158 | if($_POST["bloc_select"] === 'form'){ | 132 | if($_POST["bloc_select"] === 'form'){ |
159 | $bulk_data[0]->addAttribute('js_array', $_POST["bloc_select"]); | 133 | $page->setJS(array_merge($page->getJS(), [$_POST["bloc_select"]])); |
160 | } | 134 | } |
161 | $entityManager->persist($bulk_data[0]); | 135 | $entityManager->persist($page); |
162 | } | 136 | } |
163 | 137 | ||
164 | $block = new Node($_POST["bloc_select"], [], $position, $main, $page); | 138 | $block = new Node($_POST["bloc_select"], $position, $main, $page); |
165 | $data = new NodeData(['title' => trim(htmlspecialchars($_POST["bloc_title"]))], $block); | 139 | $data = new NodeData(['title' => trim(htmlspecialchars($_POST["bloc_title"]))], $block); |
166 | 140 | ||
167 | // valeurs par défaut | 141 | // valeurs par défaut |