Subversion Repositories eFlore/Applications.del

Rev

Rev 353 | Go to most recent revision | Details | Compare with Previous | 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';
356 aurelien 35
		$retour_completion_noms = json_encode(array());
36
		$recherche = '';
353 aurelien 37
 
38
		$this->debut = isset($_GET['debut']) ? $_GET['debut'] : $this->debut;
39
		$this->limite = isset($_GET['limite']) ? $_GET['limite'] : $this->limite;
40
 
41
		$format = isset($_GET['format']) ? strtolower($_GET['format']) : $format;
42
		$recherche = isset($uid[0]) && $uid[0] != '' ? $uid[0] : '';
356 aurelien 43
		$recherche_suite = isset($uid[1]) && $uid[1] != '' ? '/'.$uid[1] : '';
44
 
45
		$recherche .= $recherche_suite;
353 aurelien 46
 
47
		switch ($format) {
48
			case 'json':
49
				$retour_completion_noms = $this->obtenirNomsCompletes($recherche);
50
				$mime = 'application/json';
51
			break;
52
		}
53
 
356 aurelien 54
		$this->envoyer($retour_completion_noms,$mime);
353 aurelien 55
	}
56
 
57
	private function obtenirNomsCompletes($requete) {
58
		return file_get_contents("http://www.tela-botanica.org/eflore/cel2/jrest/NameSearch/".$requete);
59
	}
60
}
61
?>