Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1973 → Rev 1974

/branches/v1.0-menes/api/debogage/BOG_sql.fonct.php
New file
0,0 → 1,105
<?php
//vim: set expandtab tabstop=4 shiftwidth=4:
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | |
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library 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 |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// | |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: BOG_sql.fonct.php,v 1.2 2005-02-28 11:14:45 jpm Exp $
/**
*Paquetage : BOG - bibliothèque de fonctions de débogage.
*
* Ce paquetage contient des fonctions de débogage pour différent besoin:
* - erreur de requête
*
*@package Debogage
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Alexandre GRANIER <alex@tela-botanica.org>
*@author Laurent COUDOUNEAU <lc@gsite.org>
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.2 $ $Date: 2005-02-28 11:14:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +-------------------------------------------------------------------------+
// | Liste des fonctions |
// +-------------------------------------------------------------------------+
 
/**Fonction BOG_afficherErreurSql() - Permet d'afficher un message d'erreur sql complet.
*
* Cette fonction permet d'afficher un ensemble de données suite à une erreur de reqête sql
* permettant de trouver plus rapidement la source de l'erreur.
*
* @param string le nom du fichier d'où provient la requête erronée (utiliser __FILE__ lors de l'apple de cette fonction).
* @param integer le numéro de la ligne de la requête (utiliser __LINE__ lors de l'apple de cette fonction).
* @param string le message d'erreur fourni par le programmeur.
* @param string la requête sql erronée.
* @param string un éventuel commentaire complémentaire
*
* @return string l'ensemble des messages d'erreur et des informations collectées.
*/
function BOG_afficherErreurSql ($nom_fichier_courant, $numero_ligne_courante, $message_erreur, $requete = '', $autre = '')
{
$retour_erreur = "\n";
$retour_erreur .= '<div id="zone_erreur">'."\n";
$retour_erreur .= '<h1 > ERREUR SQL </h1><br />'."\n";
$retour_erreur .= '<p>'."\n";
$retour_erreur .= '<span class="champ_intitule" > Fichier : </span> ';
$retour_erreur .= '<span class="champ_valeur" > '.$nom_fichier_courant.'</span><br />'."\n";
$retour_erreur .= '<span class="champ_intitule" > Ligne n° : </span> ';
$retour_erreur .= '<span class="champ_valeur" > '.$numero_ligne_courante.'</span><br />'."\n";
$retour_erreur .= '<span class="champ_intitule" > Message erreur : </span> ';
$retour_erreur .= '<span class="champ_valeur" > '.$message_erreur.'</span><br />'."\n";
if ($requete != '') {
$retour_erreur .= '<span class="champ_intitule" > Requete : </span> ';
$retour_erreur .= '<span class="champ_valeur" > '.$requete.' </span><br />'."\n";
}
if ($autre != '') {
$retour_erreur .= '<span class="champ_intitule" > Autres infos : </span> ';
$retour_erreur .= '<span class="champ_valeur" > '.$autre.' </span><br />'."\n";
}
$retour_erreur .= '</p>'."\n";
$retour_erreur .= '</div>'."\n";
return $retour_erreur;
}
 
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log: not supported by cvs2svn $
* Revision 1.1 2004/06/15 10:13:07 jpm
* Intégration dans Papyrus.
*
* Revision 1.4 2004/04/21 07:49:31 jpm
* Modification des commentaires.
*
* Revision 1.3 2004/03/22 16:23:29 jpm
* Correction point-virgule en trop.
*
* Revision 1.2 2004/03/22 12:17:06 jpm
* Utilisation de class et id CSS à la place des attributs styles.
*
*
* +--Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/branches/v1.0-menes/api/debogage/BOG_Gestionnaire_Erreur.class.php
New file
0,0 → 1,218
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.3 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This file is part of Papyrus. |
// | |
// | Foobar 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 2 of the License, or |
// | (at your option) any later version. |
// | |
// | Foobar 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 Foobar; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: BOG_Gestionnaire_Erreur.class.php,v 1.5 2005-09-20 20:25:39 ddelon Exp $
/**
* Classe permettant de créer un gestionnaire d'erreur PHP
*
* La classe permet de créer un gestionnaire d'erreur PHP et de le configurer.
*
*@package Debogage
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.5 $ $Date: 2005-09-20 20:25:39 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | ENTETE du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
// +------------------------------------------------------------------------------------------------------+
// | CORPS du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
class BOG_Gestionnaire_Erreur {
// Attributs
var $tab_erreurs = array();
var $erreur_txt_tete = '';
var $erreur_txt_pied = '';
var $bln_contexte = false;
var $langue = 'fr';
var $aso_trad = array( 'niveau'=> 'Niveau d\'erreur : ', 'fichier' => 'Nom du fichier : ',
'ligne' => 'N° de ligne : ', 'contexte' => 'Contexte d\'erreur : ');
var $class = 'erreur';
var $active = 1;
// Constructeur
function BOG_Gestionnaire_Erreur($bln_contexte, $class = '', $langue = 'fr', $txt_tete = '', $txt_pied = '', $aso_trad = array())
{
$this->ecrireContexte($bln_contexte);
$this->ecrireLangue($langue);
$this->ecrireTxtTete($txt_tete);
$this->ecrireTxtPied($txt_pied);
if (count($aso_trad) != 0) {
$this->ecrireTraduction($aso_trad);
}
if (! empty($class)) {
$this->ecrireClass($class);
}
set_error_handler(array(&$this, 'gererErreur'));
}
// Accesseurs
function setActive($active)
{
$this->active=$active;
}
function ecrireErreur($aso_erreur)
{
array_push($this->tab_erreurs, $aso_erreur);
}
function lireTableauErreurs()
{
return $this->tab_erreurs;
}
function lireTxtTete()
{
return $this->erreur_txt_tete;
}
function ecrireTxtTete($txt_tete)
{
$this->erreur_txt_tete = $txt_tete;
}
function lireTxtPied()
{
return $this->erreur_txt_pied;
}
function ecrireTxtPied($txt_pied)
{
$this->erreur_txt_pied = $txt_pied;
}
function lireContexte()
{
return $this->bln_contexte;
}
function ecrireContexte($bln)
{
$this->bln_contexte = $bln;
}
function lireTraduction($cle)
{
return $this->aso_trad[$cle];
}
function ecrireTraduction($tab_trad)
{
$aso_trad['niveau'] = $tab_trad[0];
$aso_trad['fichier'] = $tab_trad[1];
$aso_trad['ligne'] = $tab_trad[2];
$aso_trad['contexte'] = $tab_trad[3];
$this->aso_trad = $aso_trad;
}
function lireClass()
{
return $this->class;
}
function ecrireClass($class)
{
$this->class = $class;
}
function lireLangue()
{
return $this->langue;
}
function ecrireLangue($langue)
{
$this->langue = $langue;
}
// Méthode
function gererErreur($niveau, $message, $fichier, $ligne, $contexte)
{
if ($this->active) {
// Ouais bof le test, mais php5 renvoie vraiment trop de message d'erreur sur Deprecated ... et
// ca concerne essentiellement les classes pear !
if (!defined('E_STRICT')) {
define("E_STRICT", 2048);
}
if ($niveau < E_STRICT) {
$aso_erreur = array();
$aso_erreur['niveau'] = $niveau;
$aso_erreur['message'] = $message;
$aso_erreur['fichier'] = $fichier;
$aso_erreur['ligne'] = $ligne;
if ($this->lireContexte()) {
$aso_erreur['contexte'] = $contexte;
}
$this->ecrireErreur($aso_erreur);
}
}
}
function retournerErreurs()
{
$retour = '';
foreach($this->lireTableauErreurs() as $aso_erreur) {
$retour .= '<p class="'.$this->lireClass().'">'."\n";
$retour .= '<strong>'.$this->lireTxtTete().$aso_erreur['message'].$this->lireTxtPied().'</strong><br />'."\n";
$retour .= '<strong>'.$this->lireTraduction('niveau').'</strong>'.$aso_erreur['niveau'].'<br />'."\n";
$retour .= '<strong>'.$this->lireTraduction('fichier').'</strong>'.$aso_erreur['fichier'].'<br />'."\n";
$retour .= '<strong>'.$this->lireTraduction('ligne').'</strong>'.$aso_erreur['ligne'].'<br />'."\n";
if ($this->lireContexte()) {
$retour .= '<pre>'."\n";
$retour .= '<stong>'.$this->lireTraduction('contexte').'</stong>'.print_r($aso_erreur['contexte'], true)."\n";
$retour .= '</pre>'."\n";
}
$retour .= '</p>'."\n";
}
return $retour;
}
}
 
 
// +------------------------------------------------------------------------------------------------------+
// | PIED du PROGRAMME |
// +------------------------------------------------------------------------------------------------------+
 
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.4 2005/09/20 17:01:22 ddelon
* php5 et bugs divers
*
* Revision 1.3 2004/11/29 15:56:23 jpm
* Correction bogue.
*
* Revision 1.2 2004/11/29 15:54:16 jpm
* Changement de nom de variable et légère correction.
*
* Revision 1.1 2004/11/15 17:12:46 jpm
* Classe de gestion d'erreur pour PHP 4.3
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/branches/v1.0-menes/api/debogage/BOG_chrono.fonct.php
New file
0,0 → 1,129
<?php
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU Lesser General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library 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 |
// | Lesser General Public License for more details. |
// | |
// | You should have received a copy of the GNU Lesser General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: BOG_chrono.fonct.php,v 1.3 2005-02-28 11:14:45 jpm Exp $
/**
* Bibliothèque de fonctions permettant de mesure le temps d'execution d'un script.
*
* Contient des fonctions permettant d'évaluer un script.
*
*@package Debogage
//Auteur original :
*@author Jean-Pascal MILCENT <jpm@tela-botanica.org>
//Autres auteurs :
*@author Aucun
*@copyright Tela-Botanica 2000-2004
*@version $Revision: 1.3 $ $Date: 2005-02-28 11:14:45 $
// +------------------------------------------------------------------------------------------------------+
*/
 
