Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 1512 → Rev 1527

/trunk/jrest/services/NameSearch.php
21,7 → 21,7
* Cas d'utilisation :
* Service completion nom scientifique
*
* 1 : L'application recoit un debut de nom scientifique
* 1 : L'application recoit un debut de nom scientifique ainsi qu'un code de référentiel
* 2 : Si le genre recu est >1, l'application retourne les 50 premieres genre commencant par ce prefixe
* 3 : Si l'espece est presente l'application retourne les 50 premieres genre+espece commencant par ce prefixe
*/
38,19 → 38,23
$liste_genre_espece = array();
$referentiel = null;
$genre = null;
$espece = null;
if(isset($uid[0])) {
$genre = $uid[0];
$referentiel = $uid[0];
}
if(isset($uid[1])) {
$espece = $uid[1];
$genre = $uid[1];
}
if(isset($uid[2])) {
$espece = $uid[2];
}
 
$chercheur_infos_taxon = new RechercheInfosTaxonBeta($this->config);
$chercheur_infos_taxon = new RechercheInfosTaxonBeta($this->config, $referentiel);
$liste_genre_espece = $chercheur_infos_taxon->rechercherGenreEspeceSurPrefixe($genre,$espece);
$this->envoyerJson($liste_genre_espece);
/trunk/jrest/services/NameMap.php
20,27 → 20,38
* 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 carte disponible
* A: Pas de carte disponible, generation de l'image
* 1: Le service recoit un référentiell et un numero nomenclatural
* 2: Le service recherche une carte disponible
*/
 
class NameMap extends Cel {
 
function getElement($uid){
$url_service_chorologie = $this->config['eflore']['url_service_chorologie_carte'];
$nt = null;
$retour = array('');
if(isset($uid[0]) && isset($uid[1])) {
$uid[0] = $uid[0] != '' ? $uid[0] : 'bdtfx';
$retour = $this->obtenirCarteChorologie($uid[0], $uid[1]);
}
 
if(isset($uid[0])) {
$retour = array('');
$file = $url_service_chorologie.'/nn%3A'.$uid[0].'?retour.format=587&retour=image%2Fpng';
$retour = array($file);
}
 
$this->envoyerJson($retour);
return true;
}
function obtenirCarteChorologie($referentiel_taxo, $nn) {
// TODO: gérer ici les cartes d'autres référentiels si celles si sont disponibles
$retour = array('');
switch($referentiel_taxo) {
case 'bdtfx':
$url_service_chorologie = $this->config['eflore']['url_service_chorologie_carte'];
$file = $url_service_chorologie.'/nn%3A'.$nn.'?retour.format=587&retour=image%2Fpng';
$retour = array($file);
break;
default:
break;
}
return $retour;
}
}
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$
/trunk/jrest/services/InventoryExport.php
55,18 → 55,19
$worksheet->write(0,3,'Numero nomenclatural nom retenu');
$worksheet->write(0,4,'Numero taxonomique');
$worksheet->write(0,5,'Famille');
$worksheet->write(0,6,'Commune');
$worksheet->write(0,7,'Identifiant Commune');
$worksheet->write(0,8,'Date');
$worksheet->write(0,9,'Lieu-dit');
$worksheet->write(0,10,'Station');
$worksheet->write(0,11,'Milieu');
$worksheet->write(0,12,'Notes');
$worksheet->write(0,13,'Latitude');
$worksheet->write(0,14,'Longitude');
$worksheet->write(0,15,'Referentiel Geographique');
$worksheet->write(0,16,'Ordre');
$worksheet->write(0,17,'Identifiant');
$worksheet->write(0,6,'Referentiel taxonomique');
$worksheet->write(0,7,'Commune');
$worksheet->write(0,8,'Identifiant Commune');
$worksheet->write(0,9,'Date');
$worksheet->write(0,10,'Lieu-dit');
$worksheet->write(0,11,'Station');
$worksheet->write(0,12,'Milieu');
$worksheet->write(0,13,'Notes');
$worksheet->write(0,14,'Latitude');
$worksheet->write(0,15,'Longitude');
$worksheet->write(0,16,'Referentiel Geographique');
$worksheet->write(0,17,'Ordre');
$worksheet->write(0,18,'Identifiant');
$numero_page = isset($criteres['numero_page']) ? $criteres['numero_page'] : 0;
$limite = isset($criteres['limite']) ? $criteres['limite'] : 0;
91,18 → 92,19
$worksheet->write($i,3,$obs['nom_ret_nn']);
$worksheet->write($i,4,$obs['nt']);
$worksheet->write($i,5,$obs['famille']);
$worksheet->write($i,6,$obs['zone_geo']);
$worksheet->write($i,7,$this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']));
$worksheet->write($i,8,$obs['date_observation']);
$worksheet->write($i,9,$obs['lieudit']);
$worksheet->write($i,10,$obs['station']);
$worksheet->write($i,11,$obs['milieu']);
$worksheet->write($i,12,$obs['commentaire']);
$worksheet->write($i,13,$obs['latitude']);
$worksheet->write($i,14,$obs['longitude']);
$worksheet->write($i,15,$obs['geodatum']);
$worksheet->write($i,16,$obs['ordre']);
$worksheet->write($i,17,$obs['id_observation']);
$worksheet->write($i,6,$obs['nom_referentiel']);
$worksheet->write($i,7,$obs['zone_geo']);
$worksheet->write($i,8,$this->convertirCodeZoneGeoVersDepartement($obs['ce_zone_geo']));
$worksheet->write($i,9,$obs['date_observation']);
$worksheet->write($i,10,$obs['lieudit']);
$worksheet->write($i,11,$obs['station']);
$worksheet->write($i,12,$obs['milieu']);
$worksheet->write($i,13,$obs['commentaire']);
$worksheet->write($i,14,$obs['latitude']);
$worksheet->write($i,15,$obs['longitude']);
$worksheet->write($i,16,$obs['geodatum']);
$worksheet->write($i,17,$obs['ordre']);
$worksheet->write($i,18,$obs['id_observation']);
$i++;
}
 
