summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
Diffstat (limited to 'public')
-rw-r--r--public/css/article_hors_editeur.css38
-rw-r--r--public/index.php128
2 files changed, 166 insertions, 0 deletions
diff --git a/public/css/article_hors_editeur.css b/public/css/article_hors_editeur.css
new file mode 100644
index 0000000..622b539
--- /dev/null
+++ b/public/css/article_hors_editeur.css
@@ -0,0 +1,38 @@
1article{width: 630px;}
2article:after{content: ""; display: block; clear: both;}
3
4img{vertical-align: bottom;}
5@media screen and (max-width: 1000px)
6{img{max-width: 900px;}}
7
8.text-tiny{font-size: x-small;}
9.text-small{font-size: small;}
10.text-big{font-size: large;}
11.text-huge{font-size: x-large;}
12
13blockquote{border-left: 5px #cccccc solid; margin: 14px 0px; padding: 2px 25px; font-style: italic;}
14
15.marker-yellow{background-color: #fdfd77;}
16.marker-green{background-color: #62f962;}
17.marker-pink{background-color: #fc7899;}
18.marker-blue{background-color: #72ccfd;}
19.pen-red{background-color: white; color: red;}
20.pen-green{background-color: white; color: green;}
21
22ul{padding-left: 10px;}
23.todo-list>li{list-style-type : none;}
24input[type=checkbox]{-webkit-appearance: none;-moz-appearance: none;-ms-appearance: none;
25height: 16px; width: 16px; border: 1px solid black; border-radius: 2px; position: relative; top: 5px; margin-right: 10px;}
26input[type="checkbox"]:checked{border: none; background: #26ab33;}
27
28.table>table{border-collapse: collapse;}
29.table td{border: 1px grey solid; padding: 7px; min-width: 30px;}
30td p{margin: 0px;}
31
32.image{margin: 0px; text-align: center; display: inline-block;}
33.image-style-side{float: right;}
34.image img{max-width: 630px;}
35.image-style-side img{max-width: 315px;}
36.image>figcaption{margin: 0px 10px; padding: 7px; text-align: center; font-size: small; background-color: #f7f7f7;}
37
38iframe{min-width: 400px; min-height: 300px; max-width: 1200px; max-height: 900px;}
diff --git a/public/index.php b/public/index.php
new file mode 100644
index 0000000..f674f0f
--- /dev/null
+++ b/public/index.php
@@ -0,0 +1,128 @@
1<?php
2// index.php
3
4$page = isset($_GET['page']) ? $_GET['page'] : 'accueil';
5$from = isset($_GET['from']) ? $_GET['from'] : 'accueil'; // pour revenir au même endroit après un submit
6$id_article = isset($_GET['id']) && !empty($_GET['id']) ? $_GET['id'] : '';
7
8
9require '../src/service/ckeditor5/CKEditor.php';
10$ckeditor = new CKEditor();
11$ckeditor->setLanguage('fr'); // attention, exécute une autre fonction qui peut échouer
12$ckeditor->setStorageMode('files');
13$ckeditor->setPage($page);
14
15
16// routage
17
18// upload images AJAX
19if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor')
20{
21 $ckeditor->checkAjaxRequest();
22}
23
24// submit normal
25if(isset($_GET['action']) && $_GET['action'] === 'submit_editor' && isset($_POST["contenu"])) // HTML envoyé par l'éditeur
26{
27 $ckeditor->setFrom($from);
28 $html_from_editor = $ckeditor->checkSubmitPOST();
29
30 if($id_article == '') // nouvel article
31 {
32 $id_article = time();
33 }
34
35 if($ckeditor->getStorageMode() === 'database')
36 {
37 // => modèle
38 }
39 elseif($ckeditor->getStorageMode() === 'files')
40 {
41 file_put_contents(CKEditor::DATA_PATH . '/html/' . $id_article . '.html', $html_from_editor);
42 }
43
44 header('Location: index.php?page=' . $ckeditor->getFrom());
45 die;
46}
47
48// modèle - récupération des articles
49$id_array = []; // noms des id en BBD ou des fichiers
50$articles_content = []; // contenu HTML
51
52if(isset($_GET['action']) && $_GET['action'] === 'open_editor' && $id_article == '')
53{
54 $articles_content = $ckeditor->openEditor() . "\n";
55}
56else
57{
58 $articles_content = $ckeditor->displayNewArticleButton() . "\n";
59}
60
61if($ckeditor->getStorageMode() === 'database')
62{
63 // => modèle
64}
65elseif($ckeditor->getStorageMode() === 'files')
66{
67 foreach(scandir(CKEditor::DATA_PATH . '/html/') as $file_name)
68 {
69 if(str_ends_with($file_name, '.html')) // filtre . et .. et d'éventuels autres fichiers
70 {
71 $id_array[] = rtrim($file_name, '.html');
72 }
73 }
74
75 // suppression et rechargement
76 if(isset($_GET['action']) && $_GET['action'] === 'delete_article')
77 {
78 if(in_array($id_article, $id_array))
79 {
80 unlink(CKEditor::DATA_PATH . '/html/' . $id_article . '.html');
81 //$ckeditor->deleteSideEffects();
82 }
83 header('Location: index.php?page=' . $from);
84 die;
85 }
86
87 // affichage
88 foreach($id_array as $id)
89 {
90 $texte = trim(file_get_contents(CKEditor::DATA_PATH . '/html/' . $id . '.html'));
91 //$texte = addslashes($texte); // échappe ', ", \ et NULL, je sais pas si c'est bien
92
93 // vue - afficher des articles et éventuellement l'éditeur dans un des articles
94 if(isset($_GET['action']) && $_GET['action'] === 'open_editor')
95 {
96 if($id === $id_article)
97 {
98 $texte = addcslashes($texte, "'"); // échapper les simples quotes pour javascript
99 $articles_content .= $ckeditor->openEditor($id, $texte) . "\n";
100 }
101 else
102 {
103 $articles_content .= $ckeditor->displayArticle($id, $texte) . "\n";
104 }
105 }
106 else
107 {
108 $articles_content .= $ckeditor->displayArticle($id, $texte) . "\n";
109 }
110 }
111}
112// vue
113?>
114<!DOCTYPE html>
115<html lang="fr">
116<head>
117 <meta charset="utf-8">
118 <title></title>
119 <link rel="icon" type="image/png" href="">
120 <?= $ckeditor->getCSSOutsideEditorTag() ?>
121 <?= $ckeditor->getCSSEditorTag() ?>
122</head>
123<body>
124 <div>
125<?= $articles_content ?>
126 </div>
127</body>
128</html>