Subversion Repositories Applications.framework

Rev

Rev 96 | Rev 129 | 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
 
98 jpm 21
	public static function setChemin($chemin_fichier_principal) {
95 jpm 22
		if (self::$chemin === null) {
23
			if (!file_exists($chemin_fichier_principal)) {
96 jpm 24
				trigger_error("Le fichier indiqué n'existe pas. Utilisez __FILE__ dans la méthode set().", E_USER_ERROR);
95 jpm 25
			} else {
26
				self::$chemin = dirname($chemin_fichier_principal).DS;
27
			}
28
		} else {
98 jpm 29
			trigger_error("Le chemin de l'application a déjà été enregistré auprès du Framework", E_USER_WARNING);
95 jpm 30
		}
31
	}
32
 
33
	public static function getChemin() {
34
		return self::$chemin;
35
	}
96 jpm 36
 
98 jpm 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
	}
52
 
96 jpm 53
	public static function getInfo($cle = null) {
54
		if ($cle !== null) {
55
			if (isset(self::$info[$cle])) {
56
				return self::$info[$cle];
57
			}
58
		} else {
59
			return self::$info;
60
		}
95 jpm 61
	}
62
}