From 32ea39f8a3cd32c45c2d31ceb736d855848aa52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20G=C3=B6tzinger?= Date: Thu, 25 Jun 2015 14:08:19 +0200 Subject: [PATCH] Versucht, Fehlermeldungen zu unterbinden --- classes/RateItPage.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/classes/RateItPage.php b/classes/RateItPage.php index f681c06..9961bf3 100644 --- a/classes/RateItPage.php +++ b/classes/RateItPage.php @@ -70,20 +70,23 @@ class RateItPage extends \Frontend { private function includeCss() { $included = false; $strHeadTags = ''; - foreach ($GLOBALS['TL_CSS'] as $script) { - if ($script == 'system/modules/rateit/public/css/rateit.css') { - $included = true; + if (is_array($GLOBALS['TL_CSS'])) { + foreach ($GLOBALS['TL_CSS'] as $script) { + if ($this->startsWith($script, 'system/modules/rateit/public/css/rateit') === true) { + $included = true; + break; + } } } if (!$included) { - $strHeadTags = ''; + $strHeadTags = ''; switch ($GLOBALS['TL_CONFIG']['rating_type']) { case 'hearts' : - $strHeadTags .= ''; + $strHeadTags .= ''; break; default: - $strHeadTags .= ''; + $strHeadTags .= ''; } } return $strHeadTags; @@ -92,9 +95,12 @@ class RateItPage extends \Frontend { private function includeJs() { $included = false; $strHeadTags = ''; - foreach ($GLOBALS['TL_JAVASCRIPT'] as $script) { - if ($script == 'system/modules/rateit/public/js/rateit.js') { - $included = true; + if (is_array($GLOBALS['TL_JAVASCRIPT'])) { + foreach ($GLOBALS['TL_JAVASCRIPT'] as $script) { + if ($this->startsWith($script, 'system/modules/rateit/public/js/rateit') === true) { + $included = true; + break; + } } } @@ -104,5 +110,10 @@ class RateItPage extends \Frontend { } return $strHeadTags; } + + function startsWith($haystack, $needle) { + // search backwards starting from haystack length characters from the end + return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== FALSE; + } } ?> \ No newline at end of file