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 |
}
|
|
|
83 |
|
|
|
84 |
|
162 |
jpm |
85 |
if (isset($_GET['type_nom'])) {
|
|
|
86 |
$this->parametres->typeNom = $_GET['type_nom'];
|
|
|
87 |
}
|
197 |
delphine |
88 |
|
|
|
89 |
if (isset($_GET['niveau'])) {
|
|
|
90 |
Registre::set('parametres.niveau', $_GET['niveau']);
|
|
|
91 |
}
|
84 |
jpm |
92 |
}
|
725 |
mathilde |
93 |
|
|
|
94 |
private function capturerParametresAvances() {
|
996 |
aurelien |
95 |
$this->capturerParametresAvancesGeneriques();
|
|
|
96 |
$this->capturerParametresAvancesDependantsLangage();
|
|
|
97 |
$this->capturerParametresAvancesPresenceSpecifiques();
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
private function capturerParametresAvancesGeneriques() {
|
|
|
101 |
foreach($this->parametresAvancesGeneriques as $param) {
|
|
|
102 |
if (isset($_GET[$param]) && $_GET[$param] != '') {
|
|
|
103 |
$this->param[$param] = urldecode($_GET[$param]);
|
|
|
104 |
}
|
725 |
mathilde |
105 |
}
|
996 |
aurelien |
106 |
}
|
|
|
107 |
|
|
|
108 |
private function capturerParametresAvancesDependantsLangage() {
|
|
|
109 |
if (isset($_GET['au']) && $_GET['au'] != ''
|
|
|
110 |
&& $_GET['au'] != urlencode($this->i18n['valeur-form-auteur'])) {
|
725 |
mathilde |
111 |
$this->param['au'] = urldecode($_GET['au']);
|
|
|
112 |
}
|
|
|
113 |
if (isset($_GET['bib']) && $_GET['bib'] != ''
|
996 |
aurelien |
114 |
&& $_GET['bib'] != urlencode($this->i18n['valeur-form-bib'])) {
|
725 |
mathilde |
115 |
$this->param['bib'] = urldecode($_GET['bib']);
|
|
|
116 |
}
|
|
|
117 |
if (isset($_GET['and']) && $_GET['and'] != ''
|
996 |
aurelien |
118 |
&& $_GET['and'] != urlencode($this->i18n['valeur-form-date'])) {
|
725 |
mathilde |
119 |
$this->param['and'] = urldecode($_GET['and']);
|
|
|
120 |
}
|
|
|
121 |
if (isset($_GET['anf']) && $_GET['anf'] != ''
|
996 |
aurelien |
122 |
&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
|
725 |
mathilde |
123 |
$this->param['anf'] = urldecode($_GET['anf']);
|
|
|
124 |
}
|
996 |
aurelien |
125 |
}
|
|
|
126 |
|
|
|
127 |
private function capturerParametresAvancesPresenceSpecifiques() {
|
|
|
128 |
$champs_presence = $this->obtenirChampsPresence();
|
|
|
129 |
foreach($champs_presence as $champ) {
|
|
|
130 |
$param = $champ['param'];
|
|
|
131 |
if (isset($_GET[$param]) && $_GET[$param] != '') {
|
|
|
132 |
$this->param[$param] = urldecode($_GET[$param]);
|
|
|
133 |
}
|
725 |
mathilde |
134 |
}
|
996 |
aurelien |
135 |
}
|
|
|
136 |
|
|
|
137 |
private function obtenirChampsPresence() {
|
|
|
138 |
$tableau_champs_presence = array();
|
|
|
139 |
$referentiel = Registre::get('parametres.referentiel');
|
|
|
140 |
$champs_presence = Config::get($referentiel.'.champsPresence');
|
|
|
141 |
$champs_presence_spl = explode('|', $champs_presence);
|
|
|
142 |
foreach($champs_presence_spl as $champ) {
|
|
|
143 |
$label_param_champ = explode(':', $champ);
|
|
|
144 |
$tableau_champs_presence[] = array('param' => $label_param_champ[1],
|
|
|
145 |
'label' => $label_param_champ[0]);
|
725 |
mathilde |
146 |
}
|
996 |
aurelien |
147 |
return $tableau_champs_presence;
|
725 |
mathilde |
148 |
}
|
|
|
149 |
|
106 |
jpm |
150 |
|
76 |
delphine |
151 |
public function executerActionParDefaut() {
|
|
|
152 |
$this->executerResultat();
|
|
|
153 |
}
|
106 |
jpm |
154 |
|
76 |
delphine |
155 |
public function executerResultat() {
|
162 |
jpm |
156 |
$this->chargerOnglets();
|
151 |
jpm |
157 |
$this->chargerNbreDeTaxons();
|
|
|
158 |
$this->chargerNomsFormates();
|
|
|
159 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
|
76 |
delphine |
160 |
}
|
725 |
mathilde |
161 |
|
106 |
jpm |
162 |
|
162 |
jpm |
163 |
private function chargerOnglets() {
|
|
|
164 |
$donnees = array();
|
|
|
165 |
$donnees['typeResultat'] = $this->parametres->typeResultat;
|
|
|
166 |
$donnees['typeNom'] = $this->parametres->typeNom;
|
855 |
mathilde |
167 |
$donnees['ongletsNs'] = array('determination', 'retenu', 'decompo');
|
861 |
mathilde |
168 |
$donnees['ongletsNv'] = array('determination', 'alphab');
|
725 |
mathilde |
169 |
if (($_GET['action']) == 'rechercheAvancee') {
|
|
|
170 |
$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
|
|
|
171 |
$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
|
|
|
172 |
$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
|
|
|
173 |
$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
|
861 |
mathilde |
174 |
} else {
|
855 |
mathilde |
175 |
|
725 |
mathilde |
176 |
$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
|
|
|
177 |
$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
|
|
|
178 |
$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
|
|
|
179 |
$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
|
|
|
180 |
}
|
855 |
mathilde |
181 |
$donnees['i18n']['nv'] = I18n::get('Resultat-onglets-nv');
|
|
|
182 |
$donnees['i18n']['ns'] = I18n::get('Resultat-onglets-ns');
|
162 |
jpm |
183 |
$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
|
84 |
jpm |
184 |
}
|
151 |
jpm |
185 |
|
|
|
186 |
private function chargerNbreDeTaxons() {
|
|
|
187 |
$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
private function chargerNomsFormates() {
|
|
|
191 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
|
|
|
192 |
$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
|
|
|
193 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
|
|
|
194 |
$formateur->formater();
|
|
|
195 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
|
|
|
196 |
$formateur->trier();
|
|
|
197 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
|
|
|
198 |
$formateur->surligner();
|
|
|
199 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
|
|
|
200 |
$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
|
|
|
201 |
if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
|
|
|
202 |
}
|
76 |
delphine |
203 |
}
|
|
|
204 |
?>
|