aboutsummaryrefslogtreecommitdiff
path: root/src/controller
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller')
-rw-r--r--src/controller/ArticleController.php4
-rw-r--r--src/controller/MenuAndPathsController.php2
-rw-r--r--src/controller/PageManagementController.php38
3 files changed, 9 insertions, 35 deletions
diff --git a/src/controller/ArticleController.php b/src/controller/ArticleController.php
index 06562e7..7061897 100644
--- a/src/controller/ArticleController.php
+++ b/src/controller/ArticleController.php
@@ -92,7 +92,7 @@ class ArticleController
92 92
93 $date = new \DateTime($content['d'] . ':' . (new \DateTime)->format('s')); // l'input type="datetime-local" ne donne pas les secondes, on les ajoute: 'hh:mm' . ':ss' 93 $date = new \DateTime($content['d'] . ':' . (new \DateTime)->format('s')); // l'input type="datetime-local" ne donne pas les secondes, on les ajoute: 'hh:mm' . ':ss'
94 $article = new Article($content['i'], $date, $content['t'], $content['p']); 94 $article = new Article($content['i'], $date, $content['t'], $content['p']);
95 $article_node = new Node('new', [], count($node->getChildren()) + 1, $node, $node->getPage(), $article); 95 $article_node = new Node('new', count($node->getChildren()) + 1, $node, $node->getPage(), $article);
96 } 96 }
97 else{ // autres cas 97 else{ // autres cas
98 $timestamp = time(); 98 $timestamp = time();
@@ -101,7 +101,7 @@ class ArticleController
101 101
102 $article = new Article($content, $date); // le "current" timestamp est obtenu par la BDD 102 $article = new Article($content, $date); // le "current" timestamp est obtenu par la BDD
103 $placement = $json['placement'] === 'first' ? 0 : count($node->getChildren()) + 1; // 103 $placement = $json['placement'] === 'first' ? 0 : count($node->getChildren()) + 1; //
104 $article_node = new Node('post', [], $placement, $node, $node->getPage(), $article); 104 $article_node = new Node('post', $placement, $node, $node->getPage(), $article);
105 105
106 if($json['placement'] === 'first'){ 106 if($json['placement'] === 'first'){
107 $node->addChild($article_node); 107 $node->addChild($article_node);
diff --git a/src/controller/MenuAndPathsController.php b/src/controller/MenuAndPathsController.php
index f0553ad..a32b210 100644
--- a/src/controller/MenuAndPathsController.php
+++ b/src/controller/MenuAndPathsController.php
@@ -22,7 +22,7 @@ class MenuAndPathsController
22 22
23 $page = new Page( 23 $page = new Page(
24 trim(htmlspecialchars($_POST["label_input"])), 24 trim(htmlspecialchars($_POST["label_input"])),
25 $url_input, 25 $url_input, '',
26 true, true, false, 26 true, true, false,
27 $previous_page->getPosition(), 27 $previous_page->getPosition(),
28 $parent); // peut et DOIT être null si on est au 1er niveau 28 $parent); // peut et DOIT être null si on est au 1er niveau
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