From 95ada5c09026882f384a4a386916b1b2decbfce9 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Fri, 9 Aug 2019 12:04:52 +0200 Subject: Feature : %CONNECT% + fix terminal.css --- app/class/modelrender.php | 80 +++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 48 deletions(-) (limited to 'app/class') diff --git a/app/class/modelrender.php b/app/class/modelrender.php index cc3b753..fb6e002 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -289,6 +289,8 @@ class Modelrender extends Modelart $text = $this->autourl($text); + $text = $this->authenticate($text); + return $text; } @@ -420,54 +422,6 @@ class Modelrender extends Modelart return $text; } - public function aautomedialist(string $text) : string - { - - - - $text = preg_replace_callback( - '~\%MEDIA:(([a-z0-9-_]+(\/([a-z0-9-_])+)*))\%~', - function ($matches) { - $dir = trim($matches[1], '/'); - $mediamanager = new Modelmedia(); - - - - if (is_dir(Model::MEDIA_DIR . $dir)) { - $medialist = $mediamanager->getlistermedia(Model::MEDIA_DIR . $dir . '/'); - - $dirid = str_replace('/', '-', $dir); - - $ul = '
' . PHP_EOL; - - foreach ($medialist as $media) { - $ul .= '
'; - if ($media->type() == 'image') { - $ul .= '' . $media->id() . ''; - } elseif ($media->type() == 'sound') { - $ul .= '
' . PHP_EOL; - } - - $ul .= '
' . PHP_EOL; - - return $ul; - } else { - return 'directory "' . $dir . '" not found'; - } - }, - $text - ); - - return $text; - } - - function sumparser($text) { @@ -605,6 +559,36 @@ class Modelrender extends Modelart + /** + * @param string $text content to analyse and replace + * + * @return string text ouput + */ + public function authenticate(string $text) + { + $id = $this->art->id(); + $regex = '~\%CONNECT(\?dir=([a-zA-Z0-9-_]+))?\%~'; + $text = preg_replace_callback($regex, function ($matches) use ($id) { + if(isset($matches[2])) { + $id = $matches[2]; + } + $form = '
+ + + + +
'; + return $form; + + }, $text); + return $text; + } + + + + + + public function linkfrom() { sort($this->linkfrom); -- cgit v1.2.3