aboutsummaryrefslogtreecommitdiff
path: root/app/class
diff options
context:
space:
mode:
authorvincent-peugnet <v.peugnet@free.fr>2019-01-18 15:05:05 +0100
committervincent-peugnet <v.peugnet@free.fr>2019-01-18 15:05:05 +0100
commitb294f7428eaebbf34cbef50fcabc95ae6ff56f8d (patch)
treea81eb031bb04bc8ef8f925b61ec78e7d0f22829e /app/class
parent2ff846f7fb65998cd6cf151554434f56f116d4f2 (diff)
downloadwcms-b294f7428eaebbf34cbef50fcabc95ae6ff56f8d.tar.gz
wcms-b294f7428eaebbf34cbef50fcabc95ae6ff56f8d.zip
auto link
Diffstat (limited to 'app/class')
-rw-r--r--app/class/modelrender.php18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/class/modelrender.php b/app/class/modelrender.php
index 413b8de..88d1e10 100644
--- a/app/class/modelrender.php
+++ b/app/class/modelrender.php
@@ -120,6 +120,7 @@ class Modelrender extends Modelart
$element = $this->automedialist($element);
$element = $this->autotaglistupdate($element);
$element = $this->date($element);
+ $element = $this->autolink($element);
$element = $this->markdown($element);
return $element;
@@ -497,6 +498,23 @@ class Modelrender extends Modelart
return $text;
}
+ public function autolink($text)
+ {
+ $rend = $this;
+ $text = preg_replace_callback('/\%LINK\%(.*)\%LINK\%/msU', function ($matches) use ($rend) {
+ return $rend->everylink($matches[1]);
+ }, $text);
+ return $text;
+ }
+
+ public function everylink($text)
+ {
+ $text = preg_replace_callback("~([\w-_éêèùïüîçà]{2,})~", function ($matches) {
+ return '<a href="' . idclean($matches[1]) . '">' . $matches[1] . '</a>';
+ }, $text);
+ return $text;
+ }
+
public function linkfrom()