Subversion Repositories Applications.framework

Rev

Rev 105 | Rev 115 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 105 Rev 114
Line 9... Line 9...
9
* @package   Framework
9
* @package   Framework
10
* @author    aurelien <aurelien@tela-botanica.org>
10
* @author    aurelien <aurelien@tela-botanica.org>
11
* @copyright 2009 Tela-Botanica
11
* @copyright 2009 Tela-Botanica
12
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL  
12
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL  
13
* @license   http://www.gnu.org/licenses/gpl.html Licence GNU-GPL  
13
* @license   http://www.gnu.org/licenses/gpl.html Licence GNU-GPL  
14
* @version   SVN: $$Id: GestionnaireException.php 105 2009-08-31 15:25:05Z aurelien $$ 
14
* @version   SVN: $$Id: GestionnaireException.php 114 2009-09-01 08:46:56Z jp_milcent $$ 
15
* @link      /doc/framework/ 
15
* @link      /doc/framework/ 
16
* 
16
* 
17
*/
17
*/
18
class GestionnaireException {
18
class GestionnaireException {
Line 32... Line 32...
32
	 */
32
	 */
33
	private $mode;		
33
	private $mode;		
Line 34... Line 34...
34
	
34
	
35
	/**
35
	/**
36
	 * le gestionnaire d'exception est un singleton
36
	 * le gestionnaire d'exception est un singleton
37
	 * et poss�de donc un "pointeur statique sur lui-m�me"
37
	 * et possède donc un "pointeur statique sur lui-même"
38
	 */
38
	 */
Line 39... Line 39...
39
	private static $gestionnaireException ;
39
	private static $gestionnaireException ;
40
	
40
	
41
	/**
41
	/**
42
	 * Constructeur avec paramètres optionnel
42
	 * Constructeur avec paramètres optionnel
43
	 * @param bool indique si l'on veut afficher ou non le contexte des exceptions (i.e. la trace)
43
	 * @param bool indique si l'on veut afficher ou non le contexte des exceptions (i.e. la trace)
44
	 */
-
 
45
	public function __construct($contexte = false) {
44
	 */
46
		
45
	public function __construct($contexte = false) {
47
		$this->exceptions = array();
46
		$this->exceptions = array();
48
		$this->contexte = $contexte;
47
		$this->contexte = $contexte;
49
		$this->mode = php_sapi_name();
48
		$this->mode = php_sapi_name();
Line 66... Line 65...
66
	}
65
	}
Line 67... Line 66...
67
	
66
	
68
	 /** Fonction d'accès au singleton
67
	 /** Fonction d'accès au singleton
69
	 * @return GestionnaireErreur le gestionnaire d'exceptions courant
68
	 * @return GestionnaireErreur le gestionnaire d'exceptions courant
70
	 */
69
	 */
71
	public static function getInstance()
-
 
72
	{
70
	public static function getInstance() {
73
		if (self::$gestionnaireException instanceof GestionnaireException) {
71
		if (self::$gestionnaireException instanceof GestionnaireException) {
74
			return self::$gestionnaireException;
72
			return self::$gestionnaireException;
75
		}
73
		}
76
		self::$gestionnaireException = new GestionnaireException;
74
		self::$gestionnaireException = new GestionnaireException;
Line 89... Line 87...
89
	/**
87
	/**
90
	 * Renvoie les exceptions au format (X)HTML
88
	 * Renvoie les exceptions au format (X)HTML
91
	 * ou bien au format texte suivant le mode d'utilisation de PHP
89
	 * ou bien au format texte suivant le mode d'utilisation de PHP
92
	 */
90
	 */
93
	public function getExceptions() {
91
	public function getExceptions() {
94
		
92
		$retour = '';
95
		foreach ($this->exceptions as $e) { 
93
		foreach ($this->exceptions as $e) { 
96
			switch($this->mode) {
94
			switch($this->mode) {
97
				case 'cli' : 
95
				case 'cli' : 
98
					$retour .= $e->getMessage()."\n";
96
					$retour .= $e->getMessage()."\n";
99
					$retour .= 'Fichier : '.$e->getFile()."\n";
97
					$retour .= 'Fichier : '.$e->getFile()."\n";