summaryrefslogtreecommitdiff
path: root/index.php
blob: f3880816ffa1d8c8550ed8dfa6d27cbe11f1a26e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// index.php

// code de l'appli principale
$page = isset($_GET['page']) ? $_GET['page'] : 'accueil';
$from = isset($_GET['from']) ? $_GET['from'] : 'accueil'; // pour revenir au même endroit après un submit
$id_article = isset($_GET['id']) ? $_GET['id'] : ''; // page pouvant avoir plusieurs articles


require 'src/integration/ckeditor5/CKEditor.php';
$ckeditor = new CKEditor();
$ckeditor->setStorageMode('files');
$ckeditor->setPage($page);


// routage

// upload images AJAX
if(isset($_GET['action']) && $_GET['action'] === 'upload_image_editor')
{
    $ckeditor->checkAjaxReqest();
}

// submit normal
if(isset($_GET['action']) && $_GET['action'] === 'submit_editor') // HTML envoyé par l'éditeur
{
    $ckeditor->setFrom($from);
    $ckeditor->setIdArticle($id_article);
    $ckeditor->checkSubmitPOST();
}

/*$articles = [];
foreach($articles as $article)
{}*/

// ouvrir l'éditeur
if(isset($_GET['action']) && $_GET['action'] === 'open_editor')
{
    $ckeditor->setIdArticle($id_article);
    $editeurHTML = $ckeditor->openEditor();
}
else // affichage article
{
    $ckeditor->setIdArticle('1646148841');
    if($ckeditor->getStorageMode() === 'database')
    {
        // ton code
    }
    elseif($ckeditor->getStorageMode() === 'files')
    {
        $texte = file_get_contents($ckeditor->getDataPath() . '/html/' . $ckeditor->getIdArticle() . '.html');
        //$texte = trim(addcslashes($texte, "'")); // échappe seulement les simples quotes
        $texte = trim($texte);
    }
    $editeurHTML = '<div class="conteneur_article" >' . $texte . '</div>
        <p><a href="index.php?page=' . $ckeditor->getPage() . '&action=open_editor&id=' . $ckeditor->getIdArticle() . '">ouvrir l\'éditeur</a></p>';
}

require 'src/view/templates/page.php';