diff options
| author | polo <ordipolo@gmx.fr> | 2025-01-22 23:45:52 +0100 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2025-01-22 23:45:52 +0100 |
| commit | 4b21b40292de8ee08220ab901651a13ec5e35199 (patch) | |
| tree | cf3a735e604a10e6d74c30a8c2c1323169bf463a | |
| parent | f1dd96bc67e497f6c07291d6e5f6f23ec243b091 (diff) | |
| download | ckeditor5-4b21b40292de8ee08220ab901651a13ec5e35199.tar.gz ckeditor5-4b21b40292de8ee08220ab901651a13ec5e35199.tar.bz2 ckeditor5-4b21b40292de8ee08220ab901651a13ec5e35199.zip | |
gestion des $page, $from et $id
| -rw-r--r-- | data/page/html/1646148841.html (renamed from data/page/html/article.html) | 0 | ||||
| -rw-r--r-- | index.php | 26 | ||||
| -rw-r--r-- | installation dans une application PHP.txt | 45 | ||||
| -rw-r--r-- | src/integration/ckeditor5/CKEditor.php | 101 | ||||
| -rw-r--r-- | src/integration/ckeditor5/view.php | 14 | ||||
| -rw-r--r-- | src/view/templates/page.php | 4 |
6 files changed, 129 insertions, 61 deletions
diff --git a/data/page/html/article.html b/data/page/html/1646148841.html index 3f0058d..3f0058d 100644 --- a/data/page/html/article.html +++ b/data/page/html/1646148841.html | |||
| @@ -1,22 +1,31 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // index.php | 2 | // index.php |
| 3 | 3 | ||
| 4 | // code de l'appli principale | ||
| 5 | $page = isset($_GET['page']) ? $_GET['page'] : 'accueil'; | ||
| 6 | $from = isset($_GET['from']) ? $_GET['from'] : 'accueil'; // pour revenir au même endroit après un submit | ||
| 7 | $id_article = isset($_GET['id']) ? $_GET['id'] : ''; // page pouvant avoir plusieurs articles | ||
| 8 | |||
| 4 | 9 | ||
| 5 | require 'src/integration/ckeditor5/CKEditor.php'; | 10 | require 'src/integration/ckeditor5/CKEditor.php'; |
| 6 | $ckeditor = new CKEditor(); | 11 | $ckeditor = new CKEditor(); |
| 12 | $ckeditor->setStorageMode('files'); | ||
| 13 | $ckeditor->setPage($page); | ||
| 7 | 14 | ||
| 8 | 15 | ||
| 9 | // routage | 16 | // routage |
| 10 | 17 | ||
| 11 | // upload images AJAX | 18 | // upload images AJAX |
| 12 | if(isset($_GET['action']) && $_GET['action'] === 'upload_image') | 19 | if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor') |
| 13 | { | 20 | { |
| 14 | $ckeditor->checkAjaxReqest(); | 21 | $ckeditor->checkAjaxReqest(); |
| 15 | } | 22 | } |
| 16 | 23 | ||
| 17 | // submit normal | 24 | // submit normal |
| 18 | if(isset($_GET['action']) && $_GET['action'] === 'submit') // HTML envoyé par l'éditeur | 25 | if(isset($_GET['action']) && $_GET['action'] === 'submit_editor') // HTML envoyé par l'éditeur |
| 19 | { | 26 | { |
| 27 | $ckeditor->setFrom($from); | ||
| 28 | $ckeditor->setIdArticle($id_article); | ||
| 20 | $ckeditor->checkSubmitPOST(); | 29 | $ckeditor->checkSubmitPOST(); |
| 21 | } | 30 | } |
| 22 | 31 | ||
| @@ -25,25 +34,26 @@ foreach($articles as $article) | |||
| 25 | {}*/ | 34 | {}*/ |
| 26 | 35 | ||
| 27 | // ouvrir l'éditeur | 36 | // ouvrir l'éditeur |
| 28 | if(isset($_GET['action']) && $_GET['action'] === 'editor') | 37 | if(isset($_GET['action']) && $_GET['action'] === 'open_editor') |
| 29 | { | 38 | { |
| 39 | $ckeditor->setIdArticle($id_article); | ||
| 30 | $editeurHTML = $ckeditor->openEditor(); | 40 | $editeurHTML = $ckeditor->openEditor(); |
| 31 | } | 41 | } |
| 32 | else // affichage article | 42 | else // affichage article |
| 33 | { | 43 | { |
| 34 | if($ckeditor->storage === 'database') | 44 | $ckeditor->setIdArticle('1646148841'); |
| 45 | if($ckeditor->getStorageMode() === 'database') | ||
| 35 | { | 46 | { |
| 36 | // ton code | 47 | // ton code |
| 37 | } | 48 | } |
| 38 | elseif($ckeditor->storage === 'files') | 49 | elseif($ckeditor->getStorageMode() === 'files') |
| 39 | { | 50 | { |
| 40 | $texte = file_get_contents($ckeditor->data_path . '/html/' . $ckeditor->nom_article . '.html'); | 51 | $texte = file_get_contents($ckeditor->getDataPath() . '/html/' . $ckeditor->getIdArticle() . '.html'); |
| 41 | //$texte = trim(addcslashes($texte, "'")); // échappe seulement les simples quotes | 52 | //$texte = trim(addcslashes($texte, "'")); // échappe seulement les simples quotes |
| 42 | $texte = trim($texte); | 53 | $texte = trim($texte); |
| 43 | } | 54 | } |
| 44 | |||
| 45 | $editeurHTML = '<div class="conteneur_article" >' . $texte . '</div> | 55 | $editeurHTML = '<div class="conteneur_article" >' . $texte . '</div> |
| 46 | <p><a href="' . $ckeditor->open_editor_link . '">ouvrir l\'éditeur</a></p>'; | 56 | <p><a href="index.php?page=' . $ckeditor->getPage() . '&action=open_editor&id=' . $ckeditor->getIdArticle() . '">ouvrir l\'éditeur</a></p>'; |
| 47 | } | 57 | } |
| 48 | 58 | ||
| 49 | require 'src/view/templates/page.php'; | 59 | require 'src/view/templates/page.php'; |
diff --git a/installation dans une application PHP.txt b/installation dans une application PHP.txt index 21d1b0b..6d1b108 100644 --- a/installation dans une application PHP.txt +++ b/installation dans une application PHP.txt | |||
| @@ -11,17 +11,15 @@ faire un install (npm) et un require (composer) dans son projet, obtenir la dern | |||
| 11 | npm install ckeditor5 | 11 | npm install ckeditor5 |
| 12 | composer require htmlawed/htmlawed | 12 | composer require htmlawed/htmlawed |
| 13 | 13 | ||
| 14 | les 11 fichiers récupérés par le git clone: | 14 | les 9 fichiers récupérés par le git clone |
| 15 | lib/ckeditor5/create.php | 15 | src/integration/ckeditor5/CKEditor.php |
| 16 | lib/ckeditor5/clean_html.php | 16 | src/integration/ckeditor5/view.php |
| 17 | lib/ckeditor5/view.php | 17 | src/integration/ckeditor5/image_upload.php |
| 18 | lib/ckeditor5/image_upload.php | 18 | src/integration/ckeditor5/articles_hors_editeur.css |
| 19 | lib/ckeditor5/articles_hors_editeur.css | ||
| 20 | config.php | ||
| 21 | installation dans une application PHP.txt | 19 | installation dans une application PHP.txt |
| 22 | index.php (appel des contrôleurs) | 20 | index.php (appel des contrôleurs) |
| 23 | src/templates/page.php (HTML principal de la page web) | 21 | src/templates/page.php (HTML principal de la page web) |
| 24 | data/page/html/articles.html | 22 | data/page/html/1646148841.html |
| 25 | data/page/images/chirurgien jaune.jpg | 23 | data/page/images/chirurgien jaune.jpg |
| 26 | 24 | ||
| 27 | 25 | ||
| @@ -31,7 +29,8 @@ gràce à un lien symbolique, le programme s'attend à trouver un dossier "trans | |||
| 31 | 29 | ||
| 32 | PHP l'ajoute avec symlink dans index.php | 30 | PHP l'ajoute avec symlink dans index.php |
| 33 | si le lien symbolique /srv/http/ckeditor5/node_modules/ckeditor5/dist/browser/translations | 31 | si le lien symbolique /srv/http/ckeditor5/node_modules/ckeditor5/dist/browser/translations |
| 34 | n'a pas été créé correctement par PHP, donner serveur les droits en écriture ou le faire en BASH | 32 | n'a pas été créé correctement par PHP, permettre au serveur d'écrire dans "browser" ou le faire en BASH |
| 33 | la commande mklink permet de faire la même chose sur un serveur windows, l'option /J créée une jointure et fonctionne sans droit d'admin | ||
| 35 | 34 | ||
| 36 | chemin absolu | 35 | chemin absolu |
| 37 | ln -s /var/www/ckeditor5/node_modules/ckeditor5/dist/translations /var/www/ckeditor5/node_modules/ckeditor5/dist/browser/ | 36 | ln -s /var/www/ckeditor5/node_modules/ckeditor5/dist/translations /var/www/ckeditor5/node_modules/ckeditor5/dist/browser/ |
| @@ -40,39 +39,37 @@ ln -s ../translations node_modules/ckeditor5/dist/browser/ | |||
| 40 | 39 | ||
| 41 | 40 | ||
| 42 | 3/ essai | 41 | 3/ essai |
| 43 | les paramètres dans config.php et les fichiers dans data permettent normalement | 42 | les paramètres dans CKEditor.php et les fichiers dans data permettent normalement |
| 44 | - d'ouvrir l'éditeur | 43 | - d'ouvrir l'éditeur |
| 45 | - de lire des données dans des fichiers et de les insérer dans l'éditeur pour modification | 44 | - de lire des données dans des fichiers et de les insérer dans l'éditeur pour modification |
| 46 | 45 | ||
| 47 | la sortie au "submit" est nettoyée puis se retrouve dans $html_from_editor | 46 | la sortie au "submit" est nettoyée puis se retrouve dans $html_from_editor |
| 48 | 47 | ||
| 49 | 48 | ||
| 50 | 3/ intégration à un projet | 49 | 4/ intégration à un projet |
| 51 | 50 | ||
| 52 | a) index.php et src/templates/page.php sont à remplacer en fonction de notre application | 51 | a) index.php et src/templates/page.php sont à remplacer en fonction de notre application |
| 53 | regarder à l'intérieur et adapter son propre code | ||
| 54 | 52 | ||
| 55 | b) config.php est à personnaliser et/ou à copier ailleurs, | 53 | b) adapter les paramètres dans CKEditor.php, $storage_mode vaut soit 'files' soit 'database' |
| 56 | du moment que les variables à l'intérieur restent disponibles | ||
| 57 | 54 | ||
| 58 | c) le dossier data et ses sous-dossiers ont besoin de droits en écriture | 55 | c) le dossier data et ses sous-dossiers ont besoin de droits en écriture |
| 59 | 56 | ||
| 60 | a) adapter le routeur dans index.php | 57 | d) adapter le routeur dans index.php |
| 61 | 58 | ||
| 62 | b) adapter ce qui suit "// modèle" dans index.php et lib/ckeditor5/create.php pour obtenir les données souhaitées (BDD, fichiers) | 59 | e) adapter la connexion à la BDD si nécéssaire |
| 63 | 60 | ||
| 64 | c) adapter le fichier config.php (vérifier les chemins) | 61 | f) insérer dans chaque page affichant des données créées avec l'éditeur: |
| 65 | 62 | <?= $ckeditor->getCSSOutsideEditorTag() ?> | |
| 66 | d) ajouter <?= $css_editeur ?> dans le <head> | ||
| 67 | ajouter aussi <?= $contenu ?> dans le <body> pour afficher l'éditeur ou du HTML créé par l'éditeur | ||
| 68 | |||
| 69 | e) insérer dans chaque page affichant des données créées avec l'éditeur: | ||
| 70 | <link rel="stylesheet" href="lib/ckeditor5/article_hors_editeur.css" /> | ||
| 71 | l'éditeur ne génère pas de CSS mais seulement du HTML basique, ce CSS imite le rendu à l'intérieur de l'éditeur | 63 | l'éditeur ne génère pas de CSS mais seulement du HTML basique, ce CSS imite le rendu à l'intérieur de l'éditeur |
| 72 | 64 | ||
| 73 | normalement c'est bon fini, ce qui suit est de l'information utile si on souhaite partir de zéro avec NPM et la doc | 65 | g) ajouter dans chaque page insérant l'éditeur: |
| 66 | <?= $ckeditor->getCSSEditorTag() ?> | ||
| 67 | |||
| 68 | h) insérer <?= $editeurHTML ?> dans toutes les pages, | ||
| 69 | quand l'éditeur n'est pas ouvert, ça fait apparaître un lien pour l'ouvrir | ||
| 74 | 70 | ||
| 75 | 71 | ||
| 72 | ce qui suit est de l'information utile si on souhaite partir de zéro avec NPM et la doc | ||
| 76 | 73 | ||
| 77 | 74 | ||
| 78 | 75 | ||
diff --git a/src/integration/ckeditor5/CKEditor.php b/src/integration/ckeditor5/CKEditor.php index f3a60e0..6f630c8 100644 --- a/src/integration/ckeditor5/CKEditor.php +++ b/src/integration/ckeditor5/CKEditor.php | |||
| @@ -1,41 +1,94 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/integration/ckeditor5/CKEditor.php | ||
| 3 | |||
| 2 | class CKEditor | 4 | class CKEditor |
| 3 | { | 5 | { |
| 4 | public const string INTEGRATION_PATH = 'src/integration/ckeditor5/'; | 6 | public const string INTEGRATION_PATH = 'src/integration/ckeditor5/'; |
| 5 | private string $from = 'index.php'; | ||
| 6 | public string $open_editor_link = 'index.php?action=editor'; | ||
| 7 | private string $form_action_file = 'index.php?action=submit'; | ||
| 8 | private string $upload_ajax_url = 'index.php?action=upload_image'; | ||
| 9 | private string $php_ini_max_size; | ||
| 10 | public string $css_editor_tag = ''; | ||
| 11 | public string $css_outside_editor_tag; | ||
| 12 | private string $toolbar_language = 'fr'; | ||
| 13 | public string $storage = 'files'; | ||
| 14 | public string $data_path = 'data/page'; | ||
| 15 | public string $nom_article = "article"; | ||
| 16 | 7 | ||
| 17 | private string $server_root; | 8 | //public const string SERVER_PATH = '/'; |
| 9 | private const string SERVER_PATH = '/ckeditor5/'; | ||
| 10 | private string $server_root; // pour les "imports" en javascript | ||
| 18 | // pour l'importmap: j'ai modifié la version "installation avec CDN de la doc pour utiliser les fichiers locaux | 11 | // pour l'importmap: j'ai modifié la version "installation avec CDN de la doc pour utiliser les fichiers locaux |
| 19 | // l'"importmap" permet d'utiliser "import" (ça ressemble pas mal au python) dans le navigateur comme n'importe quel langage de programmation normal | 12 | // l'"importmap" permet d'utiliser "import" (ça ressemble pas mal au python) dans le navigateur comme n'importe quel langage de programmation normal |
| 20 | 13 | ||
| 14 | private string $storage_mode = 'files'; | ||
| 15 | private string $page = 'accueil'; | ||
| 16 | private string $from = ''; | ||
| 17 | private string $id_article = ''; | ||
| 18 | |||
| 19 | private string $php_ini_max_size; | ||
| 20 | private string $css_editor_tag = ''; | ||
| 21 | private string $css_outside_editor_tag = ''; | ||
| 22 | private string $toolbar_language = 'fr'; | ||
| 23 | private string $data_path = 'data/page'; | ||
| 24 | |||
| 21 | 25 | ||
| 22 | public function __construct() | 26 | public function __construct() |
| 23 | { | 27 | { |
| 24 | $this->makeTranslationSymLink(); | 28 | $this->makeTranslationSymLink(); |
| 25 | $this->from .= isset($_GET['from']) ? '?page=' . $_GET['from'] : ''; | 29 | |
| 26 | $this->php_ini_max_size = $this->returnBytes(ini_get('upload_max_filesize')); // = 2M par défaut dans le php.ini | 30 | $this->php_ini_max_size = $this->returnBytes(ini_get('upload_max_filesize')); // = 2M par défaut dans le php.ini |
| 27 | $this->css_outside_editor_tag = '<link rel="stylesheet" href="' . self::INTEGRATION_PATH . 'article_hors_editeur.css" />'; | 31 | $this->css_outside_editor_tag = '<link rel="stylesheet" href="' . self::INTEGRATION_PATH . 'article_hors_editeur.css" />'; |
| 28 | $this->server_root = $_SERVER['SERVER_NAME'] . '/ckeditor5/'; | 32 | $this->server_root = $_SERVER['SERVER_NAME'] . self::SERVER_PATH; |
| 29 | } | 33 | } |
| 30 | 34 | ||
| 31 | public function checkAjaxReqest() | 35 | // getters |
| 36 | public function getPage(): string | ||
| 37 | { | ||
| 38 | return $this->page; | ||
| 39 | } | ||
| 40 | public function getFrom(): string | ||
| 41 | { | ||
| 42 | return $this->from; | ||
| 43 | } | ||
| 44 | public function getIdArticle(): string | ||
| 45 | { | ||
| 46 | return $this->id_article; | ||
| 47 | } | ||
| 48 | public function getDataPath(): string | ||
| 49 | { | ||
| 50 | return $this->data_path; | ||
| 51 | } | ||
| 52 | public function getCSSOutsideEditorTag(): string | ||
| 53 | { | ||
| 54 | return $this->css_outside_editor_tag; | ||
| 55 | } | ||
| 56 | public function getCSSEditorTag(): string | ||
| 57 | { | ||
| 58 | return $this->css_editor_tag; | ||
| 59 | } | ||
| 60 | public function getStorageMode(): string | ||
| 61 | { | ||
| 62 | return $this->storage_mode; | ||
| 63 | } | ||
| 64 | |||
| 65 | // setters | ||
| 66 | public function setPage(string $page): void | ||
| 67 | { | ||
| 68 | $this->page = $page; | ||
| 69 | } | ||
| 70 | public function setFrom(string $from): void | ||
| 71 | { | ||
| 72 | $this->from = $from; | ||
| 73 | } | ||
| 74 | public function setIdArticle(string $id_article): void | ||
| 75 | { | ||
| 76 | $this->id_article = $id_article; | ||
| 77 | } | ||
| 78 | public function setStorageMode($mode): void | ||
| 79 | { | ||
| 80 | $this->storage_mode = $mode; | ||
| 81 | } | ||
| 82 | |||
| 83 | public function checkAjaxReqest(): void | ||
| 32 | { | 84 | { |
| 33 | // dans un fichier à part parce que trop de lignes | 85 | // dans un fichier à part parce que trop de lignes |
| 34 | require self::INTEGRATION_PATH . 'image_upload.php'; | 86 | require self::INTEGRATION_PATH . 'image_upload.php'; |
| 35 | die; | 87 | die; |
| 36 | } | 88 | } |
| 37 | 89 | ||
| 38 | public function checkSubmitPOST() | 90 | |
| 91 | public function checkSubmitPOST(): void | ||
| 39 | { | 92 | { |
| 40 | $html_from_editor = $this->getAndCleanEditorOutput($_POST["contenu"]); // manipule $_POST['contenu']; | 93 | $html_from_editor = $this->getAndCleanEditorOutput($_POST["contenu"]); // manipule $_POST['contenu']; |
| 41 | 94 | ||
| @@ -47,18 +100,18 @@ class CKEditor | |||
| 47 | die; | 100 | die; |
| 48 | } | 101 | } |
| 49 | 102 | ||
| 50 | public function openEditor() | 103 | public function openEditor(): string |
| 51 | { | 104 | { |
| 52 | // version "minifiée" | 105 | // version "minifiée" |
| 53 | $this->css_editor_tag = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/browser/ckeditor5.css" />'; | 106 | $this->css_editor_tag = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/browser/ckeditor5.css" />'; |
| 54 | // version normale aérée et commentée" | 107 | // version normale aérée et commentée" |
| 55 | $this->css_editor_tag = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/ckeditor5.css" />'; | 108 | $this->css_editor_tag = '<link rel="stylesheet" href="node_modules/ckeditor5/dist/ckeditor5.css" />'; |
| 56 | 109 | ||
| 57 | if($this->storage === 'database') | 110 | if($this->getStorageMode() === 'database') |
| 58 | {} | 111 | {} |
| 59 | elseif($this->storage === 'files') | 112 | elseif($this->getStorageMode() === 'files') |
| 60 | { | 113 | { |
| 61 | $texte = file_get_contents($this->data_path . '/html/' . $this->nom_article . '.html'); | 114 | $texte = file_get_contents($this->data_path . '/html/' . $this->id_article . '.html'); |
| 62 | 115 | ||
| 63 | $texte = trim(addcslashes($texte, "'")); // échapper les simples quotes pour javascript | 116 | $texte = trim(addcslashes($texte, "'")); // échapper les simples quotes pour javascript |
| 64 | //$texte = trim(addslashes($texte)); // échappe ', ", \ et NULL, je sais pas si c'est bien | 117 | //$texte = trim(addslashes($texte)); // échappe ', ", \ et NULL, je sais pas si c'est bien |
| @@ -99,9 +152,9 @@ class CKEditor | |||
| 99 | 152 | ||
| 100 | // conversion des 2M du php.ini en 2000000 | 153 | // conversion des 2M du php.ini en 2000000 |
| 101 | // note: les kibi, mébi et gibi sont inutiles ici | 154 | // note: les kibi, mébi et gibi sont inutiles ici |
| 102 | private function returnBytes($size_str) // chaine du style '2M' | 155 | private function returnBytes(string $size_str): int // chaine du style '2M' |
| 103 | { | 156 | { |
| 104 | switch (substr ($size_str, -1)) | 157 | switch(substr($size_str, -1)) |
| 105 | { | 158 | { |
| 106 | case 'Ki': case 'ki': return (int)$size_str * 1024; | 159 | case 'Ki': case 'ki': return (int)$size_str * 1024; |
| 107 | case 'Mi': case 'mi': return (int)$size_str * 1048576; | 160 | case 'Mi': case 'mi': return (int)$size_str * 1048576; |
| @@ -109,7 +162,7 @@ class CKEditor | |||
| 109 | case 'K': case 'k': return (int)$size_str * 1000; | 162 | case 'K': case 'k': return (int)$size_str * 1000; |
| 110 | case 'M': case 'm': return (int)$size_str * 1000000; | 163 | case 'M': case 'm': return (int)$size_str * 1000000; |
| 111 | case 'G': case 'g': return (int)$size_str * 1000000000; | 164 | case 'G': case 'g': return (int)$size_str * 1000000000; |
| 112 | default: return $size_str; | 165 | default: return (int)$size_str; |
| 113 | } | 166 | } |
| 114 | } | 167 | } |
| 115 | 168 | ||
| @@ -150,4 +203,4 @@ class CKEditor | |||
| 150 | fclose($fichier); | 203 | fclose($fichier); |
| 151 | chmod('data/' . $page . '/' . $nom_fichier, 0666); | 204 | chmod('data/' . $page . '/' . $nom_fichier, 0666); |
| 152 | } | 205 | } |
| 153 | } \ No newline at end of file | 206 | } |
diff --git a/src/integration/ckeditor5/view.php b/src/integration/ckeditor5/view.php index ed1d0f7..bb1f6a2 100644 --- a/src/integration/ckeditor5/view.php +++ b/src/integration/ckeditor5/view.php | |||
| @@ -1,13 +1,21 @@ | |||
| 1 | <?php | 1 | <?php |
| 2 | // src/integration/ckeditor5/view.php | 2 | // src/integration/ckeditor5/view.php |
| 3 | 3 | ||
| 4 | $submit_action = 'index.php?from=' . $this->page . '&action=submit_editor&id=' . $this->id_article; | ||
| 5 | |||
| 6 | $cancel_button = 'index.php?page=' . $this->page; | ||
| 7 | $cancel_button .= !empty($this->id_article) ? '&id=' . $this->id_article : ''; | ||
| 8 | |||
| 9 | $upload_ajax = 'index.php?action=upload_image_editor'; | ||
| 10 | $upload_ajax .= !empty($this->id_article) ? '&id=' . $this->id_article : ''; | ||
| 11 | |||
| 4 | ob_start(); | 12 | ob_start(); |
| 5 | ?> | 13 | ?> |
| 6 | <div class="conteneur_article" > | 14 | <div class="conteneur_article" > |
| 7 | <form action="<?= $this->form_action_file ?>" method="POST" enctype="multipart/form-data" > | 15 | <form action="<?= $submit_action ?>" method="POST" enctype="multipart/form-data" > |
| 8 | <textarea id="editor" name="contenu" ></textarea> | 16 | <textarea id="editor" name="contenu" ></textarea> |
| 9 | <input class="boutonSubmitEditeur" type="submit" value="Valider"> | 17 | <input class="boutonSubmitEditeur" type="submit" value="Valider"> |
| 10 | <a class="boutonAnnuler" href="<?= $this->from ?>" > | 18 | <a class="boutonAnnuler" href="<?= $cancel_button ?>" > |
| 11 | <input type="button" value="Annuler"></a> | 19 | <input type="button" value="Annuler"></a> |
| 12 | <script type="importmap"> | 20 | <script type="importmap"> |
| 13 | { | 21 | { |
| @@ -34,7 +42,7 @@ ob_start(); | |||
| 34 | 42 | ||
| 35 | let editor; | 43 | let editor; |
| 36 | let html_existant = '<?= $texte ?>'; // $texte doit avoir été sécurisé: simple quotes échappées au minimum | 44 | let html_existant = '<?= $texte ?>'; // $texte doit avoir été sécurisé: simple quotes échappées au minimum |
| 37 | let upload_url = '<?= $this->upload_ajax_url ?>'; | 45 | let upload_url = '<?= $upload_ajax ?>'; |
| 38 | 46 | ||
| 39 | // ATTENTION: si l'éditeur ne fonctionne pas, empêcher qu'on puisse cliquer sur Valider! | 47 | // ATTENTION: si l'éditeur ne fonctionne pas, empêcher qu'on puisse cliquer sur Valider! |
| 40 | // Il y a aussi des paramètres dans le fichier de config: ckeditor/webpack.config.js | 48 | // Il y a aussi des paramètres dans le fichier de config: ckeditor/webpack.config.js |
diff --git a/src/view/templates/page.php b/src/view/templates/page.php index 5051a5f..05c7444 100644 --- a/src/view/templates/page.php +++ b/src/view/templates/page.php | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
| 5 | <title></title> | 5 | <title></title> |
| 6 | <link rel="icon" type="image/png" href=""> | 6 | <link rel="icon" type="image/png" href=""> |
| 7 | <?= $ckeditor->css_outside_editor_tag ?> | 7 | <?= $ckeditor->getCSSOutsideEditorTag() ?> |
| 8 | <?= $ckeditor->css_editor_tag ?> | 8 | <?= $ckeditor->getCSSEditorTag() ?> |
| 9 | </head> | 9 | </head> |
| 10 | <body> | 10 | <body> |
| 11 | <div> | 11 | <div> |
