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/Application.php | 29 ++++++++++++-- app/class/Colors.php | 4 +- app/class/Config.php | 2 +- app/class/Controllermedia.php | 6 ++- app/class/Element.php | 2 +- app/class/Event.php | 16 +++++++- app/class/Media.php | 9 +++-- app/class/Medialist.php | 16 +++++--- app/class/Modelfont.php | 5 ++- app/class/Modelmedia.php | 38 +++++++++---------- app/class/Modelrender.php | 88 +++++++++++++++++++++++++++---------------- app/class/Opt.php | 24 +++++++++--- app/class/Optlist.php | 11 +++--- app/class/Quickcss.php | 35 ++++++++++++++--- 14 files changed, 197 insertions(+), 88 deletions(-) (limited to 'app/class') diff --git a/app/class/Application.php b/app/class/Application.php index 0f69064..ab745a9 100644 --- a/app/class/Application.php +++ b/app/class/Application.php @@ -102,7 +102,10 @@ class Application -

Leave it empty if W-CMS is in your root folder, otherwise, indicate the subfolder(s) in witch you installed the CMS

+

+ Leave it empty if W-CMS is in your root folder, otherwise, + indicate the subfolder(s) in witch you installed the CMS +

@@ -115,8 +118,19 @@ class Application

- -

The secret key is used to secure cookies. There are no need to remind it. (16 to 128 characters)

+ +

+ The secret key is used to secure cookies. There are no need to remind it. + (16 to 128 characters) +

@@ -140,7 +154,14 @@ class Application

- +

Your user passworder as first administrator.