// +------------------------------------------------------------------------------------------------------+
// | LISTE de FONCTIONS |
// +------------------------------------------------------------------------------------------------------+
/**Fonction BOG_afficherChrono() - Permet d'afficher les temps d'éxécution de différentes parties d'un script.
*
* Cette fonction permet d'afficher un ensemble de mesure de temps prises à différents endroits d'un script.
* Ces mesures sont affichées au sein d'un tableau XHTML dont on peut controler l'indentation des balises.
* Pour un site en production, il suffit d'ajouter un style #chrono {display:none;} dans la css. De cette façon,
* le tableau ne s'affichera pas. Le webmaster lui pourra rajouter sa propre feuille de style affichant le tableau.
* Le développeur initial de cette fonction est Loic d'Anterroches. Elle a été modifiée par Jean-Pascal Milcent.
* Elle utilise une variable gobale : $_CHRONO_
*
* @author Loic d'Anterroches
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
* @param int l'indentation de base pour le code html du tableau.
* @param int le pas d'indentation pour le code html du tableau.
* @return string la chaine XHTML de mesure des temps.
*/
function BOG_afficherChrono($indentation_origine = 8, $indentation = 4)
{
$sortie = str_repeat(' ', $indentation_origine).
'<table id="chrono" lang="fr" summary="Résultat du chronométrage du programme affichant la page actuelle.">'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'<caption>Chronométrage</caption>'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'<thead>'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 2))).
'<tr><th>Action</th><th>Temps écoulé (en s.)</th><th>Cumul du temps écoulé (en s.)</th></tr>'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'</thead>'."\n";
$tbody = str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'<tbody>'."\n";
$total_tps_ecoule = 0;
// Récupération de la première mesure
list($usec, $sec) = explode(' ', $GLOBALS['_CHRONO_']['depart']);
// Ce temps correspond à tps_fin
$tps_fin = ((float)$usec + (float)$sec);
foreach ($GLOBALS['_CHRONO_'] as $cle => $valeur) {
list($usec, $sec) = explode(' ',$valeur);
$tps_debut = ((float)$usec + (float)$sec);
$tps_ecoule = abs($tps_fin - $tps_debut);
$total_tps_ecoule += $tps_ecoule;
$tbody .= str_repeat(' ', ($indentation_origine + ($indentation * 2))).
'<tr>'.
'<th>'.$cle.'</th>'.
'<td>'.number_format($tps_ecoule,3).'</td>'.
'<td>'.number_format($total_tps_ecoule,3).'</td>'.
'</tr>'."\n";
$tps_fin = $tps_debut;
}
$tbody .= str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'</tbody>'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'<tfoot>'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 2))).
'<tr>'.
'<th>'.'Total du temps écoulé (en s.)'.'</th>'.
'<td colspan="2">'.number_format($total_tps_ecoule,3).'</td>'.
'</tr>'."\n";
$sortie .= str_repeat(' ', ($indentation_origine + ($indentation * 1))).
'</tfoot>'."\n";
$sortie .= $tbody;
$sortie .= str_repeat(' ', $indentation_origine).
'</table>'."\n";
return $sortie;
}
 
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.2 2004/11/29 15:54:16 jpm
* Changement de nom de variable et légère correction.
*
* Revision 1.1 2004/06/15 10:13:07 jpm
* Intégration dans Papyrus.
*
* Revision 1.2 2004/04/22 09:01:55 jpm
* Ajout de l'attribut lang au tableau.
*
* Revision 1.1 2004/04/21 07:49:13 jpm
* Ajout d'une bibliothèque de fonction pour le chronométrage des scripts.
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>