156 |
jpm |
1 |
<?php
|
|
|
2 |
/*vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
4 |
// | PHP version 4.3 |
|
|
|
5 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
|
|
|
7 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
8 |
// | This file is part of Papyrus. |
|
|
|
9 |
// | |
|
|
|
10 |
// | Foobar 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 2 of the License, or |
|
|
|
13 |
// | (at your option) any later version. |
|
|
|
14 |
// | |
|
|
|
15 |
// | Foobar is distributed in the hope that it will be useful, |
|
|
|
16 |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
17 |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
18 |
// | GNU General Public License for more details. |
|
|
|
19 |
// | |
|
|
|
20 |
// | You should have received a copy of the GNU General Public License |
|
|
|
21 |
// | along with Foobar; if not, write to the Free Software |
|
|
|
22 |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
|
|
23 |
// +------------------------------------------------------------------------------------------------------+
|
187 |
jpm |
24 |
// CVS : $Id: BOG_Gestionnaire_Erreur.class.php,v 1.2 2004-11-29 15:54:16 jpm Exp $
|
156 |
jpm |
25 |
/**
|
|
|
26 |
* Classe permettant de créer un gestionnaire d'erreur PHP
|
|
|
27 |
*
|
|
|
28 |
* La classe permet de créer un gestionnaire d'erreur PHP et de le configurer.
|
|
|
29 |
*
|
|
|
30 |
*@package Debogage
|
|
|
31 |
//Auteur original :
|
|
|
32 |
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
33 |
//Autres auteurs :
|
|
|
34 |
*@author Aucun
|
|
|
35 |
*@copyright Tela-Botanica 2000-2004
|
187 |
jpm |
36 |
*@version $Revision: 1.2 $ $Date: 2004-11-29 15:54:16 $
|
156 |
jpm |
37 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
38 |
*/
|
|
|
39 |
|
|
|
40 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
41 |
// | ENTETE du PROGRAMME |
|
|
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
46 |
// | CORPS du PROGRAMME |
|
|
|
47 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
48 |
class BOG_Gestionnaire_Erreur {
|
|
|
49 |
// Attributs
|
|
|
50 |
var $tab_erreurs = array();
|
|
|
51 |
var $erreur_txt_tete = '';
|
|
|
52 |
var $erreur_txt_pied = '';
|
|
|
53 |
var $bln_contexte = false;
|
|
|
54 |
var $langue = 'fr';
|
|
|
55 |
var $aso_trad = array( 'niveau'=> 'Niveau d\'erreur : ', 'fichier' => 'Nom du fichier : ',
|
|
|
56 |
'ligne' => 'N° de ligne : ', 'contexte' => 'Contexte d\'erreur : ');
|
|
|
57 |
var $class = 'erreur';
|
|
|
58 |
|
|
|
59 |
// Constructeur
|
|
|
60 |
function BOG_Gestionnaire_Erreur($bln_contexte, $class = '', $langue = 'fr', $txt_tete = '', $txt_pied = '', $aso_trad = array())
|
|
|
61 |
{
|
|
|
62 |
$this->ecrireContexte($bln_contexte);
|
|
|
63 |
$this->ecrireLangue($langue);
|
|
|
64 |
$this->ecrireTxtTete($txt_tete);
|
|
|
65 |
$this->ecrireTxtPied($txt_pied);
|
|
|
66 |
if (count($aso_trad) != 0) {
|
|
|
67 |
$this->ecrireTraduction($aso_trad);
|
|
|
68 |
}
|
|
|
69 |
if (! empty($class)) {
|
|
|
70 |
$this->ecrireClass($class);
|
|
|
71 |
}
|
|
|
72 |
set_error_handler(array(&$this, 'gererErreur'));
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
// Accesseurs
|
|
|
76 |
function ecrireErreur($aso_erreur)
|
|
|
77 |
{
|
|
|
78 |
array_push($this->tab_erreurs, $aso_erreur);
|
|
|
79 |
}
|
|
|
80 |
|
|
|
81 |
function lireTableauErreurs()
|
|
|
82 |
{
|
|
|
83 |
return $this->tab_erreurs;
|
|
|
84 |
}
|
|
|
85 |
function lireTxtTete()
|
|
|
86 |
{
|
|
|
87 |
return $this->erreur_txt_tete;
|
|
|
88 |
}
|
|
|
89 |
function ecrireTxtTete($txt_tete)
|
|
|
90 |
{
|
|
|
91 |
$this->erreur_txt_tete = $txt_tete;
|
|
|
92 |
}
|
|
|
93 |
function lireTxtPied()
|
|
|
94 |
{
|
|
|
95 |
return $this->erreur_txt_pied;
|
|
|
96 |
}
|
|
|
97 |
function ecrireTxtPied($txt_pied)
|
|
|
98 |
{
|
|
|
99 |
$this->erreur_txt_pied = $txt_pied;
|
|
|
100 |
}
|
|
|
101 |
function lireContexte()
|
|
|
102 |
{
|
|
|
103 |
return $this->bln_contexte;
|
|
|
104 |
}
|
|
|
105 |
function ecrireContexte($bln)
|
|
|
106 |
{
|
|
|
107 |
$this->bln_contexte = $bln;
|
|
|
108 |
}
|
|
|
109 |
function lireTraduction($cle)
|
|
|
110 |
{
|
|
|
111 |
return $this->aso_trad[$cle];
|
|
|
112 |
}
|
|
|
113 |
function ecrireTraduction($tab_trad)
|
|
|
114 |
{
|
|
|
115 |
$aso_trad['niveau'] = $tab_trad[0];
|
|
|
116 |
$aso_trad['fichier'] = $tab_trad[1];
|
|
|
117 |
$aso_trad['ligne'] = $tab_trad[2];
|
|
|
118 |
$aso_trad['contexte'] = $tab_trad[3];
|
|
|
119 |
$this->aso_trad = $aso_trad;
|
|
|
120 |
}
|
|
|
121 |
function lireClass()
|
|
|
122 |
{
|
|
|
123 |
return $this->class;
|
|
|
124 |
}
|
|
|
125 |
function ecrireClass($class)
|
|
|
126 |
{
|
|
|
127 |
$this->class = $class;
|
|
|
128 |
}
|
|
|
129 |
function lireLangue()
|
|
|
130 |
{
|
|
|
131 |
return $this->langue;
|
|
|
132 |
}
|
|
|
133 |
function ecrireLangue($langue)
|
|
|
134 |
{
|
|
|
135 |
$this->langue = $langue;
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
// Méthode
|
187 |
jpm |
139 |
function gererErreur($niveau, $message, $fichier, $ligne, $contexte = )
|
156 |
jpm |
140 |
{
|
|
|
141 |
$aso_erreur = array();
|
|
|
142 |
$aso_erreur['niveau'] = $niveau;
|
|
|
143 |
$aso_erreur['message'] = $message;
|
|
|
144 |
$aso_erreur['fichier'] = $fichier;
|
|
|
145 |
$aso_erreur['ligne'] = $ligne;
|
|
|
146 |
if ($this->lireContexte()) {
|
|
|
147 |
$aso_erreur['contexte'] = $contexte;
|
|
|
148 |
}
|
|
|
149 |
$this->ecrireErreur($aso_erreur);
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
function retournerErreurs()
|
|
|
153 |
{
|
|
|
154 |
$retour = '';
|
|
|
155 |
foreach($this->lireTableauErreurs() as $aso_erreur) {
|
|
|
156 |
$retour .= '<p class="'.$this->lireClass().'">'."\n";
|
|
|
157 |
$retour .= '<strong>'.$this->lireTxtTete().$aso_erreur['message'].$this->lireTxtPied().'</strong><br />'."\n";
|
|
|
158 |
$retour .= '<strong>'.$this->lireTraduction('niveau').'</strong>'.$aso_erreur['niveau'].'<br />'."\n";
|
|
|
159 |
$retour .= '<strong>'.$this->lireTraduction('fichier').'</strong>'.$aso_erreur['fichier'].'<br />'."\n";
|
|
|
160 |
$retour .= '<strong>'.$this->lireTraduction('ligne').'</strong>'.$aso_erreur['ligne'].'<br />'."\n";
|
|
|
161 |
if ($this->lireContexte()) {
|
|
|
162 |
$retour .= '<pre>'."\n";
|
|
|
163 |
$retour .= '<stong>'.$this->lireTraduction('contexte').'</stong>'.print_r($aso_erreur['contexte'], true)."\n";
|
|
|
164 |
$retour .= '</pre>'."\n";
|
|
|
165 |
}
|
|
|
166 |
$retour .= '</p>'."\n";
|
|
|
167 |
}
|
|
|
168 |
return $retour;
|
|
|
169 |
}
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
|
|
|
173 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
174 |
// | PIED du PROGRAMME |
|
|
|
175 |
// +------------------------------------------------------------------------------------------------------+
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
/* +--Fin du code ----------------------------------------------------------------------------------------+
|
|
|
179 |
*
|
|
|
180 |
* $Log: not supported by cvs2svn $
|
187 |
jpm |
181 |
* Revision 1.1 2004/11/15 17:12:46 jpm
|
|
|
182 |
* Classe de gestion d'erreur pour PHP 4.3
|
156 |
jpm |
183 |
*
|
187 |
jpm |
184 |
*
|
156 |
jpm |
185 |
* +-- Fin du code ----------------------------------------------------------------------------------------+
|
|
|
186 |
*/
|
|
|
187 |
?>
|