77 lines
2.9 KiB
PHP
77 lines
2.9 KiB
PHP
<?php
|
|
/*************************************************************************************/
|
|
/* */
|
|
/* Copyright (c) CQFDev */
|
|
/* email : thelia@cqfdev.fr */
|
|
/* web : http://www.cqfdev.fr */
|
|
/* */
|
|
/*************************************************************************************/
|
|
|
|
namespace SliderRevolution\Controller;
|
|
|
|
use SliderRevolution\SliderRevolution;
|
|
use Thelia\Controller\Admin\BaseAdminController;
|
|
use Thelia\Core\Security\AccessManager;
|
|
use Thelia\Core\Security\Resource\AdminResources;
|
|
use Thelia\Form\Exception\FormValidationException;
|
|
use Thelia\Tools\URL;
|
|
|
|
/**
|
|
* @author Franck Allimant <franck@cqfdev.fr>
|
|
*/
|
|
class ConfigurationController extends BaseAdminController
|
|
{
|
|
public function configure()
|
|
{
|
|
if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'SliderRevolution', AccessManager::UPDATE)) {
|
|
return $response;
|
|
}
|
|
|
|
$configurationForm = $this->createForm('sliderrevolution.form.configure');
|
|
|
|
try {
|
|
$form = $this->validateForm($configurationForm, "POST");
|
|
|
|
// Get the form field values
|
|
$data = $form->getData();
|
|
|
|
foreach ($data as $name => $value) {
|
|
if (is_array($value)) {
|
|
$value = implode(';', $value);
|
|
}
|
|
|
|
SliderRevolution::setConfigValue($name, $value);
|
|
}
|
|
|
|
$this->adminLogAppend(
|
|
"sliderrevolution.configuration.message",
|
|
AccessManager::UPDATE,
|
|
sprintf("Configuration du franco mise à jour")
|
|
);
|
|
|
|
if ($this->getRequest()->get('save_mode') == 'stay') {
|
|
// If we have to stay on the same page, redisplay the configuration page/
|
|
$url = '/admin/module/SliderRevolution';
|
|
} else {
|
|
// If we have to close the page, go back to the module back-office page.
|
|
$url = '/admin/modules';
|
|
}
|
|
|
|
return $this->generateRedirect(URL::getInstance()->absoluteUrl($url));
|
|
} catch (FormValidationException $ex) {
|
|
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
|
} catch (\Exception $ex) {
|
|
$error_msg = $ex->getMessage();
|
|
}
|
|
|
|
$this->setupFormErrorContext(
|
|
$this->getTranslator()->trans("Configuration du franco", [], SliderRevolution::DOMAIN_NAME),
|
|
$error_msg,
|
|
$configurationForm,
|
|
$ex
|
|
);
|
|
|
|
return $this->generateRedirect(URL::getInstance()->absoluteUrl('/admin/module/SliderRevolution'));
|
|
}
|
|
}
|