1 |
<?php
|
1 |
<?php
|
2 |
/**
|
2 |
/**
|
3 |
* Initialise le chargement et l'exécution des services web.
|
3 |
* Initialise le chargement et l'exécution des services web.
|
4 |
*
|
4 |
*
|
5 |
* @category DEL
|
5 |
* @category DEL
|
6 |
* @package Services
|
6 |
* @package Services
|
7 |
* @subpackage Bibliotheque
|
7 |
* @subpackage Bibliotheque
|
8 |
* @version 0.1
|
8 |
* @version 0.1
|
9 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
9 |
* @author Mathias CHOUET <mathias@tela-botanica.org>
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
10 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
11 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
11 |
* @author Aurelien PERONNET <aurelien@tela-botanica.org>
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
12 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
13 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
14 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
14 |
* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>
|
15 |
*/
|
15 |
*/
|
16 |
|
16 |
|
17 |
// Permet d'afficher le temps d'execution du service
|
17 |
// Permet d'afficher le temps d'execution du service
|
18 |
$temps_debut = (isset($_GET['chrono']) && $_GET['chrono'] == 1) ? microtime(true) : '';
|
18 |
$temps_debut = (isset($_GET['chrono']) && $_GET['chrono'] == 1) ? microtime(true) : '';
|
19 |
|
19 |
|
20 |
// Autoloader pour les namespaces, à base de routes
|
20 |
// Autoloader pour les namespaces, à base de routes
|
21 |
function __autoload($nom_classe) {
|
21 |
function __autoload($nom_classe) {
|
22 |
//echo "AUTOLOAD\n";
|
22 |
//echo "AUTOLOAD\n";
|
23 |
$dernierAS = strrpos($nom_classe, "\\");
|
23 |
$dernierAS = strrpos($nom_classe, "\\");
|
24 |
$ns = substr($nom_classe, 0, $dernierAS);
|
24 |
$ns = substr($nom_classe, 0, $dernierAS);
|
25 |
$nom = substr($nom_classe, strrpos($nom_classe, "\\") + 1);
|
25 |
$nom = substr($nom_classe, strrpos($nom_classe, "\\") + 1);
|
26 |
//echo "Recherche : $nom / $ns\n";
|
26 |
//echo "Recherche : $nom / $ns\n";
|
27 |
// Routes selon les namespaces
|
27 |
// Routes selon les namespaces
|
28 |
$routes = array('TelaBotanica\Del\Commun' => Config::get('cheminDelCommun'));
|
28 |
$routes = array('TelaBotanica\Del\Commun' => Config::get('chemin_del_commun'));
|
29 |
if (array_key_exists($ns, $routes)) {
|
29 |
if (array_key_exists($ns, $routes)) {
|
30 |
//echo "Route trouvée: " . $routes[$ns] . "\n";
|
30 |
//echo "Route trouvée: " . $routes[$ns] . "\n";
|
31 |
$fichier_a_inclure = dirname(__FILE__) . DS . $routes[$ns] . DS . $nom . '.php';
|
31 |
$fichier_a_inclure = dirname(__FILE__) . DS . $routes[$ns] . DS . $nom . '.php';
|
32 |
if (file_exists($fichier_a_inclure)) {
|
32 |
if (file_exists($fichier_a_inclure)) {
|
33 |
include_once $fichier_a_inclure;
|
33 |
include_once $fichier_a_inclure;
|
34 |
return null;
|
34 |
return null;
|
35 |
}
|
35 |
}
|
36 |
}
|
36 |
}
|
37 |
}
|
37 |
}
|
38 |
|
38 |
|
39 |
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
|
39 |
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
|
40 |
// Sinon, rien ne sera chargé.
|
40 |
// Sinon, rien ne sera chargé.
|
41 |
// Chemin du fichier chargeant le framework requis
|
41 |
// Chemin du fichier chargeant le framework requis
|
42 |
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
|
42 |
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
|
43 |
if (!file_exists($framework)) {
|
43 |
if (!file_exists($framework)) {
|
44 |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
|
44 |
$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
|
45 |
trigger_error($e, E_USER_ERROR);
|
45 |
trigger_error($e, E_USER_ERROR);
|
46 |
} else {
|
46 |
} else {
|
47 |
// Inclusion du Framework
|
47 |
// Inclusion du Framework
|
48 |
require_once $framework;
|
48 |
require_once $framework;
|
49 |
// Ajout d'information concernant cette application
|
49 |
// Ajout d'information concernant cette application
|
50 |
Framework::setCheminAppli(__FILE__);// Obligatoire
|
50 |
Framework::setCheminAppli(__FILE__);// Obligatoire
|
51 |
Framework::setInfoAppli(Config::get('info'));
|
51 |
Framework::setInfoAppli(Config::get('info'));
|
52 |
|
52 |
|
53 |
// Initialisation et lancement du serveur
|
53 |
// Initialisation et lancement du serveur
|
54 |
$Serveur = new RestServeur();
|
54 |
$Serveur = new RestServeur();
|
55 |
$Serveur->executer();
|
55 |
$Serveur->executer();
|
56 |
}
|
56 |
}
|