<?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 CeHideawayTripReader extends \ContentElement
{
/**
* Template
* @var string
*/
protected $strTemplate = 'ce_hideaway_trip_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 Trip 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;
$id = $this->Input->get('items');
$this->import('Hideaway');
$obj = $this->Hideaway->getTripEntry($id, true);
$tmp = array();
for($i=1; $i<=10; $i++)
{
if($obj['row']['pos_'.$i.'_location']!='')
{
$objModel = \FilesModel::findByUuid($obj['row']['pos_'.$i.'_image']);
$tmp[] = array(
'pos'=>$i,
'location'=>$obj['row']['pos_'.$i.'_location'],
'image_path'=>$objModel->path,
'image_meta'=>unserialize($objModel->meta),
'teaser'=>$obj['row']['pos_'.$i.'_teaser']
);
}
}
$obj['stations'] = $tmp;
$this->Template->entry = $obj;
}
}