This repository has been archived on 2023-12-05. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ae75/www/backup/classes/tlog/AbstractTlogDestination.class.php
2020-11-02 15:46:52 +01:00

115 lines
4.3 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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/>. */
/* */
/*************************************************************************************/
require_once __DIR__ . "/../../fonctions/autoload.php";
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();
}
?>