diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-04-13 22:46:13 +0200 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-04-13 22:46:13 +0200 |
commit | 899a4bd60570ff9b77fabe89dd4902f09bbdeb47 (patch) | |
tree | d1aba3f501dc633a9e154adfb2b122502975a3c1 | |
parent | 1b6f5e650fa774cda77d511bf4cbdc638a2b42f6 (diff) | |
download | wcms-899a4bd60570ff9b77fabe89dd4902f09bbdeb47.tar.gz wcms-899a4bd60570ff9b77fabe89dd4902f09bbdeb47.zip |
V2 feat nico search lien confirm background100%
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | class/class.aff.php | 17 | ||||
-rw-r--r-- | class/class.app.php | 7 | ||||
-rw-r--r-- | class/class.art.php | 93 | ||||
-rw-r--r-- | public/css/style.css | 14 | ||||
-rw-r--r-- | public/index.php | 1 | ||||
-rw-r--r-- | public/rsc/js/app.js | 5 |
7 files changed, 104 insertions, 34 deletions
@@ -1,4 +1,5 @@ vendor/* +.vscode/* config.php error_log w/img/* diff --git a/class/class.aff.php b/class/class.aff.php index 16d77ca..3ccfd59 100644 --- a/class/class.aff.php +++ b/class/class.aff.php @@ -27,8 +27,10 @@ class Aff if ($this->session() >= $art->secure()) { ?> <style type="text/css"> - article { + body{ background: <?= $art->couleurbkg() ?>; + } + section { color: <?= $art->couleurtext() ?>; } @@ -41,11 +43,11 @@ class Aff } <?= $art->css() ?> </style> - <article> + <section> <h1><?= $art->titre() ?></h1> <h6><?= $art->soustitre() ?></h6> - <p><?= $art->html('html') ?></p> - </article> + <article><?= $art->html('html') ?></article> + </section> <?php } @@ -56,7 +58,7 @@ class Aff if ($this->session() >= self::$edit) { ?> - <article class="edit"> + <section class="edit"> <form action="?id=<?= $art->id() ?>" method="post"> <label for="titre">Titre :</label> <input type="text" name="titre" id="titre" value="<?= $art->titre(); ?>"> @@ -88,10 +90,10 @@ class Aff <input type="hidden" name="id" value="<?= $art->id() ?>"> <div class="submit"> <input type="submit" name="action" value="update"> - <input type="submit" name="action" value="delete"> + <input type="submit" name="action" value="delete" onclick="confirmSubmit(event, 'Suppression de cet article')"> </div> </form> - </article> + </section> <?php @@ -107,6 +109,7 @@ public function head($title) <meta name="viewport" content="width=device-width" /> <link href="/css/style.css" rel="stylesheet" /> <title><?= $title ?></title> + <script src="../rsc/js/app.js"></script> </head> <?php diff --git a/class/class.app.php b/class/class.app.php index d9e3fff..5891cae 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) VALUES(:id, :titre, :soustitre, :intro, :tag, :datecreation, :datemodif, :css, :html, :secure, :couleurtext, :couleurbkg, :couleurlien, :couleurlienblank)'); + $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->bindValue(':id', $art->id()); $q->bindValue(':titre', $art->titre()); @@ -42,6 +42,7 @@ class App $q->bindValue(':couleurbkg', $art->couleurbkg()); $q->bindValue(':couleurlien', $art->couleurlien()); $q->bindValue(':couleurlienblank', $art->couleurlienblank()); + $q->bindValue(':lien', $art->lien('string')); $q->execute(); } @@ -104,8 +105,9 @@ class App public function update(Art $art) { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); + $art->updatelien(); - $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 = $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->bindValue(':id', $art->id()); $q->bindValue(':titre', $art->titre()); @@ -121,6 +123,7 @@ class App $q->bindValue(':couleurbkg', $art->couleurbkg()); $q->bindValue(':couleurlien', $art->couleurlien()); $q->bindValue(':couleurlienblank', $art->couleurlienblank()); + $q->bindValue(':lien', $art->lien('string')); $q->execute(); } diff --git a/class/class.art.php b/class/class.art.php index f945767..0e87b6c 100644 --- a/class/class.art.php +++ b/class/class.art.php @@ -1,7 +1,6 @@ <?php use Michelf\Markdown; -use Michelf\MarkdownExtra; class Art @@ -19,12 +18,15 @@ class Art private $couleurtext; private $couleurbkg; private $couleurlien; + private $couleurlienblank; + private $lien; - private static $len = 255; - private static $lenhtml = 65535; - private static $securemax = 2; - private static $lencouleur = 7; - + const LEN = 255; + const LENHTML = 20000; + const SECUREMAX = 2; + const LENCOULEUR = 7; + const DEBUT = '(?id='; + const FIN = ')'; // _____________________________________________________ F U N ____________________________________________________ @@ -53,13 +55,39 @@ class Art $this->setintro('resumé'); $this->settag('sans tag,'); $this->setdatecreation($now); - $this->setcss('article {} + $this->setcss('section {} a:hover {}'); $this->sethtml('contenu'); $this->setsecure(2); $this->setcouleurtext('#000000'); $this->setcouleurbkg('#FFFFFF'); $this->setcouleurlien('#000000'); + $this->setcouleurlienblank('#000000'); + $this->setlien(''); + } + + public function updatelien() + { + function search($haystack, $debut, $fin) + { + $list = []; + + $indexdebut = strpos($haystack, $debut); + if ($indexdebut !== false) { + $indexdebut += strlen($debut); + $indexfin = strpos($haystack, $fin, $indexdebut); + if ($indexfin !== false) { + //$indexfin -= strlen($fin); + array_push($list, substr($haystack, $indexdebut, $indexfin - $indexdebut)); + $haystack = substr($haystack, $indexfin); + $list = array_merge($list, search($haystack, $debut, $fin)); + } + } + return $list; + + } + $this->lien = search($this->html('md'), self::DEBUT, self::FIN); + } // _____________________________________________________ G E T ____________________________________________________ @@ -123,8 +151,8 @@ a:hover {}'); if ($option == 'md') { return $this->html; } elseif ($option == 'html') { - $html = MarkdownExtra::defaultTransform($this->html); - $htmla = str_replace('href="http://', ' class="external" target="_blank" href="http://', $html); + $html = Markdown::defaultTransform($this->html); + $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); @@ -157,41 +185,53 @@ a:hover {}'); return $this->couleurlienblank; } + public function lien($option) + { + if ($option == 'string') { + $lien = implode(", ", $this->lien); + } elseif ($option == 'array') { + $lien = $this->lien; + } + return $lien; + + } + + // _____________________________________________________ S E T ____________________________________________________ public function setid($id) { - if (strlen($id) < self::$len and is_string($id)) { + if (strlen($id) < self::LEN and is_string($id)) { $this->id = strip_tags(strtolower(str_replace(" ", "", $id))); } } public function settitre($titre) { - if (strlen($titre) < self::$len and is_string($titre)) { + if (strlen($titre) < self::LEN and is_string($titre)) { $this->titre = strip_tags(trim($titre)); } } public function setsoustitre($soustitre) { - if (strlen($soustitre) < self::$len and is_string($soustitre)) { + if (strlen($soustitre) < self::LEN and is_string($soustitre)) { $this->soustitre = strip_tags(trim($soustitre)); } } public function setintro($intro) { - if (strlen($intro) < self::$len and is_string($intro)) { + if (strlen($intro) < self::LEN and is_string($intro)) { $this->intro = strip_tags(trim($intro)); } } public function settag($tag) { - if (strlen($tag) < self::$len and is_string($tag)) { + if (strlen($tag) < self::LEN and is_string($tag)) { $tag = strip_tags(trim(strtolower($tag))); $taglist = explode(", ", $tag); $this->tag = $taglist; @@ -218,21 +258,21 @@ a:hover {}'); public function setcss($css) { - if (strlen($css) < self::$len and is_string($css)) { + if (strlen($css) < self::LEN and is_string($css)) { $this->css = strip_tags(trim(strtolower($css))); } } public function sethtml($html) { - if (strlen($html) < self::$lenhtml and is_string($html)) { + if (strlen($html) < self::LENHTML and is_string($html)) { $this->html = $html; } } public function setsecure($secure) { - if ($secure >= 0 and $secure <= self::$securemax) { + if ($secure >= 0 and $secure <= self::SECUREMAX) { $this->secure = intval($secure); } } @@ -240,7 +280,7 @@ a:hover {}'); public function setcouleurtext($couleurtext) { $couleurtext = strval($couleurtext); - if (strlen($couleurtext) <= self::$lencouleur) { + if (strlen($couleurtext) <= self::LENCOULEUR) { $this->couleurtext = strip_tags(trim($couleurtext)); } } @@ -248,7 +288,7 @@ a:hover {}'); public function setcouleurbkg($couleurbkg) { $couleurbkg = strval($couleurbkg); - if (strlen($couleurbkg) <= self::$lencouleur) { + if (strlen($couleurbkg) <= self::LENCOULEUR) { $this->couleurbkg = strip_tags(trim($couleurbkg)); } } @@ -256,7 +296,7 @@ a:hover {}'); public function setcouleurlien($couleurlien) { $couleurlien = strval($couleurlien); - if (strlen($couleurlien) <= self::$lencouleur) { + if (strlen($couleurlien) <= self::LENCOULEUR) { $this->couleurlien = strip_tags(trim($couleurlien)); } } @@ -264,11 +304,22 @@ a:hover {}'); public function setcouleurlienblank($couleurlienblank) { $couleurlienblank = strval($couleurlienblank); - if (strlen($couleurlienblank) <= self::$lencouleur) { + if (strlen($couleurlienblank) <= self::LENCOULEUR) { $this->couleurlienblank = strip_tags(trim($couleurlienblank)); } } + public function setlien($lien) + { + if (!empty($lien) && strlen($lien) < self::LEN && is_string($lien)) { + $lien = strip_tags(trim(strtolower($lien))); + $lienlist = explode(", ", $lien); + $this->lien = $lienlist; + } else { + $this->lien = []; + } + } + } diff --git a/public/css/style.css b/public/css/style.css index 5cdb822..325a0ae 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -1,7 +1,11 @@ +html { +} + body { background-color: #dcdcdceb; font-family: helvetica, arial, sans-serif; margin: 0px; + } h1 { @@ -44,7 +48,7 @@ img { max-width: 1000px; } -article { +section { text-align: justify; padding: 3%; line-height: 1.2em; @@ -60,7 +64,7 @@ article { } -article input, textarea, select { +section input, textarea, select { width: 90%; padding-left: 15px; padding-right: 15px; @@ -89,9 +93,11 @@ aside { right: -300px; padding: 7px; z-index: 5; - background: #6c7d8a; + background: #bfbfbf; opacity: 0.3; - width: 350px; + width: 350px; + overflow-y: scroll; + max-height: 70%; } aside:hover { diff --git a/public/index.php b/public/index.php index 2409769..f935eed 100644 --- a/public/index.php +++ b/public/index.php @@ -1,3 +1,4 @@ <html> <a href="/w/">w</a> + </html>
\ No newline at end of file diff --git a/public/rsc/js/app.js b/public/rsc/js/app.js new file mode 100644 index 0000000..d1b9f55 --- /dev/null +++ b/public/rsc/js/app.js @@ -0,0 +1,5 @@ +function confirmSubmit(event, element) { + if (window.confirm('Confirmer ? ' + element) === false) { + event.preventDefault(); + } +}
\ No newline at end of file |