<?php
/*
 *
 * @package		ARI Smart Content
 * @author		ARI Soft
 * @copyright	Copyright (c) 2011 www.ari-soft.com. All rights reserved
 * @license		GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
 * 
 */

(defined('_JEXEC') && defined('ARI_FRAMEWORK_LOADED')) or die;

AriKernel::import('Joomla.Controllers.Controller');

class AriSmartContentControllerConfig extends AriController 
{
	function display() 
	{
		$config = AriSmartContentHelper::getConfig();

		$view =& $this->getView();
		$view->display($config, JRequest::getInt('scActiveTab'));
	}

	function save()
	{
		JRequest::checkToken() or jexit('Invalid Token');

		$this->_save();
		
		$activeTab = JRequest::getInt('scActiveTab');
		$this->redirect('index.php?option=com_arismartcontent&view=config' . ($activeTab ? '&scActiveTab=' . $activeTab : '') . '&__MSG=COM_ARISMARTCONTENT_COMPLETE_CONFIGSAVE');
	}

	function _save()
	{
		$data = JRequest::getVar('params', null, 'default', 'none', JREQUEST_ALLOWRAW);

		unset($data['Version']);
		unset($data['HelpPath']);
		
		$config = AriSmartContentHelper::getConfig();
		
		$group = $config->getGroups();
		$config->bind($data, $group);
		$config->save(true, $group);
	}
}