Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1165 | Details | Compare with Previous | 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();
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);
1165 aurelien 144
			if(count($label_param_champ) >= 2) {
145
				$tableau_champs_presence[] = array('param' => $label_param_champ[1],
996 aurelien 146
													'label' => $label_param_champ[0]);
1165 aurelien 147
			}
725 mathilde 148
		}
996 aurelien 149
		return $tableau_champs_presence;
725 mathilde 150
	}
151
 
106 jpm 152
 
76 delphine 153
	public function executerActionParDefaut() {
154
		$this->executerResultat();
155
	}
106 jpm 156
 
76 delphine 157
	public function executerResultat() {
162 jpm 158
		$this->chargerOnglets();
151 jpm 159
		$this->chargerNbreDeTaxons();
160
		$this->chargerNomsFormates();
161
		$this->setSortie(self::RENDU_CORPS, $this->getVue('resultat', $this->donneesTpl));
76 delphine 162
	}
725 mathilde 163
 
106 jpm 164
 
162 jpm 165
	private function chargerOnglets() {
166
		$donnees = array();
167
		$donnees['typeResultat'] = $this->parametres->typeResultat;
168
		$donnees['typeNom'] = $this->parametres->typeNom;
855 mathilde 169
		$donnees['ongletsNs'] = array('determination', 'retenu', 'decompo');
861 mathilde 170
		$donnees['ongletsNv'] = array('determination', 'alphab');
1140 raphael 171
		if (@$_GET['action'] == 'rechercheAvancee') {
725 mathilde 172
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAvanceOnglets('alphab', $this->param);
173
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatAvanceOnglets('retenu', $this->param);
174
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatAvanceOnglets('determination',$this->param);
175
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatAvanceOnglets('decompo',$this->param);
861 mathilde 176
		} else {
855 mathilde 177
 
725 mathilde 178
			$donnees['urls']['alphab'] = $this->urls->obtenirUrlResultatAlphab();
179
			$donnees['urls']['retenu'] = $this->urls->obtenirUrlResultatRetenu();
180
			$donnees['urls']['determination'] = $this->urls->obtenirUrlResultatDetermination();
181
			$donnees['urls']['decompo'] = $this->urls->obtenirUrlResultatDecompo();
182
		}
855 mathilde 183
		$donnees['i18n']['nv'] = I18n::get('Resultat-onglets-nv');
184
		$donnees['i18n']['ns'] = I18n::get('Resultat-onglets-ns');
162 jpm 185
		$this->donneesTpl['ongletsHtml'] = $this->getVue('onglets', $donnees);
84 jpm 186
	}
151 jpm 187
 
188
	private function chargerNbreDeTaxons() {
189
		$this->donneesTpl['nbreTaxons'] = $this->resultats['entete']['total'];
190
	}
191
 
192
	private function chargerNomsFormates() {
193
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt mise en forme des noms");
194
		$formateur = ResultatFormateurFabrique::creer($this->parametres, $this->resultats);
195
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt formatage des noms");
196
		$formateur->formater();
197
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt triage des noms");
198
		$formateur->trier();
199
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt surlignage des noms");
200
		$formateur->surligner();
201
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Avt création de la vue");
202
		$this->donneesTpl['nomsHtml'] = $this->getVue($formateur->getTplNom(), $formateur->getTplInfos());
203
		if (Config::get('benchmark_chrono')) Chronometre::chrono("Après mise en forme des noms");
204
	}
76 delphine 205
}
206
?>