Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1425 → Rev 1426

/trunk/jrest/services/NameImage.php
41,95 → 41,24
class NameImage extends Cel {
 
function getElement($uid){
 
$nt = null;
 
if(isset($uid[0])) {
$recherche_infos_taxon = new RechercheInfosTaxonBeta($this->config);
$nt = $recherche_infos_taxon->rechercherNumTaxSurNumNom($uid[0]);
}
 
$projet_photo = 'photoflora';
$tab_retour[$projet_photo]=chercherIllustrationsServiceXml(sprintf(EF_URL_PHOTOFLORA_SERVICE, $nt));
$image = array();
$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($uid[0])) {
$url = 'http://photoflora.free.fr/eflore-photoflora/services/index.php/0.1/projets/photoflora/images?masque.nn='.$uid[0].'&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);
$image = array($element->{'binaire.href'}, $element->{'binaire.hrefmax'});
}
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 png
if (strstr($fichier, '.png')) {
break;
}
}
}
$this->envoyerJson($value);
$this->envoyerJson($image);
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