Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 931 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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