diff options
Diffstat (limited to 'controller/admin.php')
-rw-r--r-- | controller/admin.php | 60 |
1 files changed, 47 insertions, 13 deletions
diff --git a/controller/admin.php b/controller/admin.php index 845fab1..f3eeeca 100644 --- a/controller/admin.php +++ b/controller/admin.php | |||
@@ -19,7 +19,7 @@ function pageArticlesSimplesAdmin(string $page, string $title, string $headerPai | |||
19 | } | 19 | } |
20 | 20 | ||
21 | // infos sur les fichiers | 21 | // infos sur les fichiers |
22 | $Articles = new Article($page); | 22 | $Articles = new Article($page, $page); |
23 | 23 | ||
24 | // nouvel article | 24 | // nouvel article |
25 | if($fileCode == '') | 25 | if($fileCode == '') |
@@ -47,6 +47,7 @@ function pageArticlesSimplesAdmin(string $page, string $title, string $headerPai | |||
47 | $texte = $Articles->readOne(); // entrée de l'éditeur | 47 | $texte = $Articles->readOne(); // entrée de l'éditeur |
48 | } | 48 | } |
49 | } | 49 | } |
50 | $lienBoutonAnnuler = $page; | ||
50 | 51 | ||
51 | // ajout des données dans $Articles->fileList['content'] | 52 | // ajout des données dans $Articles->fileList['content'] |
52 | if(!empty($Articles->fileList)) | 53 | if(!empty($Articles->fileList)) |
@@ -58,7 +59,7 @@ function pageArticlesSimplesAdmin(string $page, string $title, string $headerPai | |||
58 | // sécurisation du contenu pré-existant inséré dans l'éditeur | 59 | // sécurisation du contenu pré-existant inséré dans l'éditeur |
59 | if(!empty($fileCode) && !$suppression) | 60 | if(!empty($fileCode) && !$suppression) |
60 | { | 61 | { |
61 | $fileCodeArgument = '&article=' . $fileCode; | 62 | $fileCodeArgument = '&file_code=' . $fileCode; |
62 | require('controller/ckeditor.php'); | 63 | require('controller/ckeditor.php'); |
63 | $texte = preparationCKeditor($texte); | 64 | $texte = preparationCKeditor($texte); |
64 | } | 65 | } |
@@ -156,15 +157,23 @@ function legalEdit($fileCode, int $suppression) | |||
156 | } | 157 | } |
157 | 158 | ||
158 | 159 | ||
159 | // page plus complexe que les autres | 160 | // l'éditeur est ouvert dans la page album |
160 | function discoEdit($fileCode, int $suppression) | 161 | // ne servirait que pour les positions |
162 | /*function discoEdit() | ||
161 | { | 163 | { |
162 | $page = "discographie"; | 164 | inversionPositions(); |
165 | }*/ | ||
166 | |||
167 | // page complexe avec albums et articles | ||
168 | // cas où on fait quelque chose: ouvrir l'éditeur, monter, descendre, supprimer | ||
169 | function albumEdit($fileCode, int $suppression) | ||
170 | { | ||
171 | $page = $_GET['page']; | ||
163 | $title = "Discographie"; | 172 | $title = "Discographie"; |
164 | 173 | ||
165 | // modèle | 174 | // modèle |
166 | $Albums = new Album($page); | 175 | $Albums = new Album($page, 'discographie'); |
167 | $Albums->makeFileList(); | 176 | //$Albums->makeFileList(); |
168 | 177 | ||
169 | // contenu: JSON, HTML, noms et chemins des fichiers | 178 | // contenu: JSON, HTML, noms et chemins des fichiers |
170 | $Albums->readAll(); | 179 | $Albums->readAll(); |
@@ -177,6 +186,8 @@ function discoEdit($fileCode, int $suppression) | |||
177 | // nouvel album | 186 | // nouvel album |
178 | if($fileCode == '') | 187 | if($fileCode == '') |
179 | { | 188 | { |
189 | $page = 'discographie'; | ||
190 | $lienBoutonAnnuler = $page; | ||
180 | $title = "Ajouter un album"; | 191 | $title = "Ajouter un album"; |
181 | $imageFormulaire = ''; | 192 | $imageFormulaire = ''; |
182 | 193 | ||
@@ -189,9 +200,9 @@ function discoEdit($fileCode, int $suppression) | |||
189 | // album ciblé | 200 | // album ciblé |
190 | $Albums->fileCode = $fileCode; | 201 | $Albums->fileCode = $fileCode; |
191 | 202 | ||
192 | // suppression | ||
193 | if($suppression) | 203 | if($suppression) |
194 | { | 204 | { |
205 | $page = 'discographie'; | ||
195 | $Albums->delete(); | 206 | $Albums->delete(); |
196 | header('Location: index.php?page=' . $page); | 207 | header('Location: index.php?page=' . $page); |
197 | exit(); | 208 | exit(); |
@@ -199,6 +210,8 @@ function discoEdit($fileCode, int $suppression) | |||
199 | // modification | 210 | // modification |
200 | else | 211 | else |
201 | { | 212 | { |
213 | $page = 'album'; | ||
214 | $Albums->readOne(); | ||
202 | $_SESSION['target'] = $fileCode; | 215 | $_SESSION['target'] = $fileCode; |
203 | $title = "Modifier un album"; | 216 | $title = "Modifier un album"; |
204 | 217 | ||
@@ -216,7 +229,11 @@ function discoEdit($fileCode, int $suppression) | |||
216 | // image affichée à côté des formulaires | 229 | // image affichée à côté des formulaires |
217 | if(!empty($vignette[2])) | 230 | if(!empty($vignette[2])) |
218 | { | 231 | { |
219 | $imageFormulaire = '<img class="imageFormulaire" src="data/' . $page . '/images/' . $vignette[2] . '" ><br/>'; | 232 | if($page == 'album') |
233 | { | ||
234 | $dossier = 'discographie'; | ||
235 | } | ||
236 | $imageFormulaire = '<img class="imageFormulaire" src="data/' . $dossier . '/images/' . $vignette[2] . '" ><br/>'; | ||
220 | } | 237 | } |
221 | else | 238 | else |
222 | { | 239 | { |
@@ -232,7 +249,7 @@ function discoEdit($fileCode, int $suppression) | |||
232 | if(!empty($fileCode) && !$suppression && !empty($texte)) | 249 | if(!empty($fileCode) && !$suppression && !empty($texte)) |
233 | { | 250 | { |
234 | // dans l'adresse dans la balise <form> | 251 | // dans l'adresse dans la balise <form> |
235 | $fileCodeArgument = '&article=' . $fileCode; | 252 | $fileCodeArgument = '&file_code=' . $fileCode; |
236 | 253 | ||
237 | require('controller/ckeditor.php'); | 254 | require('controller/ckeditor.php'); |
238 | $texte = preparationCKeditor($texte); | 255 | $texte = preparationCKeditor($texte); |
@@ -242,10 +259,16 @@ function discoEdit($fileCode, int $suppression) | |||
242 | $fileCodeArgument = ''; | 259 | $fileCodeArgument = ''; |
243 | } | 260 | } |
244 | 261 | ||
262 | // création des liens: menu disco | ||
263 | $lienBoutonAnnuler = 'discographie'; | ||
245 | for($i = 0; $i < $Albums->fileListCount; $i++) | 264 | for($i = 0; $i < $Albums->fileListCount; $i++) |
246 | { | 265 | { |
247 | if(file_exists('data/discographie/html/' . $Albums->fileList[$i]['fileCode'] . '.html')) | 266 | if(file_exists('data/discographie/html/' . $Albums->fileList[$i]['fileCode'] . '.html')) |
248 | { | 267 | { |
268 | if($Albums->fileList[$i]['fileCode'] === $fileCode) | ||
269 | { | ||
270 | $lienBoutonAnnuler = $page . '&file_code=' . $fileCode; | ||
271 | } | ||
249 | $lienAlbum[$i] = 'page=album&file_code=' . $Albums->fileList[$i]['fileCode']; | 272 | $lienAlbum[$i] = 'page=album&file_code=' . $Albums->fileList[$i]['fileCode']; |
250 | $avecLien[$i] = true; | 273 | $avecLien[$i] = true; |
251 | $linkDiscoChrono[$i] = 'linkChrono'; // css | 274 | $linkDiscoChrono[$i] = 'linkChrono'; // css |
@@ -256,7 +279,7 @@ function discoEdit($fileCode, int $suppression) | |||
256 | $avecLien[$i] = false; | 279 | $avecLien[$i] = false; |
257 | $linkDiscoChrono[$i] = 'noLinkChrono'; // css | 280 | $linkDiscoChrono[$i] = 'noLinkChrono'; // css |
258 | } | 281 | } |
259 | $lienBoutonModif[$i] = 'page=discographie&action=edition&file_code=' . $Albums->fileList[$i]['fileCode'] . '#' . $Albums->fileList[$i]['fileCode']; | 282 | $lienBoutonModif[$i] = 'page=album&action=edition&file_code=' . $Albums->fileList[$i]['fileCode']; |
260 | } | 283 | } |
261 | 284 | ||
262 | // morceaux en HTML à assembler | 285 | // morceaux en HTML à assembler |
@@ -264,7 +287,14 @@ function discoEdit($fileCode, int $suppression) | |||
264 | require('view/template-formulaires.php'); | 287 | require('view/template-formulaires.php'); |
265 | // variables $css, $js, $header et $content, | 288 | // variables $css, $js, $header et $content, |
266 | // $content contient ???? et $editeurHTML | 289 | // $content contient ???? et $editeurHTML |
267 | require('view/discographie.php'); | 290 | if($page === 'discographie') |
291 | { | ||
292 | require('view/discographie.php'); | ||
293 | } | ||
294 | elseif($page === 'album') | ||
295 | { | ||
296 | require('view/album.php'); | ||
297 | } | ||
268 | // fin de l'assemblage | 298 | // fin de l'assemblage |
269 | require('view/template.php'); | 299 | require('view/template.php'); |
270 | } | 300 | } |
@@ -273,7 +303,11 @@ function discoEdit($fileCode, int $suppression) | |||
273 | // version sans JS (l'autre est dans ajax.php) | 303 | // version sans JS (l'autre est dans ajax.php) |
274 | function inversionPositions(string $page, $fileCode, string $class, int $direction) | 304 | function inversionPositions(string $page, $fileCode, string $class, int $direction) |
275 | { | 305 | { |
276 | $Object = new $class($page); | 306 | $Object = new $class($page, $page); |
307 | if($page === 'album') | ||
308 | { | ||
309 | $Object->setFolder('discographie'); | ||
310 | } | ||
277 | $Object->fileCode = $fileCode; | 311 | $Object->fileCode = $fileCode; |
278 | // direction: 1 = monter, -1 = descendre | 312 | // direction: 1 = monter, -1 = descendre |
279 | $Object->inversionPositions($direction); | 313 | $Object->inversionPositions($direction); |