diff options
| author | polo <ordipolo@gmx.fr> | 2025-03-21 00:47:16 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-03-21 00:47:16 +0100 |
| commit | 141291c29306391f91e7ceee57ff4d6e9907ab1d (patch) | |
| tree | 3896896e18f4c8d84c8108e1c80e3d8c7093e712 /public | |
| parent | 51a5391c96043829f7bbccda1262a51a8b8f93d8 (diff) | |
| download | ckeditor5-master.tar.gz ckeditor5-master.tar.bz2 ckeditor5-master.zip | |
Diffstat (limited to 'public')
| -rw-r--r-- | public/css/article_hors_editeur.css | 38 | ||||
| -rw-r--r-- | public/index.php | 128 |
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 @@ | |||
| 1 | article{width: 630px;} | ||
| 2 | article:after{content: ""; display: block; clear: both;} | ||
| 3 | |||
| 4 | img{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 | |||
| 13 | blockquote{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 | |||
| 22 | ul{padding-left: 10px;} | ||
| 23 | .todo-list>li{list-style-type : none;} | ||
| 24 | input[type=checkbox]{-webkit-appearance: none;-moz-appearance: none;-ms-appearance: none; | ||
| 25 | height: 16px; width: 16px; border: 1px solid black; border-radius: 2px; position: relative; top: 5px; margin-right: 10px;} | ||
| 26 | input[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;} | ||
| 30 | td 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 | |||
| 38 | iframe{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 | |||
| 9 | require '../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 | ||
| 19 | if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor') | ||
| 20 | { | ||
| 21 | $ckeditor->checkAjaxRequest(); | ||
| 22 | } | ||
| 23 | |||
| 24 | // submit normal | ||
| 25 | if(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 | |||
| 52 | if(isset($_GET['action']) && $_GET['action'] === 'open_editor' && $id_article == '') | ||
| 53 | { | ||
| 54 | $articles_content = $ckeditor->openEditor() . "\n"; | ||
| 55 | } | ||
| 56 | else | ||
| 57 | { | ||
| 58 | $articles_content = $ckeditor->displayNewArticleButton() . "\n"; | ||
| 59 | } | ||
| 60 | |||
| 61 | if($ckeditor->getStorageMode() === 'database') | ||
| 62 | { | ||
| 63 | // => modèle | ||
| 64 | } | ||
| 65 | elseif($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> | ||
