Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 725 | Rev 855 | 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 Resultat extends aControleur {

        private $parametres = null;
        private $resultats = null;
        private $donneesTpl = array();
        private $i18n =  array();

        public function initialiser() {
                spl_autoload_register(array($this, 'chargerClassesResultat'));
                $this->parametres = new ParametresResultats();
                $this->capturerParametres();
                $this->capturerParametresAvances();
                $this->parametres->reftaxCourant = Registre::get('parametres.referentiel');
                $this->parametres->projetImg = Config::get($this->parametres->reftaxCourant.'.referentielImages');
                $this->resultats = Registre::get('resultats');
                $this->i18n = I18n::get('Recherche-form-avancee');
        }

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

        private function capturerParametres() {
                if (isset($_GET['resultat'])) {
                        $this->parametres->typeResultat = $_GET['resultat'];
                }
                if (isset($_GET['nom'])) {
                        $this->parametres->masqueRecherche = trim($_GET['nom']);
                }
                if (isset($_GET['type_nom'])) {
                        $this->parametres->typeNom = $_GET['type_nom'];
                }
                
                if (isset($_GET['niveau'])) {
                        Registre::set('parametres.niveau', $_GET['niveau']);
                }
        }
        
        private function capturerParametresAvances() {
                if (isset($_GET['gen']) && $_GET['gen'] != '') {
                        $this->param['gen'] = urldecode($_GET['gen']);
                }
                if (isset($_GET['fam']) && $_GET['fam'] != '') {
                        $this->param['fam'] = urldecode($_GET['fam']);
                }
                if (isset($_GET['au']) && $_GET['au'] != '' 
                        && $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
                        $this->param['au'] = urldecode($_GET['au']);
                }
                if (isset($_GET['bib']) && $_GET['bib'] != ''
                        && $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
                        $this->param['bib'] = urldecode($_GET['bib']);
                }
                if (isset($_GET['nn']) && $_GET['nn'] != '') {
                        $this->param['nn'] = urldecode($_GET['nn']);
                }
                if (isset($_GET['nt']) && $_GET['nt'] != '') {
                        $this->param['nt'] = urldecode($_GET['nt']);
                }
                if (isset($_GET['sp']) && $_GET['sp'] != '') {
                        $this->param['sp'] = urldecode($_GET['sp']);
                }
                if (isset($_GET['ssp']) && $_GET['ssp'] != '') {
                        $this->param['ssp'] = urldecode($_GET['ssp']);
                }
                if (isset($_GET['type']) && $_GET['type'] != '') {
                        $this->param['type'] = urldecode($_GET['type']);
                }
                if (isset($_GET['and']) && $_GET['and'] != ''
                        && $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
                        $this->param['and'] = urldecode($_GET['and']);
                }
                if (isset($_GET['anf']) && $_GET['anf'] != ''
                        && $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
                        $this->param['anf'] = urldecode($_GET['anf']);
                }
                if (isset($_GET['prga']) && $_GET['prga'] != '') {
                        $this->param['prga'] = urldecode($_GET['prga']);
                }
                if (isset($_GET['prco']) && $_GET['prco'] != '') {
                        $this->param['prco'] = urldecode($_GET['prco']);
                }
                if (isset($_GET['sto']) && $_GET['sto'] != '') {
                        $this->param['sto'] = urldecode($_GET['sto']);
                }
                if (isset($_GET['sti']) && $_GET['sti'] != '') {
                        $this->param['sti'] = urldecode($_GET['sti']);
                }
                if (isset($_GET['stc']) && $_GET['stc'] != '') {
                        $this->param['stc'] = urldecode($_GET['stc']);
                }
        }
        

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

        public function executerResultat() {
                $this->chargerOnglets();
                $this->chargerNbreDeTaxons();
                $this->chargerNomsFormates();
                $this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
        }
        

        private function chargerOnglets() {
                $donnees = array();
                $donnees['typeResultat'] = $this->parametres->typeResultat;
                $donnees['typeNom'] = $this->parametres->typeNom;
                $donnees['ongletsNs'] = array('determination', 'alphab', 'retenu', 'decompo');
                if (($_GET['action']) == 'rechercheAvancee') {
                        $donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
                        $donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
                        $donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
                        $donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
                } else {
                        $donnees['ongletsNv'] = array('determination', 'alphab');
                        $donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
                        $donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
                        $donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
                        $donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
                }
                $donnees['i18n'] = I18n::get('Resultat-onglets');
                $this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
        }

        private function chargerNbreDeTaxons() {
                $this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
        }

        private function chargerNomsFormates() {
                if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
                $formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
                if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
                $formateur->formater();
                if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
                $formateur->trier();
                if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
                $formateur->surligner();
                if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
                $this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
                if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
        }
}
?>