aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-04-12 16:54:59 +0200
committervincent-peugnet <v.peugnet@free.fr>2018-04-12 16:54:59 +0200
commit1b6f5e650fa774cda77d511bf4cbdc638a2b42f6 (patch)
treeec560104a579ac0e21de40d1666f3da80bc8862a
parent552dd49b00cedb168c95cdf841971e93b0ad678d (diff)
downloadwcms-1b6f5e650fa774cda77d511bf4cbdc638a2b42f6.tar.gz
wcms-1b6f5e650fa774cda77d511bf4cbdc638a2b42f6.zip
delete_update_media_blank
-rw-r--r--.gitignore4
-rw-r--r--class/class.aff.php109
-rw-r--r--class/class.app.php6
-rw-r--r--class/class.art.php23
-rw-r--r--fn/fn.php5
-rw-r--r--public/css/style.css28
-rw-r--r--public/media/vac.pngbin0 -> 941802 bytes
-rw-r--r--public/w/index.php23
8 files changed, 152 insertions, 46 deletions
diff --git a/.gitignore b/.gitignore
index 19c393f..a027495 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
vendor/*
-config.php \ No newline at end of file
+config.php
+error_log
+w/img/*
diff --git a/class/class.aff.php b/class/class.aff.php
index 46402f4..16d77ca 100644
--- a/class/class.aff.php
+++ b/class/class.aff.php
@@ -35,11 +35,15 @@ class Aff
a {
color: <?= $art->couleurlien() ?>;
}
+
+ a[target="_blank"] {
+ color: <?= $art->couleurlienblank() ?>;
+ }
<?= $art->css() ?>
</style>
<article>
<h1><?= $art->titre() ?></h1>
- <h2><?= $art->soustitre() ?></h2>
+ <h6><?= $art->soustitre() ?></h6>
<p><?= $art->html('html') ?></p>
</article>
<?php
@@ -53,8 +57,7 @@ class Aff
?>
<article class="edit">
- <form class="edit" action="?id=<?= $art->id() ?>" method="post">
- <input type="submit" value="modifier">
+ <form action="?id=<?= $art->id() ?>" method="post">
<label for="titre">Titre :</label>
<input type="text" name="titre" id="titre" value="<?= $art->titre(); ?>">
<label for="soustitre">Sous-titre :</label>
@@ -77,12 +80,16 @@ class Aff
<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="couleurlienblank">Couleur des liens externes :</label>
+ <input type="color" name="couleurlienblank" value="<?= $art->couleurlienblank() ?>" id="couleurlienblank">
<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">
+ <div class="submit">
+ <input type="submit" name="action" value="update">
+ <input type="submit" name="action" value="delete">
+ </div>
</form>
</article>
@@ -97,6 +104,7 @@ public function head($title)
?>
<head>
<meta charset="utf8" />
+ <meta name="viewport" content="width=device-width" />
<link href="/css/style.css" rel="stylesheet" />
<title><?= $title ?></title>
</head>
@@ -109,16 +117,25 @@ public function head($title)
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>';
+ ?>
+ <form action="./" method="get">
+ <input type="text" name="id" id="id" placeholder="identifiant article" required>
+ <input type="submit" value="accéder">
+ </form>
+ <?php
+
+ if ($this->session() == 2) {
+ 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> ';
}
- echo ' </ul> ';
}
public function tag($getlist, $tag)
@@ -156,40 +173,62 @@ public function head($title)
<nav>
<?= $this->session() ?>
</br>
- <a href="?" >home</a>
+ <a href="?">home</a>
+
</br>
<?php
- if ($this->session() >= 1) {
- if (isset($_GET['id'])) {
+
+ if (isset($_GET['id']) and $app->exist($_GET['id'])) {
+ if ($this->session() == 0) {
?>
- <form action="?id=<?= $_GET['id'] ?>" method="post">
- <input type="hidden" name="action" value="logout">
- <input type="submit" value="disconnect">
- </form>
- <?php
+ <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
- }
- if (isset($_GET['id']) and $app->exist($_GET['id']) and $this->session() == 2) {
- ?>
+ }
+ if ($this->session() >= 1) {
+ ?>
+ <form action="?id=<?= $_GET['id'] ?>" method="post">
+ <input type="hidden" name="action" value="logout">
+ <input type="submit" value="disconnect">
+ </form>
+ <?php
+
+ if ($this->session() == 2) {
+ ?>
<a href="?id=<?= $_GET['id'] ?>" target="_blank">display</a>
- </br>
+ </br>
<a href="?id=<?= $_GET['id'] ?>&edit=1" >edit</a>
- <?php
+ <?php
+
+ }
}
} else {
- if (isset($_GET['id'])) {
+ if ($this->session() == 0) {
?>
- <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
+ <form action="?" 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
+
+ }
+ if ($this->session() >= 1) {
+ ?>
+ <form action="?" method="post">
+ <input type="hidden" name="action" value="logout">
+ <input type="submit" value="disconnect">
+ </form>
+ <?php
+ }
}
- }
- ?>
+ ?>
</nav>
<?php
diff --git a/class/class.app.php b/class/class.app.php
index 69d6d92..d9e3fff 100644
--- a/class/class.app.php
+++ b/class/class.app.php
@@ -26,7 +26,7 @@ class App
$now = new DateTimeImmutable(null, timezone_open("Europe/Paris"));
- $q = $this->bdd->prepare('INSERT INTO art(id, titre, soustitre, intro, tag, datecreation, datemodif, css, html, secure, couleurtext, couleurbkg, couleurlien) VALUES(:id, :titre, :soustitre, :intro, :tag, :datecreation, :datemodif, :css, :html, :secure, :couleurtext, :couleurbkg, :couleurlien)');
+ $q = $this->bdd->prepare('INSERT INTO art(id, titre, soustitre, intro, tag, datecreation, datemodif, css, html, secure, couleurtext, couleurbkg, couleurlien, couleurlienblank) VALUES(:id, :titre, :soustitre, :intro, :tag, :datecreation, :datemodif, :css, :html, :secure, :couleurtext, :couleurbkg, :couleurlien, :couleurlienblank)');
$q->bindValue(':id', $art->id());
$q->bindValue(':titre', $art->titre());
@@ -41,6 +41,7 @@ class App
$q->bindValue(':couleurtext', $art->couleurtext());
$q->bindValue(':couleurbkg', $art->couleurbkg());
$q->bindValue(':couleurlien', $art->couleurlien());
+ $q->bindValue(':couleurlienblank', $art->couleurlienblank());
$q->execute();
}
@@ -104,7 +105,7 @@ 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 = $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, couleurlienblank = :couleurlienblank WHERE id = :id');
$q->bindValue(':id', $art->id());
$q->bindValue(':titre', $art->titre());
@@ -119,6 +120,7 @@ class App
$q->bindValue(':couleurtext', $art->couleurtext());
$q->bindValue(':couleurbkg', $art->couleurbkg());
$q->bindValue(':couleurlien', $art->couleurlien());
+ $q->bindValue(':couleurlienblank', $art->couleurlienblank());
$q->execute();
}
diff --git a/class/class.art.php b/class/class.art.php
index 897cd0b..f945767 100644
--- a/class/class.art.php
+++ b/class/class.art.php
@@ -53,7 +53,8 @@ class Art
$this->setintro('resumé');
$this->settag('sans tag,');
$this->setdatecreation($now);
- $this->setcss('article {}');
+ $this->setcss('article {}
+a:hover {}');
$this->sethtml('contenu');
$this->setsecure(2);
$this->setcouleurtext('#000000');
@@ -123,8 +124,11 @@ class Art
return $this->html;
} elseif ($option == 'html') {
$html = MarkdownExtra::defaultTransform($this->html);
- $htmla = str_replace('class="b"', ' target="_blank" ', $html);
- return $htmla;
+ $htmla = str_replace('href="http://', ' class="external" target="_blank" href="http://', $html);
+
+ $htmla = str_replace('class="b"', ' target="_blank" ', $htmla);
+ $htmlmedia = str_replace('src="/', 'src="../media/', $htmla);
+ return $htmlmedia;
}
}
@@ -148,6 +152,11 @@ class Art
return $this->couleurlien;
}
+ public function couleurlienblank()
+ {
+ return $this->couleurlienblank;
+ }
+
// _____________________________________________________ S E T ____________________________________________________
@@ -252,6 +261,14 @@ class Art
}
}
+ public function setcouleurlienblank($couleurlienblank)
+ {
+ $couleurlienblank = strval($couleurlienblank);
+ if (strlen($couleurlienblank) <= self::$lencouleur) {
+ $this->couleurlienblank = strip_tags(trim($couleurlienblank));
+ }
+ }
+
}
diff --git a/fn/fn.php b/fn/fn.php
index d42b7e8..79007ef 100644
--- a/fn/fn.php
+++ b/fn/fn.php
@@ -21,14 +21,17 @@ function secure()
}
}
-function head($title) {
+function head($title)
+{
?>
<head>
<meta charset="utf8" />
+ <meta name="viexport" content="width=device-width" />
<link href="/css/style.css" rel="stylesheet" />
<title><?= $title ?></title>
</head>
<?php
+
}
?>
diff --git a/public/css/style.css b/public/css/style.css
index 163ca7d..5cdb822 100644
--- a/public/css/style.css
+++ b/public/css/style.css
@@ -19,6 +19,10 @@ h3 {
opacity: 0.7;
}
+h6 {
+ font-size: 1em;
+}
+
p{
font-size: 1em;
}
@@ -27,6 +31,14 @@ em {
opacity: 0.8;
}
+a{
+ text-decoration: none;
+}
+
+a:hover{
+ text-decoration: underline;
+}
+
img {
width: 90%;
max-width: 1000px;
@@ -38,10 +50,16 @@ article {
line-height: 1.2em;
}
-article .edit {
+.edit {
text-align: left;
+ padding-top: 1%;
+ padding-bottom: 1%;
+ padding-left: 8%;
+ padding-right: 8%;
+ line-height: 1.2em;
}
+
article input, textarea, select {
width: 90%;
padding-left: 15px;
@@ -52,6 +70,7 @@ article input, textarea, select {
height: 30px;
border-style: unset;
}
+
#html{
height: 1000px;
}
@@ -128,4 +147,11 @@ nav a {
border-width: 2px;
border-color: lightgrey;
border-style: outset;
+}
+
+.submit {
+ position: fixed;
+ top: 0px;
+ left: 0px;
+ width: 8%;
} \ No newline at end of file
diff --git a/public/media/vac.png b/public/media/vac.png
new file mode 100644
index 0000000..569f539
--- /dev/null
+++ b/public/media/vac.png
Binary files differ
diff --git a/public/w/index.php b/public/w/index.php
index 93d9f46..0a153b0 100644
--- a/public/w/index.php
+++ b/public/w/index.php
@@ -38,15 +38,33 @@ if (isset($_POST['action'])) {
}
break;
+ case 'delete':
+ if ($app->exist($_GET['id'])) {
+ $art = new Art($_POST);
+ $app->delete($art);
+ header('Location: ?id=' . $art->id());
+ }
+ break;
+
+
case 'login':
$_SESSION['level'] = $app->login($_POST['pass']);
- header('Location: ?id=' . $_GET['id']);
+ if (isset($_GET['id'])) {
+ header('Location: ?id=' . $_GET['id']);
+ } else {
+ header('Location: ?');
+ }
break;
case 'logout':
$_SESSION['level'] = $app->logout();
- header('Location: ?id=' . $_GET['id']);
+ if (isset($_GET['id'])) {
+ header('Location: ?id=' . $_GET['id']);
+ } else {
+ header('Location: ?');
+ }
break;
+
}
}
@@ -111,7 +129,6 @@ if (isset($_GET['id'])) {
$aff->tag($app->getlister(), $_GET['tag']);
} else {
- echo "<h4>Bienvenue sur ce site.</h4>";
$aff->home($app->lister());
}
echo '</body>';