<?php
/**
* @version 1.0.0
* @package RSEvents! 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 rseventsViewLocations extends JView
{
	function display($tpl = null)
	{
		$task=JRequest::getVar('task','','request');
		switch($task)
		{
			
			case 'listlocations':
			{
				JToolBarHelper::title(JText::_('RSE_LOCATION_LIST'),'generic.png');
				JToolBarHelper::addNewX('editlocation');
				JToolBarHelper::editListX('editlocation');
				JToolBarHelper::deleteList();
				JToolBarHelper::publishList();
				JToolBarHelper::unpublishList();
				JToolBarHelper::custom('main','preview.png','preview_f2.png',JText::_('RSE_RS_PRODUCT'),false);
				
				$filter			=JRequest::getVar('rs_filter');
				$sortColumn		=JRequest::getVar('filter_order','#__rsevents_locations.ordering');
				$sortOrder	=JRequest::getVar('filter_order_Dir','asc');
				$listLocat=$this->get('data');
				$pagination=$this->get('pagination');
				$LocationList=$this->get('listLocations');
				
				
				$this->assignRef('filter',$filter);
				$this->assignRef('sortColumn',$sortColumn);
				$this->assignRef('sortOrder',$sortOrder);
				$this->assignRef('listLocations',$LocationList);
				$this->assignRef('data',$listLocat);
				$this->assignRef('pagination',$pagination);
			} break;
			
			case 'editlocation':
			{
				
				global $mainframe;
				$db=& JFactory::getDBO();
				$cid=JRequest::getVar('cid',array(0),'request','array');
				if(is_array($cid)) $cid=intval($cid[0]);
				if($cid==0)
					JToolBarHelper::title(JText::_('RSE_LOCATION_NEW','generic.png'));
				else 
					JToolBarHelper::title(JText::_('RSE_LOCATION_EDIT','generic.png'));
				JToolBarHelper::save();
				JToolBarHelper::apply();
				JToolBarHelper::cancel();
				
				
				$this->assignRef('rseventsConfig',$mainframe->getUserState('rseventsConfig'));
				$location=$this->get('Location');
				$this->assignRef('data',$location);
				
				//set publish to 1 if the location is new
				if($cid == 0) $location->published=1;
			
			} break;
		}
		
		
		parent::display($tpl);
	}
}