Overview

Namespaces

  • Thelia
    • Action
    • Controller
    • Core
      • Bundle
      • Event
      • EventListener
      • Template
        • BaseParam
    • Exception
    • Log
      • Destination
    • Model
      • map
      • om
    • Routing
      • Matcher
    • Tools
    • Tpex
      • BaseParam
      • Exception
      • Loop
      • Tests

Classes

  • AbstractTlogDestination
  • Tlog
  • TlogDestinationConfig

Interfaces

  • TlogInterface
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: /*************************************************************************************/
  3: /*                                                                                   */
  4: /*      Thelia                                                                       */
  5: /*                                                                                   */
  6: /*      Copyright (c) OpenStudio                                                     */
  7: /*  email : info@thelia.net                                                      */
  8: /*      web : http://www.thelia.net                                                  */
  9: /*                                                                                   */
 10: /*      This program is free software; you can redistribute it and/or modify         */
 11: /*      it under the terms of the GNU General Public License as published by         */
 12: /*      the Free Software Foundation; either version 3 of the License                */
 13: /*                                                                                   */
 14: /*      This program is distributed in the hope that it will be useful,              */
 15: /*      but WITHOUT ANY WARRANTY; without even the implied warranty of               */
 16: /*      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                */
 17: /*      GNU General Public License for more details.                                 */
 18: /*                                                                                   */
 19: /*      You should have received a copy of the GNU General Public License            */
 20: /*      along with this program. If not, see <http://www.gnu.org/licenses/>.     */
 21: /*                                                                                   */
 22: /*************************************************************************************/
 23: 
 24: namespace Thelia\Log;
 25: 
 26: abstract class AbstractTlogDestination
 27: {
 28:     //Tableau de TlogDestinationConfig paramétrant la destination
 29:     protected $_configs;
 30: 
 31:     //Tableau des lignes de logs stockés avant utilisation par ecrire()
 32:     protected $_logs;
 33: 
 34:     // Vaudra true si on est dans le back office.
 35:     protected $flag_back_office = false;
 36: 
 37:     public function __construct()
 38:     {
 39:         $this->_configs = array();
 40:         $this->_logs = array();
 41:         
 42:         // Initialiser les variables de configuration
 43:          $this->_configs = $this->getConfigs();
 44: 
 45:          // Appliquer la configuration
 46:          $this->configure();
 47:     }
 48: 
 49:     //Affecte une valeur à une configuration de la destination
 50:     public function setConfig($name, $value)
 51:     {
 52:         foreach ($this->_configs as $config) {
 53:             if ($config->name == $name) {
 54:                 $config->value = $value;
 55:                 // Appliquer les changements
 56:                 $this->configure();
 57: 
 58:                 return true;
 59:             }
 60:         }
 61: 
 62:         return false;
 63:     }
 64: 
 65:     //Récupère la valeur affectée à une configuration de la destination
 66:     public function getConfig($name)
 67:     {
 68:         foreach ($this->_configs as $config) {
 69:             if ($config->name == $name) {
 70:                 return $config->value;
 71:             }
 72:         }
 73: 
 74:         return false;
 75:     }
 76: 
 77:     public function getConfigs()
 78:     {
 79:         return $this->_configs;
 80:     }
 81: 
 82:     public function SetBackOfficeMode($bool)
 83:     {
 84:             $this->flag_back_office = $bool;
 85:     }
 86: 
 87:     //Ajoute une ligne de logs à la destination
 88:     public function add($string)
 89:     {
 90:         $this->_logs[] = $string;
 91:     }
 92: 
 93:     protected function InsertAfterBody(&$res, $logdata)
 94:     {
 95:             $match = array();
 96: 
 97:             if (preg_match("/(<body[^>]*>)/i", $res, $match)) {
 98:                     $res = str_replace($match[0], $match[0] . "\n" . $logdata, $res);
 99:             } else {
100:                     $res = $logdata . $res;
101:             }
102:     }
103: 
104:     // Demande à la destination de se configurer pour être prête
105:     // a fonctionner. Si $config est != false, celà indique
106:     // que seul le paramètre de configuration indiqué a été modifié.
107:     protected function configure()
108:     {
109:             // Cette methode doit etre surchargée si nécessaire.
110:     }
111: 
112:     //Lance l'écriture de tous les logs par la destination
113:     //$res : contenu de la page html
114:     abstract public function write(&$res);
115: 
116:     // Retourne le titre de cette destination, tel qu'affiché dans le menu de selection
117:     abstract public function getTitle();
118: 
119:     // Retourne une brève description de la destination
120:     abstract public function getDescription();
121: }
122: 
thelia API documentation generated by ApiGen 2.8.0