Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1185 Rev 1186
1
<?php
1
<?php
2
class Recherche extends aControleur {
2
class Recherche extends aControleur {
3
	
3
	
4
	//+----------------------------------------------------------------------------------------------------------------+
4
	//+----------------------------------------------------------------------------------------------------------------+
5
	// Méthodes
5
	// Méthodes
6
	protected $nom = null;
6
	protected $nom = null;
7
	protected $type_nom = 'nom_scientifique';
7
	protected $type_nom = 'nom_scientifique';
8
	protected $type_resultat = '';
8
	protected $type_resultat = '';
9
	protected $submit = '';
9
	protected $submit = '';
10
	protected $acces_fiche = false;
10
	protected $acces_fiche = false;
11
	private $recherche_avancee;
11
	private $recherche_avancee;
12
	private $param;
12
	private $param;
13
	private $i18n =	 array();
13
	private $i18n =	 array();
14
	
14
	
15
	private $parametresAvancesGeneriques = array('gen','fam','nn','nt','sp','ssp','type','sto','sti','stc');
15
	private $parametresAvancesGeneriques = array('gen','fam','nn','nt','sp','ssp','type','sto','sti','stc');
16
	
16
	
17
	public function initialiser() {
17
	public function initialiser() {
18
		$this->capturerParametres();
18
		$this->capturerParametres();
19
		$this->capturerParametresAvances();	
19
		$this->capturerParametresAvances();	
20
		$this->i18n = I18n::get('Recherche-form-avancee');
20
		$this->i18n = I18n::get('Recherche-form-avancee');
21
	}
21
	}
22
	
22
	
23
	/**
23
	/**
24
	 * Fonction d'affichage par défaut
24
	 * Fonction d'affichage par défaut
25
	 */
25
	 */
26
	public function executerActionParDefaut() {
26
	public function executerActionParDefaut() {
27
		$this->executerAccueil();
27
		$this->executerAccueil();
28
	}
28
	}
29
	
29
	
30
	public function executerAccueil($donneesMoteur = array()) {
30
	public function executerAccueil($donneesMoteur = array()) {
31
		
31
		
32
		$meta = new MetaDonnees();
32
		$meta = new MetaDonnees();
33
		$meta->setProjet(Registre::get('parametres.referentiel'));
33
		$meta->setProjet(Registre::get('parametres.referentiel'));
34
		$metadonnees = $meta->getMetaDonnees();
34
		$metadonnees = $meta->getMetaDonnees();
35
		$donneesMoteur['metadonnees_referentiel'] = $metadonnees[0];
35
		$donneesMoteur['metadonnees_referentiel'] = $metadonnees[0];
36
		
36
		
37
		$niveau = new Niveau();
37
		$niveau = new Niveau();
38
		$donnees['form_niveau'] = $niveau->afficherNiveau();
38
		$donnees['form_niveau'] = $niveau->afficherNiveau();
39
		$recherchesimple = new RechercheSimple();
39
		$recherchesimple = new RechercheSimple();
40
		$donnees['form_nom'] = $recherchesimple->executerFormulaireNom($donneesMoteur);
40
		$donnees['form_nom'] = $recherchesimple->executerFormulaireNom($donneesMoteur);
41
		if (Registre::get('parametres.niveau') != 1) {
41
		if (Registre::get('parametres.niveau') != 1) {
42
			$recherche_avancee = new RechercheAvancee();
42
			$recherche_avancee = new RechercheAvancee();
43
			$donnees['form_recherche_av'] = $recherche_avancee->executerFormulaireRechercheAv($donneesMoteur);
43
			$donnees['form_recherche_av'] = $recherche_avancee->executerFormulaireRechercheAv($donneesMoteur);
44
		}
44
		}
45
		$donnees['description'] = "";
45
		$donnees['description'] = "";
46
 
46
 
47
		// le descriptif du référentiel est affiché lorsque seul le moteur est affiché (donc ni résultats, ni fiche)
47
		// le descriptif du référentiel est affiché lorsque seul le moteur est affiché (donc ni résultats, ni fiche)
48
		if(Registre::get('parametres.module') == 'recherche' && 
48
		if(Registre::get('parametres.module') == 'recherche' && 
49
			Registre::get('parametres.action') == 'action-par-defaut' &&
49
			Registre::get('parametres.action') == 'action-par-defaut' &&
50
			!Registre::get('resultats')) {
50
			!Registre::get('resultats')) {
51
			$referentiel = Registre::get('parametres.referentiel');
51
			$referentiel = Registre::get('parametres.referentiel');
52
			$wiki = new Wikini();
52
			$wiki = new Wikini();
53
			$description = $wiki->getDescriptionReferentielFormate($referentiel);
53
			$description = $wiki->getDescriptionReferentielFormate($referentiel);
54
			$donnees['description'] = $description;
54
			$donnees['description'] = $description;
55
		}
55
		}
56
		$this->afficherAccueil($donnees);
56
		$this->afficherAccueil($donnees);
57
	}
57
	}
58
	
58
	
59
	private function afficherAccueil($donnees) {
59
	private function afficherAccueil($donnees) {
60
		$donnees['i18n'] = I18n::get('Recherche-accueil');
60
		$donnees['i18n'] = I18n::get('Recherche-accueil');
61
		$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees), true);
61
		$this->setSortie(self::RENDU_CORPS, $this->getVue('recherche_accueil', $donnees), true);
62
	}
62
	}
