| Current Path : /home/juvelize/www/administrator/components/com_ffgate/controllers/ |
| Current File : /home/juvelize/www/administrator/components/com_ffgate/controllers/settings.php |
<?php
/**
* @package FFGate
* @author Yves Hoppe <yves@compojoom.com>
* @date 26.11.13
*
* @copyright Copyright (C) 2008 - 2013 compojoom.com - Yves Hoppe. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('_JEXEC') or die('Restricted access');
/**
* Class FFGateControllersettings
*
* @since 1.0.0
*/
class FFGateControllersettings extends JControllerLegacy
{
/**
* The constrcutor
*/
public function __construct()
{
parent::__construct();
// Add extra tasks
$this->registerTask('apply', 'save');
}
/**
* Saves the Settings
*
* @return void
*/
public function save()
{
$ffgateSet = JFactory::getApplication()->input->get('ffgateset', array(0), 'post', 'array');
require_once JPATH_COMPONENT . '/models/settings.php';
$model = new FFGateModelSettings;
switch (JFactory::getApplication()->input->get('task'))
{
case 'apply':
if ($model->store($ffgateSet))
{
$msg = JText::_('COM_FFGATE_CHANGES_TO_FFGATE_SETTINGS_SAVED');
}
else
{
$msg = JText::_('COM_FFGATE_ERROR_SAVING_FFGATE_SETTINGS');
}
$this->setRedirect('index.php?option=com_ffgate&view=settings', $msg);
break;
case 'save':
default:
if ($model->store($ffgateSet))
{
$msg = JText::_('COM_FFGATE_SETTINGS_SAVED');
}
else
{
$msg = JText::_('COM_FFGATE_ERROR_SAVING_FFGATE_SETTINGS');
}
$this->setRedirect('index.php?option=com_ffgate', $msg);
break;
}
$model->checkin();
}
/**
* Displays the form
*
* @param bool $cachable - Cachable
* @param string $urlparams - Urlparams
*
* @return void
*/
public function display($cachable = false, $urlparams = false)
{
$document = JFactory::getDocument();
$viewName = JFactory::getApplication()->input->get('view', 'settings');
$viewType = $document->getType();
$view = $this->getView($viewName, $viewType);
require_once JPATH_COMPONENT . '/models/settings.php';
$model = new FFGateModelSettings;
$view->setModel($model, true);
$view->setLayout('default');
$view->display();
}
/**
* Cancels the settings view
*
* @return void
*/
public function cancel()
{
$this->setRedirect('index.php?option=com_ffgate');
}
/**
* Resets all settings (Drops table settings)
* and reinitializes them
*
* @return void
*/
public function reset()
{
// First let us drop all settings
$db = JFactory::getDbo();
$query = "TRUNCATE TABLE #__ffgate_settings";
$db->setQuery($query);
$db->execute();
// Include script.php
require_once JPATH_COMPONENT_ADMINISTRATOR . "/script.php";
$script = new Com_FFgateInstallerScript;
$status = $script->settingsContent(false);
$msg = JText::_("COM_FFGATE_SETTINGS_RESET_SUCCESS") . " " . $status;
$this->setRedirect('index.php?option=com_ffgate&view=settings', $msg);
}
}