13,8 → 13,8 |
*/ |
|
/** |
* |
* La classe appelle les web service d'eflore pour éviter que le code client |
* |
* La classe appelle les web service d'eflore pour éviter que le code client |
* ne soit dépendant de la version d'eflore |
*/ |
class RechercheInfosTaxonBeta extends Cel { |
24,7 → 24,7 |
private $url_service_nom = null; |
private $url_service_taxon = null; |
private $url_service_chorologie = null; |
|
|
private $masque_recherche = null; |
private $code_referentiel = 'bdtfx'; |
|
45,7 → 45,7 |
$this->code_referentiel = $code_referentiel; |
$this->formaterUrlsServices($this->config); |
} |
|
|
private function formaterUrlsServices($config) { |
$this->url_service_nom = str_replace('{referentiel}', $this->code_referentiel ,$config['eflore']['url_service_nom']); |
$this->url_service_taxon = str_replace('{referentiel}', $this->code_referentiel ,$config['eflore']['url_service_taxon']); |
52,9 → 52,9 |
$this->url_service_chorologie_obs = $config['eflore']['url_service_chorologie_obs']; |
$this->config = $config; |
} |
|
|
public function rechercherGenreEspeceSurPrefixe($genre = null, $espece = null) { |
$liste_genre_espece = array(); |
$liste_genre_espece = array(); |
$this->masque_recherche = trim(trim($genre).' '.trim($espece,' *')); |
$masque = urlencode($this->masque_recherche); |
if(self::DEBUG) error_log("CEL fetch: " . $this->url_service_nom.'?masque='.$masque.'&recherche=etendue&retour.format=min&navigation.limite=50&ns.structure=au'); |
61,7 → 61,7 |
$urlService = $this->url_service_nom.'?masque='.$masque.'&recherche=etendue&retour.format=min&navigation.limite=50&ns.structure=au'; |
$requete = @file_get_contents($urlService); |
if($requete != '') { |
$requete = json_decode($requete); |
$requete = json_decode($requete); |
if(is_object($requete) && isset($requete->resultat)) { |
foreach ($requete->resultat as $id => $res) { |
$retenu = ($res->retenu == "true") ? '3' : '4'; |
68,11 → 68,11 |
$liste_genre_espece[] = array($res->nom_sci_complet, $id, $retenu); |
} |
} |
usort($liste_genre_espece, array($this, 'comparerParRetenuPuisNom')); |
usort($liste_genre_espece, array($this, 'comparerParRetenuPuisNom')); |
} |
return $liste_genre_espece; |
} |
|
|
function comparerParRetenuPuisNom($a, $b) { |
if($a[2] == 3 && $b[2] != 3) { |
return -1; |
82,7 → 82,7 |
return levenshtein($this->masque_recherche, $a[0]) >= levenshtein($this->masque_recherche, $b[0]); |
} |
} |
|
|
public function effectuerRequeteInfosComplementairesEtFormaterNom($numNom) { |
$resultat_infos_complementaires = (array)$this->effectuerRequeteInfosComplementairesSurNumNom($numNom); |
$retour_infos_complementaires = array(); |
89,10 → 89,10 |
if (isset($resultat_infos_complementaires['nom_retenu_complet']) && $resultat_infos_complementaires['nom_retenu_complet']) { |
$retour_infos_complementaires=array((self::supprimerBiblio($resultat_infos_complementaires['nom_retenu_complet']))); |
} |
|
|
return $retour_infos_complementaires; |
} |
|
|
public function rechercherInformationsComplementairesSurNom($nom_saisi) { |
$nom_saisi = trim($nom_saisi); |
// Essai de recherche sur le nom saisi tel quel |
111,10 → 111,10 |
|
// dernière tentative: concaténation (nom_sci,auteur) (= nom-retenu généré utilisé comme nom_sci) |
$liste_genre_espece = $this->effectuerRequeteUrlRecherche($nom_saisi, 'concat'); |
|
|
return $liste_genre_espece; |
} |
|
|
private function effectuerRequeteUrlRecherche($nom_saisi, $mode = 'stricte') { |
$url = sprintf( |
'%1$s?masque=%2$s&recherche=%3$s&ns.format=txt&retour.champs=%4$s&navigation.limite=1', |
134,7 → 134,7 |
$resultat = (array)$res->resultat; |
return array_pop($resultat); |
} |
|
|
static function supprimerAuteur($nom_saisi) { |
// TODO: gérer les hybrides |
if(self::estUnHybride($nom_saisi) || self::estUneFormuleHybridite($nom_saisi)) { |
143,7 → 143,7 |
$nom_saisi_sans_auteur = implode(' ',array_slice($nom_decoupe, 0, end($derniere_position_hybride) + 2)); |
} else { |
/* Attention le parseur de nom n'est pas fiable à 100% |
mais ça marche dans la plupart des cas |
mais ça marche dans la plupart des cas |
à part les formules d'hybridité saisies avec un auteur */ |
$nameparser = new NameParser(); |
$auteur = $nameparser->parse_auth($nom_saisi); |
152,15 → 152,15 |
|
return trim($nom_saisi_sans_auteur); |
} |
|
|
static function estUneFormuleHybridite($nom_saisi) { |
return strpos($nom_saisi,' x ') !== false; |
} |
|
|
static function estUnHybride($nom_saisi) { |
return strpos($nom_saisi,'x ') === 0; |
} |
|
|
public function effectuerRequeteInfosComplementairesSurNumNom($num_nom, $ref = NULL) { |
if($ref && isset($this->config['eflore']['api_host'])) { |
if(self::DEBUG) error_log("CEL fetch: " .$this->config['eflore']['api_host'] . '/'); |
183,7 → 183,7 |
static function supprimerBiblio($nom) { |
return trim(preg_replace('/ \[.*\]/','',$nom)); |
} |
|
|
public function rechercherNumTaxSurNumNom($num_nom) { |
$nt = null; |
$url = $this->url_service_nom."/".$num_nom.'?retour.champs=num_taxonomique'; |
193,10 → 193,10 |
$infos = json_decode($resultat); |
$nt = $infos->num_taxonomique; |
} |
|
|
return $nt; |
} |
|
|
public function taxonEstPresentDansDepartement($num_taxon,$code_departement) { |
$presence_taxon = false; |
$url = $this->url_service_chorologie_obs.'?masque.departement='.$code_departement.'&masque.determination.nt='.$num_taxon.'&navigation.limite=1'; |
210,9 → 210,9 |
} |
return $presence_taxon; |
} |
|
/* texte libre, nom scientifique, |
ou code nomenclatural (format bdtfx:nn:999999) |
|
/* texte libre, nom scientifique, |
ou code nomenclatural (format bdtfx:nn:999999) |
ou code taxonomique (format bdtfx:nt:999999) |
TODO: voir ce qu'on fait pour l'import de différent référentiels */ |
function rechercherInfosSurTexteCodeOuNumTax($identifiant_espece) { |
245,7 → 245,7 |
// Nom scientifique |
return $this->rechercherInformationsComplementairesSurNom($identifiant_espece); |
} |
|
|
public function rechercherSynonymesSurNumNom($num_nom) { |
$retour = array(); |
if(self::DEBUG) error_log("CEL fetch: " . $this->url_service_nom.'/'.$num_nom.'/relations/synonymie/?retour.format=min'); |
258,4 → 258,4 |
} |
return $retour; |
} |
} |
} |