63
 
63
 
64
	
64
	
65
	//+---------------------------------------------recherche avancee-------------------------------------+	
65
	//+---------------------------------------------recherche avancee-------------------------------------+	
66
	public function executerRechercheAvancee() {
66
	public function executerRechercheAvancee() {
67
		$this->param = $this->nettoyerParametresDefautRechercheAvancee($this->param);
67
		$this->param = $this->nettoyerParametresDefautRechercheAvancee($this->param);
68
		$donnees['param'] = $this->param;
68
		$donnees['param'] = $this->param;
69
		$presence = $this->rechercherCriteresDemandes();
69
		$presence = $this->rechercherCriteresDemandes();
70
		if (empty($presence) && !empty($this->param)) {
70
		if (empty($presence) && !empty($this->param)) {
71
			$donnees['message_av']['attention'] = 'info_res_vide';
71
			$donnees['message_av']['attention'] = 'info_res_vide';
72
		} 
72
		} 
73
		$this->executerAccueil($donnees);
73
		$this->executerAccueil($donnees);
74
		if (Registre::get('resultats')) {
74
		if (Registre::get('resultats')) {
75
			$_GET['resultat'] = $this->type_resultat;
75
			$_GET['resultat'] = $this->type_resultat;
76
			$this->executerAction('Resultat', 'executerResultat');
76
			$this->executerAction('Resultat', 'executerResultat');
77
		}
77
		}
78
	}
78
	}
79
 
79
 
80
	private function nettoyerParametresDefautRechercheAvancee($params) {
80
	private function nettoyerParametresDefautRechercheAvancee($params) {
81
		$params_nettoyes = array();
81
		$params_nettoyes = array();
82
		foreach ($params as $cle => $param) {
82
		foreach ($params as $cle => $param) {
83
			if(!preg_match("#^\(.*\)$#", $param)) {
83
			if(!preg_match("#^\(.*\)$#", $param)) {
84
				$params_nettoyes[$cle] = $param;
84
				$params_nettoyes[$cle] = $param;
85
			}
85
			}
86
		}
86
		}
87
		return $params_nettoyes;
87
		return $params_nettoyes;
88
	}
88
	}
89
	
89
	
90
	public function rechercherCriteresDemandes() {
90
	public function rechercherCriteresDemandes() {
91
		$noms = new Noms(Registre::get('parametres.referentiel'));
91
		$noms = new Noms(Registre::get('parametres.referentiel'));
92
		$res = $noms->getRechercheAvancee($this->param);
92
		$res = $noms->getRechercheAvancee($this->param);
93
		if ($res != false || $res['entete']['total'] != 0) {
93
		if ($res != false || $res['entete']['total'] != 0) {
94
			if ($res['entete']['total'] == 1 ) {
94
			if ($res['entete']['total'] == 1 ) {
95
				$ids = array_keys($res['resultat']);
95
				$ids = array_keys($res['resultat']);
96
				$nom = $res['resultat'][$ids[0]]['nom_sci'];
96
				$nom = $res['resultat'][$ids[0]]['nom_sci'];
97
				$url = $this->urls->obtenirUrlFiche($ids[0], 'nom_scientifique', $nom);
97
				$url = $this->urls->obtenirUrlFiche($ids[0], 'nom_scientifique', $nom);
98
				$this->redirigerVers($url);
98
				$this->redirigerVers($url);
99
			} else {
99
			} else {
100
			$res['type'] = $this->type_nom;
100
			$res['type'] = $this->type_nom;
101
			Registre::set('resultats', $res);
101
			Registre::set('resultats', $res);
102
			}
102
			}
103
		} else {
103
		} else {
104
			$res = '';
104
			$res = '';
105
		}
105
		}
106
		return $res;
106
		return $res;
107
	}
107
	}
