<?php
/**
* @version 1.0.0
* @package RSFiles! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined( '_JEXEC' ) or die( 'Restricted access' ); 
jimport( 'joomla.application.component.view');

class rsfilesViewLicenses extends JView
{
	function display($tpl = null)
	{
		global $mainframe;
	
		JSubMenuHelper::addEntry(JText::_('RSFL_FILES_MENU'), 'index.php?option=com_rsfiles&task=files'); 
		JSubMenuHelper::addEntry(JText::_('RSFL_LICENSE_MENU'), 'index.php?option=com_rsfiles&task=licenses',true); 
		JSubMenuHelper::addEntry(JText::_('RSFL_GROUPS_MENU'), 'index.php?option=com_rsfiles&task=groups'); 
		JSubMenuHelper::addEntry(JText::_('RSFL_STATISTICS_MENU'), 'index.php?option=com_rsfiles&task=statistics');
		JSubMenuHelper::addEntry(JText::_('RSFL_THEMES_MENU'), 'index.php?option=com_rsfiles&task=themes');
		JSubMenuHelper::addEntry(JText::_('RSFL_SETTINGS_MENU'), 'index.php?option=com_rsfiles&task=settings'); 
		JSubMenuHelper::addEntry(JText::_('RSFL_UPDATES_MENU'), 'index.php?option=com_rsfiles&task=updates'); 		
	
		$rsfilesConfig = rsfilesHelper::getConfig();
		$this->assignRef('rsfilesConfig',$rsfilesConfig);
		$task=JRequest::getVar('task','','request');
		switch($task)
		{
			
			case 'licenses':
			{
				JToolBarHelper::title(JText::_('RSFL_LICENSES'),'rsfl-license');
				JToolBarHelper::addNewX('editlicense');
				JToolBarHelper::editListX('editlicense');
				JToolBarHelper::deleteList();
				JToolBarHelper::publishList();
				JToolBarHelper::unpublishList();
				JToolBarHelper::custom('rsfiles','rsfiles-32','rsfiles-32',JText::_('RSFL_PRODUCT'),false);
				
				$data = $this->get('Data');
				$pagination=$this->get('pagination');
				$jFilter = JRequest::getVar('jFilter');
				
				$this->assignRef('data',$data);
				$this->assignRef('pagination',$pagination);
				$this->assignRef('jFilter',$jFilter);
				
			} break;
			
			case 'editlicense':
			{
				$cid=JRequest::getVar('cid',array(0),'request','array');
				if(is_array($cid)) $cid=intval($cid[0]);
				if($cid==0)
					JToolBarHelper::title(JText::_('RSFL_NEW_LICENSE','generic.png'));
				else 
					JToolBarHelper::title(JText::_('RSFL_EDIT_LICENSE','generic.png'));
				JToolBarHelper::save();
				JToolBarHelper::apply();
				JToolBarHelper::cancel();
				
				$data = $this->get('License');
				if(!$cid) $data->published = 1;
				
				$this->assignRef('data',$data);
			
			} break;
		}
		
		
		parent::display($tpl);
	}
}