Subversion Repositories Applications.wikini

Rev

Rev 31 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
30 aurelien 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe d'exemple de service web du projet eFlore
5
 * Source des données : {NOM_DU_PROJET} {ADRESSE_WEB_DONNEES_DU_PROJET}
6
 * Paramètres du service :
7
 *  - param1 : explication de l'utilisation du param1
8
 *  - param2 : explication de l'utilisation du param2
9
 * Exemple :
10
 * http://localhost/{CODE_DU_PROJET}/services/0.1/Exemple?param1=val1&param2=val2
11
 *
12
 * @category	php 5.2
13
 * @package		lion1906
14
 * @author		{PRENOM} {NOM}<{PRENOM}@tela-botanica.org>
15
 * @copyright	Copyright (c) 2011, Tela Botanica (accueil@tela-botanica.org)
16
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
17
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
18
 * @version		$Id$
19
 */
20
class Pages extends Service {
21
 
22
	private $pageNom = null;
23
	private $retour = 'html';
24
 
25
	public function consulter($ressources, $parametres) {
26
		$verifOk = $this->verifierParametres($parametres);
27
		if ($verifOk) {
28
			// Débuter ici le code du service
29
			$this->pageNom = $ressources[0];
30
			$wiki = Registre::get('wikiApi');
31
			$wiki->setPageCourrante($this->pageNom);
32
			$page = $wiki->LoadPage($ressources[0]);
33
			if ($this->retour == 'html') {
34
				$retour = $wiki->Format($page["body"], "wakka");
35
			} else {
36
				$retour = $page["body"];
37
			}
38
			return $retour;
39
		} else {
40
			RestServeur::envoyerEnteteStatutHttp(RestServeur::HTTP_CODE_MAUVAISE_REQUETE);
41
 
42
		}
43
	}
44
 
45
	private function verifierParametres($parametres) {
46
		$ok = true;
47
		extract($parametres);
48
		if (isset($retour) ) {
49
			if (!preg_match('/^(wiki|html)$/', $retour)) {
50
				$message = "La valeur du paramètre 'retour' peut seulement prendre les valeurs : wiki et html.";
51
				$this->ajouterMessage($message);
52
				$ok = false;
53
			} else {
54
				$this->retour = $retour;
55
			}
56
		}
57
		return $ok;
58
	}
59
}
60
?>