<?php
/**
 * @package		Joomla.Administrator
 * @subpackage	com_spstgsrv
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License, see LICENSE.php
 */

// No direct access.
defined('_JEXEC') or die;

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

/**
 * SPStgSrv Controller
 *
 * @package		Joomla.Administrator
 * @subpackage	com_spstgsrv
 * @since		1.5
 */
class SPStgSrvController extends JControllerLegacy
{
        protected $default_view = 'log';
        
	public function display($cachable = false, $urlparams = false)
	{
		require_once JPATH_COMPONENT.'/helpers/spstgsrv.php';

		$document = JFactory::getDocument();
		$vName		= JFactory::getApplication()->input->getCmd('view', $this->default_view);
		$vFormat	= $document->getType();
		$lName		= JFactory::getApplication()->input->getCmd('layout', 'default');
                
                // Get and render the view.
                $view = $this->getView($vName, $vFormat);
		if ($view) {
			
			$model = $this->getModel($vName);
                        if ($model) {
                                $view->setModel($model, true);
                        }
                        
			$view->setLayout($lName);

			// Push document object into the view.
			$view->assignRef('document', $document);
			// Load the submenu.
			SpStgSrvHelper::addSubmenu($vName);            
                        
                        $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . '/views/'.$vName.'/tmpl');
			$view->display();
		}

		return $this;
	}
}
