<?php
/*
 * @package Sj K2 Filter
 * @version 1.1.0
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @copyright (c) 2016 YouTech Company. All Rights Reserved.
 * @author YouTech Company http://www.smartaddons.com
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

$controller = JRequest::getWord('view', 'itemlist');
$task = JRequest::getWord('task');


jimport('joomla.filesystem.file');
jimport('joomla.html.parameter');

if (JFile::exists(JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php')) {
	if( JFile::exists(JPATH_BASE.DS.'components'.DS.'com_k2'.DS.'k2.php')) {
		JLoader::register('K2FilterController', JPATH_COMPONENT.DS.'controllers'.DS.'controller.php');
		JLoader::register('SJK2FilterModel', JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'model.php');
		JLoader::register('SJK2FilterView', JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'view.php');
		JLoader::register('SJK2FilterHelper', JPATH_COMPONENT.DS.'helpers'.DS.'helper.php');
		
		//load language from component k2
		$lang = JFactory::getLanguage();
		$lang->load('com_k2');

		require_once (JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php');
		$classname = 'SJK2FilterController'.$controller;
		$controller = new $classname();
		$controller->execute($task);
		$controller->redirect();
		
	}else{
		$app = JFactory::getApplication();
		$app->redirect('index.php',JText::_('COMPONENT_K2_NOT_FOUND'),'error');
		
	}
}
else {
	JError::raiseError(404, JText::_('COMPONENT_NOT_FOUND'));
}

