diff options
Diffstat (limited to 'src/controller')
-rw-r--r-- | src/controller/Director.php | 2 | ||||
-rw-r--r-- | src/controller/ajax.php | 44 | ||||
-rw-r--r-- | src/controller/installation.php | 10 | ||||
-rw-r--r-- | src/controller/password.php | 2 |
4 files changed, 53 insertions, 5 deletions
diff --git a/src/controller/Director.php b/src/controller/Director.php index b7be9b8..a2528ed 100644 --- a/src/controller/Director.php +++ b/src/controller/Director.php | |||
@@ -11,7 +11,7 @@ class Director | |||
11 | { | 11 | { |
12 | private EntityManager $entityManager; | 12 | private EntityManager $entityManager; |
13 | static public Menu $menu_data; // pour NavBuilder | 13 | static public Menu $menu_data; // pour NavBuilder |
14 | static public Path $page_path; // pour BreadcrumbBuilder | 14 | static public ?Path $page_path = null; // pour $current dans NavBuilder et pour BreadcrumbBuilder |
15 | private Page $page; | 15 | private Page $page; |
16 | private Node $node; | 16 | private Node $node; |
17 | private Node $article; | 17 | private Node $article; |
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index a4b61e4..c774bf3 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
@@ -6,7 +6,7 @@ declare(strict_types=1); | |||
6 | use App\Entity\Article; | 6 | use App\Entity\Article; |
7 | use App\Entity\Node; | 7 | use App\Entity\Node; |
8 | 8 | ||
9 | // détection des requêtes de tinymce | 9 | // détection des requêtes de tinymce ou touchant aux articles |
10 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | 10 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) |
11 | { | 11 | { |
12 | // récupération des données | 12 | // récupération des données |
@@ -204,6 +204,48 @@ if(strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false && isset($_ | |||
204 | die; | 204 | die; |
205 | } | 205 | } |
206 | 206 | ||
207 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | ||
208 | { | ||
209 | // récupération des données | ||
210 | $data = file_get_contents('php://input'); | ||
211 | $json = json_decode($data, true); | ||
212 | |||
213 | if($_GET['menu_edit'] === 'switch_positions' && isset($json['id1']) && isset($json['id2'])) | ||
214 | { | ||
215 | //$menu = new Menu($entityManager); | ||
216 | Director::$menu_data = new Menu($entityManager); | ||
217 | |||
218 | $id1 = $json['id1']; | ||
219 | $id2 = $json['id2']; | ||
220 | |||
221 | // vérifier qu'ils ont le même parent | ||
222 | $page1 = Director::$menu_data->findPageById((int)$id1); | ||
223 | $page2 = Director::$menu_data->findPageById((int)$id2); | ||
224 | |||
225 | // double le contrôle fait en JS | ||
226 | if($page1->getParent() === $page2->getParent()) // comparaison stricte d'objet (même instance du parent?) | ||
227 | { | ||
228 | // inversion | ||
229 | $tmp = $page1->getPosition(); | ||
230 | $page1->setPosition($page2->getPosition()); | ||
231 | $page2->setPosition($tmp); | ||
232 | Director::$menu_data->sortChildren(true); // modifie tableau children | ||
233 | $entityManager->flush(); | ||
234 | |||
235 | // menu utilisant les nouvelles données | ||
236 | //Director::$page_path = new Path(); | ||
237 | $nav_builder = new NavBuilder(); // builder appelé sans envoi du noeud correspondant | ||
238 | |||
239 | echo json_encode(['success' => true, 'path1' => '', 'path2' => '', 'nav' => $nav_builder->render()]); | ||
240 | } | ||
241 | else{ | ||
242 | echo json_encode(['success' => false]); | ||
243 | } | ||
244 | |||
245 | die; | ||
246 | } | ||
247 | } | ||
248 | |||
207 | // détection des requêtes de type XHR, pas d'utilité pour l'instant | 249 | // détection des requêtes de type XHR, pas d'utilité pour l'instant |
208 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ | 250 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ |
209 | echo "requête XHR reçue par le serveur"; | 251 | echo "requête XHR reçue par le serveur"; |
diff --git a/src/controller/installation.php b/src/controller/installation.php index c2b38fd..ff168eb 100644 --- a/src/controller/installation.php +++ b/src/controller/installation.php | |||
@@ -80,9 +80,9 @@ function makeStartPage(EntityManager $entityManager){ | |||
80 | $accueil = new Page('Accueil', 'accueil', true, true, 1, NULL); | 80 | $accueil = new Page('Accueil', 'accueil', true, true, 1, NULL); |
81 | $connection = new Page('Connexion', 'connexion', true, false, NULL, NULL); | 81 | $connection = new Page('Connexion', 'connexion', true, false, NULL, NULL); |
82 | $article = new Page('Article', 'article', true, false, NULL, NULL); | 82 | $article = new Page('Article', 'article', true, false, NULL, NULL); |
83 | $menu_paths = new Page("Menu et chemins", 'menu_chemins', true, false, NULL, NULL); | ||
83 | $edit_page = new Page("Modification d'une page", 'modif_page', true, false, NULL, NULL); | 84 | $edit_page = new Page("Modification d'une page", 'modif_page', true, false, NULL, NULL); |
84 | $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, NULL, NULL); | 85 | $new_page = new Page('Nouvelle page', 'nouvelle_page', true, false, NULL, NULL); |
85 | $edit_paths = new Page("Menu et chemins", 'menu_chemins', true, false, NULL, NULL); | ||
86 | 86 | ||
87 | /* -- table node -- */ | 87 | /* -- table node -- */ |
88 | // paramètres: name_node, article_timestamp, attributes, position, parent, page, article | 88 | // paramètres: name_node, article_timestamp, attributes, position, parent, page, article |
@@ -95,6 +95,8 @@ function makeStartPage(EntityManager $entityManager){ | |||
95 | $head_login = new Node('head', NULL, ["stop" => true, 'css_array' => ['body', 'head', 'nav', 'main'], 'js_array' => ['main']], 1, NULL, $connection, NULL); | 95 | $head_login = new Node('head', NULL, ["stop" => true, 'css_array' => ['body', 'head', 'nav', 'main'], 'js_array' => ['main']], 1, NULL, $connection, NULL); |
96 | $login = new Node('login', NULL, [], 1, $main, $connection, NULL); | 96 | $login = new Node('login', NULL, [], 1, $main, $connection, NULL); |
97 | $head_article = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'foot'], 'js_array' => ['main']], 1, NULL, $article, NULL); | 97 | $head_article = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'foot'], 'js_array' => ['main']], 1, NULL, $article, NULL); |
98 | $head_edit_menu = new Node('head', NULL, ['css_array' => ['body', 'head', 'nav', 'main', 'menu'], 'js_array' => ['main']], 1, NULL, $menu_paths, NULL); | ||
99 | $edit_menu = new Node('menu', NULL, [], 1, $main, $menu_paths, NULL); | ||
98 | 100 | ||
99 | /* -- table image -- */ | 101 | /* -- table image -- */ |
100 | // paramètres: file_name, file_path, file_path_mini, mime_type, alt | 102 | // paramètres: file_name, file_path, file_path_mini, mime_type, alt |
@@ -111,13 +113,14 @@ function makeStartPage(EntityManager $entityManager){ | |||
111 | $footer_data = new NodeData(["adresse" => "17, rue Raymonde Folgoas Guillou, 29120 Pont-l’Abbé", "contact_nom" => "Les Nageurs Bigoudens", "e_mail" => "nb.secretariat@orange.fr", "logo_footer" => "assets/logo-nb-et-ffn.png"], $footer); | 113 | $footer_data = new NodeData(["adresse" => "17, rue Raymonde Folgoas Guillou, 29120 Pont-l’Abbé", "contact_nom" => "Les Nageurs Bigoudens", "e_mail" => "nb.secretariat@orange.fr", "logo_footer" => "assets/logo-nb-et-ffn.png"], $footer); |
112 | $head_login_data = new NodeData(["description" => "Connexion", "title" => "Connexion"], $head_login, new ArrayCollection([$favicon])); | 114 | $head_login_data = new NodeData(["description" => "Connexion", "title" => "Connexion"], $head_login, new ArrayCollection([$favicon])); |
113 | $head_article_data = new NodeData(["description" => "", "title" => ""], $head_article, new ArrayCollection([$favicon])); | 115 | $head_article_data = new NodeData(["description" => "", "title" => ""], $head_article, new ArrayCollection([$favicon])); |
116 | $head_edit_menu_data = new NodeData(["description" => "Menu et chemins", "title" => "Menu et chemins"], $head_edit_menu, new ArrayCollection([$favicon])); | ||
114 | 117 | ||
115 | $entityManager->persist($accueil); | 118 | $entityManager->persist($accueil); |
116 | $entityManager->persist($connection); | 119 | $entityManager->persist($connection); |
117 | $entityManager->persist($article); | 120 | $entityManager->persist($article); |
121 | $entityManager->persist($menu_paths); | ||
118 | $entityManager->persist($edit_page); | 122 | $entityManager->persist($edit_page); |
119 | $entityManager->persist($new_page); | 123 | $entityManager->persist($new_page); |
120 | $entityManager->persist($edit_paths); | ||
121 | $entityManager->persist($head_accueil); | 124 | $entityManager->persist($head_accueil); |
122 | $entityManager->persist($header); | 125 | $entityManager->persist($header); |
123 | $entityManager->persist($nav); | 126 | $entityManager->persist($nav); |
@@ -127,6 +130,8 @@ function makeStartPage(EntityManager $entityManager){ | |||
127 | $entityManager->persist($head_login); | 130 | $entityManager->persist($head_login); |
128 | $entityManager->persist($login); | 131 | $entityManager->persist($login); |
129 | $entityManager->persist($head_article); | 132 | $entityManager->persist($head_article); |
133 | $entityManager->persist($head_edit_menu); | ||
134 | $entityManager->persist($edit_menu); | ||
130 | $entityManager->persist($favicon); | 135 | $entityManager->persist($favicon); |
131 | $entityManager->persist($logo); | 136 | $entityManager->persist($logo); |
132 | $entityManager->persist($facebook); | 137 | $entityManager->persist($facebook); |
@@ -137,6 +142,7 @@ function makeStartPage(EntityManager $entityManager){ | |||
137 | $entityManager->persist($footer_data); | 142 | $entityManager->persist($footer_data); |
138 | $entityManager->persist($head_login_data); | 143 | $entityManager->persist($head_login_data); |
139 | $entityManager->persist($head_article_data); | 144 | $entityManager->persist($head_article_data); |
145 | $entityManager->persist($head_edit_menu_data); | ||
140 | $entityManager->flush(); | 146 | $entityManager->flush(); |
141 | 147 | ||
142 | header('Location: ' . new URL); | 148 | header('Location: ' . new URL); |
diff --git a/src/controller/password.php b/src/controller/password.php index 47db637..66a617a 100644 --- a/src/controller/password.php +++ b/src/controller/password.php | |||
@@ -307,7 +307,7 @@ function getUser(string $login, EntityManager $entityManager): ?User | |||
307 | } | 307 | } |
308 | 308 | ||
309 | 309 | ||
310 | function disconnect(EntityManager $entityManager) | 310 | function disconnect() |
311 | { | 311 | { |
312 | // nettoyage complet | 312 | // nettoyage complet |
313 | $_SESSION = []; // mémoire vive | 313 | $_SESSION = []; // mémoire vive |