Merge branch 'master' into modules
Conflicts: core/lib/Thelia/Core/Template/Assets/AsseticAssetManager.php core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
This commit is contained in:
@@ -411,9 +411,9 @@ abstract class AbstractCrudController extends BaseAdminController
|
||||
} catch (FormValidationException $ex) {
|
||||
// Form cannot be validated
|
||||
$error_msg = $this->createStandardFormValidationErrorMessage($ex);
|
||||
} catch (\Exception $ex) {
|
||||
/*} catch (\Exception $ex) {
|
||||
// Any other error
|
||||
$error_msg = $ex->getMessage();
|
||||
$error_msg = $ex->getMessage();*/
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
|
||||
105
core/lib/Thelia/Controller/Admin/ConfigStoreController.php
Normal file
105
core/lib/Thelia/Controller/Admin/ConfigStoreController.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
|
||||
use Thelia\Core\Security\Resource\AdminResources;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Form\ConfigStoreForm;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
/**
|
||||
* Class ConfigStoreController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Christophe Laffont <claffont@openstudio.fr>
|
||||
*/
|
||||
class ConfigStoreController extends BaseAdminController
|
||||
{
|
||||
|
||||
protected function renderTemplate()
|
||||
{
|
||||
return $this->render('config-store');
|
||||
}
|
||||
|
||||
public function defaultAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::STORE, array(), AccessManager::VIEW)) return $response;
|
||||
|
||||
// Hydrate the store configuration form
|
||||
$configStoreForm = new ConfigStoreForm($this->getRequest(), 'form', array(
|
||||
'store_name' => ConfigQuery::read("store_name"),
|
||||
'store_email' => ConfigQuery::read("store_email"),
|
||||
'store_business_id' => ConfigQuery::read("store_business_id"),
|
||||
'store_phone' => ConfigQuery::read("store_phone"),
|
||||
'store_fax' => ConfigQuery::read("store_fax"),
|
||||
'store_address1' => ConfigQuery::read("store_address1"),
|
||||
'store_address2' => ConfigQuery::read("store_address2"),
|
||||
'store_address3' => ConfigQuery::read("store_address3"),
|
||||
'store_zipcode' => ConfigQuery::read("store_zipcode"),
|
||||
'store_city' => ConfigQuery::read("store_city"),
|
||||
'store_country' => ConfigQuery::read("store_country")
|
||||
));
|
||||
|
||||
$this->getParserContext()->addForm($configStoreForm);
|
||||
|
||||
return $this->renderTemplate();
|
||||
}
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::STORE, array(), AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
$configStoreForm = new ConfigStoreForm($this->getRequest());
|
||||
|
||||
try {
|
||||
$form = $this->validateForm($configStoreForm);
|
||||
|
||||
$data = $form->getData();
|
||||
|
||||
// Update store
|
||||
foreach($data as $name => $value) {
|
||||
if(! in_array($name , array('success_url', 'error_message')))
|
||||
ConfigQuery::write($name, $value, false);
|
||||
}
|
||||
|
||||
$this->adminLogAppend(AdminResources::STORE, AccessManager::UPDATE, "Store configuration changed");
|
||||
|
||||
$this->redirectToRoute('admin.configuration.store.default');
|
||||
|
||||
} catch (\Exception $ex) {
|
||||
$error_msg = $ex->getMessage();
|
||||
}
|
||||
|
||||
$this->setupFormErrorContext(
|
||||
$this->getTranslator()->trans("Store configuration failed."),
|
||||
$error_msg,
|
||||
$configStoreForm,
|
||||
$ex
|
||||
);
|
||||
|
||||
return $this->renderTemplate();
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,9 @@ use Thelia\Core\Event\Message\MessageCreateEvent;
|
||||
use Thelia\Model\MessageQuery;
|
||||
use Thelia\Form\MessageModificationForm;
|
||||
use Thelia\Form\MessageCreationForm;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Template\TemplateHelper;
|
||||
|
||||
/**
|
||||
* Manages messages sent by mail
|
||||
@@ -90,6 +93,10 @@ class MessageController extends AbstractCrudController
|
||||
->setLocale($formData["locale"])
|
||||
->setTitle($formData['title'])
|
||||
->setSubject($formData['subject'])
|
||||
->setHtmlLayoutFileName($formData['html_layout_file_name'])
|
||||
->setHtmlTemplateFileName($formData['html_template_file_name'])
|
||||
->setTextLayoutFileName($formData['text_layout_file_name'])
|
||||
->setTextTemplateFileName($formData['text_template_file_name'])
|
||||
->setHtmlMessage($formData['html_message'])
|
||||
->setTextMessage($formData['text_message'])
|
||||
;
|
||||
@@ -111,14 +118,19 @@ class MessageController extends AbstractCrudController
|
||||
{
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'name' => $object->getName(),
|
||||
'secured' => $object->getSecured(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'subject' => $object->getSubject(),
|
||||
'html_message' => $object->getHtmlMessage(),
|
||||
'text_message' => $object->getTextMessage()
|
||||
'id' => $object->getId(),
|
||||
'name' => $object->getName(),
|
||||
'secured' => $object->getSecured(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'subject' => $object->getSubject(),
|
||||
'html_message' => $object->getHtmlMessage(),
|
||||
'text_message' => $object->getTextMessage(),
|
||||
|
||||
'html_layout_file_name' => $object->getHtmlLayoutFileName(),
|
||||
'html_template_file_name' => $object->getHtmlTemplateFileName(),
|
||||
'text_layout_file_name' => $object->getTextLayoutFileName(),
|
||||
'text_template_file_name' => $object->getTextTemplateFileName(),
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
@@ -152,17 +164,36 @@ class MessageController extends AbstractCrudController
|
||||
return $this->render('messages');
|
||||
}
|
||||
|
||||
protected function listDirectoryContent($requiredExtension) {
|
||||
|
||||
$list = array();
|
||||
|
||||
$dir = TemplateHelper::getInstance()->getActiveMailTemplate()->getAbsolutePath();
|
||||
|
||||
$finder = Finder::create()->files()->in($dir)->ignoreDotFiles(true)->sortByName()->name("*.$requiredExtension");
|
||||
|
||||
foreach ($finder as $file) {
|
||||
$list[] = $file->getBasename();
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function renderEditionTemplate()
|
||||
{
|
||||
return $this->render('message-edit', array('message_id' => $this->getRequest()->get('message_id')));
|
||||
return $this->render('message-edit', array(
|
||||
'message_id' => $this->getRequest()->get('message_id'),
|
||||
'layout_list' => $this->listDirectoryContent('tpl'),
|
||||
'html_template_list' => $this->listDirectoryContent('html'),
|
||||
'text_template_list' => $this->listDirectoryContent('txt'),
|
||||
));
|
||||
}
|
||||
|
||||
protected function redirectToEditionTemplate()
|
||||
{
|
||||
$this->redirectToRoute(
|
||||
"admin.configuration.messages.update",
|
||||
array('message_id' => $this->getRequest()->get('message_id'))
|
||||
);
|
||||
$this->redirectToRoute("admin.configuration.messages.update", array(
|
||||
'message_id' => $this->getRequest()->get('message_id')
|
||||
));
|
||||
}
|
||||
|
||||
protected function redirectToListTemplate()
|
||||
|
||||
@@ -121,7 +121,7 @@ class SystemLogController extends BaseAdminController
|
||||
|
||||
public function saveAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, array(), AccessManager::UPDATE)) return $response;
|
||||
if (null !== $response = $this->checkAuth(AdminResources::SYSTEM_LOG, array(), AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
|
||||
@@ -71,8 +71,8 @@ class TranslationsController extends BaseAdminController
|
||||
|
||||
case 'mo' :
|
||||
if (null !== $module = ModuleQuery::create()->findPk($item_id)) {
|
||||
$directory = THELIA_MODULE_DIR . $module->getBaseDir();
|
||||
$i18n_directory = THELIA_TEMPLATE_DIR . $module->getI18nPath();
|
||||
$directory = $module->getAbsoluteBaseDir();
|
||||
$i18n_directory = $module->getAbsoluteI18nPath();
|
||||
$walkMode = TemplateHelper::WALK_MODE_PHP;
|
||||
}
|
||||
break;
|
||||
@@ -97,8 +97,8 @@ class TranslationsController extends BaseAdminController
|
||||
}
|
||||
|
||||
if ($template) {
|
||||
$directory = THELIA_TEMPLATE_DIR . $template->getPath();
|
||||
$i18n_directory = THELIA_TEMPLATE_DIR . $template->getI18nPath();
|
||||
$directory = $template->getAbsolutePath();
|
||||
$i18n_directory = $template->getAbsoluteI18nPath();
|
||||
}
|
||||
|
||||
// Load strings to translate
|
||||
|
||||
Reference in New Issue
Block a user