Subversion Repositories Applications.framework

Rev

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

Rev 96 Rev 98
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
* @package Framework
7
* @category Debogage
7
* @category Debogage
8
// Auteur principal :
8
// Auteur principal :
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
// Autres auteurs :
10
// Autres auteurs :
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
11
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
12
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
13
* @version $$Id$$
13
* @version $$Id$$
14
* @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
14
* @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
15
*/
15
*/
16
class Application {
16
class Application {
17
 
17
 
18
	private static $info = null;
18
	private static $info = null;
19
	private static $chemin = null;
19
	private static $chemin = null;
20
 
-
 
21
	/**
-
 
22
	 * Le tableau des informations sur l'application possède les clés suivantes :
-
 
23
	 * - nom : nom de l'application
-
 
24
	 * - abr : abréviation de l'application
-
 
25
	 * - encodage : encodage de l'application (ISO-8859-15, UTF-8...)
-
 
26
	 *
-
 
27
	 * @param string $chemin_fichier_principal
-
 
28
	 * @param array $info tableau fournissant des informations sur l'application
-
 
29
	 * @return void
-
 
30
	 */
20
 
31
	public static function set($chemin_fichier_principal, $info = null) {
21
	public static function setChemin($chemin_fichier_principal) {
32
		if (self::$chemin === null) {
22
		if (self::$chemin === null) {
33
			if (!file_exists($chemin_fichier_principal)) {
23
			if (!file_exists($chemin_fichier_principal)) {
34
				trigger_error("Le fichier indiqué n'existe pas. Utilisez __FILE__ dans la méthode set().", E_USER_ERROR);
24
				trigger_error("Le fichier indiqué n'existe pas. Utilisez __FILE__ dans la méthode set().", E_USER_ERROR);
35
			} else {
25
			} else {
36
				self::$chemin = dirname($chemin_fichier_principal).DS;
26
				self::$chemin = dirname($chemin_fichier_principal).DS;
37
			}
27
			}
38
			self::$info = $info;
-
 
39
		} else {
28
		} else {
40
			trigger_error("L'application a déjà été enregistrée auprès du Framework", E_USER_WARNING);
29
			trigger_error("Le chemin de l'application a déjà été enregistré auprès du Framework", E_USER_WARNING);
41
		}
30
		}
42
	}
31
	}
43
 
32
 
44
	public static function getChemin() {
33
	public static function getChemin() {
45
		return self::$chemin;
34
		return self::$chemin;
46
	}
35
	}
-
 
36
 
-
 
37
	/** Le tableau des informations sur l'application possède les clés suivantes :
-
 
38
	 * - nom : nom de l'application
-
 
39
	 * - abr : abréviation de l'application
-
 
40
	 * - encodage : encodage de l'application (ISO-8859-15, UTF-8...)
-
 
41
	 *
-
 
42
	 * @param array $info tableau fournissant des informations sur l'application
-
 
43
	 * @return void
-
 
44
	 */
-
 
45
	public static function setInfo($info) {
-
 
46
		if (self::$info === null) {
-
 
47
			self::$info = $info;
-
 
48
		} else {
-
 
49
			trigger_error("Le informations de l'application ont déjà été enregistrées auprès du Framework", E_USER_WARNING);
-
 
50
		}
-
 
51
	}
47
 
52
 
48
	public static function getInfo($cle = null) {
53
	public static function getInfo($cle = null) {
49
		if ($cle !== null) {
54
		if ($cle !== null) {
50
			if (isset(self::$info[$cle])) {
55
			if (isset(self::$info[$cle])) {
51
				return self::$info[$cle];
56
				return self::$info[$cle];
52
			}
57
			}
53
		} else {
58
		} else {
54
			return self::$info;
59
			return self::$info;
55
		}
60
		}
56
	}
61
	}
57
}
62
}