Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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