3 |
jpm |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* La méthode __autoload() charge dynamiquement les classes trouvées dans le code.
|
|
|
4 |
* Cette fonction est appelée par php5 quand il trouve une instanciation de classe dans le code.
|
|
|
5 |
*
|
|
|
6 |
*@param string le nom de la classe appelée.
|
|
|
7 |
*@return void le fichier contenant la classe doit être inclu par la fonction.
|
|
|
8 |
*/
|
|
|
9 |
function chargerClasse($classe) {
|
|
|
10 |
if (class_exists($classe)) {
|
|
|
11 |
return null;
|
|
|
12 |
}
|
7 |
jpm |
13 |
$cheminBase = realpath(__DIR__.'/../modules/0.1').'/';
|
|
|
14 |
$chemins = array($cheminBase);
|
3 |
jpm |
15 |
foreach ($chemins as $chemin) {
|
|
|
16 |
$chemin = $chemin.$classe.'.php';
|
|
|
17 |
if (file_exists($chemin)) {
|
|
|
18 |
require_once $chemin;
|
|
|
19 |
}
|
|
|
20 |
}
|
|
|
21 |
}
|
|
|
22 |
spl_autoload_register('chargerClasse');
|
|
|
23 |
|
|
|
24 |
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
|
|
|
25 |
// Sinon, rien ne sera chargé.
|
|
|
26 |
// Chemin du fichier chargeant le framework requis
|
|
|
27 |
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'framework.php';
|
|
|
28 |
if (!file_exists($framework)) {
|
|
|
29 |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
|
|
|
30 |
trigger_error($e, E_USER_ERROR);
|
|
|
31 |
} else {
|
|
|
32 |
// Inclusion du Framework
|
|
|
33 |
require_once $framework;
|
|
|
34 |
// Ajout d'information concernant cette application
|
|
|
35 |
Framework::setCheminAppli(realpath($framework));// Obligatoire
|
|
|
36 |
Framework::setInfoAppli(Config::get('info'));
|
|
|
37 |
}
|
|
|
38 |
/*
|
|
|
39 |
* Local Variables:
|
|
|
40 |
* mode: php
|
|
|
41 |
* coding: utf-8
|
|
|
42 |
* tab-width: 4
|
|
|
43 |
* c-basic-offset: 4
|
|
|
44 |
* c-hanging-comment-ender-p: nil
|
|
|
45 |
* indent-tabs-mode: nil
|
|
|
46 |
* End:
|
|
|
47 |
*/
|
|
|
48 |
?>
|