summaryrefslogtreecommitdiff
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php26
1 files changed, 18 insertions, 8 deletions
diff --git a/index.php b/index.php
index e02d3d1..f388081 100644
--- a/index.php
+++ b/index.php
@@ -1,22 +1,31 @@
1<?php 1<?php
2// index.php 2// index.php
3 3
4// code de l'appli principale
5$page = isset($_GET['page']) ? $_GET['page'] : 'accueil';
6$from = isset($_GET['from']) ? $_GET['from'] : 'accueil'; // pour revenir au même endroit après un submit
7$id_article = isset($_GET['id']) ? $_GET['id'] : ''; // page pouvant avoir plusieurs articles
8
4 9
5require 'src/integration/ckeditor5/CKEditor.php'; 10require 'src/integration/ckeditor5/CKEditor.php';
6$ckeditor = new CKEditor(); 11$ckeditor = new CKEditor();
12$ckeditor->setStorageMode('files');
13$ckeditor->setPage($page);
7 14
8 15
9// routage 16// routage
10 17
11// upload images AJAX 18// upload images AJAX
12if(isset($_GET['action']) && $_GET['action'] === 'upload_image') 19if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor')
13{ 20{
14 $ckeditor->checkAjaxReqest(); 21 $ckeditor->checkAjaxReqest();
15} 22}
16 23
17// submit normal 24// submit normal
18if(isset($_GET['action']) && $_GET['action'] === 'submit') // HTML envoyé par l'éditeur 25if(isset($_GET['action']) && $_GET['action'] === 'submit_editor') // HTML envoyé par l'éditeur
19{ 26{
27 $ckeditor->setFrom($from);
28 $ckeditor->setIdArticle($id_article);
20 $ckeditor->checkSubmitPOST(); 29 $ckeditor->checkSubmitPOST();
21} 30}
22 31
@@ -25,25 +34,26 @@ foreach($articles as $article)
25{}*/ 34{}*/
26 35
27// ouvrir l'éditeur 36// ouvrir l'éditeur
28if(isset($_GET['action']) && $_GET['action'] === 'editor') 37if(isset($_GET['action']) && $_GET['action'] === 'open_editor')
29{ 38{
39 $ckeditor->setIdArticle($id_article);
30 $editeurHTML = $ckeditor->openEditor(); 40 $editeurHTML = $ckeditor->openEditor();
31} 41}
32else // affichage article 42else // affichage article
33{ 43{
34 if($ckeditor->storage === 'database') 44 $ckeditor->setIdArticle('1646148841');
45 if($ckeditor->getStorageMode() === 'database')
35 { 46 {
36 // ton code 47 // ton code
37 } 48 }
38 elseif($ckeditor->storage === 'files') 49 elseif($ckeditor->getStorageMode() === 'files')
39 { 50 {
40 $texte = file_get_contents($ckeditor->data_path . '/html/' . $ckeditor->nom_article . '.html'); 51 $texte = file_get_contents($ckeditor->getDataPath() . '/html/' . $ckeditor->getIdArticle() . '.html');
41 //$texte = trim(addcslashes($texte, "'")); // échappe seulement les simples quotes 52 //$texte = trim(addcslashes($texte, "'")); // échappe seulement les simples quotes
42 $texte = trim($texte); 53 $texte = trim($texte);
43 } 54 }
44
45 $editeurHTML = '<div class="conteneur_article" >' . $texte . '</div> 55 $editeurHTML = '<div class="conteneur_article" >' . $texte . '</div>
46 <p><a href="' . $ckeditor->open_editor_link . '">ouvrir l\'éditeur</a></p>'; 56 <p><a href="index.php?page=' . $ckeditor->getPage() . '&action=open_editor&id=' . $ckeditor->getIdArticle() . '">ouvrir l\'éditeur</a></p>';
47} 57}
48 58
49require 'src/view/templates/page.php'; 59require 'src/view/templates/page.php';