From e4768cd0647d934eff424f73bfd9f5c8f6223c94 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Mon, 12 Nov 2018 13:55:40 +0100 Subject: link+log --- app/class/modelrender.php | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'app/class/modelrender.php') diff --git a/app/class/modelrender.php b/app/class/modelrender.php index 0951537..2d56f6b 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -43,7 +43,11 @@ class Modelrender extends Modelart if (isset($art->template('array')[$element])) { $templateid = $art->template('array')[$element]; $tempalteart = $this->get($templateid); - $text = $tempalteart->$element() . PHP_EOL . $art->$element(); + if($tempalteart) { + $text = $tempalteart->$element() . PHP_EOL . $art->$element(); + } else { + $text = $art->$element(); + } } else { $text = $art->$element(); } @@ -151,6 +155,7 @@ class Modelrender extends Modelart $text = str_replace(self::SUMMARY, $this->sumparser($text), $text); + $text = $this->wurl($text); $text = $this->wikiurl($text); $text = $this->tooltip($art->linkfrom('array'), $text); @@ -170,18 +175,35 @@ class Modelrender extends Modelart return $text; } + public function wurl(string $text) + { + $rend = $this; + $text = preg_replace_callback( + '%href="([\w-]+)"%', + function ($matches) use ($rend) { + $matchart = $rend->get($matches[1]); + if (!$matchart) { + return 'href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal"'; + } else { + return 'href="' . $rend->uart($matches[1]) . '" title="' . $matchart->description() . '" class="internal"'; + } + }, + $text + ); + return $text; + } + public function wikiurl(string $text) { $rend = $this; - $artlist = []; $text = preg_replace_callback( '%\[([\w-]+)\]%', function ($matches) use ($rend) { $matchart = $rend->get($matches[1]); if (!$matchart) { - return '' . $matches[1] . ''; + return '' . $matches[1] . ''; } else { - return '' . $matchart->title() . ''; + return '' . $matchart->title() . ''; } }, $text @@ -189,7 +211,6 @@ class Modelrender extends Modelart return $text; } - public function markdown($text) { //use Michelf\MarkdownExtra; -- cgit v1.2.3