aboutsummaryrefslogtreecommitdiff
path: root/class/class.aff.php
blob: d9bb56b17fac8df896f215a4f123a7c2504e74b7 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php

class Aff
{

    private $session;

    private static $edit = 2;


    // ____________________________________________________ F U N ______________________________________________

    public function __construct($session)
    {
        $this->setsession($session);
    }

    public function lecture(Art $art)
    {
        if ($art->secure() == 1) {
            echo '<span class="alert"><h4>cet article est privé</h4></span>';
        }
        if ($art->secure() == 2) {
            echo "<span class=\"alert\"><h4>cet article n'est pas publié</h4></span>";
        }

        if ($this->session() >= $art->secure()) {
            ?>
            <style type="text/css">
            article {
                background: <?= $art->couleurbkg() ?>;
                color: <?= $art->couleurtext() ?>;			
            }
            
            a {
                color: <?= $art->couleurlien() ?>;
            }
            <?= $art->css() ?>
            </style>
            <article>
            <h1><?= $art->titre() ?></h1>
            <h2><?= $art->soustitre() ?></h2>
            <p><?= $art->html('html') ?></p>
            </article>
            <?php

        }
    }

    public function edit(Art $art)
    {
        if ($this->session() >= self::$edit) {

            ?>
		<article>
            <form class="edit" action="?id=<?= $art->id() ?>" method="post">
                <input type="submit" value="modifier">
                <label for="titre">Titre :</label>
                <input type="text" name="titre" id="titre" value="<?= $art->titre(); ?>">
                <label for="soustitre">Sous-titre :</label>
                <input type="text" name="soustitre" id="soustitre" value="<?= $art->soustitre(); ?>">
                <label for="intro">Introduction :</label>
                <input type="text" name="intro" id="intro" value="<?= $art->intro(); ?>">
                <label for="tag">Tag(s) :</label>
                <input type="text" name="tag" id="tag" value="<?= $art->tag(); ?>">
                <label for="css">Styles CSS :</label>
                <textarea name="css" id="css"><?= $art->css(); ?></textarea>
                <label for="secure">Niveau de sécuritée :</label>
                <select name="secure" id="secure">
                    <option value="0" <?= $art->secure() == 0 ? 'selected' : '' ?>>0</option>
                    <option value="1" <?= $art->secure() == 1 ? 'selected' : '' ?>>1</option>
                    <option value="2" <?= $art->secure() == 2 ? 'selected' : '' ?>>2</option>
                </select>
                <label for="couleurtext">Couleur du texte :</label>
                <input type="color" name="couleurtext" value="<?= $art->couleurtext() ?>" id="couleurtext">
                <label for="couleurbkg">Couleur de l'arrière plan :</label>
                <input type="color" name="couleurbkg" value="<?= $art->couleurbkg() ?>" id="couleurbkg">
                <label for="couleurlien">Couleur des liens :</label>
                <input type="color" name="couleurlien" value="<?= $art->couleurlien() ?>" id="couleurlien">
                <label for="html">Contenu :</label>
                <textarea name="html" id="html" ><?= $art->html('md'); ?></textarea>
                <input type="hidden" name="datecreation" value="<?= $art->datecreation('string'); ?>">
                <input type="hidden" name="id" value="<?= $art->id() ?>">
                <input type="hidden" name="action" value="update">
                <input type="submit" value="modifier">
            </form>
		</article>

		<?php

}

}

public function head($title)
{
    ?>
        <head>
            <meta charset="utf8" />
            <link href="/css/style.css" rel="stylesheet" />
            <title><?= $title ?></title>
        </head>
        <?php

    }

    public function home($list)
    {
        echo '<ul>';
        foreach ($list as $item) {
            echo '<li><a href="?id=' . $item['id'] . '">' . $item['titre'] . '</a> - ' . $item['intro'];
            if ($this->session() >= 2) {
                echo ' - <a href="?id=' . $item['id'] . '&edit=1">modifier</a></li>';
            } else {
                echo '</li>';
            }
        }
        echo ' </ul> ';
    }

    public function aside($list)
    {
        if ($this->session() >= 2) {
            echo '<aside><ul>';
            foreach ($list as $item) {
                echo '<li><a href="?id=' . $item['id'] . '&edit=1">' . $item['titre'] . '</a> - <code>[' . $item['titre'] . '](?id=' . $item['id'] . ')</code>';


            }
            echo ' </ul></aside> ';
        }
    }

    public function nav($app)
    {
        ?>
        <nav>
        <?= $this->session() ?>
        </br>
        <a href="?" >home</a>
        </br>
        <?php
        if ($this->session() >= 1) {
            if (isset($_GET['id'])) {
                ?>
            <form action="?id=<?= $_GET['id'] ?>" method="post">
            <input type="hidden" name="action" value="logout">
            <input type="submit" value="disconnect">
            </form>
            <?php

        }
        if (isset($_GET['id']) and $app->exist($_GET['id']) and $this->session() == 2) {
            ?>
                    <a href="?id=<?= $_GET['id'] ?>" target="_blank">display</a>
        </br>
                    <a href="?id=<?= $_GET['id'] ?>&edit=1" >edit</a>
                <?php

            }
        } else {
            if (isset($_GET['id'])) {
                ?>
            <form action="?id=<?= $_GET['id'] ?>" method="post">
            <input type="hidden" name="action" value="login">
            <input type="password" name="pass" id="pass" placeholder="password">
            <input type="submit" value="connect">
            </form>
            <?php

        }
    }
    ?>
        </nav>
        <?php

    }

   //______________________________________________________ S E T _________________________________________________

    public function setsession($session)
    {
        if ($session <= 2 and $session >= 0) {
            $session = intval($session);
            $this->session = $session;
        }
    }

   //______________________________________________________ G E T _________________________________________________

    public function session()
    {
        return $this->session;
    }


}



?>