summaryrefslogtreecommitdiff
path: root/view/melaine.php
blob: cdb24ccb68bde4f57baa06e7c4e4c1dbad36aee3 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
// view/melaine.php

// variable $css
ob_start();
?>
        <link rel="stylesheet" type="text/css" href="public/<?= $page_actuelle ?>.css" />
        <link rel="stylesheet" type="text/css" href="public/donnees_hors_editeur.css" />
<?php
$css = ob_get_clean();


//variable $js
ob_start();
?>
        <script type="text/javascript" src="public/main.js" ></script>
<?php
if(isset($_GET['action']) && $_GET['action'] == 'editor')
{

    // bibliothèques JS ckeditor
?>
        <script src="lib/ckeditor5/build/ckeditor.js"></script>
<?php
}
$js = ob_get_clean();


// variable $header
ob_start();
echo "\n";
?>
            <header>
                <div id="titre" >
                    <span class="police_titre" >Melaine Favennec</span>
                </div>
                <div id="photo" ></div>
            </header>
 <?php
$header = ob_get_clean();


// variable $content
ob_start();
if($_SESSION['admin'] == 1)
{
    // à la place du bouton après rechargement 
    if(isset($_GET['action']) && $_GET['action'] == 'editor' && !isset($_GET['article']))
    {
        echo("<p>Rédiger un nouvel article</p>");
        echo($editeurHTML); // injection de template-editor.php
    }

    // bouton
    else
    {
?>
                <p class="boutonArticle" >
                    <a href="index.php?page=melaine&action=editor" >
                        Nouvel article
                    </a>
                </p>
<?php
    }
}

// on pourrait paginer avec des onglets contenant 5 ou 10 articles chacun

// tableau articles[] du dernier au premier (1 case = 1 article)
$j = count($articles);
foreach ($articles as $article)
{   
    // la div invisible sert à la compensation des liens d'ancre #
?>
                <div class="zoneVideNav" ></div>
                <article id="article<?= $j ?>" >
<?php

    // remplacer un article par l'éditeur
    if($_SESSION['admin'] == 1 && isset($_GET['action']) && $_GET['action'] == 'editor' && isset($_GET['article']) && $_GET['article'] == $j)
    {
        // on pourrait utiliser le timedate, ou encore le nom de l'article
        echo("\n<p>Modifier l'article " . $j . "</p>");
        //echo("<p>Modification d'un article</p>");
        echo "\n";

        echo($editeurHTML); // injection de template-editor.php
    }

    // placer un article
    else
    {
        // et voila
        echo($article . "\n");

        // bouton
        if($_SESSION['admin'] == 1)
        {
        ?>
                        <p class="boutonArticle" >
                            <a href="index.php?page=melaine&action=editor&article=<?= $j ?>#article<?= $j ?>" >
                                Modifier cet article
                            </a>
                            &nbsp;<!-- un espace -->
                            <a href="index.php?page=melaine&action=suppression&article=<?= $j ?>" onclick="confirmerSuppression()" >
                                Supprimer cet article
                            </a>
                        </p>
        <?php
        }
    }

?>
            </article>
<?php
    $j--;
}
$content = ob_get_clean();