<?php
/**
* Contao Open Source CMS
*
* Copyright (C) 2005-2013 Leo Feyer
*
* @package Comments
* @link https://contao.org
* @license http://www.gnu.org/licenses/lgpl-3.0.html LGPL
*/
/**
* Run in a custom namespace, so the class can be replaced
*/
namespace hideaway;
/**
* Class CeHideawayList
*
* @copyright Leo Feyer 2005-2013
* @author Leo Feyer <https://contao.org>
* @package Comments
*/
class CeHideawayRegionHeaderReader extends \ContentElement
{
/**
* Template
* @var string
*/
protected $strTemplate = 'ce_hideaway_region_header_reader';
/**
* Display a wildcard in the back end
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE')
{
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### Hideaway Region Header Reader ###';
$objTemplate->title = $this->headline;
return $objTemplate->parse();
}
// Set the item from the auto_item parameter
if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item']))
{
\Input::setGet('items', \Input::get('auto_item'));
}
return parent::generate();
}
/**
* Generate the module
*/
protected function compile()
{
global $objPage;
$this->import('Hideaway');
$region = $this->Hideaway->getRegionByUrl();
$this->Template->entry = $region;
// Testimonials über das zugehörige Land laden
$testimonials = array();
if ($region && isset($region['row']['country']))
{
$objTestimonials = \Database::getInstance()
->prepare("SELECT * FROM tl_hideaway_testimonial WHERE published='1' AND country=? ORDER BY sorting ASC")
->execute($region['row']['country']);
while ($objTestimonials->next())
{
$testimonials[] = (object) array(
'name' => $objTestimonials->name,
'rating' => (int) $objTestimonials->rating,
'title' => $objTestimonials->title,
'text' => $objTestimonials->text,
);
}
}
$this->Template->testimonials = $testimonials;
}
}