diff --git a/core/bootstrap.php b/core/bootstrap.php
index 468df2eac..0cc61ceaa 100755
--- a/core/bootstrap.php
+++ b/core/bootstrap.php
@@ -11,12 +11,10 @@ define('THELIA_CONF_DIR' , THELIA_LOCAL_DIR . 'config/');
define('THELIA_MODULE_DIR' , THELIA_LOCAL_DIR . 'modules/');
define('THELIA_WEB_DIR' , THELIA_ROOT . 'web/');
define('THELIA_TEMPLATE_DIR' , THELIA_ROOT . 'templates/');
-define('DS', DIRECTORY_SEPARATOR);
+define('DS' , DIRECTORY_SEPARATOR);
$loader = require __DIR__ . "/vendor/autoload.php";
-
-
if (!file_exists(THELIA_ROOT . '/local/config/database.yml') && !defined('THELIA_INSTALL_MODE')) {
$request = \Thelia\Core\HttpFoundation\Request::createFromGlobals();
header('location: '.$request->getSchemeAndHttpHost() . '/install');
diff --git a/core/lib/Thelia/Action/HttpException.php b/core/lib/Thelia/Action/HttpException.php
index 50ee92d5e..10e0dad37 100755
--- a/core/lib/Thelia/Action/HttpException.php
+++ b/core/lib/Thelia/Action/HttpException.php
@@ -24,7 +24,7 @@
namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml
index e75ab8ebb..198f9f999 100755
--- a/core/lib/Thelia/Config/Resources/config.xml
+++ b/core/lib/Thelia/Config/Resources/config.xml
@@ -55,8 +55,6 @@
%kernel.debug%
-
-
diff --git a/core/lib/Thelia/Config/Resources/form.xml b/core/lib/Thelia/Config/Resources/form.xml
index 8577bf145..dda9be749 100644
--- a/core/lib/Thelia/Config/Resources/form.xml
+++ b/core/lib/Thelia/Config/Resources/form.xml
@@ -120,6 +120,8 @@
+
+
diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php
index 46760eba9..689ac9b1b 100644
--- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php
+++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php
@@ -253,7 +253,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Render the object list, ensuring the sort order is set.
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
protected function renderList()
{
@@ -263,7 +263,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* The default action is displaying the list.
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
public function defaultAction()
{
@@ -274,7 +274,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Create a new object
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
public function createAction()
{
@@ -335,7 +335,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Load a object for modification, and display the edit template.
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
public function updateAction()
{
@@ -361,7 +361,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Save changes on a modified object, and either go back to the object list, or stay on the edition page.
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
public function processUpdateAction()
{
@@ -516,7 +516,7 @@ abstract class AbstractCrudController extends BaseAdminController
/**
* Delete an object
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
public function deleteAction()
{
diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php
index 5fc11c814..d34f2ce82 100755
--- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php
+++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php
@@ -26,7 +26,7 @@ use Symfony\Component\Routing\Exception\InvalidParameterException;
use Symfony\Component\Routing\Exception\MissingMandatoryParametersException;
use Symfony\Component\Routing\Exception\RouteNotFoundException;
use Thelia\Controller\BaseController;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Model\ConfigQuery;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -85,7 +85,7 @@ class BaseAdminController extends BaseController
/**
* Return a 404 error
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
protected function pageNotFound()
{
@@ -97,7 +97,7 @@ class BaseAdminController extends BaseController
*
* @param mixed $message a message string, or an exception instance
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
protected function errorPage($message, $status = 500)
{
@@ -373,7 +373,7 @@ class BaseAdminController extends BaseController
* @param $templateName the complete template name, with extension
* @param array $args the template arguments
* @param int $status http code status
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
protected function render($templateName, $args = array(), $status = 200)
{
@@ -387,7 +387,7 @@ class BaseAdminController extends BaseController
* @param array $args the template arguments
* @param null $templateDir
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
protected function renderRaw($templateName, $args = array(), $templateDir = null)
{
diff --git a/core/lib/Thelia/Controller/Admin/CategoryController.php b/core/lib/Thelia/Controller/Admin/CategoryController.php
index 86e4bb00c..018aa3586 100755
--- a/core/lib/Thelia/Controller/Admin/CategoryController.php
+++ b/core/lib/Thelia/Controller/Admin/CategoryController.php
@@ -23,7 +23,7 @@
namespace Thelia\Controller\Admin;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Category\CategoryDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
@@ -320,7 +320,7 @@ class CategoryController extends AbstractCrudController
/**
* Add category pictures
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function addRelatedPictureAction()
{
diff --git a/core/lib/Thelia/Controller/Admin/ConfigController.php b/core/lib/Thelia/Controller/Admin/ConfigController.php
index f8eafe820..67aec848a 100644
--- a/core/lib/Thelia/Controller/Admin/ConfigController.php
+++ b/core/lib/Thelia/Controller/Admin/ConfigController.php
@@ -181,7 +181,7 @@ class ConfigController extends AbstractCrudController
/**
* Change values modified directly from the variable list
*
- * @return Symfony\Component\HttpFoundation\Response the response
+ * @return Thelia\Core\HttpFoundation\Response the response
*/
public function changeValuesAction()
{
diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php
index adf3cc697..0b850734c 100644
--- a/core/lib/Thelia/Controller/Admin/ContentController.php
+++ b/core/lib/Thelia/Controller/Admin/ContentController.php
@@ -64,7 +64,7 @@ class ContentController extends AbstractCrudController
/**
* controller adding content to additional folder
*
- * @return mixed|\Symfony\Component\HttpFoundation\Response
+ * @return mixed|\Thelia\Core\HttpFoundation\Response
*/
public function addAdditionalFolderAction()
{
@@ -92,7 +92,7 @@ class ContentController extends AbstractCrudController
/**
* controller removing additional folder to a content
*
- * @return mixed|\Symfony\Component\HttpFoundation\Response
+ * @return mixed|\Thelia\Core\HttpFoundation\Response
*/
public function removeAdditionalFolderAction()
{
diff --git a/core/lib/Thelia/Controller/Admin/CouponController.php b/core/lib/Thelia/Controller/Admin/CouponController.php
index 5cc71ac00..0169a16b9 100755
--- a/core/lib/Thelia/Controller/Admin/CouponController.php
+++ b/core/lib/Thelia/Controller/Admin/CouponController.php
@@ -58,7 +58,7 @@ class CouponController extends BaseAdminController
/**
* Manage Coupons list display
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function browseAction()
{
@@ -90,7 +90,7 @@ class CouponController extends BaseAdminController
*
* @param int $couponId Coupon Id
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function readAction($couponId)
{
@@ -117,7 +117,7 @@ class CouponController extends BaseAdminController
/**
* Manage Coupons creation display
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function createAction()
{
@@ -165,7 +165,7 @@ class CouponController extends BaseAdminController
*
* @param int $couponId Coupon id
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function updateAction($couponId)
{
@@ -270,7 +270,7 @@ class CouponController extends BaseAdminController
*
* @param string $conditionId Condition service id
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function getConditionInputAction($conditionId)
{
@@ -300,7 +300,7 @@ class CouponController extends BaseAdminController
*
* @param int $couponId Coupon id
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
public function updateConditionsAction($couponId)
{
diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php
index 93a007426..9719748fc 100644
--- a/core/lib/Thelia/Controller/Admin/CustomerController.php
+++ b/core/lib/Thelia/Controller/Admin/CustomerController.php
@@ -61,7 +61,7 @@ class CustomerController extends BaseAdminController
* update customer action
*
* @param $customer_id
- * @return mixed|\Symfony\Component\HttpFoundation\Response
+ * @return mixed|\Thelia\Core\HttpFoundation\Response
*/
public function updateAction($customer_id)
{
diff --git a/core/lib/Thelia/Controller/Admin/FileController.php b/core/lib/Thelia/Controller/Admin/FileController.php
index ced780181..5c712898a 100755
--- a/core/lib/Thelia/Controller/Admin/FileController.php
+++ b/core/lib/Thelia/Controller/Admin/FileController.php
@@ -25,7 +25,7 @@ namespace Thelia\Controller\Admin;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Document\DocumentCreateOrUpdateEvent;
use Thelia\Core\Event\Document\DocumentDeleteEvent;
diff --git a/core/lib/Thelia/Controller/Admin/LangController.php b/core/lib/Thelia/Controller/Admin/LangController.php
index 7c9eefad5..ccf980c81 100644
--- a/core/lib/Thelia/Controller/Admin/LangController.php
+++ b/core/lib/Thelia/Controller/Admin/LangController.php
@@ -117,7 +117,7 @@ class LangController extends BaseAdminController
$changedObject = $event->getLang();
$this->adminLogAppend(AdminResources::LANGUAGE, AccessManager::UPDATE, sprintf("%s %s (ID %s) modified", 'Lang', $changedObject->getTitle(), $changedObject->getId()));
- $this->redirectToRoute('/admin/configuration/languages');
+ $this->redirectToRoute('admin.configuration.languages');
} catch (\Exception $e) {
$error_msg = $e->getMessage();
}
diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php
index 429d9837e..ff075b0e4 100644
--- a/core/lib/Thelia/Controller/Admin/OrderController.php
+++ b/core/lib/Thelia/Controller/Admin/OrderController.php
@@ -23,7 +23,7 @@
namespace Thelia\Controller\Admin;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Order\OrderAddressEvent;
use Thelia\Core\Event\Order\OrderEvent;
diff --git a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php
index 2bd6363cc..8e8f38eec 100644
--- a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php
+++ b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php
@@ -55,7 +55,7 @@ class ShippingZoneController extends BaseAdminController
}
/**
- * @return mixed|\Symfony\Component\HttpFoundation\Response
+ * @return mixed|\Thelia\Core\HttpFoundation\Response
*/
public function addArea()
{
diff --git a/core/lib/Thelia/Controller/Admin/SystemLogController.php b/core/lib/Thelia/Controller/Admin/SystemLogController.php
new file mode 100644
index 000000000..96621717c
--- /dev/null
+++ b/core/lib/Thelia/Controller/Admin/SystemLogController.php
@@ -0,0 +1,182 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Controller\Admin;
+
+
+use Thelia\Core\Security\Resource\AdminResources;
+use Thelia\Core\Security\AccessManager;
+use Thelia\Form\SystemLogConfigurationForm;
+use Thelia\Log\Tlog;
+use Thelia\Model\ConfigQuery;
+/**
+ * Class LangController
+ * @package Thelia\Controller\Admin
+ * @author Manuel Raynaud
+ */
+class SystemLogController extends BaseAdminController
+{
+
+ protected function renderTemplate()
+ {
+ $destinations = array();
+
+ $destination_directories = Tlog::getInstance()->getDestinationsDirectories();
+
+ foreach($destination_directories as $dir) {
+ $this->loadDefinedDestinations($dir, $destinations);
+ }
+
+ $active_destinations = explode(";", ConfigQuery::read(Tlog::VAR_DESTINATIONS, Tlog::DEFAUT_DESTINATIONS));
+
+ return $this->render('system-logs',
+ array(
+ 'ip_address' => $this->getRequest()->getClientIp(),
+ 'destinations' => $destinations,
+ 'active_destinations' => $active_destinations
+ )
+ );
+ }
+
+ protected function loadDefinedDestinations($directory, &$destinations) {
+
+ try {
+ foreach (new \DirectoryIterator($directory) as $fileInfo) {
+
+ if ($fileInfo->isDot()) continue;
+
+ $matches = array();
+
+ if (preg_match("/([^\.]+)\.php/", $fileInfo->getFilename(), $matches)) {
+
+ $classname = $matches[1];
+
+ if (! isset($destinations[$classname])) {
+
+ $full_class_name = "Thelia\\Log\\Destination\\".$classname;
+
+ $destinations[$classname] = new $full_class_name();
+ }
+ }
+ }
+ } catch (\UnexpectedValueException $ex) {
+ // Directory does no exists -> Nothing to do
+ }
+ }
+
+ public function defaultAction()
+ {
+ if (null !== $response = $this->checkAuth(AdminResources::SYSTEM_LOG, AccessManager::VIEW)) return $response;
+
+ /*
+ const VAR_LEVEL = "tlog_level";
+ const VAR_DESTINATIONS = "tlog_destinations";
+ const VAR_PREFIXE = "tlog_prefix";
+ const VAR_FILES = "tlog_files";
+ const VAR_IP = "tlog_ip";
+ const VAR_SHOW_REDIRECT = "tlog_show_redirect";
+
+ const DEFAULT_LEVEL = self::DEBUG;
+ const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationFile";
+ const DEFAUT_PREFIXE = "#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: ";
+ const DEFAUT_FILES = "*";
+ const DEFAUT_IP = "";
+ const DEFAUT_SHOW_REDIRECT = 0;
+
+ */
+
+ // Hydrate the general configuration form
+ $systemLogForm = new SystemLogConfigurationForm($this->getRequest(), 'form', array(
+ 'level' => ConfigQuery::read(Tlog::VAR_LEVEL, Tlog::DEFAULT_LEVEL),
+ 'format' => ConfigQuery::read(Tlog::VAR_PREFIXE, Tlog::DEFAUT_PREFIXE),
+ 'show_redirections' => ConfigQuery::read(Tlog::VAR_SHOW_REDIRECT, Tlog::DEFAUT_SHOW_REDIRECT),
+ 'files' => ConfigQuery::read(Tlog::VAR_FILES, Tlog::DEFAUT_FILES),
+ 'ip_addresses' => ConfigQuery::read(Tlog::VAR_IP, Tlog::DEFAUT_IP),
+ ));
+
+ $this->getParserContext()->addForm($systemLogForm);
+
+ return $this->renderTemplate();
+ }
+
+ public function saveAction()
+ {
+ if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
+
+ $error_msg = false;
+
+ $systemLogForm = new SystemLogConfigurationForm($this->getRequest());
+
+ try {
+ $form = $this->validateForm($systemLogForm);
+
+ $data = $form->getData();
+
+ ConfigQuery::write(Tlog::VAR_LEVEL , $data['level']);
+ ConfigQuery::write(Tlog::VAR_PREFIXE , $data['format']);
+ ConfigQuery::write(Tlog::VAR_SHOW_REDIRECT , $data['show_redirections']);
+ ConfigQuery::write(Tlog::VAR_FILES , $data['files']);
+ ConfigQuery::write(Tlog::VAR_IP , $data['ip_addresses']);
+
+ // Save destination configuration
+ $destinations = $this->getRequest()->get('destinations');
+ $configs = $this->getRequest()->get('config');
+
+ $active_destinations = array();
+
+ foreach($destinations as $classname => $destination) {
+
+ if (isset($destination['active'])) {
+ $active_destinations[] = $destination['classname'];
+ }
+
+ if (isset($configs[$classname])) {
+
+ // Update destinations configuration
+ foreach($configs[$classname] as $var => $value) {
+ ConfigQuery::write($var, $value, true, true);
+ }
+ }
+ }
+
+ // Update active destinations list
+ ConfigQuery::write(Tlog::VAR_DESTINATIONS, implode(';', $active_destinations));
+
+ $this->adminLogAppend(AdminResources::SYSTEM_LOG, AccessManager::UPDATE, "System log configuration changed");
+
+ $this->redirectToRoute('admin.configuration.system-logs.default');
+
+ } catch (\Exception $ex) {
+ $error_msg = $ex->getMessage();
+ }
+
+ $this->setupFormErrorContext(
+ $this->getTranslator()->trans("System log configuration failed."),
+ $error_msg,
+ $systemLogForm,
+ $ex
+ );
+
+ return $this->renderTemplate();
+ }
+}
diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php
index 4bfc3c65f..d5868b8d2 100755
--- a/core/lib/Thelia/Controller/BaseController.php
+++ b/core/lib/Thelia/Controller/BaseController.php
@@ -22,7 +22,7 @@
/*************************************************************************************/
namespace Thelia\Controller;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@@ -58,7 +58,7 @@ class BaseController extends ContainerAware
/**
* Return an empty response (after an ajax request, for example)
* @param int $status
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return \Thelia\Core\HttpFoundation\Response
*/
protected function nullResponse($status = 200)
{
diff --git a/core/lib/Thelia/Core/Bundle/TheliaBundle.php b/core/lib/Thelia/Core/Bundle/TheliaBundle.php
index 9a536f88d..3df5e4345 100755
--- a/core/lib/Thelia/Core/Bundle/TheliaBundle.php
+++ b/core/lib/Thelia/Core/Bundle/TheliaBundle.php
@@ -60,13 +60,12 @@ class TheliaBundle extends Bundle
$container->addScope(new Scope('request'));
$container
+ ->addCompilerPass(new TranslatorPass())
->addCompilerPass(new RegisterListenersPass())
->addCompilerPass(new RegisterParserPluginPass())
->addCompilerPass(new RegisterRouterPass())
->addCompilerPass(new RegisterCouponPass())
->addCompilerPass(new RegisterCouponConditionPass())
- ->addCompilerPass(new TranslatorPass())
-
;
}
}
diff --git a/core/lib/Thelia/Core/Controller/ControllerResolver.php b/core/lib/Thelia/Core/Controller/ControllerResolver.php
index ebf0eff86..a9cd30feb 100755
--- a/core/lib/Thelia/Core/Controller/ControllerResolver.php
+++ b/core/lib/Thelia/Core/Controller/ControllerResolver.php
@@ -26,6 +26,7 @@ namespace Thelia\Core\Controller;
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Psr\Log\LoggerInterface;
/**
* ControllerResolver that supports "a:b:c", "service:method" and class::method" notations in routes definition
diff --git a/core/lib/Thelia/Core/EventListener/ViewListener.php b/core/lib/Thelia/Core/EventListener/ViewListener.php
index db036f111..667a3d42c 100755
--- a/core/lib/Thelia/Core/EventListener/ViewListener.php
+++ b/core/lib/Thelia/Core/EventListener/ViewListener.php
@@ -27,7 +27,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Thelia\Core\Template\Exception\ResourceNotFoundException;
use Thelia\Core\Template\ParserInterface;
diff --git a/core/lib/Thelia/Core/HttpFoundation/Response.php b/core/lib/Thelia/Core/HttpFoundation/Response.php
new file mode 100644
index 000000000..277c16cc2
--- /dev/null
+++ b/core/lib/Thelia/Core/HttpFoundation/Response.php
@@ -0,0 +1,48 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\Core\HttpFoundation;
+
+use Symfony\Component\HttpFoundation\Response as BaseResponse;
+use Thelia\Log\Tlog;
+
+/**
+ * extends Thelia\Core\HttpFoundation\Response for adding some helpers
+ *
+ * Class Response
+ * @package Thelia\Core\HttpFoundation
+ * @author Franck Allimant
+ */
+class Response extends BaseResponse
+{
+ /**
+ * Allow Tlog to write log stuff in the fina content.
+ *
+ * @see \Thelia\Core\HttpFoundation\Response::sendContent()
+ */
+ public function sendContent() {
+
+ Tlog::getInstance()->write($this->content);
+
+ parent::sendContent();
+ }
+}
diff --git a/core/lib/Thelia/Core/Security/Resource/AdminResources.php b/core/lib/Thelia/Core/Security/Resource/AdminResources.php
index 6efcf89c2..295de1fe8 100644
--- a/core/lib/Thelia/Core/Security/Resource/AdminResources.php
+++ b/core/lib/Thelia/Core/Security/Resource/AdminResources.php
@@ -97,4 +97,6 @@ final class AdminResources
const TAX = "admin.configuration.tax";
const TEMPLATE = "admin.configuration.template";
+
+ const SYSTEM_LOG = "admin.configuration.system-log";
}
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
index a401755a4..ba6f1d1f9 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php
@@ -238,13 +238,13 @@ class DataAccessFunctions extends AbstractSmartyPlugin
public function ConfigDataAccess($params, $smarty)
{
- if (false === array_key_exists("key", $params)) {
- return null;
- }
+ $key = $this->getParam($params, 'key', false);
- $key = $params['key'];
+ if ($key === false) return null;
- return ConfigQuery::read($key);
+ $default = $this->getParam($params, 'default', '');
+
+ return ConfigQuery::read($key, $default);
}
/**
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php
index 61a68fdc7..e89898af6 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/FlashMessage.php
@@ -74,13 +74,18 @@ class FlashMessage extends AbstractSmartyPlugin
public function getFlashMessage($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
- $key = $params['key'];
- $flashBag = $this->request->getSession()->get('flashMessage');
- $template->assign('value', $flashBag[$key]);
- // Reset flash message (can be read once)
- unset($flashBag[$key]);
- $this->request->getSession()->set('flashMessage', $flashBag);
+ if (false !== $key = $this->getParam($params, 'key', false)) {
+
+ $flashBag = $this->request->getSession()->get('flashMessage');
+
+ $template->assign('value', $flashBag[$key]);
+
+ // Reset flash message (can be read once)
+ unset($flashBag[$key]);
+
+ $this->request->getSession()->set('flashMessage', $flashBag);
+ }
} else {
return $content;
}
diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php
index beb9a6b25..2dfbb08fc 100755
--- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php
+++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php
@@ -41,14 +41,16 @@ class Module extends AbstractSmartyPlugin
public function theliaModule($params, \Smarty_Internal_Template $template)
{
$content = null;
- if (array_key_exists('location', $params)) {
- $location = $params['location'];
+
+ if (false !== $location = $this->getParam($params, 'location', false)) {
+
$modules = ModuleQuery::getActivated();
foreach ($modules as $module) {
- $file = THELIA_MODULE_DIR . "/". ucfirst($module->getCode()) . "/AdminIncludes/".$location.".html";
- if(file_exists($file)) {
+ $file = sprintf("%s/%s/AdminIncludes/%s.html", THELIA_MODULE_DIR, ucfirst($module->getCode()), $location);
+
+ if (file_exists($file)) {
$content .= file_get_contents($file);
}
}
diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
index 92c1377ce..272f6787c 100755
--- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
+++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php
@@ -7,7 +7,7 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface;
use \Smarty;
-use Symfony\Component\HttpFoundation\Response;
+use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
@@ -155,7 +155,7 @@ class SmartyParser extends Smarty implements ParserInterface
*
* set $content with the body of the response or the Response object directly
*
- * @param string|Symfony\Component\HttpFoundation\Response $content
+ * @param string|Thelia\Core\HttpFoundation\Response $content
*/
public function setContent($content)
{
diff --git a/core/lib/Thelia/Core/Thelia.php b/core/lib/Thelia/Core/Thelia.php
index 3d476ad30..cc9f4bae4 100755
--- a/core/lib/Thelia/Core/Thelia.php
+++ b/core/lib/Thelia/Core/Thelia.php
@@ -69,7 +69,7 @@ class Thelia extends Kernel
protected function initPropel()
{
- if (file_exists(THELIA_ROOT . '/local/config/database.yml') === false) {
+ if (file_exists(THELIA_CONF_DIR . 'database.yml') === false) {
return ;
}
@@ -96,7 +96,7 @@ class Thelia extends Kernel
{
parent::boot();
- if (file_exists(THELIA_ROOT . '/local/config/database.yml') === true) {
+ if (file_exists(THELIA_CONF_DIR . 'database.yml') === true) {
$this->getContainer()->get("event_dispatcher")->dispatch(TheliaEvents::BOOT);
}
diff --git a/core/lib/Thelia/Exception/CouponExpiredException.php b/core/lib/Thelia/Exception/CouponExpiredException.php
index c1ccace0a..271927cb4 100644
--- a/core/lib/Thelia/Exception/CouponExpiredException.php
+++ b/core/lib/Thelia/Exception/CouponExpiredException.php
@@ -46,7 +46,7 @@ class CouponExpiredException extends \Exception
public function __construct($couponCode)
{
$message = 'Expired Coupon ' . $couponCode . 'attempt';
- Tlog::getInstance()->addInfo($message);
+ Tlog::getInstance()->addWarning($message);
parent::__construct($message);
}
diff --git a/core/lib/Thelia/Form/AdministratorCreationForm.php b/core/lib/Thelia/Form/AdministratorCreationForm.php
index 4b5afe34c..f0a479dd2 100644
--- a/core/lib/Thelia/Form/AdministratorCreationForm.php
+++ b/core/lib/Thelia/Form/AdministratorCreationForm.php
@@ -81,7 +81,7 @@ class AdministratorCreationForm extends BaseForm
array($this, "verifyPasswordField")
)))
),
- "label" => "Password confirmation",
+ "label" => Translator::getInstance()->trans('Password confirmation'),
"label_attr" => array(
"for" => "password_confirmation"
),
@@ -94,7 +94,7 @@ class AdministratorCreationForm extends BaseForm
"constraints" => array(
new Constraints\NotBlank(),
),
- "label" => "Profile",
+ "label" => Translator::getInstance()->trans('Profile'),
"label_attr" => array(
"for" => "profile"
),
diff --git a/core/lib/Thelia/Form/ConfigCreationForm.php b/core/lib/Thelia/Form/ConfigCreationForm.php
index e52f44c29..56df63f8a 100644
--- a/core/lib/Thelia/Form/ConfigCreationForm.php
+++ b/core/lib/Thelia/Form/ConfigCreationForm.php
@@ -25,6 +25,7 @@ namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\ConfigQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
+use Thelia\Core\Translation\Translator;
class ConfigCreationForm extends BaseForm
{
@@ -41,7 +42,7 @@ class ConfigCreationForm extends BaseForm
$this->formBuilder
->add("name", "text", array(
"constraints" => $name_constraints,
- "label" => "Name *",
+ "label" => Translator::getInstance()->trans('Name *'),
"label_attr" => array(
"for" => "name"
)
@@ -50,7 +51,7 @@ class ConfigCreationForm extends BaseForm
"constraints" => array(
new Constraints\NotBlank()
),
- "label" => "Purpose *",
+ "label" => Translator::getInstance()->trans('Purpose *'),
"label_attr" => array(
"for" => "purpose"
)
@@ -61,14 +62,14 @@ class ConfigCreationForm extends BaseForm
)
))
->add("value", "text", array(
- "label" => "Value *",
+ "label" => Translator::getInstance()->trans('Value *'),
"label_attr" => array(
"for" => "value"
)
))
->add("hidden", "hidden", array())
->add("secured", "hidden", array(
- "label" => "Prevent variable modification or deletion, except for super-admin"
+ "label" => Translator::getInstance()->trans('Prevent variable modification or deletion, except for super-admin')
))
;
}
@@ -83,7 +84,7 @@ class ConfigCreationForm extends BaseForm
$config = ConfigQuery::create()->findOneByName($value);
if ($config) {
- $context->addViolation(sprintf("A variable with name \"%s\" already exists.", $value));
+ $context->addViolation(Translator::getInstance()->trans('A variable with name "%name" already exists.', array('%name' => $value)));
}
}
diff --git a/core/lib/Thelia/Form/ConfigModificationForm.php b/core/lib/Thelia/Form/ConfigModificationForm.php
index 257af38c5..318da7185 100644
--- a/core/lib/Thelia/Form/ConfigModificationForm.php
+++ b/core/lib/Thelia/Form/ConfigModificationForm.php
@@ -24,6 +24,7 @@ namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\GreaterThan;
+use Thelia\Core\Translation\Translator;
class ConfigModificationForm extends BaseForm
{
@@ -43,20 +44,20 @@ class ConfigModificationForm extends BaseForm
"constraints" => array(
new NotBlank()
),
- "label" => "Name",
+ "label" => Translator::getInstance()->trans('Name'),
"label_attr" => array(
"for" => "name"
)
))
->add("value", "text", array(
- "label" => "Value",
+ "label" => Translator::getInstance()->trans('Value'),
"label_attr" => array(
"for" => "value"
)
))
->add("hidden", "hidden", array())
->add("secured", "hidden", array(
- "label" => "Prevent variable modification or deletion, except for super-admin"
+ "label" => Translator::getInstance()->trans('Prevent variable modification or deletion, except for super-admin')
))
;
diff --git a/core/lib/Thelia/Form/ContentCreationForm.php b/core/lib/Thelia/Form/ContentCreationForm.php
index df8838f59..663ed4c1b 100644
--- a/core/lib/Thelia/Form/ContentCreationForm.php
+++ b/core/lib/Thelia/Form/ContentCreationForm.php
@@ -34,7 +34,7 @@ class ContentCreationForm extends BaseForm
"constraints" => array(
new NotBlank()
),
- "label" => "Content title *",
+ "label" => Translator::getInstance()->trans('Content title *'),
"label_attr" => array(
"for" => "title"
)
diff --git a/core/lib/Thelia/Form/CurrencyCreationForm.php b/core/lib/Thelia/Form/CurrencyCreationForm.php
index 3328cd342..9872d100c 100644
--- a/core/lib/Thelia/Form/CurrencyCreationForm.php
+++ b/core/lib/Thelia/Form/CurrencyCreationForm.php
@@ -26,6 +26,7 @@ use Symfony\Component\Validator\Constraints;
use Thelia\Model\CurrencyQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
+use Thelia\Core\Translation\Translator;
class CurrencyCreationForm extends BaseForm
{
@@ -44,7 +45,7 @@ class CurrencyCreationForm extends BaseForm
"constraints" => array(
new NotBlank()
),
- "label" => "Name *",
+ "label" => Translator::getInstance()->trans('Name *'),
"label_attr" => array(
"for" => "name"
))
@@ -58,7 +59,7 @@ class CurrencyCreationForm extends BaseForm
"constraints" => array(
new NotBlank()
),
- "label" => "Symbol *",
+ "label" => Translator::getInstance()->trans('Symbol *'),
"label_attr" => array(
"for" => "symbol"
))
@@ -67,7 +68,7 @@ class CurrencyCreationForm extends BaseForm
"constraints" => array(
new NotBlank()
),
- "label" => "Rate from € *",
+ "label" => Translator::getInstance()->trans('Rate from € *'),
"label_attr" => array(
"for" => "rate"
))
@@ -76,7 +77,7 @@ class CurrencyCreationForm extends BaseForm
"constraints" => array(
new NotBlank()
),
- "label" => "ISO 4217 code *",
+ "label" => Translator::getInstance()->trans('ISO 4217 code *'),
"label_attr" => array(
"for" => "iso_4217_code"
))
@@ -94,7 +95,7 @@ class CurrencyCreationForm extends BaseForm
$currency = CurrencyQuery::create()->findOneByCode($value);
if ($currency) {
- $context->addViolation(sprintf("A currency with code \"%s\" already exists.", $value));
+ $context->addViolation(Translator::getInstance()->trans('A currency with code "%name" already exists.', array('%name' => $value)));
}
}
diff --git a/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php b/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php
index afea21f70..0a29aeda7 100755
--- a/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php
+++ b/core/lib/Thelia/Form/CustomerPasswordUpdateForm.php
@@ -70,7 +70,7 @@ class CustomerPasswordUpdateForm extends BaseForm
array($this, "verifyPasswordField")
)))
),
- "label" => "Password confirmation",
+ "label" => Translator::getInstance()->trans('Password confirmation'),
"label_attr" => array(
"for" => "password_confirmation"
)
diff --git a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php
index d1e928d0c..471c12432 100755
--- a/core/lib/Thelia/Form/CustomerProfilUpdateForm.php
+++ b/core/lib/Thelia/Form/CustomerProfilUpdateForm.php
@@ -58,7 +58,7 @@ class CustomerProfilUpdateForm extends CustomerCreateForm
// Add Newsletter
->add("newsletter", "checkbox", array(
- "label" => "I would like to receive the newsletter our the latest news.",
+ "label" => Translator::getInstance()->trans('I would like to receive the newsletter or the latest news.'),
"label_attr" => array(
"for" => "newsletter"
),
diff --git a/core/lib/Thelia/Form/MessageCreationForm.php b/core/lib/Thelia/Form/MessageCreationForm.php
index 6ce84cb06..288de1d36 100644
--- a/core/lib/Thelia/Form/MessageCreationForm.php
+++ b/core/lib/Thelia/Form/MessageCreationForm.php
@@ -25,6 +25,7 @@ namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Model\MessageQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
+use Thelia\Core\Translation\Translator;
class MessageCreationForm extends BaseForm
{
@@ -41,7 +42,7 @@ class MessageCreationForm extends BaseForm
$this->formBuilder
->add("name", "text", array(
"constraints" => $name_constraints,
- "label" => "Name *",
+ "label" => Translator::getInstance()->trans('Name *'),
"label_attr" => array(
"for" => "name"
)
@@ -50,7 +51,7 @@ class MessageCreationForm extends BaseForm
"constraints" => array(
new Constraints\NotBlank()
),
- "label" => "Purpose *",
+ "label" => Translator::getInstance()->trans('Purpose *'),
"label_attr" => array(
"for" => "purpose"
)
@@ -74,7 +75,7 @@ class MessageCreationForm extends BaseForm
$message = MessageQuery::create()->findOneByName($value);
if ($message) {
- $context->addViolation(sprintf("A message with name \"%s\" already exists.", $value));
+ $context->addViolation(Translator::getInstance()->trans('A message with name "%name" already exists.', array('%name' => $value)));
}
}
diff --git a/core/lib/Thelia/Form/MessageModificationForm.php b/core/lib/Thelia/Form/MessageModificationForm.php
index c8f20448d..c22d67bbf 100644
--- a/core/lib/Thelia/Form/MessageModificationForm.php
+++ b/core/lib/Thelia/Form/MessageModificationForm.php
@@ -24,6 +24,7 @@ namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\GreaterThan;
+use Thelia\Core\Translation\Translator;
class MessageModificationForm extends BaseForm
{
@@ -33,37 +34,37 @@ class MessageModificationForm extends BaseForm
->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
->add("name" , "text" , array(
"constraints" => array(new NotBlank()),
- "label" => "Name *",
+ "label" => Translator::getInstance()->trans('Name *'),
"label_attr" => array(
"for" => "name"
)
))
->add("secured" , "text" , array(
- "label" => "Prevent mailing template modification or deletion, except for super-admin"
+ "label" => Translator::getInstance()->trans('Prevent mailing template modification or deletion, except for super-admin')
))
->add("locale" , "text" , array())
->add("title" , "text" , array(
"constraints" => array(new NotBlank()),
- "label" => "Title *",
+ "label" => Translator::getInstance()->trans('Title *'),
"label_attr" => array(
"for" => "title"
)
))
->add("subject" , "text" , array(
"constraints" => array(new NotBlank()),
- "label" => "Message subject *",
+ "label" => Translator::getInstance()->trans('Message subject *'),
"label_attr" => array(
"for" => "subject"
)
))
->add("html_message" , "text" , array(
- "label" => "HTML Message",
+ "label" => Translator::getInstance()->trans('HTML Message'),
"label_attr" => array(
"for" => "html_message"
)
))
->add("text_message" , "text" , array(
- "label" => "Text Message",
+ "label" => Translator::getInstance()->trans('Text Message'),
"label_attr" => array(
"for" => "text_message"
)
diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php
index c1b8bd6b4..de683e27a 100644
--- a/core/lib/Thelia/Form/ProductCreationForm.php
+++ b/core/lib/Thelia/Form/ProductCreationForm.php
@@ -43,12 +43,12 @@ class ProductCreationForm extends BaseForm
$this->formBuilder
->add("ref", "text", array(
"constraints" => $ref_constraints,
- "label" => "Product reference *",
+ "label" => Translator::getInstance()->trans('Product reference *'),
"label_attr" => array("for" => "ref")
))
->add("title", "text", array(
"constraints" => array(new NotBlank()),
- "label" => "Product title *",
+ "label" => Translator::getInstance()->trans('Product title *'),
"label_attr" => array("for" => "title")
))
->add("default_category", "integer", array(
diff --git a/core/lib/Thelia/Form/SystemLogConfigurationForm.php b/core/lib/Thelia/Form/SystemLogConfigurationForm.php
new file mode 100644
index 000000000..9ba9e6cf2
--- /dev/null
+++ b/core/lib/Thelia/Form/SystemLogConfigurationForm.php
@@ -0,0 +1,86 @@
+. */
+/* */
+/*************************************************************************************/
+namespace Thelia\Form;
+
+use Symfony\Component\Validator\Constraints;
+use Thelia\Model\ConfigQuery;
+use Symfony\Component\Validator\ExecutionContextInterface;
+use Thelia\Log\Tlog;
+use Thelia\Core\Translation\Translator;
+
+class SystemLogConfigurationForm extends BaseForm
+{
+ protected function buildForm()
+ {
+ $this->formBuilder
+ ->add("level", "choice", array(
+ 'choices' => array(
+ Tlog::MUET => Translator::getInstance()->trans("Disabled"),
+ Tlog::DEBUG => Translator::getInstance()->trans("Debug"),
+ Tlog::INFO => Translator::getInstance()->trans("Information"),
+ Tlog::NOTICE => Translator::getInstance()->trans("Notices"),
+ Tlog::WARNING => Translator::getInstance()->trans("Warnings"),
+ Tlog::ERROR => Translator::getInstance()->trans("Errors"),
+ Tlog::CRITICAL => Translator::getInstance()->trans("Critical"),
+ Tlog::ALERT => Translator::getInstance()->trans("Alerts"),
+ Tlog::EMERGENCY => Translator::getInstance()->trans("Emergency"),
+ ),
+
+ "label" => Translator::getInstance()->trans('Log level *'),
+ "label_attr" => array(
+ "for" => "level_field"
+ )
+ ))
+ ->add("format", "text", array(
+ "label" => Translator::getInstance()->trans('Log format *'),
+ "label_attr" => array(
+ "for" => "format_field"
+ )
+ ))
+ ->add("show_redirections", "integer", array(
+ "constraints" => array(new Constraints\NotBlank()),
+ "label" => Translator::getInstance()->trans('Show redirections *'),
+ "label_attr" => array(
+ "for" => "show_redirections_field"
+ )
+ ))
+ ->add("files", "text", array(
+ "label" => Translator::getInstance()->trans('Activate logs only for these files'),
+ "label_attr" => array(
+ "for" => "files_field"
+ )
+ ))
+ ->add("ip_addresses", "text", array(
+ "label" => Translator::getInstance()->trans('Activate logs only for these IP Addresses'),
+ "label_attr" => array(
+ "for" => "files_field"
+ )
+ ))
+ ;
+ }
+
+ public function getName()
+ {
+ return "thelia_system_log_configuration";
+ }
+}
diff --git a/core/lib/Thelia/Log/AbstractTlogDestination.php b/core/lib/Thelia/Log/AbstractTlogDestination.php
index 582f57934..0d3cde9e1 100755
--- a/core/lib/Thelia/Log/AbstractTlogDestination.php
+++ b/core/lib/Thelia/Log/AbstractTlogDestination.php
@@ -31,9 +31,6 @@ abstract class AbstractTlogDestination
//Tableau des lignes de logs stockés avant utilisation par ecrire()
protected $_logs;
- // Vaudra true si on est dans le back office.
- protected $flag_back_office = false;
-
public function __construct()
{
$this->_configs = array();
@@ -50,8 +47,8 @@ abstract class AbstractTlogDestination
public function setConfig($name, $value)
{
foreach ($this->_configs as $config) {
- if ($config->name == $name) {
- $config->value = $value;
+ if ($config->getName() == $name) {
+ $config->setValue($value);
// Appliquer les changements
$this->configure();
@@ -66,8 +63,8 @@ abstract class AbstractTlogDestination
public function getConfig($name)
{
foreach ($this->_configs as $config) {
- if ($config->name == $name) {
- return $config->value;
+ if ($config->getName() == $name) {
+ return $config->getValue();
}
}
@@ -79,26 +76,19 @@ abstract class AbstractTlogDestination
return $this->_configs;
}
- public function SetBackOfficeMode($bool)
- {
- $this->flag_back_office = $bool;
- }
-
//Ajoute une ligne de logs à la destination
public function add($string)
{
$this->_logs[] = $string;
}
- protected function InsertAfterBody(&$res, $logdata)
+ protected function insertAfterBody(&$res, $logdata)
{
- $match = array();
+ $match = array();
- if (preg_match("/(]*>)/i", $res, $match)) {
- $res = str_replace($match[0], $match[0] . "\n" . $logdata, $res);
- } else {
- $res = $logdata . $res;
- }
+ if (preg_match("/(]*>)/i", $res, $match)) {
+ $res = str_replace($match[0], $match[0] . "\n" . $logdata, $res);
+ }
}
// Demande à la destination de se configurer pour être prête
@@ -106,7 +96,7 @@ abstract class AbstractTlogDestination
// que seul le paramètre de configuration indiqué a été modifié.
protected function configure()
{
- // Cette methode doit etre surchargée si nécessaire.
+ // Cette methode doit etre surchargée si nécessaire.
}
//Lance l'écriture de tous les logs par la destination
diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php
index 6d2da2b52..a045196fe 100755
--- a/core/lib/Thelia/Log/Destination/TlogDestinationFile.php
+++ b/core/lib/Thelia/Log/Destination/TlogDestinationFile.php
@@ -25,6 +25,7 @@ namespace Thelia\Log\Destination;
use Thelia\Log\AbstractTlogDestination;
use Thelia\Log\TlogDestinationConfig;
+use Thelia\Core\Translation\Translator;
class TlogDestinationFile extends AbstractTlogDestination
{
@@ -41,7 +42,7 @@ class TlogDestinationFile extends AbstractTlogDestination
public function __construct()
{
- $this->path_defaut = THELIA_ROOT . "log/" . self::TLOG_DEFAULT_NAME;
+ $this->path_defaut = THELIA_ROOT . "log" . DS . self::TLOG_DEFAULT_NAME;
parent::__construct();
}
@@ -69,12 +70,12 @@ class TlogDestinationFile extends AbstractTlogDestination
public function getTitle()
{
- return "Text File";
+ return Translator::getInstance()->trans('Text File');
}
public function getDescription()
{
- return "Store logs into text file";
+ return Translator::getInstance()->trans('Store logs into text file');
}
public function getConfigs()
@@ -82,15 +83,15 @@ class TlogDestinationFile extends AbstractTlogDestination
return array(
new TlogDestinationConfig(
self::VAR_PATH_FILE,
- "Chemin du fichier",
- "Attention, vous devez indiquer un chemin absolu.
Le répertoire de base de votre Thelia est ".dirname(getcwd()),
+ 'Absolute file path',
+ 'You should enter an abolute file path. The base directory of your Thelia installation is '.THELIA_ROOT,
$this->path_defaut,
TlogDestinationConfig::TYPE_TEXTFIELD
),
new TlogDestinationConfig(
self::VAR_MODE,
- "Mode d'ouverture (A ou E)",
- "Indiquez E pour ré-initialiser le fichier à chaque requête, A pour ne jamais réinitialiser le fichier. Pensez à le vider de temps en temps !",
+ 'File opening mode (A or E)',
+ 'Enter E to empty this file for each request, or A to always append logs. Consider resetting the file from time to time',
self::VALEUR_MODE_DEFAULT,
TlogDestinationConfig::TYPE_TEXTFIELD
)
diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php b/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php
index a510e18ef..7d0be3fa8 100755
--- a/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php
+++ b/core/lib/Thelia/Log/Destination/TlogDestinationHtml.php
@@ -24,6 +24,7 @@
namespace Thelia\Log\Destination;
use Thelia\Log\AbstractTlogDestination;
+use Thelia\Log\TlogDestinationConfig;
class TlogDestinationHtml extends AbstractTlogDestination
{
@@ -46,12 +47,12 @@ class TlogDestinationHtml extends AbstractTlogDestination
public function getTitle()
{
- return "Affichage direct dans la page, en HTML";
+ return "Direct HTML display";
}
public function getDescription()
{
- return "Permet d'afficher les logs directement dans la page resultat, avec une mise en forme HTML.";
+ return "Display logs in HTML format, on top of generated pages.";
}
public function getConfigs()
@@ -59,8 +60,8 @@ class TlogDestinationHtml extends AbstractTlogDestination
return array(
new TlogDestinationConfig(
self::VAR_STYLE,
- "Style d'affichage direct dans la page",
- "Vous pouvez aussi laisser ce champ vide, et créer un style \"tlog-trace\" dans votre feuille de style.",
+ "CSS of each log line",
+ "You may also leave this field empty, and define a \"tlog-trace\" style in your CSS.",
self::VALEUR_STYLE_DEFAUT,
TlogDestinationConfig::TYPE_TEXTAREA
)
@@ -71,6 +72,6 @@ class TlogDestinationHtml extends AbstractTlogDestination
{
$block = sprintf('%s
', $this->style, htmlspecialchars(implode("\n", $this->_logs)));
- $this->InsertAfterBody($res, $block);
+ $this->insertAfterBody($res, $block);
}
}
diff --git a/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php b/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php
new file mode 100644
index 000000000..546ab488c
--- /dev/null
+++ b/core/lib/Thelia/Log/Destination/TlogDestinationJavascriptConsole.php
@@ -0,0 +1,51 @@
+. */
+/* */
+/*************************************************************************************/
+
+namespace Thelia\Log\Destination;
+
+use Thelia\Log\AbstractTlogDestination;
+
+class TlogDestinationJavascriptConsole extends AbstractTlogDestination {
+
+ public function getTitle() {
+ return "Browser's Javascript console";
+ }
+
+ public function getDescription() {
+ return "The Thelia logs are displayed in your browser's Javascript console.";
+ }
+
+ public function write(&$res) {
+
+ $content = ''."\n";
+
+ if (preg_match("||i", $res))
+ $res = preg_replace("||i", "$content