diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-11-17 20:32:47 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-11-17 20:32:47 +0100 |
commit | 47689d1fdfb2c33ee5e00cfe9fe529d6ba3529db (patch) | |
tree | 3a9c85b79822e62a80d8820210c3670e55d96e24 /app | |
parent | b4c5790ef82a4cc248d40c8403e795089d06ab08 (diff) | |
download | wcms-47689d1fdfb2c33ee5e00cfe9fe529d6ba3529db.tar.gz wcms-47689d1fdfb2c33ee5e00cfe9fe529d6ba3529db.zip |
pdate
Diffstat (limited to 'app')
-rw-r--r-- | app/class/art2.php | 4 | ||||
-rw-r--r-- | app/class/controllerart.php | 4 | ||||
-rw-r--r-- | app/class/modelart.php | 24 | ||||
-rw-r--r-- | app/class/modelrender.php | 58 | ||||
-rw-r--r-- | app/view/templates/editleftbar.php | 4 |
5 files changed, 46 insertions, 48 deletions
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 . '</' . $element . '>' . 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 = '<ul>'; - foreach ($artlist as $art) { - $replace .= '<li><a href="?id=' . $art->id() . '" title="' . $art->description() . '">' . $art->title() . '</a></li>'; - } - $replace .= '</ul>'; - $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 = '<ul id="'.$tag.'">' . PHP_EOL; + $this->artlistsort($li, 'date', -1); + foreach ($li as $item ) { + $ul .= '<li><a href="'.$this->router->generate('artread/', ['art' => $item->id()]).'" title="'.$item->description().'" class="internal" >'.$item->title().'</a></li>' . PHP_EOL; + } + $ul .= '</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 @@ <option value="2" <?= $art->secure() == 2 ? 'selected' : '' ?>>2</option> <option value="3" <?= $art->secure() == 3 ? 'selected' : '' ?>>3</option> </select> + <label for="date">Date</label> + <input type="date" name="pdate" value="<?= $art->date('pdate') ?>" id="date"> + <label for="time">Time</label> + <input type="time" name="ptime" value="<?= $art->date('ptime') ?>" id="time"> </fieldset> </details> <details> |