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/modelrender.php | 58 +++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 24 deletions(-) (limited to 'app/class/modelrender.php') 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; } + } -- cgit v1.2.3