diff options
Diffstat (limited to 'app/class/modelrender.php')
-rw-r--r-- | app/class/modelrender.php | 31 |
1 files changed, 26 insertions, 5 deletions
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 '<a href="' . $rend->uart($matches[1]) . '">' . $matches[1] . '</a>'; + return '<a href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal">' . $matches[1] . '</a>'; } else { - return '<a href="' . $rend->uart($matches[1]) . '" title="' . $matchart->description() . '">' . $matchart->title() . '</a>'; + return '<a href="' . $rend->uart($matches[1]) . '" title="' . $matchart->description() . '" class="internal">' . $matchart->title() . '</a>'; } }, $text @@ -189,7 +211,6 @@ class Modelrender extends Modelart return $text; } - public function markdown($text) { //use Michelf\MarkdownExtra; |