123,7 → 123,7 |
$champs_demandes = explode(',', $val); |
$champs_verifies = array(); |
$champs_api = array_flip($this->champs_api); |
$champs_supp = array('nom_retenu_complet'=>'num_nom_retenu', 'basionyme_complet'=>'basionyme'); |
$champs_supp = array('nom_retenu_complet'=>'num_nom_retenu', 'num_basionyme_complet'=>'num_basionyme'); |
$champs_api = array_merge($champs_api, $champs_supp); |
foreach ($champs_demandes as $champ) { |
if (array_key_exists($champ, $champs_api)) { |
216,14 → 216,15 |
} |
|
public function traiterRessourceIdSynonymie() { |
// SELECT num_nom, nom_sci, num_nom_retenu, basionyme FROM bdtfx_v2_00 WHERE num_nom = X LIMIT 0,100; |
// SELECT num_nom, nom_sci, num_nom_retenu, num_basionyme FROM bdtfx_v2_00 WHERE num_nom = X LIMIT 0,100; |
$this->format_reponse .= '/synonymie'; |
if (strrpos($this->requete_champ, ', basionyme') === false) { |
$this->requete_champ .= ', basionyme '; |
if (strrpos($this->requete_champ, ', num_basionyme') === false) { |
$this->requete_champ .= ', num_basionyme '; |
} |
if (strrpos($this->requete_champ, ', num_type') === false) { |
$this->requete_champ .= ', num_type '; |
} |
$this->requete_champ .= ', source_biblio '; |
$this->requete_condition[0] = 'num_nom_retenu = '. |
'(SELECT num_nom_retenu FROM '.$this->table.' WHERE '.$this->requete_condition[0].')'; |
} |
243,7 → 244,9 |
} |
} |
$this->format_reponse .= '/flores'; |
$this->requete_champ = 'num_nom'.$champ_flores; |
$this->requete_champ = 'num_nom,num_nom_retenu,nom_sci,flores'.$champ_flores; |
$this->requete_condition = null; |
$this->requete_condition[] = "num_nom_retenu = ".$this->ressources[0]." OR num_nom = ".$this->ressources[0]; |
} |
|
public function traiterRessourceStatsRangs() { |
396,7 → 399,7 |
$reponse = $this->formaterIdHomonymie($resultat); |
break; |
case 'noms/id/relations/flores' : //ds CommunsNomsTaxons |
$reponse = $this->formaterIdFlores($resultat[0]); |
$reponse = $this->formaterIdFlores($resultat); |
break; |
case 'noms/stats/annees' : //ds CommunNomsTaxons |
$reponse = $this->formaterStatsAnnee($resultat); |
485,13 → 488,18 |
// résultat contient aussi l'original |
if(count($resultat) > 1) { |
//on remplit d'abord l'entete du resultat |
$this->table_retour['id'] = $this->ressources[0]; |
$this->afficherEnteteResultat('/'.$this->service.'/'.$this->ressources[0].'/relations/synonymie'); |
$retour_id_syn['entete'] = $this->table_retour; |
$this->table_retour = array(); |
foreach ($resultat as $tab) { |
//pour chaque basionyme, on recupère le résultat : num_nom, nom_sci, basionyme et num_nom_retenu : |
//pour chaque basionyme, on recupère le résultat : num_nom, nom_sci, num_basionyme et num_nom_retenu : |
$this->resultat_req = $tab; |
$num = $tab['num_nom']; |
$this->afficherNomHrefRetenu($tab, $num); |
$this->afficherDonnees('basionyme', $tab['basionyme']); |
$this->afficherDonnees('num_basionyme', $tab['num_basionyme']); |
$this->afficherDonnees('num_type', $tab['num_type']); |
$this->afficherDonnees('source_biblio', $tab['source_biblio']); |
$retour_id_syn['resultat'][$num] = $this->table_retour; |
$this->table_retour = array(); |
} |
529,40 → 537,37 |
return $retour_id_hom; |
} |
|
public function obtenirSynonymesParNumNomAvecInfosFlore($num_nom, $version='1_02') { |
|
$champs_flore = 'flore_bonnier_num, flore_bonnier_rem,'. |
'flore_cnrs_num, flore_cnrs_rem '. |
'flore_fe_num, flore_fe_rem '. |
'flore_coste_num, flore_coste_rem '. |
'flore_fh_num, flore_fh_rem '. |
'flore_fournier_num, flore_fournier_rem'; |
|
$requete = 'SELECT num_nom, nom_sci, '.$champs_flore.' '. |
'FROM '.$this->table.' '. |
'WHERE num_nom_retenu = '. |
'('. |
'SELECT num_nom_retenu FROM '.$this->table.' WHERE num_nom = "'.$num_nom.'"'. |
')'; |
|
return $this->getBdd()->recupererTous($requete . ' -- ' . __FILE__ . ':' . __LINE__ ); |
public function formaterIdFlores($synonymes_flores) {//print_r($resultat); |
$this->recupererTableSignification('noms_projets'); |
if (is_array($synonymes_flores)) {//print_r($synonymes_flores); |
foreach ($synonymes_flores as $synonyme) { |
if ($synonyme['num_nom'] === $synonyme['num_nom_retenu']) { |
$reponse['entete']['id'] = $synonyme['num_nom']; |
} |
foreach ($this->noms_projets as $flore => $valeur) { |
if (isset($synonyme[$flore.'_num']) && $synonyme[$flore.'_num'] != '') { |
$presence[$valeur] = $flore; |
$this->table_retour[$flore]['type'] = "code"; |
$this->afficherInfosFlore($synonyme, $flore, $valeur, '_num'); |
} else if (isset($synonyme[$flore.'_page']) && $synonyme[$flore.'_page'] != '') { |
$this->table_retour[$flore]['type'] = "page"; |
$this->afficherInfosFlore($synonyme, $flore, $valeur, '_page'); |
} else if (isset($synonyme[$flore]) && $synonyme[$flore] != '') { |
$this->table_retour[$flore]['type'] = "page"; |
$this->afficherInfosFlore($synonyme, $flore, $valeur, 'page'); |
} |
} |
if ($synonyme['flores'] != "") { |
$this->recupererTableSignification('correspondance_flores'); |
$flores = explode(',', $synonyme['flores']); |
$projet = array_flip($this->noms_projets); |
foreach ($flores as $b =>$code) { |
$code = trim($code); |
if (isset($this->correspondance_flores[$code]) && !isset($presence[$this->correspondance_flores[$code]])) { |
$this->table_retour[$projet[$this->correspondance_flores[$code]]]['nom_flore'] = $this->correspondance_flores[$code]; |
} |
|
public function formaterIdFlores($resultat) { |
$this->recupererTableSignification('correspondance_champs,champs_api,champs_comp,noms_projets'); |
$this->resultat_req = $resultat; |
$id = array_shift($resultat); |
$reponse['entete']['id'] = $id; |
$synonymes_flores = $this->obtenirSynonymesParNumNomAvecInfosFlore($this->ressources[0]); |
if(is_array($synonymes_flores)) { |
foreach ($synonymes_flores as $synonyme) { |
$nom_sci = $synonyme['nom_sci']; |
$num_nom = $synonyme['num_nom']; |
unset($synonyme['nom_sci']); |
unset($synonyme['num_nom']); |
foreach ($synonyme as $flores => $valeur) { |
if ($valeur != '' && $valeur != '0') { |
$this->afficherInfosFlore($synonyme, $flores, $valeur, $nom_sci, $num_nom); |
} |
} |
} |
577,42 → 582,26 |
return $reponse; |
} |
|
public function getNomCompletFlore($flore) { |
return Config::get($flore.'_texte'); |
} |
|
public function afficherInfosFlore(&$resultat, $flores, $valeur, $nom_sci, $num_nom) { |
$flore = substr($flores,0,strrpos($flores, '_')); |
$projet = $this->noms_projets[$flore]; |
|
//TODO voir si l'on peut factoriser les affectations à la table retour |
// et simplifier ce gros pavé |
if (strrpos($flores, 'num') !== false) { |
if (preg_match('/^([0-9]+)(?:[.]syn[^a-z]*|(.*))?$/', $valeur, $match)) { |
$this->table_retour[$num_nom][$flore]['id'] = $match[1]; |
if ($projet == 'coste') { |
$this->table_retour[$num_nom][$flore]['href'] = $this->ajouterHrefAutreProjet('noms', 'nn_coste:', $match[1], $projet); |
public function afficherInfosFlore($synonyme, $flore, $nom_flore, $type) { |
$statuts = array('R'=> 'nom retenu', 'S' => 'synonyme','r' => 'nom retenu', 'c' => 'cité hors clé', 's' => 'synonyme d’un nom retenu', 'cs' => 'synonyme d’un nom cité hors clé', 'i' => 'nom d’un taxon inclus dans un autre', 'is' => 'syn d’un nom d’un taxon inclus dans un autre'); |
preg_match('/^([0-9]+)(.*)?$/', $synonyme[$flore.$type], $match); |
$this->table_retour[$flore]['nom_flore'] = $nom_flore; |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['id'] = $match['1']; |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['num_nom'] = $synonyme['num_nom']; |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['nom_sci'] = $synonyme['nom_sci']; |
if (isset($synonyme[$flore.'_rem']) && $synonyme[$flore.'_rem'] != '') { |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['remarques'] = $synonyme[$flore.'_rem']; |
} |
if (isset($match[2]) && $match[2] != '') $this->table_retour[$num_nom][$flore]['cle'] = $match[2]; |
$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore); |
$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci; |
if ($flore == flore_coste) { |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['href'] = $this->ajouterHrefAutreProjet('noms', 'nn_coste:', $match[1], $projet); |
} |
if (isset($resultat[$flore.'_rem']) && !empty($resultat[$flore.'_rem'])) { |
$this->table_retour[$num_nom][$flore]['remarque'] = $resultat[$flore.'_rem']; |
$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore); |
$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci; |
unset($resultat[$flore.'_rem']); |
if (isset($statuts[trim($match[2])])) { |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['statut'] = $statuts[trim($match[2])]; |
} else if(trim($match[2]) != "") { |
$this->table_retour[$flore]['num'][$synonyme[$flore.$type]]['statut'] = trim($match[2]); |
} |
} elseif (strrpos($flores,'belge') !== false) { |
if (preg_match('/^([0-9]+) (R|S)?$/', $valeur, $match)) { |
if (isset($match[2])) $type = ($match[2] == 'R') ? 'taxons' : 'synonyme'; |
$this->table_retour[$num_nom][$flore]['page'] = $match[1]; |
$this->table_retour[$num_nom][$flore]['type'] = $type; |
$this->table_retour[$num_nom][$flore]['nom_flore'] = $this->getNomCompletFlore($flore); |
$this->table_retour[$num_nom][$flore]['nom_sci'] = $nom_sci; |
} |
} |
} |
|
//+---------------------concerne les resultats pour des requetes de type /noms avec ou sans paramètres-------+ |
|