<?php
/**
 * @package DJ-Events
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 * @developer Szymon Woronowski - szymon.woronowski@design-joomla.eu
 *
 */

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

jimport('joomla.application.component.view');

class DJEventsViewLocations extends JViewLegacy
{
	protected $items;
	protected $pagination;
	protected $state;
    public $filterForm;
    public $activeFilters;

	public function display($tpl = null)
	{
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
        $this->cities = $this->get('Cities');
        $this->filterForm    = $this->get('FilterForm');
        $this->activeFilters = $this->get('ActiveFilters');
		
		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			throw new Exception(implode("\n", $errors), 500);
			return false;
		}
		$this->addToolbar();
        $version = new JVersion;

		
		$this->classes = DJEventsHelper::getBSClasses();

        if (version_compare($version->getShortVersion(), '4.0.0-rc3', '<')) {

            $this->sidebar = JHtmlSidebar::render();
            $this->setLayout('legacy');
        }

		parent::display($tpl);
	}

	protected function addToolbar()
	{
		JToolBarHelper::title(JText::_('COM_DJEVENTS_LOCATIONS'), 'generic.png');
		JToolBarHelper::addNew('location.add','JTOOLBAR_NEW');
		JToolBarHelper::editList('location.edit','JTOOLBAR_EDIT');
		JToolBarHelper::divider();
		JToolBarHelper::custom('locations.publish', 'publish.png', 'publish_f2.png','JTOOLBAR_PUBLISH', true);
		JToolBarHelper::custom('locations.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
		JToolBarHelper::deleteList('', 'locations.delete','JTOOLBAR_DELETE');
		JToolBarHelper::divider();
		JToolBarHelper::preferences('com_djevents', '450', '900');
		JToolBarHelper::divider();
	}
}
