Subversion Repositories eFlore/Applications.del

Rev

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

Rev Author Line No. Line
353 aurelien 1
<?php
2
class NomsTaxons extends Del {
3
 
4
	private $debut = 0;
5
	private $limite = 50;
6
 
7
	/**
8
	* Méthode appelée avec une requête de type GET avec une url de la forme
9
	* http://localhost/jrest/ExempleService/
10
	*
11
	* Sert normalement à renvoyer la description des possibilités du service
12
	*
13
	*/
14
	public function getRessource() {
15
		return $this->getElement(array());
16
	}
17
 
18
	/**
19
	* Méthode appelée avec une requête de type GET avec une url de la forme
20
	* http://localhost/jrest/ExempleService/uid[0]/$uid[1]/ etc...
21
	*
22
	* Sert normalement à ramener un élément précis indiqué par un identifiant
23
	* qui se situe dans l'url après le nom du service
24
	* Le filtrage, le format de retour, les paramètres optionnels ... sont normalement indiqués
25
	* dans le tableau $_GET
26
	* Pour obtenir l'élément 2501 dans le format HTML cela pourrait donner
27
	* http://localhost/jrest/ExempleService/2501?format=HTML
28
	*
29
	* @param $uid un tableau contenant les élements passés dans l'url après le nom du service
30
	*
31
	*/
32
	public function getElement($uid)
33
	{
34
		$format = 'json';
35
 
36
		$this->debut = isset($_GET['debut']) ? $_GET['debut'] : $this->debut;
37
		$this->limite = isset($_GET['limite']) ? $_GET['limite'] : $this->limite;
38
 
39
		$format = isset($_GET['format']) ? strtolower($_GET['format']) : $format;
40
		$recherche = isset($uid[0]) && $uid[0] != '' ? $uid[0] : '';
41
 
42
		switch ($format) {
43
			case 'json':
44
				$retour_completion_noms = $this->obtenirNomsCompletes($recherche);
45
				$mime = 'application/json';
46
			break;
47
		}
48
 
49
		$this->envoyer($retour,$mime);
50
	}
51
 
52
	private function obtenirNomsCompletes($requete) {
53
		return file_get_contents("http://www.tela-botanica.org/eflore/cel2/jrest/NameSearch/".$requete);
54
	}
55
}
56
?>