From 141291c29306391f91e7ceee57ff4d6e9907ab1d Mon Sep 17 00:00:00 2001 From: polo Date: Fri, 21 Mar 2025 00:47:16 +0100 Subject: dossier public --- public/css/article_hors_editeur.css | 38 +++++++++++ public/index.php | 128 ++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 public/css/article_hors_editeur.css create mode 100644 public/index.php (limited to 'public') 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 @@ +article{width: 630px;} +article:after{content: ""; display: block; clear: both;} + +img{vertical-align: bottom;} +@media screen and (max-width: 1000px) +{img{max-width: 900px;}} + +.text-tiny{font-size: x-small;} +.text-small{font-size: small;} +.text-big{font-size: large;} +.text-huge{font-size: x-large;} + +blockquote{border-left: 5px #cccccc solid; margin: 14px 0px; padding: 2px 25px; font-style: italic;} + +.marker-yellow{background-color: #fdfd77;} +.marker-green{background-color: #62f962;} +.marker-pink{background-color: #fc7899;} +.marker-blue{background-color: #72ccfd;} +.pen-red{background-color: white; color: red;} +.pen-green{background-color: white; color: green;} + +ul{padding-left: 10px;} +.todo-list>li{list-style-type : none;} +input[type=checkbox]{-webkit-appearance: none;-moz-appearance: none;-ms-appearance: none; +height: 16px; width: 16px; border: 1px solid black; border-radius: 2px; position: relative; top: 5px; margin-right: 10px;} +input[type="checkbox"]:checked{border: none; background: #26ab33;} + +.table>table{border-collapse: collapse;} +.table td{border: 1px grey solid; padding: 7px; min-width: 30px;} +td p{margin: 0px;} + +.image{margin: 0px; text-align: center; display: inline-block;} +.image-style-side{float: right;} +.image img{max-width: 630px;} +.image-style-side img{max-width: 315px;} +.image>figcaption{margin: 0px 10px; padding: 7px; text-align: center; font-size: small; background-color: #f7f7f7;} + +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 @@ +setLanguage('fr'); // attention, exécute une autre fonction qui peut échouer +$ckeditor->setStorageMode('files'); +$ckeditor->setPage($page); + + +// routage + +// upload images AJAX +if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor') +{ + $ckeditor->checkAjaxRequest(); +} + +// submit normal +if(isset($_GET['action']) && $_GET['action'] === 'submit_editor' && isset($_POST["contenu"])) // HTML envoyé par l'éditeur +{ + $ckeditor->setFrom($from); + $html_from_editor = $ckeditor->checkSubmitPOST(); + + if($id_article == '') // nouvel article + { + $id_article = time(); + } + + if($ckeditor->getStorageMode() === 'database') + { + // => modèle + } + elseif($ckeditor->getStorageMode() === 'files') + { + file_put_contents(CKEditor::DATA_PATH . '/html/' . $id_article . '.html', $html_from_editor); + } + + header('Location: index.php?page=' . $ckeditor->getFrom()); + die; +} + +// modèle - récupération des articles +$id_array = []; // noms des id en BBD ou des fichiers +$articles_content = []; // contenu HTML + +if(isset($_GET['action']) && $_GET['action'] === 'open_editor' && $id_article == '') +{ + $articles_content = $ckeditor->openEditor() . "\n"; +} +else +{ + $articles_content = $ckeditor->displayNewArticleButton() . "\n"; +} + +if($ckeditor->getStorageMode() === 'database') +{ + // => modèle +} +elseif($ckeditor->getStorageMode() === 'files') +{ + foreach(scandir(CKEditor::DATA_PATH . '/html/') as $file_name) + { + if(str_ends_with($file_name, '.html')) // filtre . et .. et d'éventuels autres fichiers + { + $id_array[] = rtrim($file_name, '.html'); + } + } + + // suppression et rechargement + if(isset($_GET['action']) && $_GET['action'] === 'delete_article') + { + if(in_array($id_article, $id_array)) + { + unlink(CKEditor::DATA_PATH . '/html/' . $id_article . '.html'); + //$ckeditor->deleteSideEffects(); + } + header('Location: index.php?page=' . $from); + die; + } + + // affichage + foreach($id_array as $id) + { + $texte = trim(file_get_contents(CKEditor::DATA_PATH . '/html/' . $id . '.html')); + //$texte = addslashes($texte); // échappe ', ", \ et NULL, je sais pas si c'est bien + + // vue - afficher des articles et éventuellement l'éditeur dans un des articles + if(isset($_GET['action']) && $_GET['action'] === 'open_editor') + { + if($id === $id_article) + { + $texte = addcslashes($texte, "'"); // échapper les simples quotes pour javascript + $articles_content .= $ckeditor->openEditor($id, $texte) . "\n"; + } + else + { + $articles_content .= $ckeditor->displayArticle($id, $texte) . "\n"; + } + } + else + { + $articles_content .= $ckeditor->displayArticle($id, $texte) . "\n"; + } + } +} +// vue +?> + + + + + + + getCSSOutsideEditorTag() ?> + getCSSEditorTag() ?> + + +
+ +
+ + -- cgit v1.2.3