Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1140 Rev 1165
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
	private $parametresAvancesGeneriques = array('gen','fam','nn','nt','sp','ssp','type','sto','sti','stc');
22
	private $parametresAvancesGeneriques = array('gen','fam','nn','nt','sp','ssp','type','sto','sti','stc');
23
 
23
 
24
	public function initialiser() {
24
	public function initialiser() {
25
		spl_autoload_register(array($this, 'chargerClassesResultat'));
25
		spl_autoload_register(array($this, 'chargerClassesResultat'));
26
		$this->parametres = new ParametresResultats();
26
		$this->parametres = new ParametresResultats();
27
		$this->capturerParametres();
27
		$this->capturerParametres();
28
		$this->capturerParametresAvances();
28
		$this->capturerParametresAvances();
29
		$this->parametres->referentielCourant = Registre::get('parametres.referentiel');
29
		$this->parametres->referentielCourant = Registre::get('parametres.referentiel');
30
		$this->parametres->projetImg = Config::get($this->parametres->referentielCourant.'.baseImages');
30
		$this->parametres->projetImg = Config::get($this->parametres->referentielCourant.'.baseImages');
31
		$this->resultats = Registre::get('resultats');
31
		$this->resultats = Registre::get('resultats');
32
		$this->i18n = I18n::get('Recherche-form-avancee');
32
		$this->i18n = I18n::get('Recherche-form-avancee');
33
	}
33
	}
34
 
34
 
35
	private function chargerClassesResultat($classe) {
35
	private function chargerClassesResultat($classe) {
36
		$base = dirname(__FILE__).DS;
36
		$base = dirname(__FILE__).DS;
37
		$cheminFormateurs = $base.'formateurs'.DS;
37
		$cheminFormateurs = $base.'formateurs'.DS;
38
		$cheminFormateursNs = $cheminFormateurs.'nom_scientifique'.DS;
38
		$cheminFormateursNs = $cheminFormateurs.'nom_scientifique'.DS;
39
		$cheminFormateursNv = $cheminFormateurs.'nom_vernaculaire'.DS;
39
		$cheminFormateursNv = $cheminFormateurs.'nom_vernaculaire'.DS;
40
		$dossiers = array($base, $cheminFormateurs, $cheminFormateursNs, $cheminFormateursNv);
40
		$dossiers = array($base, $cheminFormateurs, $cheminFormateursNs, $cheminFormateursNv);
41
		foreach ($dossiers as $chemin) {
41
		foreach ($dossiers as $chemin) {
42
			$fichierATester = $chemin.$classe.'.php';
42
			$fichierATester = $chemin.$classe.'.php';
43
			if (file_exists($fichierATester)) {
43
			if (file_exists($fichierATester)) {
44
				include_once $fichierATester;
44
				include_once $fichierATester;
45
				return null;
45
				return null;
46
			}
46
			}
47
		}
47
		}
48
	}
48
	}
49
 
49
 
50
	private function capturerParametres() {
50
	private function capturerParametres() {
51
		$this->parametres->masqueRecherche = "";
51
		$this->parametres->masqueRecherche = "";
52
		if (isset($_GET['resultat'])) {
52
		if (isset($_GET['resultat'])) {
53
			$this->parametres->typeResultat = $_GET['resultat'];
53
			$this->parametres->typeResultat = $_GET['resultat'];
54
		}
54
		}
55
		if (isset($_GET['nom'])) {
55
		if (isset($_GET['nom'])) {
56
			$this->parametres->masqueRecherche = trim($_GET['nom']);
56
			$this->parametres->masqueRecherche = trim($_GET['nom']);
57
		}
57
		}
58
		//recherche avancee type
58
		//recherche avancee type
59
		if (isset($_GET['fam'])) {
59
		if (isset($_GET['fam'])) {
60
			$this->parametres->masqueRecherche .= trim($_GET['fam']);
60
			$this->parametres->masqueRecherche .= trim($_GET['fam']);
61
		}
61
		}
62
		if (isset($_GET['gen'])) {
62
		if (isset($_GET['gen'])) {
63
			$this->parametres->masqueRecherche .= trim($_GET['gen']);
63
			$this->parametres->masqueRecherche .= trim($_GET['gen']);
64
		}
64
		}
65
		if (isset($_GET['sp'])) {
65
		if (isset($_GET['sp'])) {
66
			$this->parametres->masqueRecherche .= trim($_GET['sp']);
66
			$this->parametres->masqueRecherche .= trim($_GET['sp']);
67
		}
67
		}
68
		if (isset($_GET['ssp'])) {
68
		if (isset($_GET['ssp'])) {
69
			$this->parametres->masqueRecherche .= trim($_GET['ssp']);
69
			$this->parametres->masqueRecherche .= trim($_GET['ssp']);
70
		}
70
		}
71
		if (isset($_GET['and'])) {
71
		if (isset($_GET['and'])) {
72
			$this->parametres->masqueRecherche .= trim($_GET['and']);
72
			$this->parametres->masqueRecherche .= trim($_GET['and']);
73
		}
73
		}
74
		if (isset($_GET['anf'])) {
74
		if (isset($_GET['anf'])) {
75
			$this->parametres->masqueRecherche .= trim($_GET['anf']);
75
			$this->parametres->masqueRecherche .= trim($_GET['anf']);
76
		}
76
		}
77
		if (isset($_GET['au'])) {
77
		if (isset($_GET['au'])) {
78
			$this->parametres->masqueRecherche .= trim($_GET['au']);
78
			$this->parametres->masqueRecherche .= trim($_GET['au']);
79
		}
79
		}
80
		if (isset($_GET['bib'])) {
80
		if (isset($_GET['bib'])) {
81
			$this->parametres->masqueRecherche .= trim($_GET['bib']);
81
			$this->parametres->masqueRecherche .= trim($_GET['bib']);
82
		}
82
		}
83
		
83
		
84
		
84
		
85
		if (isset($_GET['type_nom'])) {
85
		if (isset($_GET['type_nom'])) {
86
			$this->parametres->typeNom = $_GET['type_nom'];
86
			$this->parametres->typeNom = $_GET['type_nom'];
87
		}
87
		}
88
		
88
		
89
		if (isset($_GET['niveau'])) {
89
		if (isset($_GET['niveau'])) {
90
			Registre::set('parametres.niveau', $_GET['niveau']);
90
			Registre::set('parametres.niveau', $_GET['niveau']);
91
		}
91
		}
92
	}
92
	}
