23,9 → 23,14 |
*/ |
class NomsVernaculaires extends Commun { |
protected $champ_infos = array( |
'taxon' => array('service' => 'taxons', 'ressource' => 'nt:', 'projet' => 'bdtfx', 'nom' => 'nom_sci'), |
'conseil_emploi' => array('service' => 'ontologies', 'ressource' => 'numStatut:', 'projet' => 'nvjfl', 'nom' => 'nom'), |
'genre' => array('service' => 'ontologies', 'ressource' => 'genreNombre:', 'projet' => 'nvjfl', 'nom' => 'nom')); |
'taxon' => array('service' => 'taxons', 'ressource' => 'nt:', 'projet' => 'bdtfx', 'nom' => 'nom_sci', |
// utilisés par ajouterChampsOntologieLigneResultat() |
'intitule' => 'taxon.code', // intitulé du champ tel qu'il sera renvoyé en JSON |
'bdd_champ' => 'num_taxon'), // intitulé du champ tel qu'il est présent dans l'enregistrement MySQL |
'conseil_emploi' => array('service' => 'ontologies', 'ressource' => 'numStatut:', 'projet' => 'nvjfl', 'nom' => 'nom', |
'intitule' => 'conseil_emploi', 'bdd_champ' => 'num_statut'), |
'genre' => array('service' => 'ontologies', 'ressource' => 'genreNombre:', 'projet' => 'nvjfl', 'nom' => 'nom', |
'intitule' => 'genre', 'bdd_champ' => 'num_genre')); |
|
protected $service = 'noms-vernaculaires'; |
|
363,10 → 368,10 |
$table_retour_json['entete']['limite'] = $this->limite_requete['limite']; |
$table_retour_json['entete']['total'] = $this->total_resultat; |
$url = $this->formulerUrl($this->total_resultat, '/noms-vernaculaires/attributions'); |
if (isset($url['precedent']) && $url['precedent'] != '') { |
if (!empty($url['precedent'])) { |
$table_retour_json['entete']['href.precedent'] = $url['precedent']; |
} |
if (isset($url['suivant']) && $url['suivant'] != '') { |
if (!empty($url['suivant'])) { |
$table_retour_json['entete']['href.suivant'] = $url['suivant']; |
} |
foreach ($resultat as &$tab) { |
375,14 → 380,15 |
$resultat_json[$tab['num_nom_vernaculaire']]['code_langue'] = $tab['code_langue']; |
$resultat_json[$tab['num_nom_vernaculaire']]['taxon.code'] = 'bdtfx.nt:'.$tab['num_taxon']; |
if ($this->retour_format == 'max') { |
$this->taxons[] = $tab['num_taxon']; // utilisé pour chercher les noms latins plus bas |
if($this->champs_supp) { |
$resultat_json[$tab['num_nom_vernaculaire']] = $this->ajouterChampsOntologieLigneResultat($tab); |
} |
else { |
$resultat_json[$tab['num_nom_vernaculaire']]['num_taxon'] = $tab['num_taxon']; |
$resultat_json[$tab['num_nom_vernaculaire']]['nom_retenu.code'] = $tab['num_taxon']; |
$resultat_json[$tab['num_nom_vernaculaire']]['taxon'] = $tab['num_taxon']; |
$this->taxons[] = $tab['num_taxon']; // utilisé pour chercher les noms latins plus bas |
$resultat_json[$tab['num_nom_vernaculaire']]['href'] = $this->ajouterHref('noms-vernaculaires', $tab['id']); |
|
if($this->champs_supp != array()) { |
$resultat_json[$tab['num_nom_vernaculaire']] = $this->ajouterChampsOntologieLigneResultat($tab); |
} |
} |
} |
411,34 → 417,16 |
* @return array la ligne modifiée |
*/ |
public function ajouterChampsOntologieLigneResultat($ligne_resultat) { |
|
$intitule = ''; |
foreach($this->champ_infos as $cle => $champs_supplementaires) { |
if(in_array($cle, $this->champs_supp)) { |
if(!in_array($cle, $this->champs_supp)) continue; |
// extrait, depuis un élément de $champ_infos: |
// $service, $ressource, $projet, $nom, $intitule, $bdd_champ |
extract($champs_supplementaires); |
$valeur_recherche = ''; |
switch($cle) { |
case 'taxon': |
$valeur_recherche = $ligne_resultat['num_taxon']; |
$intitule = 'taxon.code'; |
break; |
case 'genre': |
$valeur_recherche = $ligne_resultat['num_genre']; |
$intitule = 'genre'; |
break; |
case 'conseil_emploi': |
$valeur_recherche = $ligne_resultat['num_statut']; |
$intitule = 'conseil_emploi'; |
break; |
} |
$code_valeur = ''; |
if(trim($valeur_recherche) != '') { |
$valeur_recherche = $ligne_resultat[$bdd_champ]; |
if(!trim($valeur_recherche)) continue; |
$url = $this->ajouterHrefAutreProjet($service, $ressource, $valeur_recherche, $projet); |
$code_valeur = $this->chercherSignificationCode($url, $nom); |
$ligne_resultat[$intitule] = $this->chercherSignificationCode($url, $nom); |
} |
$ligne_resultat[$intitule] = $code_valeur; |
} |
} |
return $ligne_resultat; |
} |
|