From 899a4bd60570ff9b77fabe89dd4902f09bbdeb47 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 13 Apr 2018 22:46:13 +0200 Subject: V2 feat nico search lien confirm background100% --- .gitignore | 1 + class/class.aff.php | 17 ++++++---- class/class.app.php | 7 ++-- class/class.art.php | 93 ++++++++++++++++++++++++++++++++++++++++------------ public/css/style.css | 14 +++++--- public/index.php | 1 + public/rsc/js/app.js | 5 +++ 7 files changed, 104 insertions(+), 34 deletions(-) create mode 100644 public/rsc/js/app.js diff --git a/.gitignore b/.gitignore index a027495..dd72d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -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()) { ?> -
+

titre() ?>

soustitre() ?>
-

html('html') ?>

-
+
html('html') ?>
+ session() >= self::$edit) { ?> -
+
@@ -88,10 +90,10 @@ class Aff
- +
-
+ <?= $title ?> + 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 @@ 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 @@ w + \ 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 -- cgit v1.2.3