<?php
/**
 * Adodis Blog package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2012 - 2013 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/
defined('_JEXEC') or die;

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

class AdodisBlogViewSettings extends JView
{
	protected $form;
	protected $item;
	protected $state;

	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		$this->form			= $this->get('Form');
		$this->item			= $this->get('Item');
		$this->state		= $this->get('State');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}

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

	/**
	 * Add the page title and toolbar.
	 */
	protected function addToolbar()
	{
		$canDo 				= AdodisBlogHelper::getActions();
		$title				= JText::_('COM_ADODISBLOG').' : '.JText::_('COM_ADODISBLOG_GLOBALSETTINGS');

		JToolBarHelper::title($title, 'adodisblog.png');

		if ($canDo->get('core.admin')) {
			JToolBarHelper::apply('settings.apply','JTOOLBAR_APPLY');
		}

		JToolBarHelper::cancel('settings.cancel', 'JTOOLBAR_CLOSE');
		JToolBarHelper::divider();

		if ($canDo->get('core.admin')) {
			JToolBarHelper::preferences('com_adodisblog');
			JToolBarHelper::divider();
		}

	}
}
