Subversion Repositories Applications.wikini

Rev

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

Rev 45 Rev 46
1
<?php
1
<?php
2
// Encodage : UTF-8
-
 
-
 
2
 
3
// Permet d'afficher le temps d'execution du service
3
// Permet d'afficher le temps d'execution du service
4
$temps_debut = (isset($_GET['chrono']) && $_GET['chrono'] == 1) ? microtime(true) : '';
4
$temps_debut = (isset($_GET['chrono']) && $_GET['chrono'] == 1) ? microtime(true) : '';
5
// +-------------------------------------------------------------------------------------------------------------------+
5
// +-------------------------------------------------------------------------------------------------------------------+
6
/**
6
/**
7
* Serveur
7
 * Serveur REST Wikini
8
*
-
 
9
* Description : initialise le chargement et l'exécution des services web.
-
 
10
*
8
 *
-
 
9
 * Initialise le chargement et l'exécution des services web.
11
//Auteur original :
10
 * Encodage : UTF-8
12
* @author       auteur <aut@tela-botanica.org>
11
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
13
* @copyright    Tela-Botanica 1999-2008
12
 * @copyright	Tela-Botanica 1999-2008
14
* @licence      GPL v3 & CeCILL v2
13
 * @licence		GPL v3 & CeCILL v2
15
* @version      $Id$
-
 
16
*/
14
 */
17
// +-------------------------------------------------------------------------------------------------------------------+
-
 
18
 
15
 
19
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
16
// Le fichier autoload.inc.php du Framework de Tela Botanica doit être appelée avant tout autre chose dans l'application.
20
// Sinon, rien ne sera chargé.
17
// Sinon, rien ne sera chargé.
21
// Chemin du fichier chargeant le framework requis
18
// Chemin du fichier chargeant le framework requis
22
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
19
$framework = dirname(__FILE__).DIRECTORY_SEPARATOR.'framework.php';
23
 
20
 
24
if (!file_exists($framework)) {
21
if (!file_exists($framework)) {
25
    $e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
22
	$e = "Veuillez paramétrer l'emplacement et la version du Framework dans le fichier $framework";
26
    trigger_error($e, E_USER_ERROR);
23
	trigger_error($e, E_USER_ERROR);
27
} else {
24
} else {
28
    // Inclusion du Framework
25
	// Inclusion du Framework
29
    require_once $framework;
26
	require_once $framework;
30
    // Ajout d'information concernant cette application
27
	// Ajout d'information concernant cette application
31
    Framework::setCheminAppli(__FILE__);// Obligatoire
28
	Framework::setCheminAppli(__FILE__);// Obligatoire
32
    Framework::setInfoAppli(Config::get('info'));
29
	Framework::setInfoAppli(Config::get('info'));
33
	
30
 
34
	// Transformation de l'url du handler wikini en url pour le serveur REST
31
	// Transformation de l'url du handler wikini en url pour le serveur REST
35
	// TODO : améliorer la gestion de l'url entre le wikini et le serveur REST
32
	// TODO : améliorer la gestion de l'url entre le wikini et le serveur REST
36
	//$_SERVER['REQUEST_URI'] = Config::get('serveur.baseURL').$_GET['api'];
33
	//$_SERVER['REQUEST_URI'] = Config::get('serveur.baseURL').$_GET['api'];
37
	//$_SERVER['QUERY_STRING'] = $_GET['params'] ? $_GET['params'] : '';
34
	//$_SERVER['QUERY_STRING'] = $_GET['params'] ? $_GET['params'] : '';
38
	
35
 
39
	// Création de l'objet Wiki qui sera transmis au service via le Registre
36
	// Création de l'objet Wiki qui sera transmis au service via le Registre
40
	Registre::set('cheminApi', getcwd());
37
	Registre::set('cheminApi', getcwd());
41
	Registre::set('cheminWiki', realpath(dirname(__FILE__).DS.'..'.DS.'..'.DS).DS);
38
	Registre::set('cheminWiki', realpath(dirname(__FILE__).DS.'..'.DS.'..'.DS).DS);
42
	$wikiApi = new WikiApi(Registre::get('cheminWiki'), Registre::get('cheminApi'));
39
	$wikiApi = new WikiApi(Registre::get('cheminWiki'), Registre::get('cheminApi'));
43
	Registre::set('wikiApi', $wikiApi);
40
	Registre::set('wikiApi', $wikiApi);
44
	
41
 
45
    // Initialisation et lancement du serveur
42
	// Initialisation et lancement du serveur
46
    $Serveur = new RestServeur();
43
	$Serveur = new RestServeur();
47
    $Serveur->executer();
44
	$Serveur->executer();
48
   
45
 
49
    // Affiche le temps d'execution du service
46
	// Affiche le temps d'execution du service
50
    if (isset($_GET['chrono']) && $_GET['chrono'] == 1) {
47
	if (isset($_GET['chrono']) && $_GET['chrono'] == 1) {
51
        $temps_fin = microtime(true);
48
		$temps_fin = microtime(true);
52
        echo 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4);
49
		echo 'Temps d\'execution : '.round($temps_fin - $temps_debut, 4);
53
    }
50
	}
54
}
51
}
55
?> 
52
?>