Subversion Repositories Applications.framework

Rev

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

Rev 98 Rev 105
1
<?php
1
<?php
-
 
2
// declare(encoding='UTF-8');
2
/**
3
/**
3
 * Fichier contenant la fonction de chargement automatique de classes, il doit toujours rester à la racine
4
 * Fichier contenant la fonction de chargement automatique de classes, il doit toujours rester à la racine
4
 * du framework car il initialise le chemin de l'application en se basant sur son propre emplacement.
5
 * du framework car il initialise le chemin de l'application en se basant sur son propre emplacement.
5
 * 
6
 * 
6
 * PHP Version 5.1.2
7
 * PHP Version 5.1.2
7
 * 
8
 * 
8
 * @category  Fichier_De_Fonctions
9
 * @category  Fichier_De_Fonctions
9
 * @package   Framework
10
 * @package   Framework
10
 // Auteur principal : 
11
 // Auteur principal : 
11
 * @author Aurelien PERONNET <aurelien@tela-botanica.org>
12
 * @author Aurelien PERONNET <aurelien@tela-botanica.org>
12
 // Autres auteurs :
13
 // Autres auteurs :
13
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org> 
14
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org> 
14
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
15
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
15
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
16
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
16
 * @version $$Id$$
17
 * @version $$Id$$
17
 * @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
18
 * @copyright 1999-2009 Tela Botanica (accueil@tela-botanica.org)
18
 */
19
 */
19
 
20
 
20
// Redéfinition de la constante DIRECTORY_SEPARATOR
21
// Redéfinition de la constante DIRECTORY_SEPARATOR
21
if (!defined('DS')) { 
22
if (!defined('DS')) { 
22
	define('DS', DIRECTORY_SEPARATOR);  
23
	define('DS', DIRECTORY_SEPARATOR);  
23
}
24
}
24
// Redéfinition de la constante PATH_SEPARATOR
25
// Redéfinition de la constante PATH_SEPARATOR
25
if (!defined('PS')) { 
26
if (!defined('PS')) { 
26
	define('PS', PATH_SEPARATOR);  
27
	define('PS', PATH_SEPARATOR);  
27
}
28
}
28
 
29
 
29
// Autoload pour le Framework
30
// Autoload pour le Framework
30
function autoloadFw($nom_classe_fw) {
31
function autoloadFw($nom_classe_fw) {
31
	$fichier_a_inclure = dirname(__FILE__).DS.$nom_classe_fw.'.php';
32
	$fichier_a_inclure = dirname(__FILE__).DS.$nom_classe_fw.'.php';
32
	if (file_exists($fichier_a_inclure)) {
33
	if (file_exists($fichier_a_inclure)) {
33
		include_once $fichier_a_inclure;
34
		include_once $fichier_a_inclure;
34
		return null;
35
		return null;
35
	}
36
	}
36
}
37
}
37
spl_autoload_register('autoloadFw');
38
spl_autoload_register('autoloadFw');
38
 
39
 
39
// Autoload par défaut pour l'application
40
// Autoload par défaut pour l'application
40
function autoloadAppliDefaut($nom_classe) {
41
function autoloadAppliDefaut($nom_classe) {
41
	$dossiers_classes = array(	Config::get('chemin_controleurs'),
42
	$dossiers_classes = array(	Config::get('chemin_controleurs'),
42
								Config::get('chemin_modeles'),
43
								Config::get('chemin_modeles'),
43
								Config::get('chemin_bibliotheque'));
44
								Config::get('chemin_bibliotheque'));
44
	
45
	
45
	foreach ($dossiers_classes as $chemin) {
46
	foreach ($dossiers_classes as $chemin) {
46
		$fichier_a_tester = $chemin.$nom_classe.'.php';
47
		$fichier_a_tester = $chemin.$nom_classe.'.php';
47
		if (file_exists($fichier_a_tester)) {
48
		if (file_exists($fichier_a_tester)) {
48
			include_once $fichier_a_tester;
49
			include_once $fichier_a_tester;
49
			return null;
50
			return null;
50
		}
51
		}
51
	}
52
	}
52
}
53
}
53
spl_autoload_register('autoloadAppliDefaut');
54
spl_autoload_register('autoloadAppliDefaut');
54
 
55
 
55
// Autoload définit par l'application
56
// Autoload défini par l'application
56
if (function_exists('__autoload')) {
57
if (function_exists('__autoload')) {
57
	spl_autoload_register('__autoload');
58
	spl_autoload_register('__autoload');
58
}
59
}
59
?>
60
?>