aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--class/class.aff.php25
-rw-r--r--class/class.app.php23
-rw-r--r--class/class.art.php15
-rw-r--r--public/css/style.css17
-rw-r--r--public/w/index.php11
5 files changed, 64 insertions, 27 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;
}
}
diff --git a/public/css/style.css b/public/css/style.css
index 54326c9..163ca7d 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -23,12 +23,23 @@ p{
font-size: 1em;
}
+em {
+ opacity: 0.8;
+}
+
+img {
+ width: 90%;
+ max-width: 1000px;
+}
+
article {
text-align: justify;
- padding: 3%;
+ padding: 3%;
+ line-height: 1.2em;
}
-article p{
+article .edit {
+ text-align: left;
}
article input, textarea, select {
@@ -42,7 +53,7 @@ article input, textarea, select {
border-style: unset;
}
#html{
- height: 400px;
+ height: 1000px;
}
#css{
diff --git a/public/w/index.php b/public/w/index.php
index f12e7f4..93d9f46 100644
--- a/public/w/index.php
+++ b/public/w/index.php
@@ -83,7 +83,7 @@ if (isset($_GET['id'])) {
if (isset($_GET['edit']) and $_GET['edit'] == 1) {
$aff->edit($art);
- $aff->aside($app->list());
+ $aff->aside($app->lister());
} else {
$aff->lecture($art);
@@ -92,8 +92,7 @@ if (isset($_GET['id'])) {
if (isset($_POST['action'])) {
if ($_POST['action'] == 'new') {
$art = new Art($_GET);
- $art->default();
- var_dump($art);
+ $art->reset();
$app->add($art);
header('Location: ?id=' . $_GET['id'] . '&edit=1');
}
@@ -107,9 +106,13 @@ if (isset($_GET['id'])) {
}
}
+} elseif (isset($_GET['tag'])) {
+ echo '<h4>' . $_GET['tag'] . '</h4>';
+ $aff->tag($app->getlister(), $_GET['tag']);
+
} else {
echo "<h4>Bienvenue sur ce site.</h4>";
- $aff->home($app->list());
+ $aff->home($app->lister());
}
echo '</body>';