From d39bec8e089a55ebd370fbe9f4b5388aafade10d Mon Sep 17 00:00:00 2001 From: vincent-peugnet Date: Tue, 9 Jul 2019 13:33:02 +0200 Subject: 1.2.3 fix unused thumbnail open media tag --- app/class/art2.php | 29 +++++++++++++++-------------- app/class/config.php | 4 ++-- app/class/modelrender.php | 7 ++++++- 3 files changed, 23 insertions(+), 17 deletions(-) (limited to 'app/class') diff --git a/app/class/art2.php b/app/class/art2.php index 01ce218..2bd1138 100644 --- a/app/class/art2.php +++ b/app/class/art2.php @@ -32,7 +32,6 @@ class Art2 protected $templatejavascript; protected $templateoptions; protected $favicon; - protected $thumbnail; protected $authors; protected $invites; protected $readers; @@ -104,7 +103,6 @@ class Art2 $this->settemplatejavascript(''); $this->settemplateoptions(['externalcss', 'externaljavascript', 'favicon', 'reccursivecss', 'quickcss']); $this->setfavicon(''); - $this->setthumbnail(''); $this->setauthors([]); $this->setinvites([]); $this->setreaders([]); @@ -138,6 +136,21 @@ class Art2 return $array; } + /** + * Check if page have a thumbnail + * @return bool true if the page have a thumbnail otherwise return false. + */ + public function thumbnailexist() : bool + { + $thumbnaillink = Model::THUMBNAIL_DIR . $this->id . '.jpg'; + + $test = file_exists($thumbnaillink); + + $exist = file_exists(Model::THUMBNAIL_DIR . $this->id . '.jpg'); + + return $exist; + } + // _____________________________________________________ G E T ____________________________________________________ @@ -412,11 +425,6 @@ class Art2 return $this->favicon; } - public function thumbnail($type = 'string') - { - return $this->thumbnail; - } - public function authors($type = 'array') { return $this->authors; @@ -716,13 +724,6 @@ class Art2 } } - public function setthumbnail($thumbnail) - { - if (is_string($thumbnail)) { - $this->thumbnail = $thumbnail; - } - } - public function setauthors($authors) { if(is_array($authors)) { diff --git a/app/class/config.php b/app/class/config.php index b3ef40c..dbc6d80 100644 --- a/app/class/config.php +++ b/app/class/config.php @@ -97,9 +97,9 @@ abstract class Config * Generate full url adress where W is installed * @return string url adress finished by a slash "/" */ - public static function url() : string + public static function url($endslash = true) : string { - return self::$domain . (!empty(self::$basepath) ? '/' . self::$basepath : "") . '/'; + return self::$domain . (!empty(self::$basepath) ? '/' . self::$basepath : "") . ($endslash ? '/' : ''); } // ________________________________________ G E T _______________________________________ diff --git a/app/class/modelrender.php b/app/class/modelrender.php index 914ca93..553442d 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -3,6 +3,7 @@ class Modelrender extends Modelart { protected $router; + /** @var art2 */ protected $art; protected $artlist; protected $linkfrom = []; @@ -202,7 +203,11 @@ class Modelrender extends Modelart $head .= '' . PHP_EOL; $head .= '' . PHP_EOL; - $head .= '' . PHP_EOL; + + if($this->art->thumbnailexist()) { + $head .= '' . PHP_EOL; + } + $head .= '' . PHP_EOL; -- cgit v1.2.3