diff options
| author | git-pc-greta <ordipolo@gmx.fr> | 2025-02-03 22:41:21 +0100 |
|---|---|---|
| committer | git-pc-greta <ordipolo@gmx.fr> | 2025-02-03 22:41:21 +0100 |
| commit | 51a5391c96043829f7bbccda1262a51a8b8f93d8 (patch) | |
| tree | 948d1ff5ad20fdeb8c2f11cb47a6700111d9385d | |
| parent | 13f24b014d07ab3f28c7a8ede4f4bd6eaebbaad4 (diff) | |
| download | ckeditor5-51a5391c96043829f7bbccda1262a51a8b8f93d8.tar.gz ckeditor5-51a5391c96043829f7bbccda1262a51a8b8f93d8.tar.bz2 ckeditor5-51a5391c96043829f7bbccda1262a51a8b8f93d8.zip | |
bouton supprimer
| -rw-r--r-- | index.php | 14 | ||||
| -rw-r--r-- | src/integration/ckeditor5/CKEditor.php | 5 | ||||
| -rw-r--r-- | src/integration/ckeditor5/view.php | 5 |
3 files changed, 22 insertions, 2 deletions
| @@ -71,6 +71,20 @@ elseif($ckeditor->getStorageMode() === 'files') | |||
| 71 | $id_array[] = rtrim($file_name, '.html'); | 71 | $id_array[] = rtrim($file_name, '.html'); |
| 72 | } | 72 | } |
| 73 | } | 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 | ||
| 74 | foreach($id_array as $id) | 88 | foreach($id_array as $id) |
| 75 | { | 89 | { |
| 76 | $texte = trim(file_get_contents(CKEditor::DATA_PATH . '/html/' . $id . '.html')); | 90 | $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 | |||
| 90 | public function displayArticle(string $id, string $texte): string | 90 | public function displayArticle(string $id, string $texte): string |
| 91 | { | 91 | { |
| 92 | $html = '<article>' . $texte . '</article> | 92 | $html = '<article>' . $texte . '</article> |
| 93 | <a href="index.php?page=' . $this->page . '&action=open_editor&id=' . $id . '"><button>ouvrir l\'éditeur</button></a>'; | 93 | <a href="index.php?page=' . $this->page . '&action=open_editor&id=' . $id . '"><button>Modifier</button></a> |
| 94 | <a href="index.php?page=' . $this->page . '&action=delete_article&id=' . $id . '"><button>Supprimer</button></a>'; | ||
| 94 | return $html; | 95 | return $html; |
| 95 | } | 96 | } |
| 96 | 97 | ||
| @@ -104,6 +105,8 @@ class CKEditor | |||
| 104 | require self::INTEGRATION_PATH . 'view.php'; // html + JS | 105 | require self::INTEGRATION_PATH . 'view.php'; // html + JS |
| 105 | return $editeurHTML; | 106 | return $editeurHTML; |
| 106 | } | 107 | } |
| 108 | |||
| 109 | //public function deleteSideEffects(string $id){} | ||
| 107 | 110 | ||
| 108 | public function checkSubmitPOST(): string | 111 | public function checkSubmitPOST(): string |
| 109 | { | 112 | { |
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=' . | |||
| 8 | $cancel_button = 'index.php?page=' . $this->page; | 8 | $cancel_button = 'index.php?page=' . $this->page; |
| 9 | //$cancel_button .= !empty($id) ? '&id=' . $id : ''; // à ajouter si on a besoin de revenir sur un article spécifique | 9 | //$cancel_button .= !empty($id) ? '&id=' . $id : ''; // à ajouter si on a besoin de revenir sur un article spécifique |
| 10 | 10 | ||
| 11 | $delete_button = $id != '' ? '<a href="index.php?page=' . $this->page . '&action=delete_article&id=' . $id . '"><input type="button" value="Supprimer"></a>' : ''; | ||
| 12 | |||
| 11 | $upload_ajax = 'index.php?action=upload_image_editor'; | 13 | $upload_ajax = 'index.php?action=upload_image_editor'; |
| 12 | $upload_ajax .= !empty($id) ? '&id=' . $id : ''; | 14 | $upload_ajax .= !empty($id) ? '&id=' . $id : ''; |
| 13 | 15 | ||
| @@ -17,7 +19,8 @@ ob_start(); | |||
| 17 | <form action="<?= $submit_action ?>" method="POST" enctype="multipart/form-data" > | 19 | <form action="<?= $submit_action ?>" method="POST" enctype="multipart/form-data" > |
| 18 | <textarea id="editor" name="contenu" ></textarea> | 20 | <textarea id="editor" name="contenu" ></textarea> |
| 19 | <input type="submit" value="Valider"> | 21 | <input type="submit" value="Valider"> |
| 20 | <a href="<?= $cancel_button ?>" ><input type="button" value="Annuler"></a> | 22 | <a href="<?= $cancel_button ?>"><input type="button" value="Annuler"></a> |
| 23 | <?= $delete_button ?> | ||
| 21 | <script type="importmap"> | 24 | <script type="importmap"> |
| 22 | { | 25 | { |
| 23 | "imports": { | 26 | "imports": { |
