| 416 |
aurelien |
1 |
<?php
|
| 2458 |
jpm |
2 |
// declare(encoding='UTF-8');
|
| 416 |
aurelien |
3 |
/**
|
| 2458 |
jpm |
4 |
* Service recherche d'image a partir d'un numero nomenclatural.
|
|
|
5 |
*
|
|
|
6 |
* Cas d'utilisation :
|
|
|
7 |
* 1: Le service recoit un numero nomenclatural
|
|
|
8 |
* 2: Le service calcul le numero taxonomique associe
|
|
|
9 |
* 3: Le service recherche une image disponible pour ce numero taxonomique
|
|
|
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>
|
|
|
23 |
*/
|
| 876 |
aurelien |
24 |
class NameImage extends Cel {
|
| 416 |
aurelien |
25 |
|
| 2458 |
jpm |
26 |
public function getElement($uid){
|
|
|
27 |
$image = array('', '');
|
|
|
28 |
if (isset($uid[0]) && isset($uid[1])) {
|
| 1527 |
aurelien |
29 |
$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';
|
|
|
30 |
$image = $this->obtenirIllustration($uid[0], $uid[1]);
|
| 416 |
aurelien |
31 |
}
|
| 2458 |
jpm |
32 |
|
|
|
33 |
$this->envoyerJson($image);
|
|
|
34 |
return true;
|
| 416 |
aurelien |
35 |
}
|
| 2458 |
jpm |
36 |
|
|
|
37 |
private function obtenirIllustration($referentiel_taxo, $nn) {
|
| 1527 |
aurelien |
38 |
// TODO: gérer ici les images d'autres référentiels si celles si sont disponibles
|
| 2458 |
jpm |
39 |
$retour = array('', '');
|
|
|
40 |
if ($referentiel_taxo == 'bdtfx') {
|
|
|
41 |
$retour = $this->effectuerRequetePhotoFlora($nn);
|
| 1527 |
aurelien |
42 |
}
|
|
|
43 |
return $retour;
|
|
|
44 |
}
|
| 2458 |
jpm |
45 |
|
| 1527 |
aurelien |
46 |
private function effectuerRequetePhotoFlora($nn) {
|
|
|
47 |
$url_photoflora = $this->config['eflore']['url_service_photoflora'];
|
|
|
48 |
$url = $url_photoflora.'?masque.nn='.$nn.'&navigation.limite=1';
|
|
|
49 |
$resultat = @file_get_contents($url);
|
|
|
50 |
$resultat = json_decode($resultat);
|
| 2458 |
jpm |
51 |
if (is_object($resultat) && isset($resultat->resultats)) {
|
| 1527 |
aurelien |
52 |
$element = (array)$resultat->resultats;
|
|
|
53 |
$element = array_pop($element);
|
|
|
54 |
if(is_object($element)) {
|
|
|
55 |
$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
|
|
|
56 |
} else {
|
| 2458 |
jpm |
57 |
$image = array('', '');
|
| 1527 |
aurelien |
58 |
}
|
|
|
59 |
}
|
|
|
60 |
return $image;
|
|
|
61 |
}
|
| 2458 |
jpm |
62 |
}
|