1 |
<?php
|
1 |
<?php
|
2 |
// Encodage : UTF-8
|
2 |
// Encodage : UTF-8
|
3 |
// +-------------------------------------------------------------------------------------------------------------------+
|
3 |
// +-------------------------------------------------------------------------------------------------------------------+
|
4 |
/**
|
4 |
/**
|
5 |
* Initialise le chargement et l'exécution des scripts
|
5 |
* Initialise le chargement et l'exécution des scripts
|
6 |
*
|
6 |
*
|
7 |
* Lancer ce fichier en ligne de commande avec :
|
7 |
* Lancer ce fichier en ligne de commande avec :
|
8 |
* <code>/opt/lampp/bin/php cli.php mon_script -a test</code>
|
8 |
* <code>/opt/lampp/bin/php cli.php mon_script -a test</code>
|
9 |
*
|
9 |
*
|
10 |
//Auteur original :
|
10 |
//Auteur original :
|
11 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
11 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
12 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
|
12 |
* @author Delphine CAUQUIL <delphine@tela-botanica.org>
|
13 |
* @copyright Tela-Botanica 1999-2008
|
13 |
* @copyright Tela-Botanica 1999-2008
|
14 |
* @licence GPL v3 & CeCILL v2
|
14 |
* @licence GPL v3 & CeCILL v2
|
15 |
* @version $Id$
|
15 |
* @version $Id$
|
16 |
*/
|
16 |
*/
|
17 |
// +-------------------------------------------------------------------------------------------------------------------+
|
17 |
// +-------------------------------------------------------------------------------------------------------------------+
|
18 |
|
18 |
|
19 |
|
19 |
|
20 |
|
20 |
|
21 |
// Autoloader pour les namespaces, à base de routes
|
21 |
// Autoloader pour les namespaces, à base de routes
|
22 |
function __autoload($nom_classe) {
|
22 |
function __autoload($nom_classe) {
|
23 |
//echo "AUTOLOAD\n";
|
23 |
//echo "AUTOLOAD\n";
|
24 |
$dernierAS = strrpos($nom_classe, "\\");
|
24 |
$dernierAS = strrpos($nom_classe, "\\");
|
25 |
$ns = substr($nom_classe, 0, $dernierAS);
|
25 |
$ns = substr($nom_classe, 0, $dernierAS);
|
26 |
$nom = substr($nom_classe, strrpos($nom_classe, "\\") + 1);
|
26 |
$nom = substr($nom_classe, strrpos($nom_classe, "\\") + 1);
|
27 |
//echo "Recherche : $nom / $ns\n";
|
27 |
//echo "Recherche : $nom / $ns\n";
|
28 |
// Routes selon les namespaces
|
28 |
// Routes selon les namespaces
|
29 |
$routes = array(
|
29 |
$routes = array(
|
30 |
'TelaBotanica\Del\Commun' => Config::get('cheminDelCommun')
|
30 |
'TelaBotanica\Del\Commun' => Config::get('cheminDelCommun')
|
31 |
);
|
31 |
);
|
32 |
if (array_key_exists($ns, $routes)) {
|
32 |
if (array_key_exists($ns, $routes)) {
|
33 |
//echo "Route trouvée: " . $routes[$ns] . "\n";
|
33 |
//echo "Route trouvée: " . $routes[$ns] . "\n";
|
34 |
$fichier_a_inclure = dirname(__FILE__) . DS . $routes[$ns] . DS . $nom . '.php';
|
34 |
$fichier_a_inclure = dirname(__FILE__) . DS . $routes[$ns] . DS . $nom . '.php';
|
35 |
if (file_exists($fichier_a_inclure)) {
|
35 |
if (file_exists($fichier_a_inclure)) {
|
36 |
include_once $fichier_a_inclure;
|
36 |
include_once $fichier_a_inclure;
|
37 |
return null;
|
37 |
return null;
|
38 |
}
|
38 |
}
|
39 |
}
|
39 |
}
|
40 |
}
|
40 |
}
|
41 |
|
41 |
|
42 |
// Le fichier Framework.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
|
42 |
// Le fichier Framework.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
|
43 |
// Sinon, rien ne sera chargé.
|
43 |
// Sinon, rien ne sera chargé.
|
44 |
// Chemin du fichier chargeant le framework requis
|
44 |
// Chemin du fichier chargeant le framework requis
|
45 |
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
|
45 |
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
|
46 |
if (!file_exists($framework)) {
|
46 |
if (!file_exists($framework)) {
|
47 |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
|
47 |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
|
48 |
trigger_error($e, E_USER_ERROR);
|
48 |
trigger_error($e, E_USER_ERROR);
|
49 |
} else {
|
49 |
} else {
|
50 |
// Inclusion du Framework
|
50 |
// Inclusion du Framework
|
51 |
require_once $framework;
|
51 |
require_once $framework;
|
52 |
|
52 |
|
53 |
// Ajout d'information concernant cette application
|
53 |
// Ajout d'information concernant cette application
|
54 |
Framework::setCheminAppli(__FILE__);// Obligatoire
|
54 |
Framework::setCheminAppli(__FILE__);// Obligatoire
|
55 |
Framework::setInfoAppli(Config::get('info'));
|
55 |
Framework::setInfoAppli(Config::get('info'));
|
56 |
|
56 |
|
57 |
// Initialisation et lancement du script appelé en ligne de commande
|
57 |
// Initialisation et lancement du script appelé en ligne de commande
|
58 |
Cli::executer();
|
58 |
Cli::executer();
|
59 |
}
|
59 |
}
|
60 |
?>
|
60 |
?>
|