<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_advent
 *
 * @copyright   Copyright (C) 2014-2015 astrid-guenther.de. All rights reserved.
 * @license     GNU General Public License version 2
 */
defined('_JEXEC') or die;

/**
 * AdventViewImagemap
 *
 * @since  0.0.12
 */
class AdventViewImagemap extends JViewLegacy
{
	protected $item;

	protected $form;

	/**
	 * Method display 
	 * 
	 * @param   string  $tpl  The template
	 *
	 * @return  void
	 *
	 * @since   0.0.12
	 */
	public function display($tpl = null)
	{
		$this->item = $this->get('Item');
		$this->form = $this->get('Form');

		if (count($errors = $this->get('Errors')))
		{
			JError::raiseError(500, implode('<br />', $errors));

			return false;
		}

		JHtml::_('jquery.framework');
		JHtml::script('media/jquery.Jcrop.min.js', false, true);
		JHtml::stylesheet('media/jquery.Jcrop.min.css', array(), true);
		JHtml::script('com_advent/script.js', false, true);
		JHtml::stylesheet('com_advent/custom.css', array(), true);
		$this->backpic = JURI::root() . JComponentHelper::getParams('com_advent')->get('show_image',  'media/com_advent/images/advent_grau.png');

		$this->addToolBar();
		parent::display($tpl);
	}

	/**
	 * Method addToolBar 
	 * 
	 * @return  void
	 *
	 * @since   0.0.12
	 */
	protected function addToolBar()
	{
		JFactory::getApplication()->input->set('hidemainmenu', true);

		JToolBarHelper::title(empty($this->item->id) ? JText::_('COM_ADVENT_MANAGER_ADVENT_NEW') : JText::_('COM_ADVENT_MANAGER_ADVENT_EDIT'), 'Advent');

		JToolbarHelper::save('advent.save');

		if (empty($this->item->id))
		{
			JToolbarHelper::cancel('advent.cancel');
		}
		else
		{
			JToolbarHelper::cancel('advent.cancel', 'JTOOLBAR_CLOSE');
		}
	}
}
