<?php
/**
 * @package BILLETS
 * @link 	http://www.dioscouri.com
 * @license GNU/GPLv2
 */
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

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

/**
* 	BilletsController
*/
// ************************************************************************
class BilletsControllerAddon extends BilletsController {

	var $_type;

	/**
	 * constructor (registers additional tasks to methods)
	 * @return void
	 */
	function __construct() {
		global $mainframe;
		
		parent::__construct();

		// Register Extra tasks
		// $this->registerTask( 'save' );
		// $this->registerTask( 'unpublish', 'publish' );
		
		// set the type
		$this->_type = strval( htmlspecialchars( $mainframe->getUserStateFromRequest( "type", 'type', 'lang' ) ) );
	}

	/**
	 * display 
	 * @return void
	 */
	function display() {
		JRequest::setVar( 'view', 'addon' );
		JRequest::setVar( 'layout', 'editsource'  );
		// JRequest::setVar('hidemainmenu', 1);

		parent::display();

	}

	/**
	 * display the editsource form
	 * @return void
	 */
	function edit() {
		JRequest::setVar( 'view', 'addon' );
		JRequest::setVar( 'layout', 'editsource'  );
		// JRequest::setVar('hidemainmenu', 1);

		parent::display();
	}

	/**
	 * save a record (and redirect to main page)
	 * @return void
	 */
	function save() {
		$model = $this->getModel( 'addon' );
		$model->store();
	}

	/**
	 * cancel and redirect to main page
	 * @return void
	 */
	function cancel() {
		$link = 'index.php?option='._THISCOMPONENT.'&controller=addons&type='.$this->_type;
	    $msg = JText::_( _BILLETS_OPERATIONCANCELLED );
	    $this->setRedirect( $link, $msg, 'notice' );		
	}
	    
}
// ************************************************************************

?>