<?php
/**
 * @version		$Id: view.html.php 134 2009-06-24 05:52:18Z 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 QuantaViewChart extends JView
{
	protected $state;
	protected $item;

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

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

		$this->assignRef('state',	$state);
		$this->assignRef('item',	$item);

		parent::display($tpl);

		$this->_prepareDocument();
	}

	/**
	 * Prepares the metadata in the document.
	 */
	protected function _prepareDocument()
	{
		$app		= &JFactory::getApplication();
		$pathway	= &$app->getPathway();
		$menus		= &JSite::getMenu();

		if ($menu = $menus->getActive())
		{
			if ($menu->query['view'] != 'chart') {
				$pathway->addItem($this->item->title, '');
			}
		}

		// Handle Page Title
		$this->document->setTitle($this->item->title);
		$this->document->setMetadata('title', $this->item->title);

		// Set metatags
		if ($this->item->metadesc) {
			$this->document->setDescription($this->item->metadesc);
		}
		if ($this->item->metakey) {
			$this->document->setMetadata('keywords', $this->item->metakey);
		}
	}
}