<?php
/**
 * @version		$Id: version.php 71 2009-05-30 10:16:47Z eddieajau $
 * @copyright	Copyright (C) 2009 New Life in IT Pty Ltd. All rights reserved.
 * @license		GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
 * @link		http://www.theartofjoomla.com
 */

// no direct access
defined('_JEXEC') or die;

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

/**
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 */
class QuantaViewHistories extends JView
{
	protected $state;
	protected $items;
	protected $pagination;
	protected $f_published;

	/**
	 * Display the view
	 */
	public function display($tpl = null)
	{
		$state		= $this->get('State');
		$items		= $this->get('Items');
		$pagination	= $this->get('Pagination');

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

		$this->assignRef('state',		$state);
		$this->assignRef('items',		$items);
		$this->assignRef('pagination',	$pagination);

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

	/**
	 * Display the toolbar
	 *
	 * @access	private
	 */
	protected function _addToolbar()
	{
		$state = $this->get('State');
		JToolBarHelper::title(JText::_('Quanta_Histories_Title'), 'logo');
		JToolBarHelper::custom('histories.publish', 'publish.png', 'publish_f2.png', 'Publish', true);
		JToolBarHelper::custom('histories.unpublish', 'unpublish.png', 'unpublish_f2.png', 'Unpublish', true);
		if ($state->get('filter.published') == -2) {
			JToolBarHelper::deleteList('', 'histories.delete');
		}
		else {
			JToolBarHelper::trash('histories.trash');
		}
		JToolBarHelper::custom('history.edit', 'edit.png', 'edit_f2.png', 'Edit', true);
		JToolBarHelper::custom('history.edit', 'new.png', 'new_f2.png', 'New', false);

		JToolBarHelper::divider();
		$toolbar = &JToolBar::getInstance('toolbar');
		$toolbar->appendButton('Popup', 'unarchive', 'Quanta_Toolbar_Import', 'index.php?option=com_quanta&view=import&tmpl=component', 570, 500);
	}
}