Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 712 | Rev 914 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?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;

        public function __construct(Conteneur $conteneur) {
                $this->conteneur = $conteneur;
                $this->nomCourant = $this->conteneur->getNomCourant();
                $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();
        }

        public function obtenirDonnees() {

                $donnees = array();
                $donnees['flores_synonymes'] = $this->getFlores();
                $donnees['synonymes']['noms'] = $this->getSynonymes();
                $donnees['date_maj'] = $this->nomCourant->getNomRetenu()->get('maj_modif');
                $meta = $this->meta->getMetaDonnees();
                $titreMeta = $meta[0]['titre'];
                $donnees['synonymes']['meta']['titre'] = $titreMeta;
                $donnees['synonymes']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('bdtfx');
                $donnees['num_type'] = $this->nomCourant->getNomSelectionne()->get('num_type');
                $donnees['urls'] = $this->appUrls;
                $donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
                $donnees['nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('nom_retenu.id');
                $donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
                $donnees['basionyme_nom_retenu_nn'] = $this->nomCourant->getNomRetenu()->get('basionyme.id');
                $donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html');
                $donnees['nom_retenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
                $donnees['wikini'] = $this->getWikini();
                
                $donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
                $donnees['taxon_courant']['rang.libelle'] = $this->nomCourant->getNomRetenu()->get('rang.libelle');
                $donnees['taxon_courant']['nom_sci'] = $this->nomCourant->getNomRetenu()->get('nom_sci');
                $donnees['taxon_courant']['num_nom'] = $this->nomCourant->getNomRetenu()->get('id');
                $donnees['taxons_inf'] = $this->getTaxonsInferieurs();
                return $donnees;
        }
        
        
        private function getTaxonsInferieurs() {
        $num_nom = $this->nomCourant->getNomRetenu()->get('id');
        $resultat = $this->taxons->getTaxonsInf($num_nom);
        
        return $resultat[$num_nom];
        }
        
        public function obtenirVersionDonnees() {
                $meta = $this->meta->getMetaDonnees();
                $donnees['version'] = $meta[0]['code'].' v.'.$meta[0]['version'];
                return $donnees;
        }
        

        public function getBloc() {
                $donnees['nom_selectionne'] = $this->nomCourant->getNomSelectionne()->get('nom_sci_html_complet');
                $donnees['nom_retenu_formate'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html_complet');
                $donnees['basionyme_nom_retenu'] = $this->nomCourant->getNomRetenu()->get('basionyme_html_complet');
                $synonymes = $this->getSynonymes();
                $donnees['synonymes'] = array_slice($synonymes, 0, 3);
                $donnees['autresSynonymesNbre'] = count($synonymes) - 3;
                
                $donnees['taxons_sup'] = $this->nomCourant->taxons_sup;
                $donnees['taxons_inf'] = $this->getTaxonsInferieurs();
                $donnees['taxons_sup'] = is_array($donnees['taxons_sup']) ? array_slice($donnees['taxons_sup'], -3 , 3) : array();
                $donnees['taxons_inf'] = is_array($donnees['taxons_inf']) ? array_slice($donnees['taxons_inf'], 0 , 3) : array();
                
                return $donnees;
        }

        private function getFlores() {
                $nnr = $this->nomCourant->getNnr();
                $flores = $this->noms->getFlores($nnr);
                $flores['resultat'] = (isset($flores['resultat']) && is_array($flores['resultat'])) ? $flores['resultat'] : array();
                return $flores['resultat'];
        }

        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';
                $referentiel = $this->conteneur->getParametre('referentiel');
                $num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
                $page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
                $wikini['nomenclature'] = $this->wikini->getTexteFormate($page_wiki, 'nomenclature');
                return $wikini;
        }
}
?>