From 51a5391c96043829f7bbccda1262a51a8b8f93d8 Mon Sep 17 00:00:00 2001 From: git-pc-greta Date: Mon, 3 Feb 2025 22:41:21 +0100 Subject: bouton supprimer --- index.php | 14 ++++++++++++++ src/integration/ckeditor5/CKEditor.php | 5 ++++- src/integration/ckeditor5/view.php | 5 ++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index f33b47b..3e89113 100644 --- a/index.php +++ b/index.php @@ -71,6 +71,20 @@ elseif($ckeditor->getStorageMode() === 'files') $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')); diff --git a/src/integration/ckeditor5/CKEditor.php b/src/integration/ckeditor5/CKEditor.php index e7ec181..c53f236 100644 --- a/src/integration/ckeditor5/CKEditor.php +++ b/src/integration/ckeditor5/CKEditor.php @@ -90,7 +90,8 @@ class CKEditor public function displayArticle(string $id, string $texte): string { $html = '
' . $texte . '
- '; + + '; return $html; } @@ -104,6 +105,8 @@ class CKEditor require self::INTEGRATION_PATH . 'view.php'; // html + JS return $editeurHTML; } + + //public function deleteSideEffects(string $id){} public function checkSubmitPOST(): string { diff --git a/src/integration/ckeditor5/view.php b/src/integration/ckeditor5/view.php index d80a830..57115d1 100644 --- a/src/integration/ckeditor5/view.php +++ b/src/integration/ckeditor5/view.php @@ -8,6 +8,8 @@ $submit_action = 'index.php?from=' . $this->page . '&action=submit_editor&id=' . $cancel_button = 'index.php?page=' . $this->page; //$cancel_button .= !empty($id) ? '&id=' . $id : ''; // à ajouter si on a besoin de revenir sur un article spécifique +$delete_button = $id != '' ? '' : ''; + $upload_ajax = 'index.php?action=upload_image_editor'; $upload_ajax .= !empty($id) ? '&id=' . $id : ''; @@ -17,7 +19,8 @@ ob_start();
- + +