Subversion Repositories eFlore/Applications.cel

Rev

Rev 1527 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1527 Rev 2458
1
<?php
1
<?php
-
 
2
// declare(encoding='UTF-8');
2
/**
3
/**
3
* PHP Version 5
-
 
4
*
-
 
5
* @category  PHP
-
 
6
* @package   jrest
-
 
7
* @author    David Delon <david.delon@clapas.net>
4
 * Service recherche d'image a partir d'un numero nomenclatural.
8
* @copyright 2010 Tela-Botanica
-
 
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
-
 
10
* @version   SVN: <svn_id>
-
 
11
* @link      /doc/jrest/
-
 
12
*/
-
 
13
 
-
 
14
/**
-
 
15
* NameImage.php  
-
 
16
* 
-
 
17
* in : utf8
-
 
18
* out : 8859
-
 
19
* 
5
 *
20
* Cas d'utilisation :
6
 * Cas d'utilisation :
21
* Service recherche d'image a partir d'un numero nomenclatural
-
 
22
* 
-
 
23
* 1: Le service recoit un numero nomenclatural
7
 * 1: Le service recoit un numero nomenclatural
24
* 2: Le service calcul le numero taxonomique associe
8
 * 2: Le service calcul le numero taxonomique associe
25
* 3: Le service recherche une image disponible pour ce numero taxonomique
9
 * 3: Le service recherche une image disponible pour ce numero taxonomique
26
* 4: Le service redimensionne l'image et la renvoie
10
 * 4: Le service redimensionne l'image et la renvoie
-
 
11
 *
-
 
12
 * @internal   Mininum PHP version : 5.2
-
 
13
 * @category   CEL
-
 
14
 * @package    Services
-
 
15
 * @subpackage Images
-
 
16
 * @version    0.1
-
 
17
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
-
 
18
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
-
 
19
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
-
 
20
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
-
 
21
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
-
 
22
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
27
*/
23
 */
28
class NameImage extends Cel  {
24
class NameImage extends Cel  {
29
 
25
 
30
	function getElement($uid){
-
 
31
		
26
	public function getElement($uid){
32
		$image = array("","");
27
		$image = array('', '');
33
		if(isset($uid[0]) && isset($uid[1])) {
28
		if (isset($uid[0]) && isset($uid[1])) {
34
			$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';
29
			$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';
35
			$image = $this->obtenirIllustration($uid[0], $uid[1]);
30
			$image = $this->obtenirIllustration($uid[0], $uid[1]);
36
		}
31
		}
37
		
32
 
38
		$this->envoyerJson($image);			
33
		$this->envoyerJson($image);
39
		return true;	
34
		return true;
40
	}
35
	}
41
	
36
 
42
	function obtenirIllustration($referentiel_taxo, $nn) {
37
	private function obtenirIllustration($referentiel_taxo, $nn) {
43
		// TODO: gérer ici les images d'autres référentiels si celles si sont disponibles
38
		// TODO: gérer ici les images d'autres référentiels si celles si sont disponibles
44
		$retour = array("","");
39
		$retour = array('', '');
45
		switch($referentiel_taxo) {
-
 
46
			case 'bdtfx':
40
		if ($referentiel_taxo == 'bdtfx') {
47
				$retour = $this->effectuerRequetePhotoFlora($nn);
-
 
48
				break;
-
 
49
					
-
 
50
			default:
-
 
51
				break;
41
			$retour = $this->effectuerRequetePhotoFlora($nn);
52
		}
42
		}
53
		return $retour;
43
		return $retour;
54
	}
44
	}
55
	
45
 
56
	private function effectuerRequetePhotoFlora($nn) {
46
	private function effectuerRequetePhotoFlora($nn) {
57
		$url_photoflora = $this->config['eflore']['url_service_photoflora'];
47
		$url_photoflora = $this->config['eflore']['url_service_photoflora'];
58
		$url = $url_photoflora.'?masque.nn='.$nn.'&navigation.limite=1';
48
		$url = $url_photoflora.'?masque.nn='.$nn.'&navigation.limite=1';
59
		$resultat = @file_get_contents($url);
49
		$resultat = @file_get_contents($url);
60
		$resultat = json_decode($resultat);
50
		$resultat = json_decode($resultat);
61
		if(is_object($resultat) && isset($resultat->resultats)) {
51
		if (is_object($resultat) && isset($resultat->resultats)) {
62
			$element = (array)$resultat->resultats;
52
			$element = (array)$resultat->resultats;
63
			$element = array_pop($element);
53
			$element = array_pop($element);
64
			if(is_object($element)) {
54
			if(is_object($element)) {
65
				$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
55
				$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
66
			} else {
56
			} else {
67
				$image = array('','');
57
				$image = array('', '');
68
			}
58
			}
69
		}
59
		}
70
		return $image;
60
		return $image;
71
	}
61
	}
72
}
62
}
73
/* +--Fin du code ---------------------------------------------------------------------------------------+
-
 
74
* $Log$
-
 
75
* Revision 1.4  2008-11-13 11:29:12  ddelon
-
 
76
* Reecriture gwt-ext
-
 
77
*
-
 
78
* Revision 1.2  2008-01-30 08:57:28  ddelon
-
 
79
* fin mise en place mygwt
-
 
80
*
-
 
81
* Revision 1.1  2007-06-06 13:31:16  ddelon
-
 
82
* v0.09
-
 
83
* 
-
 
84
*/
-
 
85
?>
-
 
86
63