/trunk/jrest/services/CelWidgetSaisie.php
197,7 → 197,7
$imgAAjouter['id_utilisateur'] = $id_utilisateur;
$imgAAjouter['id_obs'] = $ordreObs;
$imgAAjouter['nom'] = $obs['image_nom'];
$imgAAjouter['b64'] = $obs['image_b64'];
$imgAAjouter['b64'] = isset($obs['image_b64']) ? $obs['image_b64'] : array();
$this->debug[] = 'Contient B64 : '.(empty($obs['image_b64']) ? 'non' : 'oui');
}
}
/trunk/jrest/services/InventoryImportExcel.php
276,6 → 276,8
$info_transmettre = $this->traiterTransmettre($line[TRANSMETTRE][$i]);
break;
case ESPECE:
// suppression des accents éventuels
$line[ESPECE][$i] = remove_accent(cp1252_to_utf8($line[ESPECE][$i]));
$resultat_recherche_espece = $this->chercheur_infos_taxon->rechercherInfosSurTexteCodeOuNumTax($line[ESPECE][$i]);
if (isset($resultat_recherche_espece['en_id_nom']) && $resultat_recherche_espece['en_id_nom'] != '') {
$info_espece['nom_sel'] = $resultat_recherche_espece['nom_sel'];
289,8 → 291,10
$info_espece['nom_sel'] = $line[ESPECE][$i];
}
case IMAGE:
$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / + utilisateur
break;
if(isset($line[IMAGE])) {
$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / + utilisateur
}
break;
}
}
else {
385,17 → 389,18
}
 
function traiterLigneComplement($line,$i,$utilisateur, $id_obs = null) {
$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / + utilisateur
// creation lien image
foreach ($info_image as $pic) {
$requete = 'INSERT INTO cel_obs_images (id_image, id_observation) VALUES ('.$this->proteger($pic['id_image']).', '.$this->proteger($id_obs).') ON DUPLICATE KEY UPDATE id_image = id_image' ;
$resultat_liaison = $this->executer($requete);
if ($resultat_liaison !== false) {
$this->cpt_images_liees++;
} else {
return false;
}
if(isset($line[IMAGE])) {
$info_image=$this->traiterImage($line[IMAGE][$i],$utilisateur); // Image separee par des / + utilisateur
// creation lien image
foreach ($info_image as $pic) {
$requete = 'INSERT INTO cel_obs_images (id_image, id_observation) VALUES ('.$this->proteger($pic['id_image']).', '.$this->proteger($id_obs).') ON DUPLICATE KEY UPDATE id_image = id_image' ;
$resultat_liaison = $this->executer($requete);
if ($resultat_liaison !== false) {
$this->cpt_images_liees++;
} else {
return false;
}
}
}
}
598,6 → 603,7
}
 
function remove_accent($str) {
return supprimerAccents($str);
$a = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î',
'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß',
'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î',
629,6 → 635,18
return str_replace($a, $b, $str);
}
 
//TODO: déplacer les fonctions ci dessus et dessous dans une classe
// utilitaire
function supprimerAccents($str, $charset = 'UTF-8')
{
$str = htmlentities($str, ENT_NOQUOTES, $charset);
$str = preg_replace('#&([A-za-z])(?:acute|cedil|circ|grave|orn|ring|slash|th|tilde|uml);#', '\1', $str);
$str = preg_replace('#&([A-za-z]{2})(?:lig);#', '\1', $str); // pour les ligatures e.g. 'œ'
$str = preg_replace('#&[^;]+;#', '', $str); // supprime les autres caractères
 
return $str;
}
 
function cp1252_to_utf8($str) {
$cp1252_map = array ("\xc2\x80" => "\xe2\x82\xac",
"\xc2\x82" => "\xe2\x80\x9a",
/trunk/jrest/services/NameImage.php
25,28 → 25,50
* 3: Le service recherche une image disponible pour ce numero taxonomique
* 4: Le service redimensionne l'image et la renvoie
*/
 
class NameImage extends Cel {
 
function getElement($uid){
$image = array();
$url_photoflora = $this->config['eflore']['url_service_photoflora'];
if(isset($uid[0])) {
$url = $url_photoflora.'?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'});
}
$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;
}
function obtenirIllustration($referentiel_taxo, $nn) {
// TODO: gérer ici les images d'autres référentiels si celles si sont disponibles
$retour = array("","");
switch($referentiel_taxo) {
case 'bdtfx':
$retour = $this->effectuerRequetePhotoFlora($nn);
break;
default:
break;
}
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;
}
}
/* +--Fin du code ---------------------------------------------------------------------------------------+
* $Log$