Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1468 Rev 1527
1
<?php
1
<?php
2
/**
2
/**
3
* PHP Version 5
3
* PHP Version 5
4
*
4
*
5
* @category  PHP
5
* @category  PHP
6
* @package   jrest
6
* @package   jrest
7
* @author    David Delon <david.delon@clapas.net>
7
* @author    David Delon <david.delon@clapas.net>
8
* @copyright 2010 Tela-Botanica
8
* @copyright 2010 Tela-Botanica
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
10
* @version   SVN: <svn_id>
10
* @version   SVN: <svn_id>
11
* @link      /doc/jrest/
11
* @link      /doc/jrest/
12
*/
12
*/
13
 
13
 
14
/**
14
/**
15
* NameImage.php  
15
* NameImage.php  
16
* 
16
* 
17
* in : utf8
17
* in : utf8
18
* out : 8859
18
* out : 8859
19
* 
19
* 
20
* Cas d'utilisation :
20
* Cas d'utilisation :
21
* Service recherche d'image a partir d'un numero nomenclatural
21
* Service recherche d'image a partir d'un numero nomenclatural
22
* 
22
* 
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  {
30
 
29
 
31
	function getElement($uid){
30
	function getElement($uid){
32
		
31
		
33
		$image = array();
-
 
34
		$url_photoflora = $this->config['eflore']['url_service_photoflora'];
-
 
35
		
32
		$image = array("","");
36
		if(isset($uid[0])) {
-
 
37
			$url = $url_photoflora.'?masque.nn='.$uid[0].'&navigation.limite=1';
-
 
38
			$resultat = @file_get_contents($url);
-
 
39
			$resultat = json_decode($resultat);
-
 
40
			if(is_object($resultat) && isset($resultat->resultats)) {
33
		if(isset($uid[0]) && isset($uid[1])) {
41
				$element = (array)$resultat->resultats;
-
 
42
				$element = array_pop($element);
34
			$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';
43
				$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
-
 
44
			}
35
			$image = $this->obtenirIllustration($uid[0], $uid[1]);
45
		}
36
		}
46
		
37
		
47
		$this->envoyerJson($image);			
38
		$this->envoyerJson($image);			
48
		return true;	
39
		return true;	
49
	}
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("","");
-
 
45
		switch($referentiel_taxo) {
-
 
46
			case 'bdtfx':
-
 
47
				$retour = $this->effectuerRequetePhotoFlora($nn);
-
 
48
				break;
-
 
49
					
-
 
50
			default:
-
 
51
				break;
-
 
52
		}
-
 
53
		return $retour;
-
 
54
	}
-
 
55
	
-
 
56
	private function effectuerRequetePhotoFlora($nn) {
-
 
57
		$url_photoflora = $this->config['eflore']['url_service_photoflora'];
-
 
58
		$url = $url_photoflora.'?masque.nn='.$nn.'&navigation.limite=1';
-
 
59
		$resultat = @file_get_contents($url);
-
 
60
		$resultat = json_decode($resultat);
-
 
61
		if(is_object($resultat) && isset($resultat->resultats)) {
-
 
62
			$element = (array)$resultat->resultats;
-
 
63
			$element = array_pop($element);
-
 
64
			if(is_object($element)) {
-
 
65
				$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
-
 
66
			} else {
-
 
67
				$image = array('','');
-
 
68
			}
-
 
69
		}
-
 
70
		return $image;
-
 
71
	}
50
}
72
}
51
/* +--Fin du code ---------------------------------------------------------------------------------------+
73
/* +--Fin du code ---------------------------------------------------------------------------------------+
52
* $Log$
74
* $Log$
53
* Revision 1.4  2008-11-13 11:29:12  ddelon
75
* Revision 1.4  2008-11-13 11:29:12  ddelon
54
* Reecriture gwt-ext
76
* Reecriture gwt-ext
55
*
77
*
56
* Revision 1.2  2008-01-30 08:57:28  ddelon
78
* Revision 1.2  2008-01-30 08:57:28  ddelon
57
* fin mise en place mygwt
79
* fin mise en place mygwt
58
*
80
*
59
* Revision 1.1  2007-06-06 13:31:16  ddelon
81
* Revision 1.1  2007-06-06 13:31:16  ddelon
60
* v0.09
82
* v0.09
61
* 
83
* 
62
*/
84
*/
63
?>
85
?>