From 2060e198b1f9ac41deee93848417121fb1c066f5 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sun, 18 Mar 2018 03:48:04 +0100 Subject: classes fonctionnelles --- class/class.app.php | 35 ++++-- class/class.art.php | 342 +++++++++++++++++++++++++++++++++------------------- 2 files changed, 244 insertions(+), 133 deletions(-) (limited to 'class') diff --git a/class/class.app.php b/class/class.app.php index d9867d3..ad62c25 100644 --- a/class/class.app.php +++ b/class/class.app.php @@ -1,4 +1,3 @@ -

class.app

exist($art->id())) { - echo '

cet id existe deja

'; + echo '

cet id existe deja

'; } else { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); @@ -72,21 +71,36 @@ class App $list = []; $req = $this->bdd->query('SELECT * FROM art ORDER BY id'); - while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) - { - $list[] = new Art($donnees); + while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) { + $list[] = new Art($donnees); } return $list; } + public function menu($session) + { + $req = $this->bdd->query('SELECT * FROM art ORDER BY id'); + echo ' '; + + } + public function count() { - return $this->bdd->query('SELECT COUNT(*) FROM art')->fetchColumn(); + return $this->bdd->query(' SELECT COUNT(*) FROM art ')->fetchColumn(); } public function exist($id) { - $req = $this->bdd->prepare('SELECT COUNT(*) FROM art WHERE id = :id '); + $req = $this->bdd->prepare(' SELECT COUNT(*) FROM art WHERE id = :id '); $req->execute(array('id' => $id)); $donnees = $req->fetch(PDO::FETCH_ASSOC); @@ -98,17 +112,17 @@ 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(':datecreation', $art->datecreation()->format('Y-m-d H:i:s')); + $q->bindValue(':datecreation', $art->datecreation('string')); $q->bindValue(':datemodif', $now->format('Y-m-d H:i:s')); $q->bindValue(':css', $art->css()); $q->bindValue(':html', $art->html()); - $q->bindValue(':secure', $art->secure(), PDO::PARAM_INT); + $q->bindValue(':secure', $art->secure()); $q->bindValue(':couleurtext', $art->couleurtext()); $q->bindValue(':couleurbkg', $art->couleurbkg()); $q->bindValue(':couleurlien', $art->couleurlien()); @@ -116,6 +130,5 @@ class App $q->execute(); } - } ?> \ No newline at end of file diff --git a/class/class.art.php b/class/class.art.php index ec085d8..bf2aeef 100644 --- a/class/class.art.php +++ b/class/class.art.php @@ -1,4 +1,3 @@ -

class.art

id; + $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); + + $this->settitre($this->id()); + $this->setsoustitre($this->id()); + $this->setintro('resumé'); + $this->settag('sans tag,'); + $this->setdatecreation($now); + $this->setcss('display: inline;'); + $this->sethtml('contenu'); + $this->setsecure(2); + $this->setcouleurtext('#000000'); + $this->setcouleurbkg('#FFFFFF'); + $this->setcouleurlien('#000000'); } - public function titre() + public function edit($session) { - return $this->titre; - } + if ($session >= self::$edit) { + + ?> +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + soustitre; - } +} - public function intro() - { - return $this->intro; - } +} - public function tag() - { - return $this->tag; - } +public function display($session) +{ + if ($session >= $this->secure()) { - public function datecreation() - { + ?> + +
+

titre() ?>

+

soustitre() ?>

+

intro() ?>

+

html() ?>

+
+ id; +} + +public function titre() +{ + return $this->titre; +} + +public function soustitre() +{ + return $this->soustitre; +} + +public function intro() +{ + return $this->intro; +} + +public function tag() +{ + return $this->tag; +} + +public function datecreation($option) { + if ($option == 'string') { + return $this->datecreation->format('Y-m-d H:i:s'); + } elseif($option == 'date') { return $this->datecreation; } +} - public function datemodif() - { + +public function datemodif($option) { + if ($option == 'string') { + return $this->datemodif->format('Y-m-d H:i:s'); + } elseif($option == 'date') { return $this->datemodif; } +} - public function css() - { - return $this->css; - } +public function css() +{ + return $this->css; +} - public function html() - { - return $this->html; - } +public function html() +{ + return $this->html; +} - public function secure() - { - return $this->secure; - } +public function secure() +{ + return $this->secure; +} - public function couleurtext() - { - return $this->couleurtext; - } +public function couleurtext() +{ + return $this->couleurtext; +} - public function couleurbkg() - { - return $this->couleurbkg; - } +public function couleurbkg() +{ + return $this->couleurbkg; +} - public function couleurlien() - { - return $this->couleurlien; - } +public function couleurlien() +{ + return $this->couleurlien; +} - // _____________________________________________________ S E T ____________________________________________________ + // _____________________________________________________ S E T ____________________________________________________ - public function setid($id) - { - if (strlen($id) < self::$len and is_string($id)) { - $this->id = strip_tags(strtolower(str_replace(" ", "", $id))); - } +public function setid($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)) { - $this->titre = strip_tags(trim($titre)); - } +public function settitre($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)) { - $this->soustitre = strip_tags(trim($soustitre)); - } +public function setsoustitre($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)) { - $this->intro = strip_tags(trim($intro)); - } +public function setintro($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)) { - $this->tag = strip_tags(trim(strtolower($tag))); - } +public function settag($tag) +{ + if (strlen($tag) < self::$len and is_string($tag)) { + $this->tag = strip_tags(trim(strtolower($tag))); } +} - public function setdatecreation($datecreation) - { - if ($datecreation instanceof DateTimeImmutable) { - $this->datecreation = $datecreation; - } else { - $this->datecreation = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datecreation, new DateTimeZone('Europe/Paris')); - } +public function setdatecreation($datecreation) +{ + if ($datecreation instanceof DateTimeImmutable) { + $this->datecreation = $datecreation; + } else { + $this->datecreation = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datecreation, new DateTimeZone('Europe/Paris')); } +} - public function setdatemodif($datemodif) - { - if ($datemodif instanceof DateTimeImmutable) { - $this->datemodif = $datemodif; - } else { - $this->datemodif = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datemodif, new DateTimeZone('Europe/Paris')); - } +public function setdatemodif($datemodif) +{ + if ($datemodif instanceof DateTimeImmutable) { + $this->datemodif = $datemodif; + } else { + $this->datemodif = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $datemodif, new DateTimeZone('Europe/Paris')); } +} - public function setcss($css) - { - if (strlen($css) < self::$len and is_string($css)) { - $this->css = strip_tags(trim(strtolower($css))); - } +public function setcss($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)) { - $this->html = $html; - } +public function sethtml($html) +{ + if (strlen($html) < self::$lenhtml and is_string($html)) { + $this->html = $html; } +} - public function setsecure($secure) - { - if ($secure >= 0 and $secure <= self::$securemax) { - $this->secure = intval($secure); - } +public function setsecure($secure) +{ + if ($secure >= 0 and $secure <= self::$securemax) { + $this->secure = intval($secure); } +} - public function setcouleurtext($couleurtext) - { - $couleurtext = strval($couleurtext); - if (strlen($couleurtext) <= self::$lencouleur) { - $this->couleurtext = strip_tags(trim($couleurtext)); - } +public function setcouleurtext($couleurtext) +{ + $couleurtext = strval($couleurtext); + if (strlen($couleurtext) <= self::$lencouleur) { + $this->couleurtext = strip_tags(trim($couleurtext)); } +} - public function setcouleurbkg($couleurbkg) - { - $couleurbkg = strval($couleurbkg); - if (strlen($couleurbkg) <= self::$lencouleur) { - $this->couleurbkg = strip_tags(trim($couleurbkg)); - } +public function setcouleurbkg($couleurbkg) +{ + $couleurbkg = strval($couleurbkg); + if (strlen($couleurbkg) <= self::$lencouleur) { + $this->couleurbkg = strip_tags(trim($couleurbkg)); } +} - public function setcouleurlien($couleurlien) - { - $couleurlien = strval($couleurlien); - if (strlen($couleurlien) <= self::$lencouleur) { - $this->couleurlien = strip_tags(trim($couleurlien)); - } +public function setcouleurlien($couleurlien) +{ + $couleurlien = strval($couleurlien); + if (strlen($couleurlien) <= self::$lencouleur) { + $this->couleurlien = strip_tags(trim($couleurlien)); } +} } + + ?> \ No newline at end of file -- cgit v1.2.3