<?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 rsfilesViewRsfiles extends JView
{
	function display($tpl = null)
	{		
		global $mainframe;
		
		$rsfilesConfig = rsfilesHelper::getConfig();
		$this->assignRef('rsfilesConfig',$rsfilesConfig);
		$task=JRequest::getVar('task','','request');
		switch($task)
		{
			case 'rsfiles':
			default:
			{	
				jimport('joomla.html.pane');
				JToolBarHelper::title(JText::_('RSFL_CONTROL_PANEL'),'rsfl-cpanel');
				JToolBarHelper::custom('main','rsfiles-32','rsfiles-32',JText::_('RSFL_PRODUCT'),false);
				$slider =& JPane::getInstance('Sliders',array('allowAllClose' => true),true);
				$this->assignRef('slider',$slider);
			} break;
			
			case 'settings':
			{
				JToolBarHelper::title(JText::_('RSFL_SETTINGS'), 'rsfl-settings');
				JToolBarHelper::save();
				JToolBarHelper::apply();
				JToolBarHelper::cancel();
				JToolBarHelper::custom('main','rsfiles-32','rsfiles-32',JText::_('RSFL_PRODUCT'),false);
				
				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'); 
				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',true); 
				JSubMenuHelper::addEntry(JText::_('RSFL_UPDATES_MENU'), 'index.php?option=com_rsfiles&task=updates');
				
				JHTML::_('behavior.modal');
				JHTML::_('behavior.mootools');
				jimport('joomla.html.pane');
				$params = array();
				$params['startOffset'] = JRequest::getInt('tabposition', 0);
				$tabs =& JPane::getInstance('Tabs',$params,true);
				$slider =& JPane::getInstance('Sliders',array('allowAllClose' => true),true);
				
				$order = array();
				$order[] = JHTML::_('select.option', 'name', JText::_('RSFL_ORDER_NAME') );
				$order[] = JHTML::_('select.option', 'date', JText::_('RSFL_ORDER_DATE') );
				$order[] = JHTML::_('select.option', 'hits', JText::_('RSFL_ORDER_HITS') );
				$lists['ordering'] = JHTML::_('select.genericlist', $order, 'rsfilesConfig[default_order]', 'size="1" class="inputbox"', 'value', 'text', $rsfilesConfig['default_order'] );
				
				$way = array();
				$way[] = JHTML::_('select.option', 'ASC', JText::_('RSFL_ORDER_ASC') );
				$way[] = JHTML::_('select.option', 'DESC', JText::_('RSFL_ORDER_DESC') );
				$lists['ordering_way'] = JHTML::_('select.genericlist', $way, 'rsfilesConfig[default_order_way]', 'size="1" class="inputbox"', 'value', 'text', $rsfilesConfig['default_order_way'] );
				
				$updown = array();
				$updown[] = JHTML::_('select.option', '0', JText::_('RSFL_UP') );
				$updown[] = JHTML::_('select.option', '1', JText::_('RSFL_DOWN') );
				$updown[] = JHTML::_('select.option', '2', JText::_('RSFL_UPDWN') );
				$lists['paginationp'] = JHTML::_('select.genericlist', $updown, 'rsfilesConfig[show_pagination_position]', 'size="1" class="inputbox"', 'value', 'text', $rsfilesConfig['show_pagination_position'] );
				
				
				$this->assignRef('tabs',$tabs);
				$this->assignRef('slider',$slider);
				$this->assignRef('lists',$lists);
				$this->assignRef('editor', JFactory::getEditor());
				
			}
			break;
			
			case 'dldlocation':
			{
				$folders = $this->get('folders');
				$this->assignRef('folders', $folders);
				$this->assignRef('elements', $this->get('elements'));
				
				$this->assignRef('current', $this->get('current'));
				$this->assignRef('previous', $this->get('previous'));
				
			} break;
			
			case 'update':
			{
				JToolBarHelper::title(JText::_('RSFL_UPDATE'),'generic.png');
				JToolBarHelper::custom('main','rsfiles-32','rsfiles-32',JText::_('RSFL_PRODUCT'),false);				
			}
			break;
		 
		 }
		parent::display($tpl);
	}
	
	function genKeyCode(){
		global $mainframe;
		$rsfilesConfig = rsfilesHelper::getConfig();
		return md5($rsfilesConfig['license_code'].RSFL_RS_KEY);
	}
}