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