From 47689d1fdfb2c33ee5e00cfe9fe529d6ba3529db Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Sat, 17 Nov 2018 20:32:47 +0100 Subject: pdate --- app/class/art2.php | 4 +++ app/class/controllerart.php | 4 +++ app/class/modelart.php | 24 ---------------- app/class/modelrender.php | 58 ++++++++++++++++++++++---------------- app/view/templates/editleftbar.php | 4 +++ 5 files changed, 46 insertions(+), 48 deletions(-) (limited to 'app') diff --git a/app/class/art2.php b/app/class/art2.php index 3ba23cb..e8ae061 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -154,6 +154,10 @@ class Art2 } elseif ($option == 'hrdi') { $now = new DateTimeImmutable(null, timezone_open("Europe/Paris")); return hrdi($this->date->diff($now)); + } elseif ($option == 'pdate') { + return $this->date->format('Y-m-d'); + } elseif ($option == 'ptime') { + return $this->date->format('H:i'); } diff --git a/app/class/controllerart.php b/app/class/controllerart.php index b990237..ab3fec6 100644 --- a/app/class/controllerart.php +++ b/app/class/controllerart.php @@ -155,8 +155,12 @@ class Controllerart extends Controller $_SESSION['workspace']['showrightpanel'] = isset($_POST['workspace']['showrightpanel']); $_SESSION['workspace']['showleftpanel'] = isset($_POST['workspace']['showleftpanel']); + $date = new DateTimeImmutable($_POST['pdate'] . $_POST['ptime'], new DateTimeZone('Europe/Paris')); + $date = ['date' => $date]; + if ($this->importart() && $this->user->canedit()) { $this->art->hydrate($_POST); + $this->art->hydrate($date); $this->art->updateedited(); $this->artmanager->update($this->art); diff --git a/app/class/modelart.php b/app/class/modelart.php index ef4d61d..d887436 100644 --- a/app/class/modelart.php +++ b/app/class/modelart.php @@ -63,25 +63,10 @@ class Modelart extends Modeldb $this->artstore->store($artdata); } - public function getlisteropt(Opt $opt) - { - - $artlist = []; - - $select = 'SELECT ' . $opt->col('string') . ' FROM ' . Config::arttable(); - $req = $this->bdd->query($select); - while ($donnees = $req->fetch(PDO::FETCH_ASSOC)) { - $artlist[] = new Art2($donnees); - } - return $artlist; - - } - public function artcompare($art1, $art2, $method = 'id', $order = 1) { $result = ($art1->$method('sort') <=> $art2->$method('sort')); return $result * $order; - } public function buildsorter($sortby, $order) @@ -141,15 +126,6 @@ class Modelart extends Modeldb } - public function lister() - { - $req = $this->bdd->query(' SELECT * FROM ' . Config::arttable() . ' ORDER BY id '); - $donnees = $req->fetchAll(PDO::FETCH_ASSOC); - $req->closeCursor(); - return $donnees; - - } - public function tag(array $artlist, $tagchecked) { $artcheckedlist = []; diff --git a/app/class/modelrender.php b/app/class/modelrender.php index 64a07fa..82911aa 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -3,6 +3,7 @@ class Modelrender extends Modelart { protected $router; + protected $artlist; const SUMMARY = '%SUMMARY%'; @@ -12,6 +13,7 @@ class Modelrender extends Modelart parent::__construct(); $this->router = $router; + $this->artlist = $this->getlister(); } public function uart($id) @@ -52,7 +54,10 @@ class Modelrender extends Modelart $text = $art->$element(); } $text = $this->article($text); + $text = $this->autotaglistupdate($text); + $text = $this->desctitle($text, $art->description(), $art->title()); $text = $this->markdown($text); + $elements[$element] = PHP_EOL . '<' . $element . '>' . PHP_EOL . $text . PHP_EOL . '' . PHP_EOL; } @@ -148,11 +153,17 @@ class Modelrender extends Modelart } + public function desctitle($text, $desc, $title) + { + $text = str_replace('%TITLE%', $title, $text); + $text = str_replace('%DESCRIPTION%', $desc, $text); + return $text; + } + public function parser(Art2 $art, string $text) { - $text = str_replace('%TITLE%', $art->title(), $text); - $text = str_replace('%DESCRIPTION%', $art->description(), $text); + $text = str_replace(self::SUMMARY, $this->sumparser($text), $text); @@ -282,42 +293,41 @@ class Modelrender extends Modelart - //tag auto menu - - - public function autotaglist() + public function autotaglist($text) { $pattern = "/%%(\w*)%%/"; - preg_match_all($pattern, $this->md(), $out); + preg_match_all($pattern, $text, $out); return $out[1]; } - public function autotaglistupdate($taglist) - { - foreach ($taglist as $tag => $artlist) { - $replace = ''; - $text = str_replace('%%' . $tag . '%%', $replace, $text); - } - } - - public function autotaglistcalc($taglist) + public function autotaglistupdate($text) { - foreach ($taglist as $tag => $artlist) { - foreach ($artlist as $art) { - if (!in_array($art->id(), $this->linkfrom('array')) && $art->id() != $this->id()) { - $this->linkfrom[] = $art->id(); + $taglist = $this->autotaglist($text); + foreach ($taglist as $tag ) { + $li = []; + foreach ($this->artlist as $item ) { + if(in_array($tag, $item->tag('array'))) { + $li[] = $item; } + } + $ul = '' . PHP_EOL; + + + $text = str_replace('%%'.$tag.'%%', $ul, $text); } + return $text; } + } diff --git a/app/view/templates/editleftbar.php b/app/view/templates/editleftbar.php index 247e271..2f184af 100644 --- a/app/view/templates/editleftbar.php +++ b/app/view/templates/editleftbar.php @@ -18,6 +18,10 @@ + + + +
-- cgit v1.2.3