From eba4d7aa0ee5ea1bcb29e8254c28a272023ea54f Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Tue, 21 Apr 2020 18:57:18 +0200 Subject: correct warning psr 12 : 120 characters lines --- app/class/Modelrender.php | 88 +++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 33 deletions(-) (limited to 'app/class/Modelrender.php') diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index a683d65..553857b 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -84,7 +84,7 @@ class Modelrender extends Modelpage $body = $this->getbody($this->readbody()); $parsebody = $this->bodyparser($body); - $html = '' . PHP_EOL . '' . PHP_EOL . '' . PHP_EOL . $head . PHP_EOL . '' . PHP_EOL . $parsebody . PHP_EOL . ''; + $html = '\n\n\n' . $head . '\n\n' . $parsebody . '\N'; return $html; } @@ -158,10 +158,12 @@ class Modelrender extends Modelpage $subcontent = $this->getpageelement($source, $type); if ($subcontent !== false) { if (empty($subcontent && self::RENDER_VERBOSE > 0)) { - $subcontent = PHP_EOL . '' . PHP_EOL; + $message = 'The ' . strtoupper($type) . ' from page "' . $source . '" is currently empty !'; + $subcontent = '\n\n'; } } else { - $read = '

Rendering error :

The page ' . $source . ', does not exist yet.

'; + $read = '

Rendering error :

'; + $read .= '

The page ' . $source . ', does not exist yet.

'; //throw new Exception($read); } } else { @@ -227,38 +229,42 @@ class Modelrender extends Modelpage $head = ''; - $head .= '' . PHP_EOL; - $head .= '' . $this->page->title() . '' . PHP_EOL; + $head .= '\n'; + $head .= '' . $this->page->title() . '\n'; if (!empty($this->page->favicon())) { - $head .= ''; + $href = Model::faviconpath() . $this->page->favicon(); + $head .= ''; } elseif (!empty(Config::defaultfavicon())) { - $head .= ''; + $href = Model::faviconpath() . Config::defaultfavicon(); + $head .= ''; } - $head .= '' . PHP_EOL; - $head .= '' . PHP_EOL; + $head .= '\n'; + $head .= '\n'; - $head .= '' . PHP_EOL; - $head .= '' . PHP_EOL; + $head .= '\n'; + $head .= '\n'; if (!empty($this->page->thumbnail())) { - $head .= '' . PHP_EOL; + $content = Config::domain() . self::thumbnailpath() . $this->page->thumbnail(); + $head .= '\n'; } elseif (!empty(Config::defaultthumbnail())) { - $head .= '' . PHP_EOL; + $content = Config::domain() . self::thumbnailpath() . Config::defaultthumbnail(); + $head .= '\n'; } - $head .= '' . PHP_EOL; + $head .= '\n'; foreach ($this->page->externalcss() as $externalcss) { - $head .= '' . PHP_EOL; + $head .= '\n'; } if (!empty($this->page->templatecss() && in_array('externalcss', $this->page->templateoptions()))) { $templatecss = $this->get($this->page->templatecss()); if ($templatecss !== false) { foreach ($templatecss->externalcss() as $externalcss) { - $head .= '' . PHP_EOL; + $head .= '\n'; } } } @@ -266,25 +272,25 @@ class Modelrender extends Modelpage $head .= PHP_EOL . $this->page->customhead() . PHP_EOL; - $head .= '' . PHP_EOL; - $head .= '' . PHP_EOL; + $head .= '\n'; + $head .= '\n'; if (!empty($this->page->templatecss())) { $tempaltecsspage = $this->page->templatecss(); - $head .= '' . PHP_EOL; + $head .= '\n'; } - $head .= '' . PHP_EOL; + $head .= '\n'; if (!empty($this->page->templatejavascript())) { $templatejspage = $this->page->templatejavascript(); - $head .= '' . PHP_EOL; + $head .= '\n'; } if (!empty($this->page->javascript())) { - $head .= '' . PHP_EOL; + $head .= '\n'; } if (!empty(Config::analytics())) { - $head .= PHP_EOL . ' + $head .= '\n - ' . PHP_EOL; + \n'; } if (!empty($this->page->redirection())) { if (preg_match('%https?:\/\/\S*%', $this->page->redirection(), $out)) { $url = $out[0]; - $head .= PHP_EOL . ''; + $head .= '\n'; } elseif (key_exists($this->page->redirection(), $this->pagelist())) { $url = $this->upage($this->page->redirection()); - $head .= PHP_EOL . ''; + $head .= '\n'; } } @@ -343,7 +349,8 @@ class Modelrender extends Modelpage public function media(string $text): string { - $text = preg_replace('%(src|href)="([\w-_]+(\/([\w-_])+)*\.[a-z0-9]{1,5})"%', '$1="' . Model::mediapath() . '$2" target="_blank" class="media"', $text); + $regex = '%(src|href)="([\w-_]+(\/([\w-_])+)*\.[a-z0-9]{1,5})"%'; + $text = preg_replace($regex, '$1="' . Model::mediapath() . '$2" target="_blank" class="media"', $text); if (!is_string($text)) { //throw new Exception('Rendering error -> media module'); } @@ -381,11 +388,16 @@ class Modelrender extends Modelpage function ($matches) use ($rend, &$linkto) { $matchpage = $rend->get($matches[1]); if (!$matchpage) { - $link = 'href="' . $rend->upage($matches[1]) . '"" title="' . Config::existnot() . '" class="internal existnot"' . $this->internallinkblank; + $href = $rend->upage($matches[1]); + $t = Config::existnot(); + $c = 'internal existnot"' . $this->internallinkblank; } else { + $href = $rend->upage($matches[1]) . $matches[2]; + $t = $matchpage->description(); + $c = 'internal exist ' . $matchpage->secure('string'); $linkto[] = $matchpage->id(); - $link = 'href="' . $rend->upage($matches[1]) . $matches[2] . '" title="' . $matchpage->description() . '" class="internal exist ' . $matchpage->secure('string') . '"' . $this->internallinkblank; } + $link = 'href="' . $href . '" title="' . $t . '" class="' . $c . '"' . $this->internallinkblank; return $link; }, $text @@ -403,11 +415,19 @@ class Modelrender extends Modelpage function ($matches) use ($rend, &$linkto) { $matchpage = $rend->get($matches[1]); if (!$matchpage) { - return 'internallinkblank . ' >' . $matches[1] . ''; + $href = $rend->upage($matches[1]); + $t = Config::existnot(); + $c = 'internal existnot" ' . $this->internallinkblank; + $a = $matches[1]; } else { + $href = $rend->upage($matches[1]) . $matches[2]; + $t = $matchpage->description(); + $c = 'internal exist ' . $matchpage->secure('string'); + $a = $matchpage->title(); $linkto[] = $matchpage->id(); - return 'internallinkblank . ' >' . $matchpage->title() . ''; } + $i = $this->internallinkblank; + return '' . $a . ''; }, $text ); @@ -478,7 +498,7 @@ class Modelrender extends Modelpage } else { $id = ' '; } - return '
' . PHP_EOL . PHP_EOL . $matches[3] . PHP_EOL . PHP_EOL . '
' . PHP_EOL . PHP_EOL; + return '
\n\n' . $matches[3] . '\n\n
\n\n'; }, $text); $text = preg_replace('/\R\R[=]{3,}([\w-]*)\R/', '', $text); return $text; @@ -591,7 +611,9 @@ class Modelrender extends Modelpage */ public function thumbnail(string $text): string { - $img = '' . $this->page->title() . ''; + $src = Model::thumbnailpath() . $this->page->thumbnail(); + $alt = $this->page->title(); + $img = '' . $alt . ''; $img = PHP_EOL . $img . PHP_EOL; $text = str_replace('%THUMBNAIL%', $img, $text); -- cgit v1.2.3