summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgit-pc-greta <ordipolo@gmx.fr>2025-01-30 16:27:18 +0100
committergit-pc-greta <ordipolo@gmx.fr>2025-01-30 16:27:18 +0100
commit376bb178196bdea3604e230436dbabb8259ce74c (patch)
treebeb165c128ba60b780cebd2603980dd41af750da
parent63759dbbf023daa8f7f310b914a04310a4770154 (diff)
downloadckeditor5-376bb178196bdea3604e230436dbabb8259ce74c.zip
declare(strict_types=1);
-rw-r--r--index.php28
-rw-r--r--installation dans une application PHP.txt15
-rw-r--r--src/integration/ckeditor5/CKEditor.php4
-rw-r--r--src/integration/ckeditor5/image_upload.php2
-rw-r--r--src/integration/ckeditor5/view.php2
-rw-r--r--src/view/templates/page.php20
6 files changed, 38 insertions, 33 deletions
diff --git a/index.php b/index.php
index d998d96..a7815be 100644
--- a/index.php
+++ b/index.php
@@ -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
72require '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
85foreach($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
11npm install ckeditor5 11npm install ckeditor5
12composer require htmlawed/htmlawed 12composer require htmlawed/htmlawed
13 13
14les 9 fichiers récupérés par le git clone 14les fichiers récupérés par le git clone, src/integration/ckeditor5/ est à insérer dans son projet:
15src/integration/ckeditor5/CKEditor.php 15src/integration/ckeditor5/CKEditor.php
16src/integration/ckeditor5/view.php 16src/integration/ckeditor5/view.php
17src/integration/ckeditor5/image_upload.php 17src/integration/ckeditor5/image_upload.php
18src/integration/ckeditor5/articles_hors_editeur.css 18src/integration/ckeditor5/articles_hors_editeur.css
19installation dans une application PHP.txt 19installation dans une application PHP.txt
20index.php (appel des contrôleurs) 20index.php (appel des contrôleurs)
21src/templates/page.php (HTML principal de la page web)
22data/page/html/1646148841.html 21data/page/html/1646148841.html
22data/page/html/1646148842.html
23data/page/images/chirurgien jaune.jpg 23data/page/images/chirurgien jaune.jpg
24data/page/images/garfield4.png
24 25
25 26
262/ lien symbolique nécéssaire pour trouver les traductions (commande pour debian): 272/ 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
494/ intégration à un projet 504/ intégration à un projet
50 51
51a) index.php et src/templates/page.php sont à remplacer en fonction de notre application 52a) insérer le dossier: src/integration/ckeditor5/
52 53
53b) adapter les paramètres dans CKEditor.php, $storage_mode vaut soit 'files' soit 'database' 54b) adapter les paramètres dans CKEditor.php, $storage_mode vaut soit 'files' soit 'database'
54 55
55c) le dossier data et ses sous-dossiers ont besoin de droits en écriture 56c) les autres fichiers sont un exemple pour y prendre du code,
57=> piocher dans index.php!
56 58
57d) adapter le routeur dans index.php 59d) le dossier data et ses sous-dossiers ont besoin de droits en écriture
58 60
59e) adapter la connexion à la BDD si nécéssaire 61e) 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
65g) ajouter dans chaque page insérant l'éditeur: 67g) ajouter dans chaque page insérant l'éditeur:
66<?= $ckeditor->getCSSEditorTag() ?> 68<?= $ckeditor->getCSSEditorTag() ?>
67 69
68h) insérer <?= $editeurHTML ?> dans toutes les pages,
69quand l'éditeur n'est pas ouvert, ça fait apparaître un lien pour l'ouvrir
70
71 70
72ce qui suit est de l'information utile si on souhaite partir de zéro avec NPM et la doc 71ce 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
4declare(strict_types=1);
5
4class CKEditor 6class 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
4declare(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
4declare(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
13foreach ($articles_content as $article)
14{
15 echo $article;
16}
17?>
18 </div>
19</body>
20</html>