Rev 892 | Rev 1426 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php/*** PHP Version 5** @category PHP* @package jrest* @author David Delon <david.delon@clapas.net>* @copyright 2010 Tela-Botanica* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL* @version SVN: <svn_id>* @link /doc/jrest/*//*** NameImage.php** in : utf8* out : 8859** Cas d'utilisation :* Service recherche d'image a partir d'un numero nomenclatural** 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*//** Constante stockant l'URL de la page d'accueil de Photoflora.*/define('EF_URL_PHOTOFLORA', 'http://photoflora.free.fr/');/** Constante stockant l'URL de la page de Photoflora affichant toutes les images d'un taxon donné.*/define('EF_URL_PHOTOFLORA_TAXON', EF_URL_PHOTOFLORA.'FiTax.php?NumTaxon=%s');/** Constante stockant l'URL du dossier de photoflora contenant les images miniatures.*/define('EF_URL_PHOTOFLORA_IMG_MIN', 'http://photoflora.free.fr/photos/%s/min/%s');/** Constante stockant l'URL du service XML de Photoflora.*/define('EF_URL_PHOTOFLORA_SERVICE', EF_URL_PHOTOFLORA.'ef_photoflora.php?nt=%s');define('EF_URL_PHOTOFLORA_REGEXP_01', '/\/photos\/([^\/]+)\/max\/(.+)$/');define('EF_URL_PHOTOFLORA_REGEXP_02', '/photoflora([^.]+)\.free\.fr\/max\/(.+)$/');class NameImage extends Cel {function getElement($uid){$nt = null;if(isset($uid[0])) {$recherche_infos_taxon = new RechercheInfosTaxon($this->config);$nt = $recherche_infos_taxon->rechercherNumTaxSurNumNom($uid[0]);}$projet_photo = 'photoflora';$tab_retour[$projet_photo]=chercherIllustrationsServiceXml(sprintf(EF_URL_PHOTOFLORA_SERVICE, $nt));$value=array('null','null');foreach ($tab_retour[$projet_photo] as $cle => $illustration) {if (preg_match(EF_URL_PHOTOFLORA_REGEXP_01, $illustration['about'], $match)) {$abreviation = $match[1];$fichier = $match[2];}else {if (preg_match(EF_URL_PHOTOFLORA_REGEXP_02, $illustration['about'], $match)) {$abreviation = $match[1];$fichier = $match[2];}}if (isset($abreviation)) {$url_miniature = sprintf(EF_URL_PHOTOFLORA_IMG_MIN, $abreviation, $fichier);;$url_max = $illustration['about'];$value=array($url_miniature,$url_max);// Priorite aux images en pngif (strstr($fichier, '.png')) {break;}}}$this->envoyerJson($value);return true;}}function chercherIllustrationsServiceXml($url){return analyserFichierRdf($url);}function analyserFichierRdf($chemin){$aso_info = array();$dom = new DOMDocument();$dom->validateOnParse = true;if (preg_match('/^http:\/\//', $chemin)) {@$dom->loadXML(file_get_contents($chemin));} else {@$dom->load($chemin);}$tab_infos = array();foreach ($dom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $rdf_description) {$aso_info['about'] = $rdf_description->getAttribute('about');$aso_info['dc:identifier'] = $rdf_description->getAttribute('identifier');$aso_info['dc:title'] = utf8_decode($rdf_description->getAttribute('title'));$aso_info['dc:creator'] = utf8_decode($rdf_description->getAttribute('creator'));$aso_info['dc:contributor'] = utf8_decode($rdf_description->getAttribute('contributor'));$aso_info['dc:publisher'] = utf8_decode($rdf_description->getAttribute('publisher'));$aso_info['dc:type'] = utf8_decode($rdf_description->getAttribute('type'));$aso_info['dc:format'] = utf8_decode($rdf_description->getAttribute('format'));if (function_exists('date_default_timezone_set')) {date_default_timezone_set('Europe/Paris');}if (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $rdf_description->getAttribute('created'))) {$aso_info['dcterms:created'] = date('j-m-Y à H:i:s', strtotime($rdf_description->getAttribute('created')));} else {$aso_info['dcterms:created'] = $rdf_description->getAttribute('created');}$aso_info['dcterms:dateSubmitted'] = utf8_decode($rdf_description->getAttribute('dateSubmitted'));$aso_info['dcterms:spatial'] = utf8_decode($rdf_description->getAttribute('spatial'));$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence'));$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info;}return $tab_infos;}/* +--Fin du code ---------------------------------------------------------------------------------------+* $Log$* Revision 1.4 2008-11-13 11:29:12 ddelon* Reecriture gwt-ext** Revision 1.2 2008-01-30 08:57:28 ddelon* fin mise en place mygwt** Revision 1.1 2007-06-06 13:31:16 ddelon* v0.09**/?>