Subversion Repositories Applications.framework

Rev

Rev 98 | Rev 153 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 98 Rev 129
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
* Classe fournissant des informations au Framework sur l'application.
4
 * Classe fournissant des informations au Framework sur l'application.
5
*
5
 *
6
* @package Framework
6
 * PHP version 5
-
 
7
 *
7
* @category Debogage
8
 * @category Debogage
-
 
9
 * @package Framework
8
// Auteur principal :
10
 // Auteur principal :
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
// Autres auteurs :
12
 // Autres auteurs :
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
13
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
14
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
13
* @version $$Id$$
15
 * @version $$Id$$
14
* @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
16
 * @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
15
*/
17
 */
16
class Application {
18
class Application {
-
 
19
 
-
 
20
	/**
-
 
21
	 * tableau d'informations sur l'application
17
 
22
	 */
-
 
23
	private static $info = null;
-
 
24
	/**
-
 
25
	 * chemin de base de l'application
18
	private static $info = null;
26
	 */
-
 
27
	private static $chemin = null;
-
 
28
 
-
 
29
	/**
-
 
30
	 * Modificateur pour le chemin de base
19
	private static $chemin = null;
31
	 * @param string $chemin_fichier_principal chemin de base
20
 
32
	 */
21
	public static function setChemin($chemin_fichier_principal) {
33
	public static function setChemin($chemin_fichier_principal) {
22
		if (self::$chemin === null) {
34
		if (self::$chemin === null) {
23
			if (!file_exists($chemin_fichier_principal)) {
35
			if (!file_exists($chemin_fichier_principal)) {
24
				trigger_error("Le fichier indiqué n'existe pas. Utilisez __FILE__ dans la méthode set().", E_USER_ERROR);
36
				trigger_error("Le fichier indiqué n'existe pas. Utilisez __FILE__ dans la méthode set().", E_USER_ERROR);
25
			} else {
37
			} else {
26
				self::$chemin = dirname($chemin_fichier_principal).DS;
38
				self::$chemin = dirname($chemin_fichier_principal).DS;
27
			}
39
			}
28
		} else {
40
		} else {
29
			trigger_error("Le chemin de l'application a déjà été enregistré auprès du Framework", E_USER_WARNING);
41
			trigger_error("Le chemin de l'application a déjà été enregistré auprès du Framework", E_USER_WARNING);
30
		}
42
		}
31
	}
43
	}
-
 
44
 
-
 
45
	/**
-
 
46
	 * accesseur pour le chemin
-
 
47
	 * @return string le chemin
32
 
48
	 */
33
	public static function getChemin() {
49
	public static function getChemin() {
34
		return self::$chemin;
50
		return self::$chemin;
35
	}
51
	}
36
 
52
 
37
	/** Le tableau des informations sur l'application possède les clés suivantes :
53
	/** Le tableau des informations sur l'application possède les clés suivantes :
38
	 * - nom : nom de l'application
54
	 * - nom : nom de l'application
39
	 * - abr : abréviation de l'application
55
	 * - abr : abréviation de l'application
40
	 * - encodage : encodage de l'application (ISO-8859-15, UTF-8...)
56
	 * - encodage : encodage de l'application (ISO-8859-15, UTF-8...)
41
	 *
57
	 *
42
	 * @param array $info tableau fournissant des informations sur l'application
58
	 * @param array $info tableau fournissant des informations sur l'application
43
	 * @return void
59
	 * @return void
44
	 */
60
	 */
45
	public static function setInfo($info) {
61
	public static function setInfo($info) {
46
		if (self::$info === null) {
62
		if (self::$info === null) {
47
			self::$info = $info;
63
			self::$info = $info;
48
		} else {
64
		} else {
49
			trigger_error("Le informations de l'application ont déjà été enregistrées auprès du Framework", E_USER_WARNING);
65
			trigger_error("Le informations de l'application ont déjà été enregistrées auprès du Framework", E_USER_WARNING);
50
		}
66
		}
51
	}
67
	}
-
 
68
 
-
 
69
	/**
-
 
70
	 * accesseur pour le tableau d'infos
-
 
71
	 * @param string $cle la clé à laquelle on veut accéder
52
 
72
	 */
53
	public static function getInfo($cle = null) {
73
	public static function getInfo($cle = null) {
54
		if ($cle !== null) {
74
		if ($cle !== null) {
55
			if (isset(self::$info[$cle])) {
75
			if (isset(self::$info[$cle])) {
56
				return self::$info[$cle];
76
				return self::$info[$cle];
57
			}
77
			}
58
		} else {
78
		} else {
59
			return self::$info;
79
			return self::$info;
60
		}
80
		}
61
	}
81
	}
62
}
82
}