put copyright in head files and create abstract log destination class

This commit is contained in:
Manuel Raynaud
2012-12-27 14:10:43 +01:00
parent d7f3e0ea2e
commit e74752cc3a
15 changed files with 448 additions and 30 deletions

View File

@@ -1,5 +1,25 @@
<?php <?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\Autoload; namespace Thelia\Autoload;
/** /**

View File

@@ -1,5 +1,25 @@
<?php <?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\Autoload; namespace Thelia\Autoload;
use Symfony\Component\ClassLoader\UniversalClassLoader; use Symfony\Component\ClassLoader\UniversalClassLoader;

View File

@@ -1,5 +1,25 @@
<?php <?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\Bundle; namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\Bundle;

View File

@@ -1,5 +1,25 @@
<?php <?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\Bundle; namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\Bundle;

View File

@@ -1,5 +1,25 @@
<?php <?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\Bundle; namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle; use Symfony\Component\HttpKernel\Bundle\Bundle;

View File

@@ -1,5 +1,25 @@
<?php <?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\EventListener; namespace Thelia\Core\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;

View File

@@ -1,5 +1,25 @@
<?php <?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\EventListener; namespace Thelia\Core\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;

View File

@@ -1,5 +1,25 @@
<?php <?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\Template; namespace Thelia\Core\Template;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;

View File

@@ -1,5 +1,25 @@
<?php <?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\Template; namespace Thelia\Core\Template;
/** /**

View File

@@ -1,4 +1,25 @@
<?php <?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; namespace Thelia\Core;

View File

@@ -1,5 +1,25 @@
<?php <?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; namespace Thelia\Core;
use Symfony\Component\HttpKernel\HttpKernel; use Symfony\Component\HttpKernel\HttpKernel;
@@ -9,6 +29,11 @@ use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class TheliaHttpKernel extends HttpKernel class TheliaHttpKernel extends HttpKernel
{ {
public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver) public function __construct(EventDispatcherInterface $dispatcher, ContainerInterface $container, ControllerResolverInterface $controllerResolver)

View File

@@ -1,7 +1,35 @@
<?php <?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\Database; namespace Thelia\Database;
/**
*
* Class Thelia\Database\NotORM extending \NotORM library http://www.notorm.com/
*
* This class create or redifine some setters
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class NotORM extends \NotORM class NotORM extends \NotORM
{ {

View File

@@ -0,0 +1,113 @@
<?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\Log;
abstract class AbstractTlogDestination {
//Tableau de TlogDestinationConfig paramétrant la destination
protected $_configs;
//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();
$this->_logs = array();
// Initialiser les variables de configuration
$this->_configs = $this->get_configs();
// Appliquer la configuration
$this->configurer();
}
//Affecte une valeur à une configuration de la destination
public function set_config($nom, $valeur) {
foreach($this->_configs as $config) {
if($config->nom == $nom) {
$config->valeur = $valeur;
// Appliquer les changements
$this->configurer($config);
return true;
}
}
return false;
}
//Récupère la valeur affectée à une configuration de la destination
public function get_config($nom) {
foreach($this->_configs as $config) {
if($config->nom == $nom) {
return $config->valeur;
}
}
return false;
}
public function get_configs() {
return $this->_configs;
}
public function mode_back_office($bool) {
$this->flag_back_office = $bool;
}
//Ajoute une ligne de logs à la destination
public function ajouter($string) {
$this->_logs[] = $string;
}
protected function inserer_apres_body(&$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;
}
}
// Demande à la destination de se configurer pour être prête
// a fonctionner. Si $config est != false, celà indique
// que seul le paramètre de configuration indiqué a été modifié.
protected function configurer($config = false) {
// Cette methode doit etre surchargée si nécessaire.
}
//Lance l'écriture de tous les logs par la destination
//$res : contenu de la page html
abstract public function ecrire(&$res);
// Retourne le titre de cette destination, tel qu'affiché dans le menu de selection
abstract public function get_titre();
// Retourne une brève description de la destination
abstract public function get_description();
}

View File

@@ -1,20 +1,48 @@
<?php <?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\Log; namespace Thelia\Log;
use Thelia\Model\Config; use Thelia\Model\Config;
/**
*
* Thelia Logger
*
* Allow to define different level and output.
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class Tlog class Tlog
{ {
// Nom des variables de configuration // Nom des variables de configuration
const VAR_NIVEAU = "tlog_niveau"; const VAR_LEVEL = "tlog_level";
const VAR_DESTINATIONS = "tlog_destinations"; const VAR_DESTINATIONS = "tlog_destinations";
const VAR_PREFIXE = "tlog_prefixe"; const VAR_PREFIXE = "tlog_prefix";
const VAR_FILES = "tlog_files"; const VAR_FILES = "tlog_files";
const VAR_IP = "tlog_ip"; const VAR_IP = "tlog_ip";
const VAR_SHOW_REDIRECT = "tlog_show_redirect"; const VAR_SHOW_REDIRECT = "tlog_show_redirect";
// Les differents niveaux de trace // all level of trace
const TRACE = 1; const TRACE = 1;
const DEBUG = 2; const DEBUG = 2;
const WARNING = 3; const WARNING = 3;
@@ -23,8 +51,8 @@ class Tlog
const FATAL = 6; const FATAL = 6;
const MUET = PHP_INT_MAX; const MUET = PHP_INT_MAX;
// Valeurs par defaut // default values
const DEFAUT_NIVEAU = self::MUET; const DEFAULT_LEVEL = self::MUET;
const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationHtml"; const DEFAUT_DESTINATIONS = "Thelia\Log\Destination\TlogDestinationHtml";
const DEFAUT_PREFIXE = "#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: "; const DEFAUT_PREFIXE = "#NUM: #NIVEAU [#FICHIER:#FONCTION()] {#LIGNE} #DATE #HEURE: ";
const DEFAUT_FILES = "*"; const DEFAUT_FILES = "*";
@@ -36,7 +64,7 @@ class Tlog
protected $destinations = array(); protected $destinations = array();
protected $mode_back_office = false; protected $mode_back_office = false;
protected $niveau = self::MUET; protected $level = self::MUET;
protected $prefixe = ""; protected $prefixe = "";
protected $files = array(); protected $files = array();
protected $all_files = false; protected $all_files = false;
@@ -46,7 +74,7 @@ class Tlog
protected static $ecrire_effectue = false; protected static $ecrire_effectue = false;
// Les repertoires où rechercher les classes destination // directories where are the Destinations Files
public $dir_destinations = array(); public $dir_destinations = array();
public static function instance() { public static function instance() {
@@ -63,12 +91,12 @@ class Tlog
} }
protected function init() { protected function init() {
$niveau = Config::read(self::VAR_NIVEAU, self::DEFAUT_NIVEAU); $level = Config::read(self::VAR_LEVEL, self::DEFAULT_LEVEL);
$this->set_niveau($niveau); $this->set_niveau($level);
$this->dir_destinations = array( $this->dir_destinations = array(
__DIR__.'/tlog/destinations' __DIR__.'/Destination'
//, __DIR__.'/../client/tlog/destinations' //, __DIR__.'/../client/tlog/destinations'
); );
@@ -85,7 +113,7 @@ class Tlog
// Configuration // Configuration
// ------------- // -------------
public function set_destinations($destinations) { public function set_destinations(AbstractTlogDestination $destinations) {
if (! empty($destinations)) { if (! empty($destinations)) {
$this->destinations = array(); $this->destinations = array();
@@ -95,8 +123,8 @@ class Tlog
} }
} }
public function set_niveau($niveau) { public function set_niveau($level) {
$this->niveau = $niveau; $this->niveau = $level;
} }
public function set_prefixe($prefixe) { public function set_prefixe($prefixe) {
@@ -247,9 +275,9 @@ class Tlog
// Permet de déterminer si la trace est active, en prenant en compte // Permet de déterminer si la trace est active, en prenant en compte
// le niveau et le filtrage par fichier // le niveau et le filtrage par fichier
public function active($niveau) { public function active($level) {
if ($this->niveau <= $niveau) { if ($this->niveau <= $level) {
$origine = $this->trouver_origine(); $origine = $this->trouver_origine();

View File

@@ -1,7 +1,30 @@
<?php <?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\Model\Base; namespace Thelia\Model\Base;
/**
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
abstract class Base abstract class Base
{ {
/** /**