diff --git a/app/class/Colors.php b/app/class/Colors.php index 06875b5..234adb2 100644 --- a/app/class/Colors.php +++ b/app/class/Colors.php @@ -88,7 +88,9 @@ class Colors extends Item { $html = ''; return $html; diff --git a/app/class/Config.php b/app/class/Config.php index 74f2757..3c9afd9 100644 --- a/app/class/Config.php +++ b/app/class/Config.php @@ -21,7 +21,7 @@ abstract class Config protected static $privatepass = false; protected static $notpublishedpass = false; protected static $alertcss = false; - protected static $defaultbody = '%HEADER%' . PHP_EOL . PHP_EOL . '%NAV%' . PHP_EOL . PHP_EOL . '%ASIDE%' . PHP_EOL . PHP_EOL . '%MAIN%' . PHP_EOL . PHP_EOL . '%FOOTER%'; + protected static $defaultbody = '%HEADER%\n\n%NAV%\n\n%ASIDE%\n\n%MAIN%\n\n%FOOTER%'; protected static $defaultfavicon = ''; protected static $defaultthumbnail = ''; protected static $analytics = ''; diff --git a/app/class/Controllermedia.php b/app/class/Controllermedia.php index 11a27d3..06885b3 100644 --- a/app/class/Controllermedia.php +++ b/app/class/Controllermedia.php @@ -102,7 +102,11 @@ class Controllermedia extends Controller { if ($this->user->issupereditor() && isset($_POST['action']) && isset($_POST['id'])) { if ($_POST['action'] == 'delete') { - $this->mediamanager->multifiledelete($_POST['id']); + if ($this->mediamanager->multifiledelete($_POST['id'])) { + Model::sendflashmessage('Files deletion successfull', 'success'); + } else { + Model::sendflashmessage('Error while deleting files', 'error'); + } } elseif ($_POST['action'] == 'move' && isset($_POST['dir'])) { $this->mediamanager->multimovefile($_POST['id'], $_POST['dir']); } diff --git a/app/class/Element.php b/app/class/Element.php index 3160986..638d624 100644 --- a/app/class/Element.php +++ b/app/class/Element.php @@ -46,7 +46,7 @@ class Element extends Item public function addtags() { - $this->content = PHP_EOL . '<' . $this->type() . '>' . PHP_EOL . $this->content() . PHP_EOL . 'type() . '>' . PHP_EOL; + $this->content = '\n<' . $this->type() . '>\n' . $this->content() . '\ntype() . '>\n'; } diff --git a/app/class/Event.php b/app/class/Event.php index c14b0e8..3317a1b 100644 --- a/app/class/Event.php +++ b/app/class/Event.php @@ -16,7 +16,15 @@ class Event extends Dbitem protected $message; protected $clap = 0; - public const EVENT_TYPES = ['message', 'page_add', 'page_edit', 'page_delete', 'media_add', 'media_delete', 'font_add']; + public const EVENT_TYPES = [ + 'message', + 'page_add', + 'page_edit', + 'page_delete', + 'media_add', + 'media_delete', + 'font_add' + ]; public const EVENT_BASE = ['message']; public const EVENT_ART = ['page_add', 'page_edit', 'page_delete']; public const EVENT_MEDIA = ['media_add', 'media_delete']; @@ -112,7 +120,11 @@ class Event extends Dbitem if ($date instanceof DateTimeImmutable) { $this->date = $date; } elseif (is_string($date)) { - $this->date = DateTimeImmutable::createFromFormat(DateTime::ISO8601, $date, new DateTimeZone('Europe/Paris')); + $this->date = DateTimeImmutable::createFromFormat( + DateTime::ISO8601, + $date, + new DateTimeZone('Europe/Paris') + ); } } diff --git a/app/class/Media.php b/app/class/Media.php index def4645..9df2fef 100644 --- a/app/class/Media.php +++ b/app/class/Media.php @@ -100,7 +100,10 @@ class Media extends Item break; case 'video': - $code = '<video controls=""><source src="' . $this->getincludepath() . '" type="video/' . $this->extension . '"></video>'; + $src = $this->getincludepath(); + $ext = $this->extension; + $code = '<video controls="">'; + $code .= '<source src="' . $src . '" type="video/' . $ext . '"></video>'; break; default: @@ -267,14 +270,14 @@ class Media extends Item public function setwidth($width) { if (is_int($width)) { - $this->width = strip_tags(strtolower($width)); + $this->width = $width; } } public function setheight($height) { if (is_int($height)) { - $this->height = strip_tags(strtolower($height)); + $this->height = $height; } } diff --git a/app/class/Medialist.php b/app/class/Medialist.php index 35ea991..c597505 100644 --- a/app/class/Medialist.php +++ b/app/class/Medialist.php @@ -28,7 +28,7 @@ class Medialist extends Item /** @var int display download links*/ protected $links = 0; - /** @var string display the file name of the file */ + /** @var int display the file name of the file */ protected $filename = 0; public const TYPES = ['image', 'sound', 'video', 'other']; @@ -56,7 +56,6 @@ class Medialist extends Item $mediamanager = new Modelmedia(); $medialist = $mediamanager->getlistermedia($this->dir(), $this->type); if (!$medialist) { - $this->content = 'RENDERING ERROR : path : ' . Model::MEDIA_DIR . $this->path . '/ does not exist'; return false; } else { $mediamanager->medialistsort($medialist, $this->sortby, $this->order); @@ -67,14 +66,19 @@ class Medialist extends Item foreach ($medialist as $media) { $div .= '
'; + $id = 'id="media_' . $media->id() . '"'; + $path = $media->getincludepath(); + $ext = $media->extension(); if ($media->type() == 'image') { - $div .= '' . $media->id() . ''; + $div .= '' . $media->id() . ''; } elseif ($media->type() == 'sound') { - $div .= '
' . PHP_EOL; } diff --git a/app/class/Modelfont.php b/app/class/Modelfont.php index 4353b1c..be8de81 100644 --- a/app/class/Modelfont.php +++ b/app/class/Modelfont.php @@ -69,7 +69,10 @@ class Modelfont extends Model { $fontface = ''; foreach ($fontlist as $font) { - $fontface .= '@font-face {' . PHP_EOL . 'font-family: ' . $font['id'] . ';' . PHP_EOL . ' src: url( ' . Model::fontpath() . $font['id'] . '.' . $font['ext'] . ');' . PHP_EOL . '}' . PHP_EOL . PHP_EOL; + $fontface .= '@font-face {\n + font-family: ' . $font['id'] . ';\n + src: url( ' . Model::fontpath() . $font['id'] . '.' . $font['ext'] . '); + }\n\n'; } return $fontface; } diff --git a/app/class/Modelmedia.php b/app/class/Modelmedia.php index fc8a727..ceb9bc7 100644 --- a/app/class/Modelmedia.php +++ b/app/class/Modelmedia.php @@ -2,6 +2,8 @@ namespace Wcms; +use phpDocumentor\Reflection\Types\Mixed_; + class Modelmedia extends Model { @@ -38,36 +40,33 @@ class Modelmedia extends Model } /** - * Display a list of media + * get a list of media of selected types * - * @param string $path + * @param string $dir Media directory ot look at * @param array $type * - * @return array of Media objects + * @return Media[]|bool of Media objects */ public function getlistermedia($dir, $type = []) { - if (is_dir($dir)) { - if ($handle = opendir($dir)) { - $list = []; - while (false !== ($entry = readdir($handle))) { - if ($entry != "." && $entry != "..") { - $media = $this->getmedia($entry, $dir); - - if ($media != false) { - $media->analyse(); - - if (empty($type) || in_array($media->type(), $type)) { - $list[] = $media; - } + if (is_dir($dir) && $handle = opendir($dir)) { + $list = []; + while (false !== ($entry = readdir($handle))) { + if ($entry != "." && $entry != "..") { + $media = $this->getmedia($entry, $dir); + + if ($media != false) { + $media->analyse(); + + if (empty($type) || in_array($media->type(), $type)) { + $list[] = $media; } } } - return $list; } - } else { - return false; + return $list; } + return false; } @@ -313,7 +312,6 @@ class Modelmedia extends Model $success[] = $this->deletefile($filedir); } } - Model::sendflashmessage(count(array_filter($success)) . ' / ' . count($filelist) . ' files have been deleted', 'success'); if (in_array(false, $success)) { return false; } else { 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); diff --git a/app/class/Opt.php b/app/class/Opt.php index 0dc99cf..df3cb50 100644 --- a/app/class/Opt.php +++ b/app/class/Opt.php @@ -148,7 +148,8 @@ class Opt extends Item { $tagstring = ""; foreach ($taglist as $tag) { - $tagstring .= '' . $tag . '' . PHP_EOL; + $href = $this->getfilteradress(['tagfilter' => [$tag]]); + $tagstring .= '' . $tag . '' . PHP_EOL; } return $tagstring; } @@ -163,21 +164,24 @@ class Opt extends Item { $authorstring = ""; foreach ($authorlist as $author) { - $authorstring .= '' . $author . '' . PHP_EOL; + $href = $this->getfilteradress(['authorfilter' => [$author]]); + $authorstring .= '' . $author . '\n'; } return $authorstring; } public function securelink(int $level, string $secure) { - return '' . $secure . '' . PHP_EOL; + $href = $this->getfilteradress(['secure' => $level]); + return '' . $secure . '\n'; } public function linktolink(array $linktolist) { $linktostring = ""; foreach ($linktolist as $linkto) { - $linktostring .= '' . $linkto . '' . PHP_EOL; + $href = $this->getfilteradress(['linkto' => $linkto]); + $linktostring .= '' . $linkto . '\n'; } return $linktostring; } @@ -185,7 +189,17 @@ class Opt extends Item public function getfilteradress(array $vars = []) { - $varlist = ['sortby', 'order', 'secure', 'tagfilter', 'tagcompare', 'authorfilter', 'authorcompare', 'linkto', 'invert', 'limit']; + $varlist = [ + 'sortby', + 'order', + 'secure', + 'tagfilter', + 'tagcompare', + 'authorfilter', + 'authorcompare', + 'linkto', 'invert', + 'limit' + ]; // array_filter($vars, function ()) $object = $this->drylist($varlist); $object = array_merge($object, $vars); diff --git a/app/class/Optlist.php b/app/class/Optlist.php index 63536ee..32107d7 100644 --- a/app/class/Optlist.php +++ b/app/class/Optlist.php @@ -56,16 +56,17 @@ class Optlist extends Opt $content .= '' . $page->description() . ''; } if ($this->date()) { - $content .= '' . PHP_EOL; + $content .= '\n'; } if ($this->time()) { - $content .= '' . PHP_EOL; + $content .= '\n'; } if ($this->author()) { $content .= $page->authors('string') . PHP_EOL; } if ($this->thumbnail) { - $content .= '' . $page->title() . ''; + $src = Model::thumbnailpath() . $page->thumbnail(); + $content .= '' . $page->title() . ''; } @@ -93,12 +94,12 @@ class Optlist extends Opt public function li(string $content, string $id) { - return '
  • ' . PHP_EOL . $content . PHP_EOL . '
  • ' . PHP_EOL; + return '
  • ' . PHP_EOL . $content . PHP_EOL . '
  • \n'; } public function a(string $content, string $class, string $id) { - return '' . $content . '' . PHP_EOL; + return '' . $content . '\n'; } public function spandescription(Page $page) diff --git a/app/class/Quickcss.php b/app/class/Quickcss.php index bddea66..e2ee9f4 100644 --- a/app/class/Quickcss.php +++ b/app/class/Quickcss.php @@ -199,14 +199,23 @@ class Quickcss extends Item echo '

    ' . $element . '

    '; foreach ($css as $param => $value) { echo '
    '; - echo ''; + echo ''; echo ''; echo '
    '; echo '
    '; if (in_array($param, self::COLOR)) { - echo ''; + echo ''; } if (in_array($param, self::SIZE)) { @@ -238,7 +247,12 @@ class Quickcss extends Item public function sizeinput($element, $param, $value) { - echo ''; + echo ''; $unit = preg_replace('/\d/', '', $value); ?> @@ -251,7 +265,12 @@ class Quickcss extends Item public function fontsizeinput($element, $param, $value) { - echo ''; + echo ''; $unit = preg_replace('/\d/', '', $value); ?> @@ -264,7 +283,13 @@ class Quickcss extends Item public function opacityinput($element, $param, $value) { - echo ''; + echo ''; } public function selectinput($element, $param, $value) -- cgit v1.2.3