93
	
93
	
94
	private function capturerParametresAvances() {
94
	private function capturerParametresAvances() {
95
		$this->capturerParametresAvancesGeneriques();
95
		$this->capturerParametresAvancesGeneriques();
96
		$this->capturerParametresAvancesDependantsLangage();
96
		$this->capturerParametresAvancesDependantsLangage();
97
		$this->capturerParametresAvancesPresenceSpecifiques();
97
		$this->capturerParametresAvancesPresenceSpecifiques();
98
	}
98
	}
99
	
99
	
100
	private function capturerParametresAvancesGeneriques() {
100
	private function capturerParametresAvancesGeneriques() {
101
		foreach($this->parametresAvancesGeneriques as $param) {
101
		foreach($this->parametresAvancesGeneriques as $param) {
102
			if (isset($_GET[$param]) && $_GET[$param] != '') {
102
			if (isset($_GET[$param]) && $_GET[$param] != '') {
103
				$this->param[$param] = urldecode($_GET[$param]);
103
				$this->param[$param] = urldecode($_GET[$param]);
104
			}
104
			}
105
		}
105
		}
106
	}
106
	}
107
	
107
	
108
	private function capturerParametresAvancesDependantsLangage() {
108
	private function capturerParametresAvancesDependantsLangage() {
109
		if (isset($_GET['au']) && $_GET['au'] != ''
109
		if (isset($_GET['au']) && $_GET['au'] != ''
110
		&& $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
110
		&& $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
111
			$this->param['au'] = urldecode($_GET['au']);
111
			$this->param['au'] = urldecode($_GET['au']);
112
		}
112
		}
113
		if (isset($_GET['bib']) && $_GET['bib'] != ''
113
		if (isset($_GET['bib']) && $_GET['bib'] != ''
114
		&& $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
114
		&& $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
115
			$this->param['bib'] = urldecode($_GET['bib']);
115
			$this->param['bib'] = urldecode($_GET['bib']);
116
		}
116
		}
117
		if (isset($_GET['and']) && $_GET['and'] != ''
117
		if (isset($_GET['and']) && $_GET['and'] != ''
118
		&& $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
118
		&& $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
119
			$this->param['and'] = urldecode($_GET['and']);
119
			$this->param['and'] = urldecode($_GET['and']);
120
		}
120
		}
121
		if (isset($_GET['anf']) && $_GET['anf'] != ''
121
		if (isset($_GET['anf']) && $_GET['anf'] != ''
122
		&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
122
		&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
123
			$this->param['anf'] = urldecode($_GET['anf']);
123
			$this->param['anf'] = urldecode($_GET['anf']);
124
		}
124
		}
125
	}
125
	}
126
	
126
	
