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();
|
996 |
aurelien |
21 |
|
|
|
22 |
private $parametresAvancesGeneriques = array('gen','fam','nn','nt','sp','ssp','type','sto','sti','stc');
|
106 |
jpm |
23 |
|
84 |
jpm |
24 |
public function initialiser() {
|
146 |
jpm |
25 |
spl_autoload_register(array($this, 'chargerClassesResultat'));
|
|
|
26 |
$this->parametres = new ParametresResultats();
|
84 |
jpm |
27 |
$this->capturerParametres();
|
725 |
mathilde |
28 |
$this->capturerParametresAvances();
|
931 |
delphine |
29 |
$this->parametres->referentielCourant = Registre::get('parametres.referentiel');
|
|
|
30 |
$this->parametres->projetImg = Config::get($this->parametres->referentielCourant.'.baseImages');
|
146 |
jpm |
31 |
$this->resultats = Registre::get('resultats');
|
725 |
mathilde |
32 |
$this->i18n = I18n::get('Recherche-form-avancee');
|
84 |
jpm |
33 |
}
|
106 |
jpm |
34 |
|
146 |
jpm |
35 |
private function chargerClassesResultat($classe) {
|
154 |
jpm |
36 |
$base = dirname(__FILE__).DS;
|
163 |
jpm |
37 |
$cheminFormateurs = $base.'formateurs'.DS;
|
|
|
38 |
$cheminFormateursNs = $cheminFormateurs.'nom_scientifique'.DS;
|
|
|
39 |
$cheminFormateursNv = $cheminFormateurs.'nom_vernaculaire'.DS;
|
|
|
40 |
$dossiers = array($base, $cheminFormateurs, $cheminFormateursNs, $cheminFormateursNv);
|
146 |
jpm |
41 |
foreach ($dossiers as $chemin) {
|
|
|
42 |
$fichierATester = $chemin.$classe.'.php';
|
|
|
43 |
if (file_exists($fichierATester)) {
|
|
|
44 |
include_once $fichierATester;
|
|
|
45 |
return null;
|
|
|
46 |
}
|
|
|
47 |
}
|
|
|
48 |
}
|
|
|
49 |
|
84 |
jpm |
50 |
private function capturerParametres() {
|
967 |
delphine |
51 |
$this->parametres->masqueRecherche = "";
|
84 |
jpm |
52 |
if (isset($_GET['resultat'])) {
|
162 |
jpm |
53 |
$this->parametres->typeResultat = $_GET['resultat'];
|
84 |
jpm |
54 |
}
|
135 |
jpm |
55 |
if (isset($_GET['nom'])) {
|
819 |
mathilde |
56 |
$this->parametres->masqueRecherche = trim($_GET['nom']);
|
135 |
jpm |
57 |
}
|
967 |
delphine |
58 |
//recherche avancee type
|
|
|
59 |
if (isset($_GET['fam'])) {
|
|
|
60 |
$this->parametres->masqueRecherche .= trim($_GET['fam']);
|
|
|
61 |
}
|
|
|
62 |
if (isset($_GET['gen'])) {
|
|
|
63 |
$this->parametres->masqueRecherche .= trim($_GET['gen']);
|
|
|
64 |
}
|
|
|
65 |
if (isset($_GET['sp'])) {
|
|
|
66 |
$this->parametres->masqueRecherche .= trim($_GET['sp']);
|
|
|
67 |
}
|
|
|
68 |
if (isset($_GET['ssp'])) {
|
|
|
69 |
$this->parametres->masqueRecherche .= trim($_GET['ssp']);
|
|
|
70 |
}
|
|
|
71 |
if (isset($_GET['and'])) {
|
|
|
72 |
$this->parametres->masqueRecherche .= trim($_GET['and']);
|
|
|
73 |
}
|
|
|
74 |
if (isset($_GET['anf'])) {
|
|
|
75 |
$this->parametres->masqueRecherche .= trim($_GET['anf']);
|
|
|
76 |
}
|
|
|
77 |
if (isset($_GET['au'])) {
|
|
|
78 |
$this->parametres->masqueRecherche .= trim($_GET['au']);
|
|
|
79 |
}
|
|
|
80 |
if (isset($_GET['bib'])) {
|
|
|
81 |
$this->parametres->masqueRecherche .= trim($_GET['bib']);
|
|
|
82 |
}
|
1210 |
mathias |
83 |
|
|
|
84 |
// Si spécifié, seuls les résultats du niveau spécifié sont affichés.
|
|
|
85 |
// Passer "*" pour annuler le filtre par rang (le paramètre est mis à "null").
|
|
|
86 |
// Par défaut, seules les espèces sont affichées (paramètre par défaut).
|
|
|
87 |
if (isset($_GET['rang'])) {
|
|
|
88 |
$this->parametres->rang = ($_GET['rang'] == '*' ? null : $_GET['rang']);
|
|
|
89 |
}
|
|
|
90 |
|
162 |
jpm |
91 |
if (isset($_GET['type_nom'])) {
|
|
|
92 |
$this->parametres->typeNom = $_GET['type_nom'];
|
|
|
93 |
}
|
197 |
delphine |
94 |
|
|
|
95 |
if (isset($_GET['niveau'])) {
|
|
|
96 |
Registre::set('parametres.niveau', $_GET['niveau']);
|
|
|
97 |
}
|
84 |
jpm |
98 |
}
|
725 |
mathilde |
99 |
|
|
|
100 |
private function capturerParametresAvances() {
|
996 |
aurelien |
101 |
$this->capturerParametresAvancesGeneriques();
|
|
|
102 |
$this->capturerParametresAvancesDependantsLangage();
|
|
|
103 |
$this->capturerParametresAvancesPresenceSpecifiques();
|
1210 |
mathias |
104 |
$this->capturerParametresAvancesRang();
|
996 |
aurelien |
105 |
}
|
1210 |
mathias |
106 |
|
|
|
107 |
private function capturerParametresAvancesRang() {
|
|
|
108 |
// rang à afficher
|
|
|
109 |
$this->param['rang'] = $this->parametres->rang;
|
|
|
110 |
if ($this->param['rang'] === null) {
|
|
|
111 |
$this->param['rang'] = '*';
|
|
|
112 |
}
|
|
|
113 |
}
|
|
|
114 |
|
996 |
aurelien |
115 |
private function capturerParametresAvancesGeneriques() {
|
|
|
116 |
foreach($this->parametresAvancesGeneriques as $param) {
|
|
|
117 |
if (isset($_GET[$param]) && $_GET[$param] != '') {
|
|
|
118 |
$this->param[$param] = urldecode($_GET[$param]);
|
|
|
119 |
}
|
725 |
mathilde |
120 |
}
|
996 |
aurelien |
121 |
}
|
|
|
122 |
|
|
|
123 |
private function capturerParametresAvancesDependantsLangage() {
|
|
|
124 |
if (isset($_GET['au']) && $_GET['au'] != ''
|
|
|
125 |
&& $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
|
725 |
mathilde |
126 |
$this->param['au'] = urldecode($_GET['au']);
|
|
|
127 |
}
|
|
|
128 |
if (isset($_GET['bib']) && $_GET['bib'] != ''
|
996 |
aurelien |
129 |
&& $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
|
725 |
mathilde |
130 |
$this->param['bib'] = urldecode($_GET['bib']);
|
|
|
131 |
}
|
|
|
132 |
if (isset($_GET['and']) && $_GET['and'] != ''
|
996 |
aurelien |
133 |
&& $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
|
725 |
mathilde |
134 |
$this->param['and'] = urldecode($_GET['and']);
|
|
|
135 |
}
|
|
|
136 |
if (isset($_GET['anf']) && $_GET['anf'] != ''
|
996 |
aurelien |
137 |
&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
|
725 |
mathilde |
138 |
$this->param['anf'] = urldecode($_GET['anf']);
|
|
|
139 |
}
|
996 |
aurelien |
140 |
}
|
|
|
141 |
|
|
|
142 |
private function capturerParametresAvancesPresenceSpecifiques() {
|
|
|
143 |
$champs_presence = $this->obtenirChampsPresence();
|
|
|
144 |
foreach($champs_presence as $champ) {
|
|
|
145 |
$param = $champ['param'];
|
|
|
146 |
if (isset($_GET[$param]) && $_GET[$param] != '') {
|
|
|
147 |
$this->param[$param] = urldecode($_GET[$param]);
|
|
|
148 |
}
|
725 |
mathilde |
149 |
}
|
996 |
aurelien |
150 |
}
|
|
|
151 |
|
|
|
152 |
private function obtenirChampsPresence() {
|
|
|
153 |
$tableau_champs_presence = array();
|
|
|
154 |
$referentiel = Registre::get('parametres.referentiel');
|
|
|
155 |
$champs_presence = Config::get($referentiel.'.champsPresence');
|
|
|
156 |
$champs_presence_spl = explode('|', $champs_presence);
|
|
|
157 |
foreach($champs_presence_spl as $champ) {
|
|
|
158 |
$label_param_champ = explode(':', $champ);
|
1165 |
aurelien |
159 |
if(count($label_param_champ) >= 2) {
|
|
|
160 |
$tableau_champs_presence[] = array('param' => $label_param_champ[1],
|
996 |
aurelien |
161 |
'label' => $label_param_champ[0]);
|
1165 |
aurelien |
162 |
}
|
725 |
mathilde |
163 |
}
|
996 |
aurelien |
164 |
return $tableau_champs_presence;
|
725 |
mathilde |
165 |
}
|
|
|
166 |
|
106 |
jpm |
167 |
|
76 |
delphine |
168 |
public function executerActionParDefaut() {
|
|
|
169 |
$this->executerResultat();
|
|
|
170 |
}
|
106 |
jpm |
171 |
|
76 |
delphine |
172 |
public function executerResultat() {
|
162 |
jpm |
173 |
$this->chargerOnglets();
|
151 |
jpm |
174 |
$this->chargerNbreDeTaxons();
|
|
|
175 |
$this->chargerNomsFormates();
|
|
|
176 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
|
76 |
delphine |
177 |
}
|
106 |
jpm |
178 |
|
162 |
jpm |
179 |
private function chargerOnglets() {
|
|
|
180 |
$donnees = array();
|
|
|
181 |
$donnees['typeResultat'] = $this->parametres->typeResultat;
|
|
|
182 |
$donnees['typeNom'] = $this->parametres->typeNom;
|
855 |
mathilde |
183 |
$donnees['ongletsNs'] = array('determination', 'retenu', 'decompo');
|
861 |
mathilde |
184 |
$donnees['ongletsNv'] = array('determination', 'alphab');
|
1140 |
raphael |
185 |
if (@$_GET['action'] == 'rechercheAvancee') {
|
725 |
mathilde |
186 |
$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
|
|
|
187 |
$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
|
|
|
188 |
$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
|
|
|
189 |
$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
|
861 |
mathilde |
190 |
} else {
|
1210 |
mathias |
191 |
$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultat('alphab', $this->param);
|
|
|
192 |
$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultat('retenu', $this->param);
|
|
|
193 |
$donnees['urls']['determination'] = $this->urls->obtenirUrlResultat('determination', $this->param);
|
|
|
194 |
$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultat('decompo', $this->param);
|
725 |
mathilde |
195 |
}
|
1210 |
mathias |
196 |
// Inversion du critère de filtrage de rang : espèces seulement VS tout (pas d'autre choix pour l'instant)
|
|
|
197 |
//echo "PARAMS: <pre>" . print_r($this->param, true) . "</pre><br/>";
|
|
|
198 |
$paramsAvecRangInverse = $this->param;
|
|
|
199 |
if (array_key_exists('rang', $paramsAvecRangInverse)) {
|
|
|
200 |
if ($paramsAvecRangInverse['rang'] == '*') {
|
1213 |
mathias |
201 |
$paramsAvecRangInverse['rang'] = 290;
|
|
|
202 |
} else {
|
1210 |
mathias |
203 |
unset ($paramsAvecRangInverse['rang']);
|
|
|
204 |
}
|
|
|
205 |
}
|
|
|
206 |
//echo "PARAMS INV: <pre>" . print_r($paramsAvecRangInverse, true) . "</pre><br/>";
|
|
|
207 |
$this->donneesTpl['urlInverse'] = $this->urls->obtenirUrlResultat($donnees['typeResultat'], $paramsAvecRangInverse);
|
|
|
208 |
//echo "URL INV: " . $this->donneesTpl['urlInverse'] . "<br/>";
|
|
|
209 |
|
855 |
mathilde |
210 |
$donnees['i18n']['nv'] = I18n::get('Resultat-onglets-nv');
|
|
|
211 |
$donnees['i18n']['ns'] = I18n::get('Resultat-onglets-ns');
|
162 |
jpm |
212 |
$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
|
84 |
jpm |
213 |
}
|
151 |
jpm |
214 |
|
|
|
215 |
private function chargerNbreDeTaxons() {
|
|
|
216 |
$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
|
|
|
217 |
}
|
|
|
218 |
|
1210 |
mathias |
219 |
// Filtre selon le rang à afficher (espèce, genre... tout)
|
|
|
220 |
// et renvoie le nombre de taxons réellement affichés
|
|
|
221 |
private function filtrer() {
|
|
|
222 |
$nbTaxAff = 0;
|
|
|
223 |
if ($this->parametres->rang != null) {
|
|
|
224 |
foreach ($this->resultats['resultat'] as $c => $v) {
|
|
|
225 |
$numRang = substr($v['rang.code'], strrpos($v['rang.code'], ':') +1);
|
|
|
226 |
if ($numRang != $this->parametres->rang) {
|
|
|
227 |
unset($this->resultats['resultat'][$c]);
|
|
|
228 |
} else {
|
|
|
229 |
$nbTaxAff++;
|
|
|
230 |
}
|
|
|
231 |
}
|
|
|
232 |
} else {
|
|
|
233 |
$nbTaxAff = $this->resultats['entete']['total'];
|
|
|
234 |
}
|
|
|
235 |
return $nbTaxAff;
|
|
|
236 |
}
|
|
|
237 |
|
151 |
jpm |
238 |
private function chargerNomsFormates() {
|
|
|
239 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
|
1210 |
mathias |
240 |
|
|
|
241 |
// Filtre selon $this->parametres['rang'] pour afficher seulement un rang, ou bien tous
|
|
|
242 |
// Valable uniquement pour la recherche par nom scientifique
|
|
|
243 |
//echo "<pre>".print_r($this->parametres, true)."</pre>";
|
|
|
244 |
if ($this->parametres->typeNom == 'nom_scientifique') {
|
|
|
245 |
$this->donneesTpl['nombreTaxonsAffiches'] = $this->filtrer();
|
|
|
246 |
$this->donneesTpl['rang'] = $this->parametres->rang;
|
|
|
247 |
} else {
|
|
|
248 |
$this->donneesTpl['nombreTaxonsAffiches'] = $this->donneesTpl['nbreTaxons'];
|
|
|
249 |
}
|
|
|
250 |
$this->donneesTpl['typeNom'] = $this->parametres->typeNom;
|
|
|
251 |
|
151 |
jpm |
252 |
$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
|
|
|
253 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
|
|
|
254 |
$formateur->formater();
|
|
|
255 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
|
|
|
256 |
$formateur->trier();
|
|
|
257 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
|
|
|
258 |
$formateur->surligner();
|
|
|
259 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
|
|
|
260 |
$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
|
|
|
261 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
|
|
|
262 |
}
|
76 |
delphine |
263 |
}
|
|
|
264 |
?>
|