. * * PHP version 5 * @copyright cgo IT, 2013 * @author Carsten Götzinger (info@cgo-it.de) * @package rateit * @license GNU/LGPL * @filesource */ namespace cgoIT\rateit; class RateItPage extends \Frontend { /** * Initialize the controller */ public function __construct() { parent::__construct(); $this->loadDataContainer('settings'); } public function outputFrontendTemplate($strContent, $strTemplate) { global $objPage; if ($objPage->addRating && !($strTemplate == $GLOBALS['TL_CONFIG']['rating_template'])) { $actRecord = $this->Database->prepare("SELECT * FROM tl_rateit_items WHERE rkey=? and typ='page'") ->execute($objPage->id) ->fetchAssoc(); if ($actRecord['active']) { $this->import('rateit\\RateItRating', 'RateItRating'); $this->RateItRating->rkey = $objPage->id; $this->RateItRating->generate(); $rating = $this->RateItRating->output(); $rating .= $this->includeJs(); $rating .= $this->includeCss(); $posMainDiv = strpos($strContent, '
'); $posInsideDiv = strpos($strContent, '
', $posMainDiv); $return = substr($strContent, 0, $posInsideDiv).'
'; $return .= $rating; $return .= substr($strContent, $posInsideDiv + strlen('
') + 3); $strContent = $return; } } return $strContent; } private function includeCss() { $included = false; $strHeadTags = ''; foreach ($GLOBALS['TL_CSS'] as $script) { if ($script == 'system/modules/rateit/public/css/rateit.css') { $included = true; } } if (!$included) { $strHeadTags = ''; switch ($GLOBALS['TL_CONFIG']['rating_type']) { case 'hearts' : $strHeadTags .= ''; break; default: $strHeadTags .= ''; } } return $strHeadTags; } private function includeJs() { $included = false; $strHeadTags = ''; foreach ($GLOBALS['TL_JAVASCRIPT'] as $script) { if ($script == 'system/modules/rateit/public/js/rateit.js') { $included = true; } } if (!$included) { $strHeadTags = 'outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('system/modules/rateit/public/js/onReadyRateIt.js') . '">' . "\n"; $strHeadTags .= 'outputFormat == 'xhtml') ? ' type="text/javascript"' : '') . ' src="' . $this->addStaticUrlTo('system/modules/rateit/public/js/rateit.js') . '">' . "\n"; } return $strHeadTags; } } ?>