summaryrefslogtreecommitdiff
path: root/controller/admin.php
diff options
context:
space:
mode:
Diffstat (limited to 'controller/admin.php')
-rw-r--r--controller/admin.php60
1 files changed, 41 insertions, 19 deletions
diff --git a/controller/admin.php b/controller/admin.php
index 2b3583f..77ab34e 100644
--- a/controller/admin.php
+++ b/controller/admin.php
@@ -4,37 +4,59 @@
4// utilisation du site en écriture 4// utilisation du site en écriture
5 5
6// pages du site en version admin 6// pages du site en version admin
7function melaineAdmin($numArticle) 7function melaineEdit($numArticle)
8{ 8{
9 $title = "Ajouter ou modifier un article";
10 $page_actuelle = "melaine"; 9 $page_actuelle = "melaine";
11 10
12 // variables $nombreDarticles et tableau $articles[] 11 // tableau $articles[]
13 require('model/melaine-read.php'); 12 require('model/melaine-read.php');
13 $croissant = False;
14 $articles = lireArticles($page_actuelle, $croissant);
15
16 if($numArticle == 0)
17 {
18 $title = "Ajouter un article";
19 $texte = '';
20 //$numArticle = count($articles) + 1;
21 }
22 else
23 {
24 $title = "Modifier un article";
25 // faire correspondre le numéro de l'article du GET et le tableau des articles qui est inversé
26 $texte = $articles[count($articles) - $numArticle];
27 }
14 28
15 // traitements PHP pour l'éditeur 29 // traitements PHP pour l'éditeur
16 require('controller/ckeditor.php'); 30 require('controller/ckeditor.php');
31 // sécurisation du contenu pré-existant inséré dans l'éditeur
32 $initial = preparationCKeditor($numArticle, $texte);
17 33
18 // NB: penser à ajouter au template la fonctionnalité "autosave" 34 // NB: penser à ajouter au template la fonctionnalité "autosave"
19 // https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/saving-data.html 35 // https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/saving-data.html
20 36
21 // récupération des dones du modèle 37 // if($numArticle > $nombreDarticles || $numArticle < 0) // erreur nombre trop grand (bug?)
22 if($numArticle > $nombreDarticles || $numArticle < 0) // erreur nombre trop grand (bug?) 38 // {
23 { 39 // header('Location: index.php?page=melaine');
24 header('Location: index.php?page=melaine'); 40 // }
25 } 41 // elseif($numArticle == 0) // nouvel article
26 elseif($numArticle == 0) // nouvel article 42 // {
27 { 43 // $texte = '';
28 $texte = ''; 44 // $numArticle = $nombreDarticles + 1;
29 $numArticle = $nombreDarticles + 1; 45 // }
30 } 46 // else // modification d'un article
31 else // modification d'un article 47 // {
32 { 48 // $texte = $articles[$numArticle - 1];
33 $texte = $articles[$numArticle - 1]; 49 // }
34 } 50
35 51
36 // traitement du contenu pré-existant 52 // if($initial == '')
37 $initial = preparationCKeditor($page_actuelle, $numArticle, $texte); 53 // {
54 // $article = "nouveau";
55 // }
56 // else
57 // {
58 // $article = "modif";
59 // }
38 60
39 // variable $editeurHTML, $initial est inséré dedans 61 // variable $editeurHTML, $initial est inséré dedans
40 require('view/template-ckeditor.php'); 62 require('view/template-ckeditor.php');