Subversion Repositories eFlore/Applications.cel

Rev

Rev 1468 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1468 Rev 1527
Line 23... Line 23...
23
* 1: Le service recoit un numero nomenclatural
23
* 1: Le service recoit un numero nomenclatural
24
* 2: Le service calcul le numero taxonomique associe
24
* 2: Le service calcul le numero taxonomique associe
25
* 3: Le service recherche une image disponible pour ce numero taxonomique
25
* 3: Le service recherche une image disponible pour ce numero taxonomique
26
* 4: Le service redimensionne l'image et la renvoie
26
* 4: Le service redimensionne l'image et la renvoie
27
*/
27
*/
28
 
-
 
29
class NameImage extends Cel  {
28
class NameImage extends Cel  {
Line 30... Line 29...
30
 
29
 
Line 31... Line 30...
31
	function getElement($uid){
30
	function getElement($uid){
-
 
31
		
-
 
32
		$image = array("","");
-
 
33
		if(isset($uid[0]) && isset($uid[1])) {
-
 
34
			$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';
-
 
35
			$image = $this->obtenirIllustration($uid[0], $uid[1]);
-
 
36
		}
-
 
37
		
-
 
38
		$this->envoyerJson($image);			
-
 
39
		return true;	
-
 
40
	}
-
 
41
	
-
 
42
	function obtenirIllustration($referentiel_taxo, $nn) {
-
 
43
		// TODO: gérer ici les images d'autres référentiels si celles si sont disponibles
-
 
44
		$retour = array("","");
32
		
45
		switch($referentiel_taxo) {
-
 
46
			case 'bdtfx':
Line -... Line 47...
-
 
47
				$retour = $this->effectuerRequetePhotoFlora($nn);
-
 
48
				break;
-
 
49
					
33
		$image = array();
50
			default:
-
 
51
				break;
-
 
52
		}
-
 
53
		return $retour;
-
 
54
	}
34
		$url_photoflora = $this->config['eflore']['url_service_photoflora'];
55
	
35
		
56
	private function effectuerRequetePhotoFlora($nn) {
36
		if(isset($uid[0])) {
57
		$url_photoflora = $this->config['eflore']['url_service_photoflora'];
37
			$url = $url_photoflora.'?masque.nn='.$uid[0].'&navigation.limite=1';
58
		$url = $url_photoflora.'?masque.nn='.$nn.'&navigation.limite=1';
38
			$resultat = @file_get_contents($url);
59
		$resultat = @file_get_contents($url);
39
			$resultat = json_decode($resultat);
60
		$resultat = json_decode($resultat);
-
 
61
		if(is_object($resultat) && isset($resultat->resultats)) {
40
			if(is_object($resultat) && isset($resultat->resultats)) {
62
			$element = (array)$resultat->resultats;
-
 
63
			$element = array_pop($element);
-
 
64
			if(is_object($element)) {
41
				$element = (array)$resultat->resultats;
65
				$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
42
				$element = array_pop($element);
66
			} else {
43
				$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
-
 
44
			}
-
 
45
		}
67
				$image = array('','');
46
		
68
			}
47
		$this->envoyerJson($image);			
69
		}
48
		return true;	
70
		return $image;
49
	}
71
	}
50
}
72
}