- md5
- 780e3be4f9159838e3a255eda1f58460
- sha1
- 6ab462bfdc986257a7e91cf3ad06195321875d72
- sha256
- 90f8f76044b041d98058e480bf576246dd7f81f409016049dfc7590605279106
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Config\Site\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
use Joomla\Component\Templates\Administrator\Controller\Style;
/**
* Component Controller
*
* @since 1.5
*/
class TemplatesController extends BaseController
{
/**
* Constructor.
*
* @param array $config An optional associative array of configuration settings.
* @param MVCFactoryInterface $factory The factory.
* @param CMSApplication $app The JApplication for the dispatcher
* @param \JInput $input Input
*
* @since 1.6
* @see \JControllerLegacy
*/
public function __construct($config = array(), MVCFactoryInterface $factory = null, $app = null, $input = null)
{
parent::__construct($config, $factory, $app, $input);
// Apply, Save & New, and Save As copy should be standard on forms.
$this->registerTask('apply', 'save');
}
/**
* Method to handle cancel
*
* @return boolean True on success.
*
* @since 3.2
*/
public function cancel()
{
// Redirect back to home(base) page
$this->setRedirect(\JUri::base());
}
/**
* Method to save global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function save()
{
// Check for request forgeries.
if (!\JSession::checkToken())
{
$this->setRedirect('index.php', \JText::_('JINVALID_TOKEN'));
}
// Check if the user is authorized to do this.
if (!\JFactory::getUser()->authorise('core.admin'))
{
$this->setRedirect('index.php', \JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// Set FTP credentials, if given.
\JClientHelper::setCredentialsFromRequest('ftp');
$app = $this->app;
// Access backend com_templates
\JLoader::register('TemplatesControllerStyle', JPATH_ADMINISTRATOR . '/components/com_templates/controllers/style.php');
\JLoader::register('TemplatesModelStyle', JPATH_ADMINISTRATOR . '/components/com_templates/models/style.php');
\JLoader::register('TemplatesTableStyle', JPATH_ADMINISTRATOR . '/components/com_templates/tables/style.php');
$controllerClass = new Style;
// Get a document object
$document = \JFactory::getDocument();
// Set backend required params
$document->setType('json');
$this->input->set('id', $app->getTemplate('template')->id);
// Execute backend controller
$return = $controllerClass->save();
// Reset params back after requesting from service
$document->setType('html');
// Check the return value.
if ($return === false)
{
// Save the data in the session.
// TODO Which data?! How did that work?
$app->setUserState('com_config.config.global.data', $data);
// Save failed, go back to the screen and display a notice.
$message = \JText::sprintf('JERROR_SAVE_FAILED');
$app->redirect(\JRoute::_('index.php?option=com_config&view=templates', false), $message, 'error');
return false;
}
// Set the success message.
$message = \JText::_('COM_CONFIG_SAVE_SUCCESS');
// Redirect back to com_config display
$app->redirect(\JRoute::_('index.php?option=com_config&view=templates', false), $message);
return true;
}
}
No other release has this exact content. See every version of this file.