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