Rev 1527 | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php// declare(encoding='UTF-8');/*** Service recherche d'image a partir d'un numero nomenclatural.** Cas d'utilisation :* 1: Le service recoit un numero nomenclatural* 2: Le service calcul le numero taxonomique associe* 3: Le service recherche une image disponible pour ce numero taxonomique* 4: Le service redimensionne l'image et la renvoie** @internal Mininum PHP version : 5.2* @category CEL* @package Services* @subpackage Images* @version 0.1* @author Mathias CHOUET <mathias@tela-botanica.org>* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>* @author Aurelien PERONNET <aurelien@tela-botanica.org>* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>* @copyright 1999-2014 Tela Botanica <accueil@tela-botanica.org>*/class NameImage extends Cel {public function getElement($uid){$image = array('', '');if (isset($uid[0]) && isset($uid[1])) {$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';$image = $this->obtenirIllustration($uid[0], $uid[1]);}$this->envoyerJson($image);return true;}private function obtenirIllustration($referentiel_taxo, $nn) {// TODO: gérer ici les images d'autres référentiels si celles si sont disponibles$retour = array('', '');if ($referentiel_taxo == 'bdtfx') {$retour = $this->effectuerRequetePhotoFlora($nn);}return $retour;}private function effectuerRequetePhotoFlora($nn) {$url_photoflora = $this->config['eflore']['url_service_photoflora'];$url = $url_photoflora.'?masque.nn='.$nn.'&navigation.limite=1';$resultat = @file_get_contents($url);$resultat = json_decode($resultat);if (is_object($resultat) && isset($resultat->resultats)) {$element = (array)$resultat->resultats;$element = array_pop($element);if(is_object($element)) {$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});} else {$image = array('', '');}}return $image;}}