<?php
/**
 * @version		$Id: controller.php 132 2009-06-23 07:25:22Z 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.controller');

/**
 * Component Controller
 *
 * @package		TAOJ.Quanta
 * @subpackage	com_quanta
 */
class QuantaController extends JController
{
	/**
	 * Display the view
	 */
	function display()
	{
		// Get the document object.
		$document	= &JFactory::getDocument();

		// Set the default view name and format from the Request.
		$vName		= JRequest::getWord('view', 'charts');
		$vFormat	= $document->getType();
		$lName		= JRequest::getWord('layout', 'default');

		// Get and render the view.
		if ($view = &$this->getView($vName, $vFormat))
		{
			switch ($vName)
			{
				default:
					$model	= &$this->getModel($vName);
					break;
			}

			// Push the model into the view (as default).
			$view->setModel($model, true);
			$view->setLayout($lName);

			// Push document object into the view.
			$view->assignRef('document', $document);

			$this->_addSubmenu($vName);
			$view->display();
		}
	}

	/**
	 * Configure the Linkbar
	 *
	 * @param	string	The name of the active view
	 */
	protected function _addSubmenu($vName)
	{
		JSubMenuHelper::addEntry(JText::_('Quanta_Submenu_Charts'),		'index.php?option=com_quanta&view=charts',		$vName == 'charts');
		JSubMenuHelper::addEntry(JText::_('Quanta_Submenu_Categories'),	'index.php?option=com_quanta&view=categories',	$vName == 'categories');
		JSubMenuHelper::addEntry(JText::_('Quanta_Submenu_Records'),	'index.php?option=com_quanta&view=records',		$vName == 'records');
		JSubMenuHelper::addEntry(JText::_('Quanta_Submenu_Histories'),	'index.php?option=com_quanta&view=histories',	$vName == 'histories');
	}
}