108
	
108
	
109
	//+---------------------------------------------recherche simple-------------------------------------+
109
	//+---------------------------------------------recherche simple-------------------------------------+
110
	/*
110
	/*
111
	  grep-friendly: ICI->executerRechercheSimple()
111
	  grep-friendly: ICI->executerRechercheSimple()
112
	  En effet, cette méthode n'est jamais invoquée explicitement.
112
	  En effet, cette méthode n'est jamais invoquée explicitement.
113
	  Le processus est le suivant:
113
	  Le processus est le suivant:
114
	  * URL = index.php?type_nom=...&referentiel=..&module=recherche&action=rechercheSimple
114
	  * URL = index.php?type_nom=...&referentiel=..&module=recherche&action=rechercheSimple
115
	  * AppControleur::initialiser()
115
	  * AppControleur::initialiser()
116
	  * `-> AppControleur::$parametres['action'] = $_GET['action']
116
	  * `-> AppControleur::$parametres['action'] = $_GET['action']
117
	  * `-> AppControleur::executerModule()
117
	  * `-> AppControleur::executerModule()
118
	  *	 `-> effecture $module->$action()
118
	  *	 `-> effecture $module->$action()
119
	  * qui nous appelle ici
119
	  * qui nous appelle ici
120
	 */
120
	 */
121
	public function executerRechercheSimple() {
121
	public function executerRechercheSimple() {
122
		$donnees['type_nom'] = $this->type_nom;
122
		$donnees['type_nom'] = $this->type_nom;
123
		$donnees['nom'] = $this->nom;
123
		$donnees['nom'] = $this->nom;
124
		if (strlen($donnees['nom']) < 3) {
124
		if (strlen($donnees['nom']) < 3) {
125
			$donnees['message']['attention'] = 'info_nb_lettres';
125
			$donnees['message']['attention'] = 'info_nb_lettres';
126
		} else {
126
		} else {
127
			$presence = $this->rechercherNom();
127
			$presence = $this->rechercherNom();
128
			if ($presence == '') { // s'il n'y a pas de nom
128
			if ($presence == '') { // s'il n'y a pas de nom
129
				$donnees['message']['attention'] = 'info_sp_abs';
129
				$donnees['message']['attention'] = 'info_sp_abs';
130
			} elseif ($presence == 'sans_correspondance') {
130
			} elseif ($presence == 'sans_correspondance') {
131
				$res = Registre::get('resultats');
131
				$res = Registre::get('resultats');
132
				$id = array_keys($res['resultat']);
132
				$id = array_keys($res['resultat']);
133
				$donnees['message']['nom_ss_corresp']['id'] = $id[0];
133
				$donnees['message']['nom_ss_corresp']['id'] = $id[0];
134
				$nom = array_shift($res['resultat']);
134
				$nom = array_shift($res['resultat']);
135
				$donnees['message']['nom_ss_corresp']['nom'] = $nom['nom_sci'];
135
				$donnees['message']['nom_ss_corresp']['nom'] = $nom['nom_sci'];
136
			} elseif ($presence != 'ok') { // s'il y a des noms approchés
136
			} elseif ($presence != 'ok') { // s'il y a des noms approchés
137
				if (!Registre::get('resultats')) { // s'il n'y a aucun nom exact
137
				if (!Registre::get('resultats')) { // s'il n'y a aucun nom exact
138
					$donnees['message']['attention'] = 'info_sp_abs';
138
					$donnees['message']['attention'] = 'info_sp_abs';
139
				}
139
				}
140
				$donnees['message']['nom_approche'] = $presence;
140
				$donnees['message']['nom_approche'] = $presence;
141
			}
141
			}
142
		}
142
		}
143
 
143
 
144
		$this->executerAccueil($donnees);
144
		$this->executerAccueil($donnees);
145
		if (Registre::get('resultats')) {
145
		if (Registre::get('resultats')) {
146
			$_GET['resultat'] = $this->type_resultat;
146
			$_GET['resultat'] = $this->type_resultat;
147
			$this->executerAction('Resultat', 'executerResultat');
147
			$this->executerAction('Resultat', 'executerResultat');
148
		}
148
		}
149
	}
149
	}