127
	private function capturerParametresAvancesPresenceSpecifiques()  {
127
	private function capturerParametresAvancesPresenceSpecifiques()  {
128
		$champs_presence = $this->obtenirChampsPresence();
128
		$champs_presence = $this->obtenirChampsPresence();
129
		foreach($champs_presence as $champ) {
129
		foreach($champs_presence as $champ) {
130
			$param = $champ['param'];
130
			$param = $champ['param'];
131
			if (isset($_GET[$param]) && $_GET[$param] != '') {
131
			if (isset($_GET[$param]) && $_GET[$param] != '') {
132
				$this->param[$param] = urldecode($_GET[$param]);
132
				$this->param[$param] = urldecode($_GET[$param]);
133
			}
133
			}
134
		}
134
		}
135
	}
135
	}
136
	
136
	
137
	private function obtenirChampsPresence() {
137
	private function obtenirChampsPresence() {
138
		$tableau_champs_presence = array();
138
		$tableau_champs_presence = array();
139
		$referentiel = Registre::get('parametres.referentiel');
139
		$referentiel = Registre::get('parametres.referentiel');
140
		$champs_presence = Config::get($referentiel.'.champsPresence');
140
		$champs_presence = Config::get($referentiel.'.champsPresence');
141
		$champs_presence_spl = explode('|', $champs_presence);
141
		$champs_presence_spl = explode('|', $champs_presence);
142
		foreach($champs_presence_spl as $champ) {
142
		foreach($champs_presence_spl as $champ) {
143
			$label_param_champ = explode(':', $champ);
143
			$label_param_champ = explode(':', $champ);
-
 
144
			if(count($label_param_champ) >= 2) {
144
			$tableau_champs_presence[] = array('param' => $label_param_champ[1],
145
				$tableau_champs_presence[] = array('param' => $label_param_champ[1],
145
													'label' => $label_param_champ[0]);
146
													'label' => $label_param_champ[0]);
-
 
147
			}
146
		}
148
		}
147
		return $tableau_champs_presence;
149
		return $tableau_champs_presence;
148
	}
150
	}
149
	
151
	
150
 
152
 
151
	public function executerActionParDefaut() {
153
	public function executerActionParDefaut() {
152
		$this->executerResultat();
154
		$this->executerResultat();
153
	}
155
	}
154
 
156
 
155
	public function executerResultat() {
157
	public function executerResultat() {
156
		$this->chargerOnglets();
158
		$this->chargerOnglets();
157
		$this->chargerNbreDeTaxons();
159
		$this->chargerNbreDeTaxons();
158
		$this->chargerNomsFormates();
160
		$this->chargerNomsFormates();
159
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
161
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
160
	}
162
	}
161
	
163
	
162
 
164
 
163
	private function chargerOnglets() {
165
	private function chargerOnglets() {
164
		$donnees = array();
166
		$donnees = array();
165
		$donnees['typeResultat'] = $this->parametres->typeResultat;
167
		$donnees['typeResultat'] = $this->parametres->typeResultat;
166
		$donnees['typeNom'] = $this->parametres->typeNom;
168
		$donnees['typeNom'] = $this->parametres->typeNom;
167
		$donnees['ongletsNs'] = array('determination', 'retenu', 'decompo');
169
		$donnees['ongletsNs'] = array('determination', 'retenu', 'decompo');
168
		$donnees['ongletsNv'] = array('determination', 'alphab');
170
		$donnees['ongletsNv'] = array('determination', 'alphab');
169
		if (@$_GET['action'] == 'rechercheAvancee') {
171
		if (@$_GET['action'] == 'rechercheAvancee') {
170
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
172
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
171
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
173
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
172
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
174
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
173
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
175
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
174
		} else {
176
		} else {
175
			
177
			
176
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
178
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
177
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
179
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
178
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
180
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
179
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
181
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
180
		}
182
		}
181
		$donnees['i18n']['nv'] = I18n::get('Resultat-onglets-nv');
183
		$donnees['i18n']['nv'] = I18n::get('Resultat-onglets-nv');
182
		$donnees['i18n']['ns'] = I18n::get('Resultat-onglets-ns');
184
		$donnees['i18n']['ns'] = I18n::get('Resultat-onglets-ns');
183
		$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
185
		$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
184
	}
186
	}
185
 
187
 
186
	private function chargerNbreDeTaxons() {
188
	private function chargerNbreDeTaxons() {
187
		$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
189
		$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
188
	}
190
	}
189
 
191
 
190
	private function chargerNomsFormates() {
192
	private function chargerNomsFormates() {
191
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
193
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
192
		$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
194
		$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
193
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
195
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
194
		$formateur->formater();
196
		$formateur->formater();
195
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
197
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
196
		$formateur->trier();
198
		$formateur->trier();
197
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
199
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
198
		$formateur->surligner();
200
		$formateur->surligner();
199
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
201
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
200
		$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
202
		$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
201
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
203
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
202
	}
204
	}
203
}
205
}
204
?>
206
?>