Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
76 delphine 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe mère du module Liste.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Resultat extends aControleur {
106 jpm 16
 
146 jpm 17
	private $parametres = null;
18
	private $resultats = null;
151 jpm 19
	private $donneesTpl = array();
725 mathilde 20
	private $i18n =  array();
106 jpm 21
 
84 jpm 22
	public function initialiser() {
146 jpm 23
		spl_autoload_register(array($this, 'chargerClassesResultat'));
24
		$this->parametres = new ParametresResultats();
84 jpm 25
		$this->capturerParametres();
725 mathilde 26
		$this->capturerParametresAvances();
146 jpm 27
		$this->parametres->reftaxCourant = Registre::get('parametres.referentiel');
28
		$this->parametres->projetImg = Config::get($this->parametres->reftaxCourant.'.referentielImages');
29
		$this->resultats = Registre::get('resultats');
725 mathilde 30
		$this->i18n = I18n::get('Recherche-form-avancee');
84 jpm 31
	}
106 jpm 32
 
146 jpm 33
	private function chargerClassesResultat($classe) {
154 jpm 34
		$base = dirname(__FILE__).DS;
163 jpm 35
		$cheminFormateurs = $base.'formateurs'.DS;
36
		$cheminFormateursNs = $cheminFormateurs.'nom_scientifique'.DS;
37
		$cheminFormateursNv = $cheminFormateurs.'nom_vernaculaire'.DS;
38
		$dossiers = array($base, $cheminFormateurs, $cheminFormateursNs, $cheminFormateursNv);
146 jpm 39
		foreach ($dossiers as $chemin) {
40
			$fichierATester = $chemin.$classe.'.php';
41
			if (file_exists($fichierATester)) {
42
				include_once $fichierATester;
43
				return null;
44
			}
45
		}
46
	}
47
 
84 jpm 48
	private function capturerParametres() {
49
		if (isset($_GET['resultat'])) {
162 jpm 50
			$this->parametres->typeResultat = $_GET['resultat'];
84 jpm 51
		}
135 jpm 52
		if (isset($_GET['nom'])) {
819 mathilde 53
			$this->parametres->masqueRecherche = trim($_GET['nom']);
135 jpm 54
		}
162 jpm 55
		if (isset($_GET['type_nom'])) {
56
			$this->parametres->typeNom = $_GET['type_nom'];
57
		}
197 delphine 58
 
59
		if (isset($_GET['niveau'])) {
60
			Registre::set('parametres.niveau', $_GET['niveau']);
61
		}
84 jpm 62
	}
725 mathilde 63
 
64
	private function capturerParametresAvances() {
65
		if (isset($_GET['gen']) && $_GET['gen'] != '') {
66
			$this->param['gen'] = urldecode($_GET['gen']);
67
		}
68
		if (isset($_GET['fam']) && $_GET['fam'] != '') {
69
			$this->param['fam'] = urldecode($_GET['fam']);
70
		}
71
		if (isset($_GET['au']) && $_GET['au'] != ''
72
			&& $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
73
			$this->param['au'] = urldecode($_GET['au']);
74
		}
75
		if (isset($_GET['bib']) && $_GET['bib'] != ''
76
			&& $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
77
			$this->param['bib'] = urldecode($_GET['bib']);
78
		}
79
		if (isset($_GET['nn']) && $_GET['nn'] != '') {
80
			$this->param['nn'] = urldecode($_GET['nn']);
81
		}
82
		if (isset($_GET['nt']) && $_GET['nt'] != '') {
83
			$this->param['nt'] = urldecode($_GET['nt']);
84
		}
85
		if (isset($_GET['sp']) && $_GET['sp'] != '') {
86
			$this->param['sp'] = urldecode($_GET['sp']);
87
		}
88
		if (isset($_GET['ssp']) && $_GET['ssp'] != '') {
89
			$this->param['ssp'] = urldecode($_GET['ssp']);
90
		}
91
		if (isset($_GET['type']) && $_GET['type'] != '') {
92
			$this->param['type'] = urldecode($_GET['type']);
93
		}
94
		if (isset($_GET['and']) && $_GET['and'] != ''
95
			&& $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
96
			$this->param['and'] = urldecode($_GET['and']);
97
		}
98
		if (isset($_GET['anf']) && $_GET['anf'] != ''
99
			&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
100
			$this->param['anf'] = urldecode($_GET['anf']);
101
		}
102
		if (isset($_GET['prga']) && $_GET['prga'] != '') {
103
			$this->param['prga'] = urldecode($_GET['prga']);
104
		}
105
		if (isset($_GET['prco']) && $_GET['prco'] != '') {
106
			$this->param['prco'] = urldecode($_GET['prco']);
107
		}
108
		if (isset($_GET['sto']) && $_GET['sto'] != '') {
109
			$this->param['sto'] = urldecode($_GET['sto']);
110
		}
111
		if (isset($_GET['sti']) && $_GET['sti'] != '') {
112
			$this->param['sti'] = urldecode($_GET['sti']);
113
		}
114
		if (isset($_GET['stc']) && $_GET['stc'] != '') {
115
			$this->param['stc'] = urldecode($_GET['stc']);
116
		}
117
	}
118
 
106 jpm 119
 
76 delphine 120
	public function executerActionParDefaut() {
121
		$this->executerResultat();
122
	}
106 jpm 123
 
76 delphine 124
	public function executerResultat() {
162 jpm 125
		$this->chargerOnglets();
151 jpm 126
		$this->chargerNbreDeTaxons();
127
		$this->chargerNomsFormates();
128
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
76 delphine 129
	}
725 mathilde 130
 
106 jpm 131
 
162 jpm 132
	private function chargerOnglets() {
133
		$donnees = array();
134
		$donnees['typeResultat'] = $this->parametres->typeResultat;
135
		$donnees['typeNom'] = $this->parametres->typeNom;
136
		$donnees['ongletsNs'] = array('determination', 'alphab', 'retenu', 'decompo');
725 mathilde 137
		if (($_GET['action']) == 'rechercheAvancee') {
138
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
139
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
140
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
141
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
142
		} else {
143
			$donnees['ongletsNv'] = array('determination', 'alphab');
144
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
145
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
146
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
147
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
148
		}
162 jpm 149
		$donnees['i18n'] = I18n::get('Resultat-onglets');
150
		$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
84 jpm 151
	}
151 jpm 152
 
153
	private function chargerNbreDeTaxons() {
154
		$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
155
	}
156
 
157
	private function chargerNomsFormates() {
158
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
159
		$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
160
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
161
		$formateur->formater();
162
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
163
		$formateur->trier();
164
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
165
		$formateur->surligner();
166
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
167
		$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
168
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
169
	}
76 delphine 170
}
171
?>