aboutsummaryrefslogtreecommitdiff
path: root/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2018-05-07 11:34:45 +0200
committervincent-peugnet <v.peugnet@free.fr>2018-05-07 11:34:45 +0200
commit97d6db419e1782abaa554dc9b88c208835d1a8b4 (patch)
tree4effa38f18eb0249d0587902cf9e34efd784eb82 /class
parent8ad36569c333324614a864225d507972247f22be (diff)
downloadwcms-97d6db419e1782abaa554dc9b88c208835d1a8b4.tar.gz
wcms-97d6db419e1782abaa554dc9b88c208835d1a8b4.zip
W 2.1 M 0.1
Diffstat (limited to 'class')
-rw-r--r--class/class.aff.php20
-rw-r--r--class/class.app.php6
-rw-r--r--class/class.art.php32
3 files changed, 51 insertions, 7 deletions
diff --git a/class/class.aff.php b/class/class.aff.php
index 61ee142..a62274e 100644
--- a/class/class.aff.php
+++ b/class/class.aff.php
@@ -42,7 +42,7 @@ class Aff
section a[target="_blank"] {
color: <?= $art->couleurlienblank() ?>;
}
- <?= $art->css() ?>
+ <?= $art->csstemplate($app) ?>
</style>
<section>
<h1><?= $art->titre() ?></h1>
@@ -55,7 +55,7 @@ class Aff
echo '</body>';
}
- public function edit(Art $art)
+ public function edit(Art $art, $list)
{
if ($this->session() >= self::$edit) {
@@ -82,6 +82,18 @@ class Aff
</details>
<details close>
<summary>CSS</summary>
+ <label for="template">Template :</label>
+ <select name="template" id="template">
+ <?php
+ foreach ($list as $item) {
+ if ($item['id'] == $art->template()) {
+ echo '<option value="' . $item['id'] . '" selected >' . $item['titre'] . '</option>';
+ } else {
+ echo '<option value="' . $item['id'] . '">' . $item['titre'] . '</option>';
+ }
+ }
+ ?>
+ </select>
<label for="css">Styles CSS :</label>
<textarea name="css" id="css"><?= $art->css(); ?></textarea>
<label for="couleurtext">Couleur du texte :</label>
@@ -299,7 +311,7 @@ public function head($title, $tool)
</br>
<?php
- if (isset($_GET['id']) and $app->exist($_GET['id'])) {
+ if (isset($_GET['id'])) {
if ($this->session() == 0) {
?>
<form action="?id=<?= $_GET['id'] ?>" method="post">
@@ -318,7 +330,7 @@ public function head($title, $tool)
</form>
<?php
- if ($this->session() == 2) {
+ if ($this->session() == 2 and $app->exist($_GET['id'])) {
?>
<a class="button" href="?id=<?= $_GET['id'] ?>" target="_blank">display</a>
</br>
diff --git a/class/class.app.php b/class/class.app.php
index 2a863dd..3fac66b 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, couleurlienblank, lien) VALUES(:id, :titre, :soustitre, :intro, :tag, :datecreation, :datemodif, :css, :html, :secure, :couleurtext, :couleurbkg, :couleurlien, :couleurlienblank, :lien)');
+ $q = $this->bdd->prepare('INSERT INTO art(id, titre, soustitre, intro, tag, datecreation, datemodif, css, html, secure, couleurtext, couleurbkg, couleurlien, couleurlienblank, lien, template) VALUES(:id, :titre, :soustitre, :intro, :tag, :datecreation, :datemodif, :css, :html, :secure, :couleurtext, :couleurbkg, :couleurlien, :couleurlienblank, :lien, :template)');
$q->bindValue(':id', $art->id());
$q->bindValue(':titre', $art->titre());
@@ -43,6 +43,7 @@ class App
$q->bindValue(':couleurlien', $art->couleurlien());
$q->bindValue(':couleurlienblank', $art->couleurlienblank());
$q->bindValue(':lien', $art->lien('string'));
+ $q->bindValue(':template', $art->template());
$q->execute();
}
@@ -115,7 +116,7 @@ class App
var_dump($now);
- $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, lien = :lien 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, lien = :lien, template = :template WHERE id = :id');
$q->bindValue(':id', $art->id());
$q->bindValue(':titre', $art->titre());
@@ -132,6 +133,7 @@ class App
$q->bindValue(':couleurlien', $art->couleurlien());
$q->bindValue(':couleurlienblank', $art->couleurlienblank());
$q->bindValue(':lien', $art->lien('string'));
+ $q->bindValue(':template', $art->template());
$q->execute();
}
diff --git a/class/class.art.php b/class/class.art.php
index 58653ca..2b03a7d 100644
--- a/class/class.art.php
+++ b/class/class.art.php
@@ -128,6 +128,22 @@ a:hover {}');
return $this->css;
}
+ public function csstemplate(App $app)
+ {
+ $data = [];
+ $temp = '';
+ if (!empty($this->template())) {
+ if ($app->exist($this->template()) and !in_array($this->template(), $data)) {
+ $template = $app->get($this->template());
+ $temp = $temp . $template->css($app);
+ $data[] = $template->id();
+
+ }
+
+ }
+ return $temp . $this->css;
+ }
+
public function md()
{
return $this->html;
@@ -192,6 +208,11 @@ a:hover {}');
}
+ public function template()
+ {
+ return $this->template;
+ }
+
@@ -254,7 +275,7 @@ a:hover {}');
public function setcss($css)
{
- if (strlen($css) < self::LEN and is_string($css)) {
+ if (strlen($css) < self::LENHTML and is_string($css)) {
$this->css = strip_tags(trim(strtolower($css)));
}
}
@@ -316,6 +337,15 @@ a:hover {}');
}
}
+ public function settemplate($template)
+ {
+ $template = strip_tags($template);
+ if (strlen($template) == 0) {
+ $template = 'NULL';
+ }
+ $this->template = $template;
+ }
+
}