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();
931 delphine 27
		$this->parametres->referentielCourant = Registre::get('parametres.referentiel');
28
		$this->parametres->projetImg = Config::get($this->parametres->referentielCourant.'.baseImages');
146 jpm 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() {
967 delphine 49
		$this->parametres->masqueRecherche = "";
84 jpm 50
		if (isset($_GET['resultat'])) {
162 jpm 51
			$this->parametres->typeResultat = $_GET['resultat'];
84 jpm 52
		}
135 jpm 53
		if (isset($_GET['nom'])) {
819 mathilde 54
			$this->parametres->masqueRecherche = trim($_GET['nom']);
135 jpm 55
		}
967 delphine 56
		//recherche avancee type
57
		if (isset($_GET['fam'])) {
58
			$this->parametres->masqueRecherche .= trim($_GET['fam']);
59
		}
60
		if (isset($_GET['gen'])) {
61
			$this->parametres->masqueRecherche .= trim($_GET['gen']);
62
		}
63
		if (isset($_GET['sp'])) {
64
			$this->parametres->masqueRecherche .= trim($_GET['sp']);
65
		}
66
		if (isset($_GET['ssp'])) {
67
			$this->parametres->masqueRecherche .= trim($_GET['ssp']);
68
		}
69
		if (isset($_GET['and'])) {
70
			$this->parametres->masqueRecherche .= trim($_GET['and']);
71
		}
72
		if (isset($_GET['anf'])) {
73
			$this->parametres->masqueRecherche .= trim($_GET['anf']);
74
		}
75
		if (isset($_GET['au'])) {
76
			$this->parametres->masqueRecherche .= trim($_GET['au']);
77
		}
78
		if (isset($_GET['bib'])) {
79
			$this->parametres->masqueRecherche .= trim($_GET['bib']);
80
		}
81
 
82
 
162 jpm 83
		if (isset($_GET['type_nom'])) {
84
			$this->parametres->typeNom = $_GET['type_nom'];
85
		}
197 delphine 86
 
87
		if (isset($_GET['niveau'])) {
88
			Registre::set('parametres.niveau', $_GET['niveau']);
89
		}
84 jpm 90
	}
725 mathilde 91
 
92
	private function capturerParametresAvances() {
93
		if (isset($_GET['gen']) && $_GET['gen'] != '') {
94
			$this->param['gen'] = urldecode($_GET['gen']);
95
		}
96
		if (isset($_GET['fam']) && $_GET['fam'] != '') {
97
			$this->param['fam'] = urldecode($_GET['fam']);
98
		}
99
		if (isset($_GET['au']) && $_GET['au'] != ''
100
			&& $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
101
			$this->param['au'] = urldecode($_GET['au']);
102
		}
103
		if (isset($_GET['bib']) && $_GET['bib'] != ''
104
			&& $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
105
			$this->param['bib'] = urldecode($_GET['bib']);
106
		}
107
		if (isset($_GET['nn']) && $_GET['nn'] != '') {
108
			$this->param['nn'] = urldecode($_GET['nn']);
109
		}
110
		if (isset($_GET['nt']) && $_GET['nt'] != '') {
111
			$this->param['nt'] = urldecode($_GET['nt']);
112
		}
113
		if (isset($_GET['sp']) && $_GET['sp'] != '') {
114
			$this->param['sp'] = urldecode($_GET['sp']);
115
		}
116
		if (isset($_GET['ssp']) && $_GET['ssp'] != '') {
117
			$this->param['ssp'] = urldecode($_GET['ssp']);
118
		}
119
		if (isset($_GET['type']) && $_GET['type'] != '') {
120
			$this->param['type'] = urldecode($_GET['type']);
121
		}
122
		if (isset($_GET['and']) && $_GET['and'] != ''
123
			&& $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
124
			$this->param['and'] = urldecode($_GET['and']);
125
		}
126
		if (isset($_GET['anf']) && $_GET['anf'] != ''
127
			&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
128
			$this->param['anf'] = urldecode($_GET['anf']);
129
		}
130
		if (isset($_GET['prga']) && $_GET['prga'] != '') {
131
			$this->param['prga'] = urldecode($_GET['prga']);
132
		}
133
		if (isset($_GET['prco']) && $_GET['prco'] != '') {
134
			$this->param['prco'] = urldecode($_GET['prco']);
135
		}
136
		if (isset($_GET['sto']) && $_GET['sto'] != '') {
137
			$this->param['sto'] = urldecode($_GET['sto']);
138
		}
139
		if (isset($_GET['sti']) && $_GET['sti'] != '') {
140
			$this->param['sti'] = urldecode($_GET['sti']);
141
		}
142
		if (isset($_GET['stc']) && $_GET['stc'] != '') {
143
			$this->param['stc'] = urldecode($_GET['stc']);
144
		}
145
	}
146
 
106 jpm 147
 
76 delphine 148
	public function executerActionParDefaut() {
149
		$this->executerResultat();
150
	}
106 jpm 151
 
76 delphine 152
	public function executerResultat() {
162 jpm 153
		$this->chargerOnglets();
151 jpm 154
		$this->chargerNbreDeTaxons();
155
		$this->chargerNomsFormates();
156
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
76 delphine 157
	}
725 mathilde 158
 
106 jpm 159
 
162 jpm 160
	private function chargerOnglets() {
161
		$donnees = array();
162
		$donnees['typeResultat'] = $this->parametres->typeResultat;
163
		$donnees['typeNom'] = $this->parametres->typeNom;
855 mathilde 164
		$donnees['ongletsNs'] = array('determination', 'retenu', 'decompo');
861 mathilde 165
		$donnees['ongletsNv'] = array('determination', 'alphab');
725 mathilde 166
		if (($_GET['action']) == 'rechercheAvancee') {
167
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
168
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
169
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
170
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
861 mathilde 171
		} else {
855 mathilde 172
 
725 mathilde 173
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
174
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
175
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
176
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
177
		}
855 mathilde 178
		$donnees['i18n']['nv'] = I18n::get('Resultat-onglets-nv');
179
		$donnees['i18n']['ns'] = I18n::get('Resultat-onglets-ns');
162 jpm 180
		$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
84 jpm 181
	}
151 jpm 182
 
183
	private function chargerNbreDeTaxons() {
184
		$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
185
	}
186
 
187
	private function chargerNomsFormates() {
188
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
189
		$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
190
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
191
		$formateur->formater();
192
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
193
		$formateur->trier();
194
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
195
		$formateur->surligner();
196
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
197
		$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
198
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
199
	}
76 delphine 200
}
201
?>