New file |
0,0 → 1,168 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Classe mère du module Liste. |
* |
* @category PHP 5.2 |
* @package eflore-consultation |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @author Delphine CAUQUIL <delphine@tela-botanica.org> |
* @copyright 2011 Tela-Botanica |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2 |
* @version $Id$ |
*/ |
class Nomenclature extends aControleur { |
|
private $conteneur = null; |
private $nomCourant = null; |
private $noms = null; |
private $meta = null; |
private $referentiel = 'bdtfx'; |
private $donnees = array(); |
|
public function __construct(Conteneur $conteneur) { |
$this->conteneur = $conteneur; |
$this->nomCourant = $this->conteneur->getNomCourant(); |
$this->referentiel = $this->conteneur->getParametre('referentiel'); |
$this->taxons = $this->conteneur->getApiTaxons(); |
$this->noms = $this->conteneur->getApiNoms(); |
$this->meta = $this->conteneur->getApiMetaDonnees(); |
$this->appUrls = $this->conteneur->getAppUrls(); |
$this->wikini = $this->conteneur->getApiWikini(); |
//print_r($_GET['niveau']); |
//Registre::set('parametres.niveau', 2); |
} |
|
public function obtenirDonnees() { |
$this->donnees['baseUrlIco'] = $this->appUrls->obtenirUrlBaseDossier(); |
$this->donnees['referentiel'] = $this->referentiel; |
$this->getFlores(); |
$this->donnees['synonymes']['noms'] = $this->trierSynonymesParBasionyme($this->getSynonymes()); |
$this->donnees['date_maj'] = $this->nomCourant->getNomRetenu()->get('maj_modif'); |
$meta = $this->meta->getMetaDonnees(); |
$this->donnees['synonymes']['meta'] = $meta[0]; |
$this->donnees['synonymes']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel); |
$this->donnees['num_type'] = $this->nomCourant->getNomSelectionne()->get('num_type'); |
$this->donnees['urls'] = $this->appUrls; |
$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet'); |
$this->donnees['nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('nom_retenu.id'); |
$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet'); |
$this->donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id'); |
$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html'); |
$this->donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci'); |
$this->donnees['wikini'] = $this->getWikini(); |
$this->donnees['hybride_parent_01'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01_html_complet'); |
$this->donnees['hybride_parent_02'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02_html_complet'); |
$this->donnees['hybride_parent_01_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_01.id'); |
$this->donnees['hybride_parent_02_nn'] = $this->nomCourant->getNomRetenu()->get('hybride.parent_02.id'); |
|
|
$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup; |
$this->donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle'); |
$this->donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci'); |
$this->donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id'); |
$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs(); |
|
return $this->donnees; |
} |
|
private function trierSynonymesParBasionyme($synonymes) { |
$synonymes_t = array(); |
$basionyme_inconnu = array(); |
foreach($synonymes as $num_nom => $syn) { |
if($syn['num_type'] != "") { |
$index = $syn['num_type']; |
// regroupement sous le 1er basionyme (num_type == num_nom) |
if(!isset($synonymes_t[$index]['infos_basionyme'])) { |
$synonymes_t[$index]['infos_basionyme'] = $this->extraireInfosBasionymeDuSynonyme($syn); |
} |
$synonymes_t[$index]['synonymes'][$num_nom] = $syn; |
} else { |
$basionyme_inconnu['synonymes'][$num_nom] = $syn; |
} |
} |
// mise à la fin du tableau des noms sans basionymes |
if(!empty($basionyme_inconnu)) { |
$synonymes_t['basionyme_inconnu'] = $basionyme_inconnu; |
} |
|
return $synonymes_t; |
} |
|
private function extraireInfosBasionymeDuSynonyme($synonyme) { |
return array( |
'basionyme.id' => $synonyme['basionyme.id'], |
'basionyme.libelle' => $synonyme['basionyme.libelle'], |
'basionyme_html' => $synonyme['basionyme_html'], |
'basionyme_complet' => $synonyme['basionyme_complet'], |
'basionyme_html_complet' => $synonyme['basionyme_html_complet'], |
'basionyme.href' => $synonyme['basionyme.href'] |
); |
} |
|
private function getTaxonsInferieurs() { |
$num_nom = $this->nomCourant->getNomRetenu()->get('id'); |
$resultat = $this->taxons->getTaxonsInf($num_nom); |
// TODO: le webservice retourne le taxon demandé comme l'un des taxon inférieurs |
// workaround: on le supprime ici car l'on ignore si d'autre app' dépendent de ce comportement |
unset($resultat[$num_nom][$num_nom]); |
return $resultat[$num_nom]; |
} |
|
public function obtenirVersionDonnees() { |
$meta = $this->meta->getMetaDonnees(); |
$this->donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version']; |
return $this->donnees; |
} |
|
|
public function getBloc() { |
$this->donnees['urls'] = $this->appUrls; |
$this->donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet'); |
$this->donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet'); |
$this->donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet'); |
$synonymes = $this->getSynonymes(); |
$this->donnees['synonymes'] = array_slice($synonymes, 0, 3); |
$this->donnees['autresSynonymesNbre'] = count($synonymes) - 3; |
|
$this->donnees['taxons_sup'] = $this->nomCourant->taxons_sup; |
$this->donnees['taxons_inf'] = $this->getTaxonsInferieurs(); |
$this->donnees['taxons_sup'] = is_array($this->donnees['taxons_sup']) ? array_slice($this->donnees['taxons_sup'], -3 , 3) : array(); |
$this->donnees['taxons_inf'] = is_array($this->donnees['taxons_inf']) ? array_slice($this->donnees['taxons_inf'], 0 , 3) : array(); |
|
return $this->donnees; |
} |
|
private function getFlores() { |
if (Config::get($this->referentiel.'.baseFloresRef') != "") { |
$nnr = $this->nomCourant->getNnr(); |
$flores = $this->noms->getFlores($nnr); |
$this->donnees['flores_synonymes'] = (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array(); |
} |
} |
|
private function getSynonymes() { |
$nns = $this->nomCourant->getNns(); |
$synonymesReponse = $this->noms->getSynonymes($nns); |
|
$synonymes = array(); |
if (isset($synonymesReponse['resultat']) && is_array($synonymesReponse['resultat'])) { |
$synonymes = $synonymesReponse['resultat']; |
if (array_key_exists($this->nomCourant->getNnr(), $synonymes)) { |
unset($synonymes[$this->nomCourant->getNnr()]); |
} |
} |
return $synonymes; |
} |
|
private function getWikini() { |
$wikini = array(); |
$wikini['titre'] = 'Wikini'; |
$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique'); |
$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($this->referentiel, $num_tax); |
$wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature'); |
return $wikini; |
} |
} |
?> |