150
	
150
	
151
	
151
	
152
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
152
	// regarde si il y a des résultats correspondant au nom recherché sinon recherche un nom approché
153
	// $noms classe métier nom ou nom
153
	// $noms classe métier nom ou nom
154
	private function rechercherNom() {
154
	private function rechercherNom() {
155
		$noms = ($this->type_nom == 'nom_vernaculaire') 
155
		$noms = ($this->type_nom == 'nom_vernaculaire') 
156
				? new NomsVernaculaires(Config::get(Registre::get('parametres.referentiel').'.referentielVerna')) 
156
				? new NomsVernaculaires(Config::get(Registre::get('parametres.referentiel').'.referentielVerna')) 
157
				: new Noms(Registre::get('parametres.referentiel'));
157
				: new Noms(Registre::get('parametres.referentiel'));
158
		$approche = '';
158
		$approche = '';
159
		$res = $noms->getRechercheEtendue($this->nom, $this->type_resultat);
159
		$res = $noms->getRechercheEtendue($this->nom, $this->type_resultat);
160
		echo "RES: <pre>".print_r($res,true)."</pre>";
-
 
161
		$form = I18n::get('Recherche-form-nom');
160
		$form = I18n::get('Recherche-form-nom');
162
		if ($res == false || $res['entete']['total'] === 0) { // recherche nom approché
161
		if ($res == false || $res['entete']['total'] === 0) { // recherche nom approché
163
			$approche = $this->rechercherNomApproche($noms);
162
			$approche = $this->rechercherNomApproche($noms);
164
		} elseif ($res['entete']['total'] == 1 || $this->acces_fiche) { // renvoie à la fiche
163
		} elseif ($res['entete']['total'] == 1 || $this->acces_fiche) { // renvoie à la fiche
165
			$approche = $this->traiterAccesFiche($res);
164
			$approche = $this->traiterAccesFiche($res);
166
		} else { // affiche les résultats
165
		} else { // affiche les résultats
167
			$res['type'] = $this->type_nom;
166
			$res['type'] = $this->type_nom;
168
			Registre::set('resultats', $res);
167
			Registre::set('resultats', $res);
169
			$approche = 'ok';
168
			$approche = 'ok';
170
			if ($res['entete']['total'] < 3) { // si moins de 16 noms affiche en plus un nom approché
169
			if ($res['entete']['total'] < 3) { // si moins de 16 noms affiche en plus un nom approché
171
				$approche = $this->rechercherNomApproche($noms);
170
				$approche = $this->rechercherNomApproche($noms);
172
			}
171
			}
173
		}
172
		}
174
		return $approche;
173
		return $approche;
175
	}
174
	}
176
	
175
	
177
	private function traiterAccesFiche($res) {
176
	private function traiterAccesFiche($res) {
178
		$ids = array_keys($res['resultat']);
177
		$ids = array_keys($res['resultat']);
179
		if ($this->type_nom == 'nom_vernaculaire') {
178
		if ($this->type_nom == 'nom_vernaculaire') {
180
			$id = explode(':',$res['resultat'][$ids[0]]['nom_retenu.code']);
179
			$id = explode(':',$res['resultat'][$ids[0]]['nom_retenu.code']);
181
			$id = $id[1];
180
			$id = $id[1];
182
		} else {
181
		} else {
183
			if ($res['resultat'][$ids[0]]['retenu'] == 'absent') { // dans le cas d'un nom sans correspondance
182
			if ($res['resultat'][$ids[0]]['retenu'] == 'absent') { // dans le cas d'un nom sans correspondance
184
				$res['type'] = $this->type_nom;
183
				$res['type'] = $this->type_nom;
185
				Registre::set('resultats', $res);
184
				Registre::set('resultats', $res);
186
				$approche = 'sans_correspondance';
185
				$approche = 'sans_correspondance';
187
				return $approche;
186
				return $approche;
188
			} else {
187
			} else {
189
				$id = $ids[0];
188
				$id = $ids[0];
190
			}
189
			}
191
		}
190
		}
192
		$url = $this->urls->obtenirUrlFiche($id, $this->type_nom, $this->nom);
191
		$url = $this->urls->obtenirUrlFiche($id, $this->type_nom, $this->nom);
193
		$this->redirigerVers($url);
192
		$this->redirigerVers($url);
194
	}
193
	}
