diff options
| -rw-r--r-- | public/css/foot.css | 39 | ||||
| -rw-r--r-- | public/css/main.css | 53 | ||||
| -rw-r--r-- | public/css/trombinoscope.css | 35 | ||||
| -rw-r--r-- | public/js/main.js | 29 | ||||
| -rw-r--r-- | src/controller/Director.php | 26 | ||||
| -rw-r--r-- | src/controller/ajax.php | 39 | ||||
| -rw-r--r-- | src/controller/post.php | 34 | ||||
| -rw-r--r-- | src/model/Position.php | 4 | ||||
| -rw-r--r-- | src/model/entities/NodeData.php | 4 | ||||
| -rw-r--r-- | src/view/FooterBuilder.php | 28 | ||||
| -rw-r--r-- | src/view/MainBuilder.php | 26 | ||||
| -rw-r--r-- | src/view/templates/footer.php | 3 |
12 files changed, 263 insertions, 57 deletions
diff --git a/public/css/foot.css b/public/css/foot.css index 038d33b..023a0f2 100644 --- a/public/css/foot.css +++ b/public/css/foot.css | |||
| @@ -6,7 +6,7 @@ footer | |||
| 6 | background-color: #B7E9FE; | 6 | background-color: #B7E9FE; |
| 7 | /*width: 1200px;*/ | 7 | /*width: 1200px;*/ |
| 8 | margin: auto; | 8 | margin: auto; |
| 9 | padding: 0 20px; | 9 | /*padding: 0 20px;*/ |
| 10 | 10 | ||
| 11 | } | 11 | } |
| 12 | footer > div | 12 | footer > div |
| @@ -39,7 +39,7 @@ footer > div | |||
| 39 | /*max-width: 45%;*/ | 39 | /*max-width: 45%;*/ |
| 40 | /*margin-right: 10px;*/ | 40 | /*margin-right: 10px;*/ |
| 41 | /*margin: 16px 0;*/ /* = p */ | 41 | /*margin: 16px 0;*/ /* = p */ |
| 42 | padding: 10px; | 42 | padding: 15px; |
| 43 | list-style: none; /* retirer les puces */ | 43 | list-style: none; /* retirer les puces */ |
| 44 | font-size: small; | 44 | font-size: small; |
| 45 | text-align: right; | 45 | text-align: right; |
| @@ -69,6 +69,11 @@ footer > div | |||
| 69 | margin: 0 3px; | 69 | margin: 0 3px; |
| 70 | }*/ | 70 | }*/ |
| 71 | 71 | ||
| 72 | .contact | ||
| 73 | { | ||
| 74 | padding: 0 15px; | ||
| 75 | } | ||
| 76 | |||
| 72 | .footer_logo img | 77 | .footer_logo img |
| 73 | { | 78 | { |
| 74 | max-width: 288px; | 79 | max-width: 288px; |
| @@ -85,6 +90,7 @@ footer > div | |||
| 85 | footer > div | 90 | footer > div |
| 86 | { | 91 | { |
| 87 | flex-direction: column; | 92 | flex-direction: column; |
| 93 | align-items: center; | ||
| 88 | } | 94 | } |
| 89 | } | 95 | } |
| 90 | 96 | ||
| @@ -95,6 +101,17 @@ footer > div | |||
| 95 | } | 101 | } |
| 96 | 102 | ||
| 97 | /* zone admin */ | 103 | /* zone admin */ |
| 104 | .admin_buttons_zone | ||
| 105 | { | ||
| 106 | margin: 5px; | ||
| 107 | display: flex; | ||
| 108 | flex-wrap: wrap; | ||
| 109 | align-items: center; | ||
| 110 | } | ||
| 111 | .admin_buttons_zone p | ||
| 112 | { | ||
| 113 | margin: 0; | ||
| 114 | } | ||
| 98 | .logged_out | 115 | .logged_out |
| 99 | { | 116 | { |
| 100 | /*display: none;*/ | 117 | /*display: none;*/ |
| @@ -107,23 +124,17 @@ footer > div | |||
| 107 | } | 124 | } |
| 108 | .empty_admin_zone | 125 | .empty_admin_zone |
| 109 | { | 126 | { |
| 110 | height: 32px; | 127 | height: 70px; |
| 111 | } | 128 | } |
| 112 | .logged_in | 129 | .logged_in |
| 113 | { | 130 | { |
| 114 | height: 32px; | 131 | /*height: 70px;*/ |
| 115 | width: 1200px; | 132 | width: 100%; |
| 116 | margin: auto; | 133 | margin: auto; |
| 117 | background-color: #ffff00; | 134 | background-color: #ffff00; |
| 118 | position: fixed; | 135 | position: fixed; |
| 119 | bottom: 0px; | 136 | bottom: 0px; |
| 120 | } | 137 | } |
| 121 | .logged_in > p | ||
| 122 | { | ||
| 123 | margin: 5px 0; | ||
| 124 | display: flex; | ||
| 125 | justify-content: center; | ||
| 126 | } | ||
| 127 | .logged_in button | 138 | .logged_in button |
| 128 | { | 139 | { |
| 129 | margin-left: 5px; | 140 | margin-left: 5px; |
| @@ -132,6 +143,7 @@ footer > div | |||
| 132 | border: lightgrey 2px outset; | 143 | border: lightgrey 2px outset; |
| 133 | border-radius: 4px; | 144 | border-radius: 4px; |
| 134 | background-color: white; | 145 | background-color: white; |
| 146 | margin: 2px; | ||
| 135 | } | 147 | } |
| 136 | .logged_in button:hover | 148 | .logged_in button:hover |
| 137 | { | 149 | { |
| @@ -139,6 +151,11 @@ footer > div | |||
| 139 | background-color: #ffff00; | 151 | background-color: #ffff00; |
| 140 | border-radius: 4px; | 152 | border-radius: 4px; |
| 141 | } | 153 | } |
| 154 | .modif_mode | ||
| 155 | { | ||
| 156 | background-color: #ffae1a; /* orange clair soupe de poisson */ | ||
| 157 | } | ||
| 158 | |||
| 142 | 159 | ||
| 143 | .toast { | 160 | .toast { |
| 144 | visibility: hidden; | 161 | visibility: hidden; |
diff --git a/public/css/main.css b/public/css/main.css index 93a7bcf..870082a 100644 --- a/public/css/main.css +++ b/public/css/main.css | |||
| @@ -11,15 +11,25 @@ section > h3 | |||
| 11 | margin: 0; | 11 | margin: 0; |
| 12 | text-align: center; | 12 | text-align: center; |
| 13 | } | 13 | } |
| 14 | section > p /* boutons spéciaux mode admin */ | ||
| 15 | { | ||
| 16 | /*margin-left: 15px;*/ | ||
| 17 | } | ||
| 18 | .grid_columns | 14 | .grid_columns |
| 19 | { | 15 | { |
| 20 | display: grid; | 16 | display: grid; |
| 21 | grid-template-columns: repeat(3, 1fr); | 17 | grid-template-columns: repeat(3, 1fr); |
| 22 | } | 18 | } |
| 19 | @media screen and (max-width: 800px) | ||
| 20 | { | ||
| 21 | .grid_columns | ||
| 22 | { | ||
| 23 | grid-template-columns: repeat(2, 1fr); | ||
| 24 | } | ||
| 25 | } | ||
| 26 | @media screen and (max-width: 550px) | ||
| 27 | { | ||
| 28 | .grid_columns | ||
| 29 | { | ||
| 30 | display: block; | ||
| 31 | } | ||
| 32 | } | ||
| 23 | .galery_photos | 33 | .galery_photos |
| 24 | { | 34 | { |
| 25 | display: flex; | 35 | display: flex; |
| @@ -148,23 +158,35 @@ article a:hover | |||
| 148 | flex-wrap: wrap; | 158 | flex-wrap: wrap; |
| 149 | font-size: smaller; | 159 | font-size: smaller; |
| 150 | }*/ | 160 | }*/ |
| 151 | .new_bloc | 161 | .edit_bloc_zone |
| 152 | { | 162 | { |
| 153 | background-color: white; | 163 | background-color: white; |
| 154 | padding: 10px; | 164 | padding: 10px; |
| 155 | margin: 10px 20px; | 165 | margin: 10px 15px; |
| 156 | 166 | display: flex; | |
| 167 | justify-content: space-evenly; | ||
| 168 | flex-wrap: wrap; | ||
| 157 | } | 169 | } |
| 158 | .new_bloc p | 170 | .edit_bloc_zone p |
| 159 | { | 171 | { |
| 160 | margin: 5px; | 172 | margin: 5px; |
| 161 | } | 173 | } |
| 174 | .new_bloc, .modify_bloc | ||
| 175 | { | ||
| 176 | /*background-color: white; | ||
| 177 | padding: 10px; | ||
| 178 | margin: 10px 20px;*/ | ||
| 179 | } | ||
| 180 | .new_bloc p | ||
| 181 | { | ||
| 182 | /*margin: 5px;*/ | ||
| 183 | } | ||
| 162 | .new_bloc #bloc_title | 184 | .new_bloc #bloc_title |
| 163 | { | 185 | { |
| 164 | width: 100%; | 186 | width: 70%; |
| 165 | max-width: 300px; | 187 | max-width: 300px; |
| 166 | } | 188 | } |
| 167 | .new_bloc form select, .new_bloc form input[type=submit] | 189 | .new_bloc form select, .new_bloc form input[type=submit], .modify_bloc form input[type=submit] |
| 168 | { | 190 | { |
| 169 | color: #ff1d04; | 191 | color: #ff1d04; |
| 170 | font-size: medium; | 192 | font-size: medium; |
| @@ -176,9 +198,18 @@ select:hover | |||
| 176 | { | 198 | { |
| 177 | cursor: pointer; | 199 | cursor: pointer; |
| 178 | } | 200 | } |
| 179 | .new_bloc form input[type=submit]:hover | 201 | .new_bloc form input[type=submit]:hover, .modify_bloc form input[type=submit]:hover |
| 180 | { | 202 | { |
| 181 | background-color: #ffff00; | 203 | background-color: #ffff00; |
| 182 | border-radius: 4px; | 204 | border-radius: 4px; |
| 183 | cursor: pointer; | 205 | cursor: pointer; |
| 206 | } | ||
| 207 | .modify_bloc > div | ||
| 208 | { | ||
| 209 | display: flex; | ||
| 210 | align-items: baseline; | ||
| 211 | } | ||
| 212 | .modify_bloc img | ||
| 213 | { | ||
| 214 | vertical-align: middle; | ||
| 184 | } \ No newline at end of file | 215 | } \ No newline at end of file |
diff --git a/public/css/trombinoscope.css b/public/css/trombinoscope.css index 357e6b0..cee2666 100644 --- a/public/css/trombinoscope.css +++ b/public/css/trombinoscope.css | |||
| @@ -1,10 +1,39 @@ | |||
| 1 | /* css personnalissé à cette page, | ||
| 2 | .grid_columns utilise un nombre de colonnes spécifique */ | ||
| 1 | article img | 3 | article img |
| 2 | { | 4 | { |
| 3 | border-radius: 50%; | 5 | border-radius: 50%; |
| 4 | } | 6 | } |
| 5 | |||
| 6 | .grid_columns | 7 | .grid_columns |
| 7 | { | 8 | { |
| 8 | /* écrase les 3 colonnes par défaut */ | 9 | grid-template-columns: repeat(4, 1fr); |
| 9 | grid-template-columns: repeat(4, 1fr); | 10 | } |
| 11 | @media screen and (max-width: 900px) | ||
| 12 | { | ||
| 13 | .grid_columns | ||
| 14 | { | ||
| 15 | grid-template-columns: repeat(3, 1fr); | ||
| 16 | } | ||
| 17 | } | ||
| 18 | @media screen and (max-width: 650px) | ||
| 19 | { | ||
| 20 | .grid_columns | ||
| 21 | { | ||
| 22 | grid-template-columns: repeat(2, 1fr); | ||
| 23 | } | ||
| 24 | } | ||
| 25 | @media screen and (max-width: 550px) | ||
| 26 | { | ||
| 27 | .grid_columns | ||
| 28 | { | ||
| 29 | display: grid; | ||
| 30 | grid-template-columns: repeat(2, 1fr); | ||
| 31 | } | ||
| 32 | } | ||
| 33 | @media screen and (max-width: 350px) | ||
| 34 | { | ||
| 35 | .grid_columns | ||
| 36 | { | ||
| 37 | display: block; | ||
| 38 | } | ||
| 10 | } \ No newline at end of file | 39 | } \ No newline at end of file |
diff --git a/public/js/main.js b/public/js/main.js index e278325..802bbbe 100644 --- a/public/js/main.js +++ b/public/js/main.js | |||
| @@ -202,4 +202,33 @@ function findParent(element, tag_name){ | |||
| 202 | element = element.parentElement; | 202 | element = element.parentElement; |
| 203 | } | 203 | } |
| 204 | return null; | 204 | return null; |
| 205 | } | ||
| 206 | |||
| 207 | |||
| 208 | /* -- mode Modification d'une page -- */ | ||
| 209 | function renamePageBloc(bloc_id){ | ||
| 210 | const input = document.getElementById("bloc_rename_" + bloc_id); | ||
| 211 | const title = document.getElementById(bloc_id).querySelector("h3"); | ||
| 212 | |||
| 213 | fetch('index.php?bloc_edit=rename_page_bloc', { | ||
| 214 | method: 'POST', | ||
| 215 | headers: { | ||
| 216 | 'Content-Type': 'application/json' | ||
| 217 | }, | ||
| 218 | body: JSON.stringify({bloc_title: input.value, bloc_id: bloc_id}) | ||
| 219 | }) | ||
| 220 | .then(response => response.json()) | ||
| 221 | .then(data => { | ||
| 222 | if(data.success){ | ||
| 223 | title.innerHTML = data.title; | ||
| 224 | console.log(data.title); | ||
| 225 | toastNotify('Le bloc a été renommé: ' + data.title); | ||
| 226 | } | ||
| 227 | else{ | ||
| 228 | console.error('Erreur au renommage du titre.'); | ||
| 229 | } | ||
| 230 | }) | ||
| 231 | .catch(error => { | ||
| 232 | console.error('Erreur:', error); | ||
| 233 | }); | ||
| 205 | } \ No newline at end of file | 234 | } \ No newline at end of file |
diff --git a/src/controller/Director.php b/src/controller/Director.php index 56a90cb..b154432 100644 --- a/src/controller/Director.php +++ b/src/controller/Director.php | |||
| @@ -36,6 +36,7 @@ class Director | |||
| 36 | return $this->article; | 36 | return $this->article; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | // affichage d'une page ordinaire | ||
| 39 | public function makeRootNode(string $id = ''): void | 40 | public function makeRootNode(string $id = ''): void |
| 40 | { | 41 | { |
| 41 | // on récupère toutes les entrées | 42 | // on récupère toutes les entrées |
| @@ -91,6 +92,12 @@ class Director | |||
| 91 | } | 92 | } |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 95 | // le basique | ||
| 96 | public function findNodeById(int $id): void | ||
| 97 | { | ||
| 98 | $this->node = $this->entityManager->find('App\Entity\Node', $id); | ||
| 99 | } | ||
| 100 | |||
| 94 | // récupération d'un article pour modification | 101 | // récupération d'un article pour modification |
| 95 | public function makeArticleNode(string $id = '', bool $get_section = false): bool | 102 | public function makeArticleNode(string $id = '', bool $get_section = false): bool |
| 96 | { | 103 | { |
| @@ -112,7 +119,8 @@ class Director | |||
| 112 | 119 | ||
| 113 | if($get_section){ | 120 | if($get_section){ |
| 114 | $this->article = $bulk_data[0]; | 121 | $this->article = $bulk_data[0]; |
| 115 | $this->makeSectionNode($bulk_data[0]->getParent()->getId()); | 122 | $this->findNodeById($bulk_data[0]->getParent()->getId()); |
| 123 | $this->makeSectionNode(); | ||
| 116 | } | 124 | } |
| 117 | else{ | 125 | else{ |
| 118 | $this->article = $bulk_data[0]; | 126 | $this->article = $bulk_data[0]; |
| @@ -122,31 +130,30 @@ class Director | |||
| 122 | } | 130 | } |
| 123 | 131 | ||
| 124 | // récupération des articles d'un bloc <section> à la création d'un article | 132 | // récupération des articles d'un bloc <section> à la création d'un article |
| 125 | public function makeSectionNode(int $section_id): bool | 133 | public function makeSectionNode(): bool |
| 126 | { | 134 | { |
| 127 | $section = $this->entityManager->find('App\Entity\Node', (string)$section_id); | ||
| 128 | |||
| 129 | $bulk_data = $this->entityManager | 135 | $bulk_data = $this->entityManager |
| 130 | ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent') | 136 | ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent') |
| 131 | ->setParameter('parent', $section) | 137 | ->setParameter('parent', $this->node) |
| 132 | ->getResult(); | 138 | ->getResult(); |
| 133 | 139 | ||
| 134 | foreach($bulk_data as $article){ | 140 | foreach($bulk_data as $article){ |
| 135 | $section->addChild($article); // pas de flush, on ne va pas écrire dans la BDD à chaque nouvelle page | 141 | $this->node->addChild($article); // pas de flush, on ne va pas écrire dans la BDD à chaque nouvelle page |
| 136 | } | 142 | } |
| 137 | $this->node = $section; | ||
| 138 | return true; | 143 | return true; |
| 139 | } | 144 | } |
| 140 | 145 | ||
| 141 | public function findNodeByName(string $name): void | 146 | public function findUniqueNodeByName(string $name): void // = unique en BDD, donc sans "page" associée |
| 142 | { | 147 | { |
| 143 | $bulk_data = $this->entityManager | 148 | $bulk_data = $this->entityManager |
| 144 | ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.name_node = :name') | 149 | ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.name_node = :name') |
| 145 | ->setParameter('name', $name) | 150 | ->setParameter('name', $name) |
| 146 | ->getResult(); | 151 | ->getResult(); |
| 147 | $this->node = $bulk_data[0]; | 152 | $this->node = $bulk_data[0]; |
| 148 | echo $this->page->getPageName() . ' '; | 153 | } |
| 149 | 154 | ||
| 155 | public function findItsChildren(): void | ||
| 156 | { | ||
| 150 | $bulk_data = $this->entityManager | 157 | $bulk_data = $this->entityManager |
| 151 | ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent AND n.page = :page') | 158 | ->createQuery('SELECT n FROM App\Entity\Node n WHERE n.parent = :parent AND n.page = :page') |
| 152 | ->setParameter('parent', $this->node) | 159 | ->setParameter('parent', $this->node) |
| @@ -154,7 +161,6 @@ class Director | |||
| 154 | ->getResult(); | 161 | ->getResult(); |
| 155 | foreach($bulk_data as $child){ | 162 | foreach($bulk_data as $child){ |
| 156 | $this->node->addChild($child); | 163 | $this->node->addChild($child); |
| 157 | echo $child->getName() . ' '; | ||
| 158 | } | 164 | } |
| 159 | } | 165 | } |
| 160 | } | 166 | } |
diff --git a/src/controller/ajax.php b/src/controller/ajax.php index a20bd87..a6786d9 100644 --- a/src/controller/ajax.php +++ b/src/controller/ajax.php | |||
| @@ -35,7 +35,8 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['action'])) | |||
| 35 | if($id[0] === 'n') | 35 | if($id[0] === 'n') |
| 36 | { | 36 | { |
| 37 | $section_id = (int)substr($id, 1); // id du bloc <section> | 37 | $section_id = (int)substr($id, 1); // id du bloc <section> |
| 38 | $director->makeSectionNode($section_id); | 38 | $director->findNodeById($section_id); |
| 39 | $director->makeSectionNode(); | ||
| 39 | $node = $director->getNode(); // = <section> | 40 | $node = $director->getNode(); // = <section> |
| 40 | 41 | ||
| 41 | if(is_array($content)){ | 42 | if(is_array($content)){ |
| @@ -205,6 +206,8 @@ if(strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false && isset($_ | |||
| 205 | die; | 206 | die; |
| 206 | } | 207 | } |
| 207 | 208 | ||
| 209 | |||
| 210 | /* -- page Menu et chemins -- */ | ||
| 208 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | 211 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) |
| 209 | { | 212 | { |
| 210 | // récupération des données | 213 | // récupération des données |
| @@ -347,7 +350,39 @@ if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['menu_edit'])) | |||
| 347 | } | 350 | } |
| 348 | } | 351 | } |
| 349 | 352 | ||
| 350 | // détection des requêtes de type XHR?, pas d'utilité pour l'instant | 353 | |
| 354 | /* -- mode Modification d'une page -- */ | ||
| 355 | if($_SERVER['CONTENT_TYPE'] === 'application/json' && isset($_GET['bloc_edit'])) | ||
| 356 | { | ||
| 357 | // récupération des données | ||
| 358 | $data = file_get_contents('php://input'); | ||
| 359 | $json = json_decode($data, true); | ||
| 360 | |||
| 361 | // renommage d'un bloc | ||
| 362 | if($_GET['bloc_edit'] === 'rename_page_bloc') | ||
| 363 | { | ||
| 364 | if(isset($json['bloc_title']) && $json['bloc_title'] !== null && isset($json['bloc_id']) && is_int($json['bloc_id'])){ | ||
| 365 | $director = new Director($entityManager); | ||
| 366 | $director->findNodeById($json['bloc_id']); | ||
| 367 | |||
| 368 | // le titre (du JSON en BDD) est récupéré sous forme de tableau, modifié et renvoyé | ||
| 369 | $data = $director->getNode()->getNodeData()->getData(); | ||
| 370 | $data['title'] = htmlspecialchars($json['bloc_title']); | ||
| 371 | $director->getNode()->getNodeData()->setData($data); | ||
| 372 | |||
| 373 | $entityManager->flush(); | ||
| 374 | echo json_encode(['success' => true, 'title' => $data['title']]); | ||
| 375 | } | ||
| 376 | else{ | ||
| 377 | echo json_encode(['success' => false]); | ||
| 378 | } | ||
| 379 | die; | ||
| 380 | } | ||
| 381 | |||
| 382 | } | ||
| 383 | |||
| 384 | |||
| 385 | // détection des requêtes de type XHR?, pas d'utilité à priori | ||
| 351 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ | 386 | /*elseif(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ |
| 352 | echo "requête XHR reçue par le serveur"; | 387 | echo "requête XHR reçue par le serveur"; |
| 353 | die; | 388 | die; |
diff --git a/src/controller/post.php b/src/controller/post.php index 76ac72b..d437423 100644 --- a/src/controller/post.php +++ b/src/controller/post.php | |||
| @@ -15,10 +15,13 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) | |||
| 15 | /* -- mode Modification d'une page -- */ | 15 | /* -- mode Modification d'une page -- */ |
| 16 | 16 | ||
| 17 | // ajout d'un bloc dans une page | 17 | // ajout d'un bloc dans une page |
| 18 | if(isset($_POST['bloc_title']) && isset($_POST['bloc_select'])){ | 18 | if(isset($_POST['bloc_title']) && $_POST['bloc_title'] !== null && 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 | ||
| 20 | { | ||
| 19 | $director = new Director($entityManager, true); // on a besoin de page_path qui dépend de menu_data | 21 | $director = new Director($entityManager, true); // on a besoin de page_path qui dépend de menu_data |
| 20 | $page = Director::$page_path->getLast(); | 22 | $page = Director::$page_path->getLast(); |
| 21 | $director->findNodeByName('main'); | 23 | $director->findUniqueNodeByName('main'); |
| 24 | $director->findItsChildren(); | ||
| 22 | $main = $director->getNode(); | 25 | $main = $director->getNode(); |
| 23 | $position = count($main->getChildren()) + 1; // position dans la fraterie | 26 | $position = count($main->getChildren()) + 1; // position dans la fraterie |
| 24 | 27 | ||
| @@ -37,7 +40,30 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) | |||
| 37 | $entityManager->flush(); | 40 | $entityManager->flush(); |
| 38 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | 41 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); |
| 39 | } | 42 | } |
| 43 | // suppression d'un bloc de page | ||
| 44 | elseif(isset($_POST['delete_bloc_id']) && $_POST['delete_bloc_id'] !== null | ||
| 45 | && isset($_POST['delete_bloc_hidden']) && $_POST['delete_bloc_hidden'] === '') // contrôle anti-robot avec input hidden | ||
| 46 | { | ||
| 47 | $director = new Director($entityManager, true); | ||
| 48 | $director->findUniqueNodeByName('main'); | ||
| 49 | $director->findItsChildren(); | ||
| 50 | //$director->findNodeById((int)$_POST['delete_bloc_id']); | ||
| 51 | $main = $director->getNode(); | ||
| 52 | $bloc; | ||
| 53 | foreach($main->getChildren() as $child){ | ||
| 54 | if($child->getId() === (int)$_POST['delete_bloc_id']){ | ||
| 55 | $bloc = $child; | ||
| 56 | break; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | $main->removeChild($bloc); // réindex le tableau $children au passage | ||
| 60 | $main->reindexPositions(); | ||
| 40 | 61 | ||
| 62 | $entityManager->remove($bloc); // suppression en BDD | ||
| 63 | $entityManager->flush(); | ||
| 64 | header("Location: " . new URL(['page' => $_GET['page'], 'action' => 'modif_page'])); | ||
| 65 | } | ||
| 66 | |||
| 41 | 67 | ||
| 42 | /* -- page Menu et chemins -- */ | 68 | /* -- page Menu et chemins -- */ |
| 43 | 69 | ||
| @@ -60,7 +86,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) | |||
| 60 | $parent = Director::$menu_data; | 86 | $parent = Director::$menu_data; |
| 61 | } | 87 | } |
| 62 | $parent->addChild($page); // true pour réindexer les positions en BDD | 88 | $parent->addChild($page); // true pour réindexer les positions en BDD |
| 63 | $parent->reindex(); | 89 | $parent->reindexPositions(); |
| 64 | 90 | ||
| 65 | $entityManager->persist($page); | 91 | $entityManager->persist($page); |
| 66 | $entityManager->flush(); | 92 | $entityManager->flush(); |
| @@ -76,7 +102,7 @@ if($_SERVER['REQUEST_METHOD'] === 'POST' && $_SESSION['admin'] === true) | |||
| 76 | } | 102 | } |
| 77 | 103 | ||
| 78 | $parent->removeChild($page); // suppression de $children avant de trier | 104 | $parent->removeChild($page); // suppression de $children avant de trier |
| 79 | $parent->reindex(); | 105 | $parent->reindexPositions(); |
| 80 | 106 | ||
| 81 | $entityManager->remove($page); // suppression en BDD | 107 | $entityManager->remove($page); // suppression en BDD |
| 82 | $entityManager->flush(); | 108 | $entityManager->flush(); |
diff --git a/src/model/Position.php b/src/model/Position.php index b5040df..8035481 100644 --- a/src/model/Position.php +++ b/src/model/Position.php | |||
| @@ -30,12 +30,12 @@ trait Position | |||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | if($reindexation){ | 32 | if($reindexation){ |
| 33 | $this->reindex(); | 33 | $this->reindexPositions(); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | // nouvelles positions (tableau $children => BDD) | 37 | // nouvelles positions (tableau $children => BDD) |
| 38 | public function reindex(): void | 38 | public function reindexPositions(): void |
| 39 | { | 39 | { |
| 40 | $i = 1; | 40 | $i = 1; |
| 41 | foreach($this->children as $child){ | 41 | foreach($this->children as $child){ |
diff --git a/src/model/entities/NodeData.php b/src/model/entities/NodeData.php index ddf6083..aaffb6a 100644 --- a/src/model/entities/NodeData.php +++ b/src/model/entities/NodeData.php | |||
| @@ -47,11 +47,11 @@ class NodeData | |||
| 47 | { | 47 | { |
| 48 | return $this->data; | 48 | return $this->data; |
| 49 | } | 49 | } |
| 50 | /*public function setData(array $data): void | 50 | public function setData(array $data): void |
| 51 | { | 51 | { |
| 52 | $this->data = $data; | 52 | $this->data = $data; |
| 53 | } | 53 | } |
| 54 | public function setNode(Node $node): void | 54 | /*public function setNode(Node $node): void |
| 55 | { | 55 | { |
| 56 | $this->node = $node; | 56 | $this->node = $node; |
| 57 | }*/ | 57 | }*/ |
diff --git a/src/view/FooterBuilder.php b/src/view/FooterBuilder.php index 8678f56..084e122 100644 --- a/src/view/FooterBuilder.php +++ b/src/view/FooterBuilder.php | |||
| @@ -27,9 +27,19 @@ class FooterBuilder extends AbstractBuilder | |||
| 27 | //$zone_admin = ''; | 27 | //$zone_admin = ''; |
| 28 | if($_SESSION['admin']) | 28 | if($_SESSION['admin']) |
| 29 | { | 29 | { |
| 30 | $div_admin = 'logged_in'; | ||
| 31 | $empty_admin_zone = 'empty_admin_zone'; | 30 | $empty_admin_zone = 'empty_admin_zone'; |
| 32 | $link_edit_page = new URL(['page' => CURRENT_PAGE, 'action' => 'modif_page']); | 31 | if(MainBuilder::$modif_mode){ |
| 32 | $mode = 'modification de page'; | ||
| 33 | $div_admin = 'logged_in modif_mode'; | ||
| 34 | $link_edit_page = new URL(['page' => CURRENT_PAGE]); | ||
| 35 | $link_edit_label = 'Sortir du mode modification'; | ||
| 36 | } | ||
| 37 | else{ | ||
| 38 | $mode = 'administrateur'; | ||
| 39 | $div_admin = 'logged_in'; | ||
| 40 | $link_edit_page = new URL(['page' => CURRENT_PAGE, 'action' => 'modif_page']); | ||
| 41 | $link_edit_label = 'Modifier la page'; | ||
| 42 | } | ||
| 33 | $link_new_page = new URL(['page' => 'nouvelle_page']); | 43 | $link_new_page = new URL(['page' => 'nouvelle_page']); |
| 34 | $link_change_paths = new URL(['page' => 'menu_chemins']); | 44 | $link_change_paths = new URL(['page' => 'menu_chemins']); |
| 35 | 45 | ||
| @@ -39,12 +49,14 @@ class FooterBuilder extends AbstractBuilder | |||
| 39 | $link_logout = new URL(['page' => CURRENT_PAGE, 'action' => 'deconnexion']); | 49 | $link_logout = new URL(['page' => CURRENT_PAGE, 'action' => 'deconnexion']); |
| 40 | isset($_GET['id']) ? $link_logout->addParams(['id' => $_GET['id']]) : ''; | 50 | isset($_GET['id']) ? $link_logout->addParams(['id' => $_GET['id']]) : ''; |
| 41 | 51 | ||
| 42 | $zone_admin = '<p>Vous êtes en mode administrateur.' . "\n" . | 52 | $zone_admin = '<div class="admin_buttons_zone"> |
| 43 | '<a href="' . $link_edit_page . '"><button>Modifier la page</button></a>' . "\n" . | 53 | <p>Vous êtes en mode ' . $mode . ".</p>\n" . |
| 44 | '<a href="' . $link_new_page . '"><button>Nouvelle page</button></a>' . "\n" . | 54 | '<div><a href="' . $link_edit_page . '"><button>' . $link_edit_label . '</button></a></div>' . "\n" . |
| 45 | '<a href="' . $link_change_paths . '"><button>Menu et chemins</button></a>' . "\n" . | 55 | '<div><a href="' . $link_new_page . '"><button>Nouvelle page</button></a></div>' . "\n" . |
| 46 | '<a href="' . $link_change_password . '"><button>Changer de mot de passe</button></a>' . "\n" . | 56 | '<div><a href="' . $link_change_paths . '"><button>Menu et chemins</button></a></div>' . "\n" . |
| 47 | '<a href="' . $link_logout . '"><button>Déconnexion</button></a></p>' . "\n"; | 57 | '<div><a href="' . $link_change_password . '"><button>Changer de mot de passe</button></a></div>' . "\n" . |
| 58 | '<div><a href="' . $link_logout . '"><button>Déconnexion</button></a></div>' . "\n" . | ||
| 59 | '</div>' . "\n"; | ||
| 48 | } | 60 | } |
| 49 | else | 61 | else |
| 50 | { | 62 | { |
diff --git a/src/view/MainBuilder.php b/src/view/MainBuilder.php index fbdfbdd..4664c17 100644 --- a/src/view/MainBuilder.php +++ b/src/view/MainBuilder.php | |||
| @@ -69,8 +69,9 @@ class MainBuilder extends AbstractBuilder | |||
| 69 | </aside>' . "\n";*/ | 69 | </aside>' . "\n";*/ |
| 70 | 70 | ||
| 71 | // ajout d'un nouveau bloc | 71 | // ajout d'un nouveau bloc |
| 72 | $this->html .= '<div class="new_bloc"> | 72 | $this->html .= '<div class="edit_bloc_zone"> |
| 73 | <p>Ajouter un bloc dans la page:</p> | 73 | <div class="new_bloc"> |
| 74 | <p>Ajouter un bloc de page</p> | ||
| 74 | <form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> | 75 | <form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> |
| 75 | <p><label for="bloc_title">Titre</label> | 76 | <p><label for="bloc_title">Titre</label> |
| 76 | <input type="text" id="bloc_title" name="bloc_title" required></p> | 77 | <input type="text" id="bloc_title" name="bloc_title" required></p> |
| @@ -78,11 +79,30 @@ class MainBuilder extends AbstractBuilder | |||
| 78 | <select id="bloc_select" name="bloc_select" required>' | 79 | <select id="bloc_select" name="bloc_select" required>' |
| 79 | . $options . | 80 | . $options . |
| 80 | '</select> | 81 | '</select> |
| 82 | <input type="hidden" name="bloc_title_hidden"> | ||
| 81 | <input type="submit" value="Valider"></p> | 83 | <input type="submit" value="Valider"></p> |
| 82 | </form> | 84 | </form> |
| 83 | </div>' . "\n"; | 85 | </div>' . "\n"; |
| 86 | $this->html .= '<div class="modify_bloc"> | ||
| 87 | <p>Modifier un bloc</p>'; | ||
| 84 | foreach($node->getChildren() as $child_node){ | 88 | foreach($node->getChildren() as $child_node){ |
| 85 | //$this->html .= | 89 | // renommage d'un bloc |
| 90 | $this->html .= '<div> | ||
| 91 | <p><label for="bloc_rename_title">Titre</label> | ||
| 92 | <input type="text" id="bloc_rename_' . $child_node->getId() . '" name="bloc_rename_title" value="' . $child_node->getNodeData()->getdata()['title'] . '" required> | ||
| 93 | <button onclick="renamePageBloc(' . $child_node->getId() . ')">Renommer</button>'. "\n"; | ||
| 94 | // déplacement d'un bloc | ||
| 95 | $this->html .= '<img class="action_icon" onclick="switchBlocPositions(' . $child_node->getId() . ', \'up\')" src="assets/arrow-up.svg"> | ||
| 96 | <img class="action_icon" onclick="switchBlocPositions(' . $child_node->getId() . ', \'down\')" src="assets/arrow-down.svg">' . "\n"; | ||
| 97 | // suppression d'un bloc | ||
| 98 | $this->html .= '<form method="post" action="' . new URL(['page' => CURRENT_PAGE]) . '"> | ||
| 99 | <input type="hidden" name="delete_bloc_id" value="' . $child_node->getId() . '"> | ||
| 100 | <input type="hidden" name="delete_bloc_hidden"> | ||
| 101 | <input type="submit" value="Supprimer"></p> | ||
| 102 | </form> | ||
| 103 | </div>'. "\n"; | ||
| 86 | } | 104 | } |
| 105 | $this->html .= "</div> | ||
| 106 | </div>\n"; | ||
| 87 | } | 107 | } |
| 88 | } | 108 | } |
diff --git a/src/view/templates/footer.php b/src/view/templates/footer.php index 52cb1b5..8f6d465 100644 --- a/src/view/templates/footer.php +++ b/src/view/templates/footer.php | |||
| @@ -7,11 +7,12 @@ | |||
| 7 | <a href="mailto:<?= $e_mail ?>"><?= $e_mail ?></a></p> | 7 | <a href="mailto:<?= $e_mail ?>"><?= $e_mail ?></a></p> |
| 8 | <p class="footer_logo"><img src="<?= $logo_footer ?>" alt="logo"><p> | 8 | <p class="footer_logo"><img src="<?= $logo_footer ?>" alt="logo"><p> |
| 9 | </div> | 9 | </div> |
| 10 | </footer> | ||
| 11 | <div class="<?= $empty_admin_zone ?>"></div> | 10 | <div class="<?= $empty_admin_zone ?>"></div> |
| 12 | <div class="<?= $div_admin ?>"> | 11 | <div class="<?= $div_admin ?>"> |
| 13 | <?= $zone_admin ?> | 12 | <?= $zone_admin ?> |
| 14 | </div> | 13 | </div> |
| 14 | <div id="toast"></div> | ||
| 15 | </footer> | ||
| 15 | </div> | 16 | </div> |
| 16 | </body> | 17 | </body> |
| 17 | </html> \ No newline at end of file | 18 | </html> \ No newline at end of file |
