Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 709 | Rev 913 | 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 Fiche extends aControleur {

        private $onglet = 'synthese';
        private $parametres = array();
        private $conteneur = null;
        private $num_nom = 0;
        private $nom_retenu = '';
        private $url;


        public function initialiser() {
                $this->capturerParametres();
                $this->conteneur = new Conteneur($this->parametres);
                $this->url = $this->conteneur->getAppUrls();
                $this->nom_retenu = $this->conteneur->getNomCourant()->getNomRetenu();
                spl_autoload_register(array($this, 'chargerClassesOnglets'));
        }

        private function capturerParametres() {
                if (isset($_GET['num_nom'])) {
                        $this->parametres['num_nom'] = $_GET['num_nom'];
                }
                if (isset($_GET['nom'])) {
                        $this->parametres['nom'] = $_GET['nom'];
                }
                if (isset($_GET['type_nom'])) {
                        $this->parametres['type_nom'] = $_GET['type_nom'];
                }
                if (isset($_GET['referentiel'])) {
                        $this->parametres['referentiel'] = $_GET['referentiel'];
                }
                if (isset($_GET['niveau'])) {
                        Registre::set('parametres.niveau', $_GET['niveau']);
                }
                if (isset($_GET['onglet'])) {
                        $this->onglet = $_GET['onglet'];
                }
        }

        private function chargerClassesOnglets($classe) {
                $base = dirname(__FILE__).DS;
                $cheminFormateurs = $base.'formateurs'.DS;
                $dossiers = array($base, $cheminFormateurs);
                foreach ($dossiers as $chemin) {
                        $fichierATester = $chemin.$classe.'.php';
                        if (file_exists($fichierATester)) {
                                include_once $fichierATester;
                                return null;
                        }
                }
        }

        public function executerActionParDefaut() {
                $this->executerFiche();
        }

        public function executerFiche(){
                $squelette = 'fiche_'.$this->onglet;
                
                //Gestion du niveau
                $niveau = isset($_GET['niveau']) ? $_GET['niveau'] : 2;
                if ($this->onglet == 'synthese' && $niveau != null) {
                        $squelette .= '_niveau'.$niveau;
                }
                
                $donnees = $this->parametres;
                $donnees['nom_retenu'] = $this->nom_retenu->get('nom_sci_html').' '.$this->nom_retenu->get('auteur');
                $donnees['famille'] = $this->nom_retenu->getTaxonSupRang('180');
                $this->executerAction('Recherche', 'executerAccueil', $this->parametres);
                $blocs_niveaux = $this->conteneur->getParametreTableau('blocs_fiche_defaut');
                $donnees['blocs'] = '"'.str_replace('|', '","', $blocs_niveaux[Registre::get('parametres.niveau')]).'"';

                $donnees = array_merge($this->obtenirDonnees(), $donnees);
                $donnees['onglet'] = $this->onglet;
                $donnees['contenu_onglet'] = $this->getVue($squelette, $donnees);
                
                
                $this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_accueil_niveau'.$niveau, $donnees), true);
                $this->ajouterPiedDePage();
        }

        public function ajouterLienModuleExport() {
                $donnees['lien'] = $this->url->obtenirUrlPdfExport($this->parametres['num_nom']);
                $export = $this->getVue('fiche_pdf_lien', $donnees);
                return $export;
        }
        
        public function ajouterPiedDePage() {
                $description = new Description($this->conteneur);
                $taxons = new Taxons($this->conteneur);
                $referentiel = $this->conteneur->getParametre('referentiel');
                $donnees = array('wikipedia' => $description->getWikipedia(),
                                                 'export_pdf' => $this->ajouterLienModuleExport(),
                                                 'permalien_num_nom' => $taxons->getUrlPermalienNumNom($referentiel, 1, $this->conteneur->getNomCourant()->getNns()),
                                                 'permalien_taxon' => $taxons->getUrlPermalienTaxon($referentiel, 1, $this->conteneur->getNomCourant()->getNt()),
                                                 'nn' => $this->conteneur->getNomCourant()->getNns(),
                                                 'nt' => $this->conteneur->getNomCourant()->getNt(),
                                                 'wiki' => $description->getLienWikini());
                $this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_pied_page', $donnees), true);
        }
        
        public function executerOnglet(){
                $donnees = $this->obtenirDonnees();
                header('Content-type: text/html');
                $this->setSortie(self::RENDU_CORPS, $this->getVue('fiche_'.$this->onglet, $donnees));
        }

        private function obtenirDonnees() {
                $donnees = array();
                $classe = ucfirst($this->onglet);
                $onglet = new $classe($this->conteneur);
                $donnees = $onglet->obtenirDonnees();
                return $donnees;
        }
}
?>