195
	
194
	
196
	private function rechercherNomApproche($noms) {
195
	private function rechercherNomApproche($noms) {
197
		$approche = '';
196
		$approche = '';
198
		$res = $noms->getRechercheFloue($this->nom);
197
		$res = $noms->getRechercheFloue($this->nom);
199
		if (!($res == false || $res['entete']['total'] == 0)) {
198
		if (!($res == false || $res['entete']['total'] === 0)) {
200
			for ($i = 0; $i < 3; $i++) {
199
			for ($i = 0; $i < 3; $i++) {
201
				$nom_proche = array_shift($res['resultat']);
200
				$nom_proche = array_shift($res['resultat']);
202
				$approche[$i]['nom'] = ($this->type_nom == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
201
				$approche[$i]['nom'] = ($this->type_nom == 'nom_vernaculaire') ? $nom_proche['nom'] : $nom_proche['nom_sci'];
203
				$approche[$i]['url_nom_approche'] = $this->urls->obtenirUrlRechercheSimple($approche[$i]['nom'], $this->type_nom);
202
				$approche[$i]['url_nom_approche'] = $this->urls->obtenirUrlRechercheSimple($approche[$i]['nom'], $this->type_nom);
204
			}
203
			}
205
		}
204
		}
206
		return $approche;
205
		return $approche;
207
	}
206
	}
208
	
207
	
209
	//+-----------------------------------------------méthodes utiles---------------------------------+
208
	//+-----------------------------------------------méthodes utiles---------------------------------+
210
	
209
	
211
	private function capturerParametres() {
210
	private function capturerParametres() {
212
		if (isset($_REQUEST['nom'])) {
211
		if (isset($_REQUEST['nom'])) {
213
			$this->nom = $this->convertirEncodageEntree(urldecode($_REQUEST['nom']));
212
			$this->nom = $this->convertirEncodageEntree(urldecode($_REQUEST['nom']));
214
		}
213
		}
215
		if (isset($_GET['type_nom'])) {
214
		if (isset($_GET['type_nom'])) {
216
			$this->type_nom = $this->convertirEncodageEntree(urldecode($_GET['type_nom']));
215
			$this->type_nom = $this->convertirEncodageEntree(urldecode($_GET['type_nom']));
217
		}
216
		}
218
		if (isset($_GET['submit'])) {
217
		if (isset($_GET['submit'])) {
219
			$this->submit = $this->convertirEncodageEntree(urldecode($_GET['submit']));
218
			$this->submit = $this->convertirEncodageEntree(urldecode($_GET['submit']));
220
		}
219
		}
221
		if(isset($_GET['acces_fiche'])) {
220
		if(isset($_GET['acces_fiche'])) {
222
			$this->acces_fiche = true;
221
			$this->acces_fiche = true;
223
		}
222
		}
224
		if (isset($_GET['niveau'])) {
223
		if (isset($_GET['niveau'])) {
225
			Registre::set('parametres.niveau', $this->convertirEncodageEntree($_GET['niveau']));
224
			Registre::set('parametres.niveau', $this->convertirEncodageEntree($_GET['niveau']));
226
		}
225
		}
227
		if (isset($_GET['resultat'])) {
226
		if (isset($_GET['resultat'])) {
228
			$this->type_resultat = $this->convertirEncodageEntree(urldecode($_GET['resultat']));
227
			$this->type_resultat = $this->convertirEncodageEntree(urldecode($_GET['resultat']));
229
		} else {
228
		} else {
230
			$onglet_resultat = $this->recupererTableauConfig('affich_resultats');
229
			$onglet_resultat = $this->recupererTableauConfig('affich_resultats');
231
			$this->type_resultat = $onglet_resultat[Registre::get('parametres.niveau').'_'.$this->type_nom];
230
			$this->type_resultat = $onglet_resultat[Registre::get('parametres.niveau').'_'.$this->type_nom];
232
		}
231
		}
233
	}
232
	}
234
	
233
	
235
	private function capturerParametresAvances() {
234
	private function capturerParametresAvances() {
236
		$this->capturerParametresAvancesGeneriques();
235
		$this->capturerParametresAvancesGeneriques();
237
		$this->capturerParametresAvancesDependantsLangage();
236
		$this->capturerParametresAvancesDependantsLangage();
238
		$this->capturerParametresAvancesPresenceSpecifiques();
237
		$this->capturerParametresAvancesPresenceSpecifiques();
239
	}
238
	}
240
	
239
	
241
	private function capturerParametresAvancesGeneriques() {
240
	private function capturerParametresAvancesGeneriques() {
242
		foreach($this->parametresAvancesGeneriques as $param) {
241
		foreach($this->parametresAvancesGeneriques as $param) {
243
			if (isset($_GET[$param]) && $_GET[$param] != '') {
242
			if (isset($_GET[$param]) && $_GET[$param] != '') {
244
				$this->param[$param] = $this->convertirEncodageEntree(urldecode($_GET[$param]));
243
				$this->param[$param] = $this->convertirEncodageEntree(urldecode($_GET[$param]));
245
			}
244
			}
246
		}
245
		}
247
	}
246
	}
248
	
247
	
249
	private function capturerParametresAvancesDependantsLangage() {
248
	private function capturerParametresAvancesDependantsLangage() {
250
		if (isset($_GET['au']) && $_GET['au'] != ''
249
		if (isset($_GET['au']) && $_GET['au'] != ''
251
		&& $_GET['au'] != $this->convertirEncodageEntree(urlencode($this->i18n['valeur-form-auteur']))) {
250
		&& $_GET['au'] != $this->convertirEncodageEntree(urlencode($this->i18n['valeur-form-auteur']))) {
252
			$this->param['au'] = $this->convertirEncodageEntree(urldecode($_GET['au']));
251
			$this->param['au'] = $this->convertirEncodageEntree(urldecode($_GET['au']));
253
		}
252
		}
254
		if (isset($_GET['bib']) && $_GET['bib'] != ''
253
		if (isset($_GET['bib']) && $_GET['bib'] != ''
255
		&& $_GET['bib'] != $this->convertirEncodageEntree(urlencode($this->i18n['valeur-form-bib']))) {
254
		&& $_GET['bib'] != $this->convertirEncodageEntree(urlencode($this->i18n['valeur-form-bib']))) {
256
			$this->param['bib'] = $this->convertirEncodageEntree(urldecode($_GET['bib']));
255
			$this->param['bib'] = $this->convertirEncodageEntree(urldecode($_GET['bib']));
257
		}
256
		}
258
		if (isset($_GET['and']) && $_GET['and'] != ''
257
		if (isset($_GET['and']) && $_GET['and'] != ''
259
		&& $_GET['and'] != $this->convertirEncodageEntree(urlencode($this->i18n['valeur-form-date']))) {
258
		&& $_GET['and'] != $this->convertirEncodageEntree(urlencode($this->i18n['valeur-form-date']))) {
260
			$this->param['and'] = $this->convertirEncodageEntree(urldecode($_GET['and']));
259
			$this->param['and'] = $this->convertirEncodageEntree(urldecode($_GET['and']));
261
		}
260
		}
262
		if (isset($_GET['anf']) && $_GET['anf'] != ''
261
		if (isset($_GET['anf']) && $_GET['anf'] != ''
263
		&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
262
		&& $_GET['anf'] != urlencode($this->i18n['valeur-form-date'])) {
264
			$this->param['anf'] = $this->convertirEncodageEntree(urldecode($_GET['anf']));
263
			$this->param['anf'] = $this->convertirEncodageEntree(urldecode($_GET['anf']));
265
		}
264
		}
266
	}
265
	}
267
	
266
	
268
	private function capturerParametresAvancesPresenceSpecifiques()	 {
267
	private function capturerParametresAvancesPresenceSpecifiques()	 {
269
		$champs_presence = $this->obtenirChampsPresence();
268
		$champs_presence = $this->obtenirChampsPresence();
270
		foreach($champs_presence as $champ) {
269
		foreach($champs_presence as $champ) {
271
			$param = $champ['param'];
270
			$param = $champ['param'];
272
			if (isset($_GET[$param]) && $_GET[$param] != '') {
271
			if (isset($_GET[$param]) && $_GET[$param] != '') {
273
				$this->param[$param] = $this->convertirEncodageEntree(urldecode($_GET[$param]));
272
				$this->param[$param] = $this->convertirEncodageEntree(urldecode($_GET[$param]));
274
			}
273
			}
275
		}
274
		}
276
	}
275
	}
277
	
276
	
278
	private function obtenirChampsPresence() {
277
	private function obtenirChampsPresence() {
279
		$tableau_champs_presence = array();
278
		$tableau_champs_presence = array();
280
		$referentiel = Registre::get('parametres.referentiel');
279
		$referentiel = Registre::get('parametres.referentiel');
281
		$champs_presence_spl = explode('|', Config::get($referentiel.'.champsPresence'));
280
		$champs_presence_spl = explode('|', Config::get($referentiel.'.champsPresence'));
282
		foreach($champs_presence_spl as $champ) {
281
		foreach($champs_presence_spl as $champ) {
283
			$label_param_champ = explode(':', $champ);
282
			$label_param_champ = explode(':', $champ);
284
			if(count($label_param_champ) >= 2) {
283
			if(count($label_param_champ) >= 2) {
285
				$tableau_champs_presence[] = array('param' => $label_param_champ[1],
284
				$tableau_champs_presence[] = array('param' => $label_param_champ[1],
286
														'label' => $label_param_champ[0]);
285
														'label' => $label_param_champ[0]);
287
			}
286
			}
288
		}
287
		}
289
		return $tableau_champs_presence;
288
		return $tableau_champs_presence;
290
	}
289
	}
291
	
290
	
292
	protected function recupererTableauConfig($param) {
291
	protected function recupererTableauConfig($param) {
293
		$tableau = array();
292
		$tableau = array();
294
		$tableauPartiel = explode(',', Config::get($param));
293
		$tableauPartiel = explode(',', Config::get($param));
295
		$tableauPartiel = array_map('trim', $tableauPartiel);
294
		$tableauPartiel = array_map('trim', $tableauPartiel);
296
		foreach ($tableauPartiel as $champ) {
295
		foreach ($tableauPartiel as $champ) {
297
			if (strpos($champ, '=') === false) {
296
			if (strpos($champ, '=') === false) {
298
				$tableau[] = $champ;
297
				$tableau[] = $champ;
299
			} else {
298
			} else {
300
				list($cle, $val) = explode('=', $champ);
299
				list($cle, $val) = explode('=', $champ);
301
				$tableau[$cle] = $val;
300
				$tableau[$cle] = $val;
302
			}
301
			}
303
		}
302
		}
304
		return $tableau;
303
		return $tableau;
305
	}
304
	}
306
 
305
 
307
 
306
 
308
	 /**
307
	 /**
309
	 * Convertion des valeurs de requête dans l'encodage de l'application (voir fichier config.ini : appli_encodage),
308
	 * Convertion des valeurs de requête dans l'encodage de l'application (voir fichier config.ini : appli_encodage),
310
	 * A cause d'un bug en cours d'investigation, celle ci utilise des paramètres différents de la fonction de conversion 
309
	 * A cause d'un bug en cours d'investigation, celle ci utilise des paramètres différents de la fonction de conversion 
311
	 * D'encodage de sortie
310
	 * D'encodage de sortie
312
	 * Cette convertion a lieu seulement si les formats sont différents.
311
	 * Cette convertion a lieu seulement si les formats sont différents.
313
	 */
312
	 */
314
	private function convertirEncodageEntree($contenu) {
313
	private function convertirEncodageEntree($contenu) {
315
		if (Config::get('sortie_encodage') != Config::get('appli_encodage')) {
314
		if (Config::get('sortie_encodage') != Config::get('appli_encodage')) {
316
			$contenu = mb_convert_encoding($contenu, Config::get('appli_encodage'), Config::get('sortie_encodage'));
315
			$contenu = mb_convert_encoding($contenu, Config::get('appli_encodage'), Config::get('sortie_encodage'));
317
		}
316
		}
318
		return $contenu;
317
		return $contenu;
319
	}
318
	}
320
	
319
	
321
}
320
}
322
?>
321
?>