Finished log configuration. All loggers are currentrly working
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -55,8 +55,6 @@
|
||||
<argument >%kernel.debug%</argument>
|
||||
</service>
|
||||
|
||||
|
||||
|
||||
<service id="http_kernel" class="Thelia\Core\TheliaHttpKernel">
|
||||
<argument type="service" id="event_dispatcher" />
|
||||
<argument type="service" id="service_container" />
|
||||
|
||||
@@ -120,6 +120,8 @@
|
||||
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
|
||||
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
|
||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||
|
||||
<form name="thelia.system-logs.configuration" class="Thelia\Form\SystemLogConfigurationForm"/>
|
||||
</forms>
|
||||
|
||||
</config>
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -55,7 +55,7 @@ class ShippingZoneController extends BaseAdminController
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|\Symfony\Component\HttpFoundation\Response
|
||||
* @return mixed|\Thelia\Core\HttpFoundation\Response
|
||||
*/
|
||||
public function addArea()
|
||||
{
|
||||
|
||||
182
core/lib/Thelia/Controller/Admin/SystemLogController.php
Normal file
182
core/lib/Thelia/Controller/Admin/SystemLogController.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?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\SystemLogConfigurationForm;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
/**
|
||||
* Class LangController
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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())
|
||||
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
48
core/lib/Thelia/Core/HttpFoundation/Response.php
Normal file
48
core/lib/Thelia/Core/HttpFoundation/Response.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?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\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 <franck@cqfdev.fr>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -97,4 +97,6 @@ final class AdminResources
|
||||
const TAX = "admin.configuration.tax";
|
||||
|
||||
const TEMPLATE = "admin.configuration.template";
|
||||
|
||||
const SYSTEM_LOG = "admin.configuration.system-log";
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,13 +74,18 @@ class FlashMessage extends AbstractSmartyPlugin
|
||||
public function getFlashMessage($params, $content, \Smarty_Internal_Template $template, &$repeat)
|
||||
{
|
||||
if ($repeat) {
|
||||
$key = $params['key'];
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
),
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
),
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
)
|
||||
|
||||
@@ -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(
|
||||
|
||||
86
core/lib/Thelia/Form/SystemLogConfigurationForm.php
Normal file
86
core/lib/Thelia/Form/SystemLogConfigurationForm.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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\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";
|
||||
}
|
||||
}
|
||||
@@ -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,25 +76,18 @@ 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();
|
||||
|
||||
if (preg_match("/(<body[^>]*>)/i", $res, $match)) {
|
||||
$res = str_replace($match[0], $match[0] . "\n" . $logdata, $res);
|
||||
} else {
|
||||
$res = $logdata . $res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.<br />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
|
||||
)
|
||||
|
||||
@@ -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('<pre class="tlog-trace" style="%s">%s</pre>', $this->style, htmlspecialchars(implode("\n", $this->_logs)));
|
||||
|
||||
$this->InsertAfterBody($res, $block);
|
||||
$this->insertAfterBody($res, $block);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : thelia@openstudio.fr */
|
||||
/* web : http://www.openstudio.fr */
|
||||
/* */
|
||||
/* 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\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 = '<script>try {'."\n";
|
||||
|
||||
foreach($this->_logs as $line) {
|
||||
$content .= "console.log('".str_replace("'", "\\'", str_replace(array("\r\n", "\r", "\n"), '\\n', $line))."');\n";
|
||||
}
|
||||
|
||||
$content .= '} catch(ex) { alert("Les logs Thelia ne peuvent être affichés dans la console javascript:" + ex); }</script>'."\n";
|
||||
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$content</html>", $res);
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,12 @@ class TlogDestinationNull extends AbstractTlogDestination
|
||||
{
|
||||
public function getTitle()
|
||||
{
|
||||
return "Trou noir";
|
||||
return "Black hole";
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Cette destination ne provoque aucune sortie";
|
||||
return "This destinations consumes the logs but don't display them";
|
||||
}
|
||||
|
||||
public function add($string)
|
||||
|
||||
111
core/lib/Thelia/Log/Destination/TlogDestinationPopup.php
Normal file
111
core/lib/Thelia/Log/Destination/TlogDestinationPopup.php
Normal file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : thelia@openstudio.fr */
|
||||
/* web : http://www.openstudio.fr */
|
||||
/* */
|
||||
/* 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\Log\Destination;
|
||||
|
||||
use Thelia\Log\AbstractTlogDestination;
|
||||
use Thelia\Log\TlogDestinationConfig;
|
||||
|
||||
class TlogDestinationPopup extends AbstractTlogDestination {
|
||||
|
||||
// Nom des variables de configuration
|
||||
// ----------------------------------
|
||||
const VAR_POPUP_WIDTH = "tlog_destinationpopup_width";
|
||||
const VALEUR_POPUP_WIDTH_DEFAUT = "600";
|
||||
|
||||
const VAR_POPUP_HEIGHT = "tlog_destinationpopup_height";
|
||||
const VALEUR_POPUP_HEIGHT_DEFAUT = "600";
|
||||
|
||||
const VAR_POPUP_TPL = "tlog_destinationpopup_template";
|
||||
// Ce fichier doit se trouver dans le même répertoire que TlogDestinationPopup.class.php
|
||||
const VALEUR_POPUP_TPL_DEFAUT = "TlogDestinationPopup.tpl";
|
||||
|
||||
public function getTitle() {
|
||||
return "Javascript popup window";
|
||||
}
|
||||
|
||||
public function getDescription() {
|
||||
return "Display logs in a popup window, separate from the main window .";
|
||||
}
|
||||
|
||||
public function getConfigs() {
|
||||
return array(
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_TPL,
|
||||
"Popup windows template",
|
||||
"Put #LOGTEXT in the template text where you want to display logs..",
|
||||
file_get_contents(__DIR__.DS. self::VALEUR_POPUP_TPL_DEFAUT),
|
||||
TlogDestinationConfig::TYPE_TEXTAREA
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_HEIGHT,
|
||||
"Height of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_HEIGHT_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
),
|
||||
new TlogDestinationConfig(
|
||||
self::VAR_POPUP_WIDTH,
|
||||
"Width of the popup window",
|
||||
"In pixels",
|
||||
self::VALEUR_POPUP_WIDTH_DEFAUT,
|
||||
TlogDestinationConfig::TYPE_TEXTFIELD
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function write(&$res) {
|
||||
|
||||
$content = ""; $count = 1;
|
||||
|
||||
foreach($this->_logs as $line) {
|
||||
$content .= "<div class=\"".($count++ % 2 ? "paire" : "impaire")."\">".htmlspecialchars($line)."</div>";
|
||||
}
|
||||
|
||||
$tpl = $this->getConfig(self::VAR_POPUP_TPL);
|
||||
|
||||
$tpl = str_replace('#LOGTEXT', $content, $tpl);
|
||||
$tpl = str_replace(array("\r\n", "\r", "\n"), '\\n', $tpl);
|
||||
|
||||
$wop = sprintf('
|
||||
<script>
|
||||
_thelia_console = window.open("","thelia_console","width=%s,height=%s,resizable,scrollbars=yes");
|
||||
if (_thelia_console == null) {
|
||||
alert("The log popup window could not be opened. Please disable your popup blocker for this site.");
|
||||
}
|
||||
else {
|
||||
_thelia_console.document.write("%s");
|
||||
_thelia_console.document.close();
|
||||
}
|
||||
</script>',
|
||||
$this->getConfig(self::VAR_POPUP_WIDTH),
|
||||
$this->getConfig(self::VAR_POPUP_HEIGHT),
|
||||
str_replace('"', '\\"', $tpl)
|
||||
);
|
||||
|
||||
if (preg_match("|</body>|i", $res))
|
||||
$res = preg_replace("|</body>|i", "$wop\n</body>", $res);
|
||||
else
|
||||
$res .= $wop;
|
||||
}
|
||||
}
|
||||
52
core/lib/Thelia/Log/Destination/TlogDestinationPopup.tpl
Normal file
52
core/lib/Thelia/Log/Destination/TlogDestinationPopup.tpl
Normal file
@@ -0,0 +1,52 @@
|
||||
<!--
|
||||
Default template for TlogDestinationPopup. Insert #LOGTEXT where you want to
|
||||
write the log text in your template.
|
||||
-->
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Thelia logs</title>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: "Courier New", courier, fixed;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
background-color: #868F99;
|
||||
border-bottom: 2px solid #127AED;
|
||||
color: #FFFFFF;
|
||||
font-family: Arial,Helvetica,sans-serif;
|
||||
font-weight: bold;
|
||||
line-height: 20px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
pre {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.paire {
|
||||
background-color: #EBEDEE;
|
||||
padding: 5px;
|
||||
border-bottom: 1px dotted #fff;
|
||||
}
|
||||
|
||||
.impaire {
|
||||
background-color: #D4DADD;
|
||||
padding: 5px;
|
||||
border-bottom: 1px dotted #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Thelia Debug</h1>
|
||||
<pre>#LOGTEXT</pre>
|
||||
</body>
|
||||
</html>
|
||||
@@ -34,12 +34,12 @@ class TlogDestinationText extends AbstractTlogDestination
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "Affichage direct dans la page, en texte brut";
|
||||
return "Direct text display";
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Permet d'afficher les logs directement dans la page resultat, au format texte brut.";
|
||||
return "Display logs in raw text format, on top of generated pages.";
|
||||
}
|
||||
|
||||
public function add($texte)
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Thelia\Log;
|
||||
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -69,7 +70,7 @@ class Tlog Implements LoggerInterface
|
||||
// default values
|
||||
const DEFAULT_LEVEL = self::DEBUG;
|
||||
const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationFile";
|
||||
const DEFAUT_PREFIXE = "#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: ";
|
||||
const DEFAUT_PREFIXE = "#INDEX: #LEVEL [#FILE:#FUNCTION()] {#LINE} #DATE #HOUR: ";
|
||||
const DEFAUT_FILES = "*";
|
||||
const DEFAUT_IP = "";
|
||||
const DEFAUT_SHOW_REDIRECT = 0;
|
||||
@@ -95,7 +96,7 @@ class Tlog Implements LoggerInterface
|
||||
|
||||
private $linecount = 0;
|
||||
|
||||
protected static $done = false;
|
||||
protected $done = false;
|
||||
|
||||
// directories where are the Destinations Files
|
||||
public $dir_destinations = array();
|
||||
@@ -132,8 +133,8 @@ class Tlog Implements LoggerInterface
|
||||
$this->setLevel(ConfigQuery::read(self::VAR_LEVEL, self::DEFAULT_LEVEL));
|
||||
|
||||
$this->dir_destinations = array(
|
||||
__DIR__.'/Destination'
|
||||
//, __DIR__.'/../client/tlog/destinations'
|
||||
__DIR__.DS.'Destination',
|
||||
THELIA_LOCAL_DIR.'tlog'.DS.'destinations'
|
||||
);
|
||||
|
||||
$this->setPrefix(ConfigQuery::read(self::VAR_PREFIXE, self::DEFAUT_PREFIXE));
|
||||
@@ -160,10 +161,20 @@ class Tlog Implements LoggerInterface
|
||||
$this->destinations = array();
|
||||
|
||||
$classes_destinations = explode(';', $destinations);
|
||||
|
||||
$this->loadDestinations($this->destinations, $classes_destinations);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the directories where destinations classes should be searched.
|
||||
*
|
||||
* @return array of directories
|
||||
*/
|
||||
public function getDestinationsDirectories() {
|
||||
return $this->dir_destinations;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* change the debug level. Use Tlog constant : \Thelia\Log\Tlog::DEBUG set level to Debug
|
||||
@@ -489,16 +500,6 @@ class Tlog Implements LoggerInterface
|
||||
$this->out($this->levels[$level], $message, $context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Mode back office
|
||||
public static function SetBackOfficeMode($booleen)
|
||||
{
|
||||
foreach (Tlog::getInstance()->destinations as $dest) {
|
||||
$dest->SetBackOfficeMode($booleen);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* final end method. Write log for each destination handler
|
||||
@@ -508,7 +509,7 @@ class Tlog Implements LoggerInterface
|
||||
*/
|
||||
public function write(&$res)
|
||||
{
|
||||
self::$done = true;
|
||||
$this->done = true;
|
||||
|
||||
// Muet ? On ne fait rien
|
||||
if ($this->level == self::MUET) return;
|
||||
@@ -524,7 +525,7 @@ class Tlog Implements LoggerInterface
|
||||
public function writeOnExit()
|
||||
{
|
||||
// Si les infos de debug n'ont pas été ecrites, le faire maintenant
|
||||
if (self::$done === false) {
|
||||
if ($this->done === false) {
|
||||
|
||||
$res = "";
|
||||
|
||||
@@ -539,12 +540,12 @@ class Tlog Implements LoggerInterface
|
||||
if ($this->level != self::MUET && $this->show_redirect) {
|
||||
echo "
|
||||
<html>
|
||||
<head><title>Redirection...</title></head>
|
||||
<head><title>".Translator::getInstance()->trans('Redirecting ...')."</title></head>
|
||||
<body>
|
||||
<a href=\"$url\">Redirection vers $url</a>
|
||||
<a href=\"$url\">".Translator::getInstance()->trans('Redirecting to %url', array('%url' => $url))."</a>
|
||||
</body>
|
||||
</html>
|
||||
";
|
||||
";
|
||||
|
||||
return true;
|
||||
} else {
|
||||
@@ -670,7 +671,7 @@ class Tlog Implements LoggerInterface
|
||||
$line = $origine['line'];
|
||||
|
||||
$prefixe = str_replace(
|
||||
array("#NUM", "#NIVEAU", "#FICHIER", "#FONCTION", "#LIGNE", "#DATE", "#HEURE"),
|
||||
array("#INDEX", "#LEVEL", "#FILE", "#FUNCTION", "#LINE", "#DATE", "#HOUR"),
|
||||
array(1+$this->linecount, $level, $file, $function, $line, date("Y-m-d"), date("G:i:s")),
|
||||
$this->prefixe
|
||||
);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Log;
|
||||
|
||||
use Thelia\Model\Config;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
@@ -32,12 +31,12 @@ class TlogDestinationConfig
|
||||
const TYPE_TEXTAREA = 1;
|
||||
const TYPE_TEXTFIELD = 2;
|
||||
|
||||
public $name;
|
||||
public $title;
|
||||
public $label;
|
||||
public $default;
|
||||
public $type;
|
||||
public $value;
|
||||
protected $name;
|
||||
protected $title;
|
||||
protected $label;
|
||||
protected $default;
|
||||
protected $type;
|
||||
protected $value;
|
||||
|
||||
public function __construct($name, $title, $label, $default, $type)
|
||||
{
|
||||
@@ -45,22 +44,67 @@ class TlogDestinationConfig
|
||||
$this->title = $title;
|
||||
$this->label = $label;
|
||||
$this->default = $default;
|
||||
$this->type = $type;
|
||||
|
||||
$this->load();
|
||||
$this->type= $type;
|
||||
$this->value = ConfigQuery::read($this->name, $this->default);
|
||||
}
|
||||
|
||||
public function load()
|
||||
public function getName()
|
||||
{
|
||||
if (null === $config = ConfigQuery::create()->findOneByName($this->name)) {
|
||||
$config = new Config();
|
||||
$config->setName($this->name);
|
||||
$config->setValue($this->default);
|
||||
$config->setHidden(1);
|
||||
$config->setSecured(1);
|
||||
$config->save();
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
$this->value = $config->getValue();
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
public function getDefault()
|
||||
{
|
||||
return $this->default;
|
||||
}
|
||||
|
||||
public function setDefault($default)
|
||||
{
|
||||
$this->default = $default;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
return self::$cache[$search];
|
||||
}
|
||||
|
||||
public static function write($configName, $value, $secured, $hidden)
|
||||
public static function write($configName, $value, $secured = null, $hidden = null)
|
||||
{
|
||||
$config = self::create()->findOneByName($configName);
|
||||
|
||||
@@ -41,8 +41,9 @@ class ConfigQuery extends BaseConfigQuery {
|
||||
$config->setName($configName);
|
||||
}
|
||||
|
||||
$config->setSecured($secured ? 1 : 0);
|
||||
$config->setHidden($hidden ? 1 : 0);
|
||||
if ($secured !== null) $config->setSecured($secured ? 1 : 0);
|
||||
if ($hidden !== null) $config->setHidden($hidden ? 1 : 0);
|
||||
|
||||
$config->setValue($value);
|
||||
$config->save();
|
||||
|
||||
|
||||
@@ -24,14 +24,17 @@
|
||||
namespace Thelia\Tools;
|
||||
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
class Redirect
|
||||
{
|
||||
public static function exec($url, $status = 302)
|
||||
{
|
||||
if (false == Tlog::getInstance()->showRedirect($url)) {
|
||||
$response = new RedirectResponse($url, $status);
|
||||
|
||||
$response->send();
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Thelia\Tools\Rest;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
|
||||
use Symfony\Component\Serializer\Serializer;
|
||||
use Symfony\Component\Serializer\Encoder\XmlEncoder;
|
||||
|
||||
@@ -319,7 +319,7 @@
|
||||
</table>
|
||||
<table name="config" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="value" required="true" size="255" type="VARCHAR" />
|
||||
<column name="name" required="true" size="255" type="VARCHAR" />
|
||||
<column name="value" required="true" type="LONGVARCHAR" />
|
||||
<column defaultValue="1" name="secured" required="true" type="TINYINT" />
|
||||
<column defaultValue="1" name="hidden" required="true" type="TINYINT" />
|
||||
|
||||
@@ -167,8 +167,8 @@
|
||||
|
||||
{loop type="auth" name="pcc8" role="ADMIN" resource="admin.configuration.system-logs" access="VIEW"}
|
||||
<tr>
|
||||
<td><a href="{url path='/admin/configuration/system_logs'}">{intl l='System logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/system_logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
<td><a href="{url path='/admin/configuration/system-logs'}">{intl l='System logs'}</a></td>
|
||||
<td><a class="btn btn-default btn-xs" href="{url path='/admin/configuration/system-logs'}"><i class="glyphicon glyphicon-edit"></i></a></td>
|
||||
</tr>
|
||||
{/loop}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ A toolbar displayed in forms, to display language change flags, submit and close
|
||||
|
||||
Parameters:
|
||||
|
||||
- hide_flags: true / false. If true, the flags will not be visible
|
||||
- hide_submit_buttons: true / false. If true, only the close button will be deplayed.
|
||||
- show_currencies: true/false. If true, show the currency selection bar
|
||||
- page_url: the current page URL. Dafault id $current_url. Used to switchedition anguage.
|
||||
@@ -11,6 +12,7 @@ Parameters:
|
||||
|
||||
<div class="row inner-toolbar">
|
||||
<div class="col-md-3 inner-actions">
|
||||
{if $hide_flags != true}
|
||||
<ul class="nav nav-pills">
|
||||
{loop name="lang_list" type="lang"}
|
||||
<li {if $ID == $edit_language_id}class="active"{/if}>
|
||||
@@ -20,6 +22,7 @@ Parameters:
|
||||
</li>
|
||||
{/loop}
|
||||
</ul>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 inner-actions">
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
{module_include location='modules_table_row'}
|
||||
|
||||
<td>
|
||||
<td class="text-right">
|
||||
<div class="btn-group">
|
||||
|
||||
{* {loop type="auth" name="can_change" role="ADMIN" resource="admin.modules" access="VIEW"}
|
||||
|
||||
213
templates/admin/default/system-logs.html
Normal file
213
templates/admin/default/system-logs.html
Normal file
@@ -0,0 +1,213 @@
|
||||
{extends file="admin-layout.tpl"}
|
||||
|
||||
{block name="page-title"}{intl l='System Logs'}{/block}
|
||||
|
||||
{block name="check-resource"}admin.configuration.variable{/block}
|
||||
{block name="check-access"}update{/block}
|
||||
|
||||
{block name="main-content"}
|
||||
<div class="variables edit-variable">
|
||||
|
||||
<div id="wrapper" class="container">
|
||||
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="{url path='/admin/home'}">{intl l="Home"}</a></li>
|
||||
<li><a href="{url path='/admin/configuration'}">{intl l="Configuration"}</a></li>
|
||||
<li>{intl l="System logs"}</li>
|
||||
</ul>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 general-block-decorator">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-12 title title-without-tabs">
|
||||
{intl l="System Logs configuration"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{form name='thelia.system-logs.configuration'}
|
||||
<form method="POST" action="{url path='/admin/configuration/system-logs/save'}">
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{include
|
||||
file = "includes/inner-form-toolbar.html"
|
||||
hide_flags = true
|
||||
|
||||
page_url = "{url path='/admin/configuration/system-logs'}"
|
||||
close_url = "{url path='/admin/configuration'}"
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<p class="title title-without-tabs">{intl l='General configuration'}</p>
|
||||
|
||||
{if $form_error}
|
||||
<div class="alert alert-danger">{$form_error_message}</div>
|
||||
{/if}
|
||||
|
||||
<fieldset>
|
||||
|
||||
{form_field form=$form field="level"}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
||||
|
||||
<select name="{$name}" id="{$label_attr.for}" class="form-control">
|
||||
{foreach $choices as $choice}
|
||||
<option value="{$choice->value}" {if $value == $choice->value}selected="selected"{/if}>{$choice->label}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
<span class="help-block">
|
||||
{intl l='Messages which have a level greater or equal to the selected level will be added to the log destinations. '}
|
||||
</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='format'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='Log lines format'}">
|
||||
</div>
|
||||
|
||||
<span class="help-block">
|
||||
{intl l='Log lines header format. You may use the following variables: '}
|
||||
<ul>
|
||||
<li>#INDEX : {intl l='Sequential number of log line'}</li>
|
||||
<li>#LEVEL : {intl l='Message level'}</li>
|
||||
<li>#FILE : {intl l='Originating file name'}</li>
|
||||
<li>#FUNCTION : {intl l='Originating function name '}</li>
|
||||
<li>#LINE : {intl l='Originating file line number '}</li>
|
||||
<li>#DATE : {intl l='date in yyyy-mm-dd format'}</li>
|
||||
<li>#HOUR : {intl l='hour in hh:mm:ss format'}</li>
|
||||
</ul>
|
||||
</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='show_redirections'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
||||
|
||||
<div>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}> {intl l='Yes'}
|
||||
</label>
|
||||
<label class="radio-inline">
|
||||
<input type="radio" name="{$name}" value="0" {if $value == 0}checked="checked"{/if}> {intl l='No'}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<span class="help-block">{intl l='If yes, redirections through Redirect::exec() will be displayed as links'}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='files'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='File names'}">
|
||||
</div>
|
||||
|
||||
<span class="help-block">{intl l='Enter one or more file names without path separated by ";". Use "!" before a file name to exclude it. Use "*" to activate logs for all files.'}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='ip_addresses'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label}: </label>
|
||||
|
||||
<div class="form-group">
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{$label}" placeholder="{intl l='IP Addresses'}">
|
||||
</div>
|
||||
|
||||
<span class="help-block">{intl l='Enter one or more IP V4 addresses separated by ";". Leave empty to display logs for all IP addresses'}</span>
|
||||
<span class="help-block">{intl l='Your current IP address is %ip' ip=$ip_address}</span>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<p class="title title-without-tabs">{intl l='Destinations'}</p>
|
||||
|
||||
<div class="alert alert-info">
|
||||
{intl l='The destinations processes logs to display, store or send them. You can select and configure zero, one or more destinations below.'}
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
{foreach $destinations as $classname => $destination}
|
||||
{$active = in_array(get_class($destination), $active_destinations)}
|
||||
<div class="well well-sm">
|
||||
<input type="hidden" name="destinations[{$classname}][classname]" value="{get_class($destination)}" />
|
||||
|
||||
<p class="title title-without-tabs">{$destination->getTitle()}</p>
|
||||
<p>{$destination->getDescription()}</p>
|
||||
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<label class="checkbox control-label">
|
||||
<input type="checkbox" class="activation-checkbox" name="destinations[{$classname}][active]" value="{$classname}" {if $active}checked="checked"{/if}> {intl l='Activate this log destination'}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if count($destination->getConfigs()) > 0}
|
||||
<div class="config config-{$classname}" {if ! $active}style="display: none"{/if}>
|
||||
{foreach $destination->getConfigs() as $config}
|
||||
<div class="form-group">
|
||||
<label>{$config->getTitle()}</label>
|
||||
{if $config->getType() == 2}
|
||||
<input class="form-control" type="text" name="config[{$classname}][{$config->getName()}]" value="{$config->getValue()}" />
|
||||
{else if $config->getType() == 1}
|
||||
<textarea class="form-control" name="config[{$classname}][{$config->getName()}]">{$config->getValue()}</textarea>
|
||||
{/if}
|
||||
<span class="help-block">{$config->getLabel()}</span>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{/foreach}
|
||||
</fieldset>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{/form}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
{block name="javascript-initialization"}
|
||||
<script>
|
||||
$(function() {
|
||||
$('.activation-checkbox').click(function(ev) {
|
||||
|
||||
var classname = $(this).val();
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
$('.config-'+classname).slideDown();
|
||||
}
|
||||
else {
|
||||
$('.config-'+classname).slideUp();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{/block}
|
||||
@@ -21,9 +21,8 @@
|
||||
/* */
|
||||
/**********************************************************************************/
|
||||
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
|
||||
//use Symfony\Component\DependencyInjection;
|
||||
|
||||
Reference in New Issue
Block a user