diff options
Diffstat (limited to 'class')
-rw-r--r-- | class/class.aff.php | 25 | ||||
-rw-r--r-- | class/class.app.php | 23 | ||||
-rw-r--r-- | class/class.art.php | 15 |
3 files changed, 43 insertions, 20 deletions
diff --git a/class/class.aff.php b/class/class.aff.php index d9bb56b..46402f4 100644 --- a/class/class.aff.php +++ b/class/class.aff.php @@ -52,7 +52,7 @@ class Aff if ($this->session() >= self::$edit) { ?> - <article> + <article class="edit"> <form class="edit" action="?id=<?= $art->id() ?>" method="post"> <input type="submit" value="modifier"> <label for="titre">Titre :</label> @@ -62,10 +62,10 @@ class Aff <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(); ?>"> + <input type="text" name="tag" id="tag" value="<?= $art->tag('string'); ?>"> <label for="css">Styles CSS :</label> <textarea name="css" id="css"><?= $art->css(); ?></textarea> - <label for="secure">Niveau de sécuritée :</label> + <label for="secure">Niveau de sécurité :</label> <select name="secure" id="secure"> <option value="0" <?= $art->secure() == 0 ? 'selected' : '' ?>>0</option> <option value="1" <?= $art->secure() == 1 ? 'selected' : '' ?>>1</option> @@ -104,6 +104,9 @@ public function head($title) } + + + public function home($list) { echo '<ul>'; @@ -118,6 +121,22 @@ public function head($title) echo ' </ul> '; } + public function tag($getlist, $tag) + { + echo '<ul>'; + foreach ($getlist as $item) { + if (in_array($tag, $item->tag('array'))) { + 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) { diff --git a/class/class.app.php b/class/class.app.php index 00c9095..69d6d92 100644 --- a/class/class.app.php +++ b/class/class.app.php @@ -32,7 +32,7 @@ class App $q->bindValue(':titre', $art->titre()); $q->bindValue(':soustitre', $art->soustitre()); $q->bindValue(':intro', $art->intro()); - $q->bindValue(':tag', $art->tag()); + $q->bindValue(':tag', $art->tag('string')); $q->bindValue(':datecreation', $now->format('Y-m-d H:i:s')); $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s')); $q->bindValue(':css', $art->css()); @@ -65,7 +65,7 @@ class App } - public function getlist() + public function getlister() { $list = []; @@ -76,12 +76,12 @@ class App return $list; } - public function list() + public function lister() { $req = $this->bdd->query('SELECT * FROM art ORDER BY id'); $donnees = $req->fetchAll(PDO::FETCH_ASSOC); return $donnees; - + $req->closeCursor(); } @@ -105,12 +105,12 @@ class App $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); $q = $this->bdd->prepare('UPDATE art SET titre = :titre, soustitre = :soustitre, intro = :intro, tag = :tag, datecreation = :datecreation, datemodif = :datemodif, css = :css, html = :html, secure = :secure, couleurtext = :couleurtext, couleurbkg = :couleurbkg, couleurlien = :couleurlien WHERE id = :id'); - + $q->bindValue(':id', $art->id()); $q->bindValue(':titre', $art->titre()); $q->bindValue(':soustitre', $art->soustitre()); $q->bindValue(':intro', $art->intro()); - $q->bindValue(':tag', $art->tag()); + $q->bindValue(':tag', $art->tag('string')); $q->bindValue(':datecreation', $art->datecreation('string')); $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s')); $q->bindValue(':css', $art->css()); @@ -127,19 +127,16 @@ class App public function login($pass) { - if(strip_tags($pass) == $this->admin) - { + if (strip_tags($pass) == $this->admin) { var_dump($this->admin); return $level = 2; - } - elseif(strip_tags($pass) == $this->secure) - { - return $level = 1; + } elseif (strip_tags($pass) == $this->secure) { + return $level = 1; } } public function logout() - { + { return $level = 0; } diff --git a/class/class.art.php b/class/class.art.php index cc7a0d0..897cd0b 100644 --- a/class/class.art.php +++ b/class/class.art.php @@ -44,7 +44,7 @@ class Art } } - public function default() + public function reset() { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); @@ -83,9 +83,14 @@ class Art return $this->intro; } - public function tag() + public function tag($option) { - return $this->tag; + if ($option == 'string') { + $tag = implode(", ", $this->tag); + } elseif ($option == 'array') { + $tag = $this->tag; + } + return $tag; } public function datecreation($option) @@ -178,7 +183,9 @@ class Art public function settag($tag) { if (strlen($tag) < self::$len and is_string($tag)) { - $this->tag = strip_tags(trim(strtolower($tag))); + $tag = strip_tags(trim(strtolower($tag))); + $taglist = explode(", ", $tag); + $this->tag = $taglist; } } |