diff options
author | git-pc-greta <ordipolo@gmx.fr> | 2025-01-30 16:27:18 +0100 |
---|---|---|
committer | git-pc-greta <ordipolo@gmx.fr> | 2025-01-30 16:27:18 +0100 |
commit | 376bb178196bdea3604e230436dbabb8259ce74c (patch) | |
tree | beb165c128ba60b780cebd2603980dd41af750da | |
parent | 63759dbbf023daa8f7f310b914a04310a4770154 (diff) | |
download | ckeditor5-376bb178196bdea3604e230436dbabb8259ce74c.zip |
declare(strict_types=1);
-rw-r--r-- | index.php | 28 | ||||
-rw-r--r-- | installation dans une application PHP.txt | 15 | ||||
-rw-r--r-- | src/integration/ckeditor5/CKEditor.php | 4 | ||||
-rw-r--r-- | src/integration/ckeditor5/image_upload.php | 2 | ||||
-rw-r--r-- | src/integration/ckeditor5/view.php | 2 | ||||
-rw-r--r-- | src/view/templates/page.php | 20 |
6 files changed, 38 insertions, 33 deletions
@@ -49,7 +49,7 @@ elseif($ckeditor->getStorageMode() === 'files') | |||
49 | $texte = trim(file_get_contents(CKEditor::DATA_PATH . '/html/' . $id . '.html')); | 49 | $texte = trim(file_get_contents(CKEditor::DATA_PATH . '/html/' . $id . '.html')); |
50 | //$texte = addslashes($texte); // échappe ', ", \ et NULL, je sais pas si c'est bien | 50 | //$texte = addslashes($texte); // échappe ', ", \ et NULL, je sais pas si c'est bien |
51 | 51 | ||
52 | // ouvrir l'éditeur sur un des articles ou aucun | 52 | // vue - afficher des articles et éventuellement l'éditeur dans un des articles |
53 | if(isset($_GET['action']) && $_GET['action'] === 'open_editor') | 53 | if(isset($_GET['action']) && $_GET['action'] === 'open_editor') |
54 | { | 54 | { |
55 | if($id === $id_article) | 55 | if($id === $id_article) |
@@ -62,11 +62,31 @@ elseif($ckeditor->getStorageMode() === 'files') | |||
62 | $articles_content[] = $ckeditor->displayArticle($id, $texte); | 62 | $articles_content[] = $ckeditor->displayArticle($id, $texte); |
63 | } | 63 | } |
64 | } | 64 | } |
65 | else // affichage article | 65 | else |
66 | { | 66 | { |
67 | $articles_content[] = $ckeditor->displayArticle($id, $texte); | 67 | $articles_content[] = $ckeditor->displayArticle($id, $texte); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | // vue | |
72 | require 'src/view/templates/page.php'; | 72 | ?> |
73 | <!DOCTYPE html> | ||
74 | <html lang="fr"> | ||
75 | <head> | ||
76 | <meta charset="utf-8"> | ||
77 | <title></title> | ||
78 | <link rel="icon" type="image/png" href=""> | ||
79 | <?= $ckeditor->getCSSOutsideEditorTag() ?> | ||
80 | <?= $ckeditor->getCSSEditorTag() ?> | ||
81 | </head> | ||
82 | <body> | ||
83 | <div> | ||
84 | <?php | ||
85 | foreach($articles_content as $article) | ||
86 | { | ||
87 | echo $article; | ||
88 | } | ||
89 | ?> | ||
90 | </div> | ||
91 | </body> | ||
92 | </html> | ||
diff --git a/installation dans une application PHP.txt b/installation dans une application PHP.txt index 6d1b108..76ec201 100644 --- a/installation dans une application PHP.txt +++ b/installation dans une application PHP.txt | |||
@@ -11,16 +11,17 @@ 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 9 fichiers récupérés par le git clone | 14 | les fichiers récupérés par le git clone, src/integration/ckeditor5/ est à insérer dans son projet: |
15 | src/integration/ckeditor5/CKEditor.php | 15 | src/integration/ckeditor5/CKEditor.php |
16 | src/integration/ckeditor5/view.php | 16 | src/integration/ckeditor5/view.php |
17 | src/integration/ckeditor5/image_upload.php | 17 | src/integration/ckeditor5/image_upload.php |
18 | src/integration/ckeditor5/articles_hors_editeur.css | 18 | src/integration/ckeditor5/articles_hors_editeur.css |
19 | installation dans une application PHP.txt | 19 | installation dans une application PHP.txt |
20 | index.php (appel des contrôleurs) | 20 | index.php (appel des contrôleurs) |
21 | src/templates/page.php (HTML principal de la page web) | ||
22 | data/page/html/1646148841.html | 21 | data/page/html/1646148841.html |
22 | data/page/html/1646148842.html | ||
23 | data/page/images/chirurgien jaune.jpg | 23 | data/page/images/chirurgien jaune.jpg |
24 | data/page/images/garfield4.png | ||
24 | 25 | ||
25 | 26 | ||
26 | 2/ lien symbolique nécéssaire pour trouver les traductions (commande pour debian): | 27 | 2/ lien symbolique nécéssaire pour trouver les traductions (commande pour debian): |
@@ -48,13 +49,14 @@ la sortie au "submit" est nettoyée puis se retrouve dans $html_from_editor | |||
48 | 49 | ||
49 | 4/ intégration à un projet | 50 | 4/ intégration à un projet |
50 | 51 | ||
51 | a) index.php et src/templates/page.php sont à remplacer en fonction de notre application | 52 | a) insérer le dossier: src/integration/ckeditor5/ |
52 | 53 | ||
53 | b) adapter les paramètres dans CKEditor.php, $storage_mode vaut soit 'files' soit 'database' | 54 | b) adapter les paramètres dans CKEditor.php, $storage_mode vaut soit 'files' soit 'database' |
54 | 55 | ||
55 | c) le dossier data et ses sous-dossiers ont besoin de droits en écriture | 56 | c) les autres fichiers sont un exemple pour y prendre du code, |
57 | => piocher dans index.php! | ||
56 | 58 | ||
57 | d) adapter le routeur dans index.php | 59 | d) le dossier data et ses sous-dossiers ont besoin de droits en écriture |
58 | 60 | ||
59 | e) adapter la connexion à la BDD si nécéssaire | 61 | e) adapter la connexion à la BDD si nécéssaire |
60 | 62 | ||
@@ -65,9 +67,6 @@ l'éditeur ne génère pas de CSS mais seulement du HTML basique, ce CSS imite l | |||
65 | g) ajouter dans chaque page insérant l'éditeur: | 67 | g) ajouter dans chaque page insérant l'éditeur: |
66 | <?= $ckeditor->getCSSEditorTag() ?> | 68 | <?= $ckeditor->getCSSEditorTag() ?> |
67 | 69 | ||
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 | ||
70 | |||
71 | 70 | ||
72 | ce qui suit est de l'information utile si on souhaite partir de zéro avec NPM et la doc | 71 | ce qui suit est de l'information utile si on souhaite partir de zéro avec NPM et la doc |
73 | 72 | ||
diff --git a/src/integration/ckeditor5/CKEditor.php b/src/integration/ckeditor5/CKEditor.php index 9fa0f42..58fa42c 100644 --- a/src/integration/ckeditor5/CKEditor.php +++ b/src/integration/ckeditor5/CKEditor.php | |||
@@ -1,6 +1,8 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/integration/ckeditor5/CKEditor.php | 2 | // src/integration/ckeditor5/CKEditor.php |
3 | 3 | ||
4 | declare(strict_types=1); | ||
5 | |||
4 | class CKEditor | 6 | class CKEditor |
5 | { | 7 | { |
6 | public const string INTEGRATION_PATH = 'src/integration/ckeditor5/'; | 8 | public const string INTEGRATION_PATH = 'src/integration/ckeditor5/'; |
@@ -17,7 +19,7 @@ class CKEditor | |||
17 | private string $from = ''; | 19 | private string $from = ''; |
18 | //private string $id_article = ''; | 20 | //private string $id_article = ''; |
19 | 21 | ||
20 | private string $php_ini_max_size; | 22 | private int $php_ini_max_size; |
21 | private string $css_editor_tag = ''; | 23 | private string $css_editor_tag = ''; |
22 | private string $css_outside_editor_tag = ''; | 24 | private string $css_outside_editor_tag = ''; |
23 | private string $toolbar_language = 'fr'; | 25 | private string $toolbar_language = 'fr'; |
diff --git a/src/integration/ckeditor5/image_upload.php b/src/integration/ckeditor5/image_upload.php index d549690..5cef369 100644 --- a/src/integration/ckeditor5/image_upload.php +++ b/src/integration/ckeditor5/image_upload.php | |||
@@ -1,6 +1,8 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/integration/ckeditor5/image_upload.php | 2 | // src/integration/ckeditor5/image_upload.php |
3 | 3 | ||
4 | declare(strict_types=1); | ||
5 | |||
4 | // le "simple upload adapter" envoie un POST appelé: $_FILES['upload'] | 6 | // le "simple upload adapter" envoie un POST appelé: $_FILES['upload'] |
5 | // en retour il attend impérativement des données au format JSON du genre: {"url": "data/page/images/monfichier.jpg"} | 7 | // en retour il attend impérativement des données au format JSON du genre: {"url": "data/page/images/monfichier.jpg"} |
6 | // cette adresse doit permettre à l'éditeur de télécharger l'image afficher de manière normale: <img scr="data/page/images/monfichier.jpg"> | 8 | // cette adresse doit permettre à l'éditeur de télécharger l'image afficher de manière normale: <img scr="data/page/images/monfichier.jpg"> |
diff --git a/src/integration/ckeditor5/view.php b/src/integration/ckeditor5/view.php index 4bcad52..b6e6a5f 100644 --- a/src/integration/ckeditor5/view.php +++ b/src/integration/ckeditor5/view.php | |||
@@ -1,6 +1,8 @@ | |||
1 | <?php | 1 | <?php |
2 | // src/integration/ckeditor5/view.php | 2 | // src/integration/ckeditor5/view.php |
3 | 3 | ||
4 | declare(strict_types=1); | ||
5 | |||
4 | $submit_action = 'index.php?from=' . $this->page . '&action=submit_editor&id=' . $id; | 6 | $submit_action = 'index.php?from=' . $this->page . '&action=submit_editor&id=' . $id; |
5 | 7 | ||
6 | $cancel_button = 'index.php?page=' . $this->page; | 8 | $cancel_button = 'index.php?page=' . $this->page; |
diff --git a/src/view/templates/page.php b/src/view/templates/page.php deleted file mode 100644 index 3ea227a..0000000 --- a/src/view/templates/page.php +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | <!DOCTYPE html> | ||
2 | <html lang="fr"> | ||
3 | <head> | ||
4 | <meta charset="utf-8"> | ||
5 | <title></title> | ||
6 | <link rel="icon" type="image/png" href=""> | ||
7 | <?= $ckeditor->getCSSOutsideEditorTag() ?> | ||
8 | <?= $ckeditor->getCSSEditorTag() ?> | ||
9 | </head> | ||
10 | <body> | ||
11 | <div> | ||
12 | <?php | ||
13 | foreach ($articles_content as $article) | ||
14 | { | ||
15 | echo $article; | ||
16 | } | ||
17 | ?> | ||
18 | </div> | ||
19 | </body> | ||
20 | </html> | ||