Subversion Repositories Applications.framework

Rev

Rev 95 | Rev 98 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
95 jpm 1
<?php
96 jpm 2
// declare(encoding='UTF-8');
3
/**
4
* Classe fournissant des informations au Framework sur l'application.
5
*
6
* @package Framework
7
* @category Debogage
8
// Auteur principal :
9
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
// Autres auteurs :
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>
13
* @version $$Id$$
14
* @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
15
*/
95 jpm 16
class Application {
96 jpm 17
 
18
	private static $info = null;
95 jpm 19
	private static $chemin = null;
96 jpm 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
	 */
31
	public static function set($chemin_fichier_principal, $info = null) {
95 jpm 32
		if (self::$chemin === null) {
33
			if (!file_exists($chemin_fichier_principal)) {
96 jpm 34
				trigger_error("Le fichier indiqué n'existe pas. Utilisez __FILE__ dans la méthode set().", E_USER_ERROR);
95 jpm 35
			} else {
36
				self::$chemin = dirname($chemin_fichier_principal).DS;
37
			}
96 jpm 38
			self::$info = $info;
95 jpm 39
		} else {
96 jpm 40
			trigger_error("L'application a déjà été enregistrée auprès du Framework", E_USER_WARNING);
95 jpm 41
		}
42
	}
43
 
44
	public static function getChemin() {
45
		return self::$chemin;
46
	}
96 jpm 47
 
48
	public static function getInfo($cle = null) {
49
		if ($cle !== null) {
50
			if (isset(self::$info[$cle])) {
51
				return self::$info[$cle];
52
			}
53
		} else {
54
			return self::$info;
55
		}
95 jpm 56
	}
57
}