From 0660c99cb9e2dae3b0e41975f643609231258147 Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Wed, 28 Nov 2018 07:58:55 +0100 Subject: minor changes --- app/class/art2.php | 2 ++ app/class/modelrender.php | 46 +++++++++++++++++++++++++++++++--------------- app/class/modeluser.php | 2 +- app/class/routes.php | 2 +- 4 files changed, 35 insertions(+), 17 deletions(-) (limited to 'app/class') diff --git a/app/class/art2.php b/app/class/art2.php index e8ae061..8c48dee 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -315,6 +315,8 @@ class Art2 $linkfrom = $this->linkfrom; } elseif ($option == 'sort') { return count($this->linkfrom); + } elseif ($option == 'string') { + return implode(', ', $this->linkfrom); } return $linkfrom; diff --git a/app/class/modelrender.php b/app/class/modelrender.php index 3fb1f81..e00dcc8 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -5,6 +5,7 @@ class Modelrender extends Modelart protected $router; protected $artlist; protected $linkfrom = []; + protected $sum = []; const SUMMARY = '%SUMMARY%'; @@ -56,7 +57,6 @@ class Modelrender extends Modelart } $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; @@ -165,16 +165,19 @@ class Modelrender extends Modelart public function parser(Art2 $art, string $text) { - + $text = $this->headerid($text); $text = str_replace(self::SUMMARY, $this->sumparser($text), $text); $text = $this->wurl($text); $text = $this->wikiurl($text); + $text = $this->desctitle($text, $art->description(), $art->title()); + + $text = str_replace('href="http', ' class="external" target="_blank" href="http', $text); - $text = str_replace('get($matches[1]); if (!$matchart) { return 'href="' . $rend->uart($matches[1]) . '"" title="' . Config::existnot() . '" class="internal"'; } else { $linkfrom[] = $matchart->id(); - return 'href="' . $rend->uart($matches[1]) . '" title="' . $matchart->description() . '" class="internal"'; + return 'href="' . $rend->uart($matches[1]) . $matches[2]. '" title="' . $matchart->description() . '" class="internal"'; } }, $text @@ -214,14 +217,14 @@ class Modelrender extends Modelart $linkfrom = []; $rend = $this; $text = preg_replace_callback( - '%\[([\w-]+)\]%', + '%\[([\w-]+)\/?#?([a-z-_]*)\]%', function ($matches) use ($rend, &$linkfrom) { $matchart = $rend->get($matches[1]); if (!$matchart) { return '' . $matches[1] . ''; } else { $linkfrom[] = $matchart->id(); - return '' . $matchart->title() . ''; + return '' . $matchart->title() . ''; } }, $text @@ -230,14 +233,29 @@ class Modelrender extends Modelart return $text; } + public function headerid($text) + { + $sum = []; + $text = preg_replace_callback('/(.+)<\/h[1-6]>/mU', + function ($matches) use (&$sum) { + $cleanid = idclean($matches[4]); + $sum[$cleanid][$matches[1]] = $matches[4]; + return ''.$matches[4].''; + }, + $text + ); + $this->sum = $sum; + return $text; + } + public function markdown($text) { //use Michelf\MarkdownExtra; $fortin = new Michelf\MarkdownExtra; // id in headers - $fortin->header_id_func = function ($header) { - return preg_replace('/[^\w]/', '', strtolower($header)); - }; + // $fortin->header_id_func = function ($header) { + // return preg_replace('/[^\w]/', '', strtolower($header)); + // }; $fortin->hard_wrap = true; $text = $fortin->transform($text); return $text; @@ -267,10 +285,8 @@ class Modelrender extends Modelart preg_match_all('#(.+)#iU', $text, $out); - $sum = []; - foreach ($out[2] as $key => $value) { - $sum[$value][$out[1][$key]] = $out[3][$key]; - } + $sum = $this->sum; + $sumstring = ''; diff --git a/app/class/modeluser.php b/app/class/modeluser.php index 1644a35..9dc2af1 100644 --- a/app/class/modeluser.php +++ b/app/class/modeluser.php @@ -46,7 +46,7 @@ class Modeluser extends Model } } - public function invitetest() + public function invitetest($pass) { $invitepasslist = []; if(in_array($pass, $invitepasslist)) { diff --git a/app/class/routes.php b/app/class/routes.php index d2658a5..384d274 100644 --- a/app/class/routes.php +++ b/app/class/routes.php @@ -26,7 +26,7 @@ class Routes ['POST', '/[cid:art]/edit', 'Controllerart#update', 'artupdate'], ['GET', '/[cid:art]/delete', 'Controllerart#confirmdelete', 'artconfirmdelete'], ['POST', '/[cid:art]/delete', 'Controllerart#delete', 'artdelete'], - ['GET', '/[cid:art]/[*]', 'Controllerart#artdirect', 'artread/etoile'], + //['GET', '/[cid:art]/[*]', 'Controllerart#artdirect', 'artread/etoile'], ]); $match = $router->match(); -- cgit v1.2.3