diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 51 |
1 files changed, 32 insertions, 19 deletions
@@ -25,35 +25,48 @@ if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor') | |||
25 | if(isset($_GET['action']) && $_GET['action'] === 'submit_editor') // HTML envoyé par l'éditeur | 25 | if(isset($_GET['action']) && $_GET['action'] === 'submit_editor') // HTML envoyé par l'éditeur |
26 | { | 26 | { |
27 | $ckeditor->setFrom($from); | 27 | $ckeditor->setFrom($from); |
28 | $ckeditor->setIdArticle($id_article); | ||
29 | $ckeditor->checkSubmitPOST(); | 28 | $ckeditor->checkSubmitPOST(); |
30 | } | 29 | } |
31 | 30 | ||
32 | /*$articles = []; | 31 | // modèle - récupération des articles |
33 | foreach($articles as $article) | 32 | $articles_id = []; // noms des id en BBD ou des fichiers |
34 | {}*/ | 33 | $articles_content = []; // contenu HTML |
35 | 34 | if($ckeditor->getStorageMode() === 'database') | |
36 | // ouvrir l'éditeur | ||
37 | if(isset($_GET['action']) && $_GET['action'] === 'open_editor') | ||
38 | { | 35 | { |
39 | $ckeditor->setIdArticle($id_article); | 36 | // => modèle |
40 | $editeurHTML = $ckeditor->openEditor(); | ||
41 | } | 37 | } |
42 | else // affichage article | 38 | elseif($ckeditor->getStorageMode() === 'files') |
43 | { | 39 | { |
44 | $ckeditor->setIdArticle('1646148841'); | 40 | foreach(scandir(CKEditor::DATA_PATH . '/html/') as $file_name) |
45 | if($ckeditor->getStorageMode() === 'database') | ||
46 | { | 41 | { |
47 | // ton code | 42 | if(str_ends_with($file_name, '.html')) // filtre . et .. et d'éventuels autres fichiers |
43 | { | ||
44 | $articles_id[] = rtrim($file_name, '.html'); | ||
45 | } | ||
48 | } | 46 | } |
49 | elseif($ckeditor->getStorageMode() === 'files') | 47 | foreach($articles_id as $id) |
50 | { | 48 | { |
51 | $texte = file_get_contents($ckeditor->getDataPath() . '/html/' . $ckeditor->getIdArticle() . '.html'); | 49 | $texte = trim(file_get_contents(CKEditor::DATA_PATH . '/html/' . $id . '.html')); |
52 | //$texte = trim(addcslashes($texte, "'")); // échappe seulement les simples quotes | 50 | //$texte = addslashes($texte); // échappe ', ", \ et NULL, je sais pas si c'est bien |
53 | $texte = trim($texte); | 51 | |
52 | // ouvrir l'éditeur sur un des articles ou aucun | ||
53 | if(isset($_GET['action']) && $_GET['action'] === 'open_editor') | ||
54 | { | ||
55 | if($id === $id_article) | ||
56 | { | ||
57 | $texte = addcslashes($texte, "'"); // échapper les simples quotes pour javascript | ||
58 | $articles_content[] = $ckeditor->openEditor($id, $texte); | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | $articles_content[] = $ckeditor->displayArticle($id, $texte); | ||
63 | } | ||
64 | } | ||
65 | else // affichage article | ||
66 | { | ||
67 | $articles_content[] = $ckeditor->displayArticle($id, $texte); | ||
68 | } | ||
54 | } | 69 | } |
55 | $editeurHTML = '<div class="conteneur_article" >' . $texte . '</div> | ||
56 | <p><a href="index.php?page=' . $ckeditor->getPage() . '&action=open_editor&id=' . $ckeditor->getIdArticle() . '">ouvrir l\'éditeur</a></p>'; | ||
57 | } | 70 | } |
58 | 71 | ||
59 | require 'src/view/templates/page.php'; | 72 | require 'src/view/templates/page.php'; |