<?php
/**
 * @package     SP Soccer
 * @author      JoomShaper http://www.joomshaper.com
 * @copyright   Copyright (C) 2010 - 2016 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die('Restricted access');

class SpsoccerViewVanues extends FOFViewForm{

	public function display($tpl = null){
		// Get model
		$model = $this->getModel();
		$this->items = $model->getItemList();

		JHtml::_('jquery.framework');
		// get component params
		jimport('joomla.application.component.helper');
		$this->cParams      = JComponentHelper::getParams('com_spsoccer');
		$gmap_api           = $this->cParams->get('gmap_api');

		// Add Script
		$doc = JFactory::getDocument();
		if ($gmap_api) {
				$doc->addScript('//maps.google.com/maps/api/js?libraries=places&key='. $gmap_api .'');
		} else {
				$doc->addScript('//maps.google.com/maps/api/js?libraries=places');
		}
		$doc->addScript( JURI::base(true) . '/components/com_spsoccer/assets/js/gmap.js');

		foreach ($this->items as &$this->item) {
			$this->item->url 				= JRoute::_('index.php?option=com_spsoccer&view=vanue&id=' . $this->item->spsoccer_vanue_id . ':' . $this->item->slug . SpsoccerHelper::getItemid('vanues'));
			$this->item->socials 		= json_decode($this->item->socials);
			// Map
			$this->item->map = explode(',', $this->item->map);
		}

		return parent::display($tpl = null);
	}

}
