Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 790 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 790 Rev 798
Line 123... Line 123...
123
	private function supprimerCodeReftax($chaine) {
123
	private function supprimerCodeReftax($chaine) {
124
		$codeReftax = $this->parametres->reftaxCourant.'.';
124
		$codeReftax = $this->parametres->reftaxCourant.'.';
125
		$chaine = str_replace($codeReftax, '', $chaine);
125
		$chaine = str_replace($codeReftax, '', $chaine);
126
		return $chaine;
126
		return $chaine;
127
	}
127
	}
128
 
128
	
-
 
129
	function supprimerAccents($chaine){
-
 
130
		return strtr($chaine,array('à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a',
-
 
131
										'ç' => 'c',
-
 
132
										'è' => 'e','é' => 'e','ê' => 'e','ë' => 'e',
-
 
133
										'ì' => 'i','í' => 'i','î' => 'i','ï' => 'i',
-
 
134
										'ñ' => 'n',
-
 
135
										'ò' => 'o', 'ó' => 'o' , 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 
-
 
136
										'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 
-
 
137
										'ý' => 'y', 'ÿ' => 'y'));
-
 
138
	}
129
 
139
	
Line 130... Line 140...
130
 
140
 
131
	private function extraireInfosNomsPourTplDetermination() {
141
	private function extraireInfosNomsPourTplDetermination() {
132
		$taxons = array();
142
		$taxons = array();
133
		foreach ($this->noms as $idNomCourant => $nom) {
143
		foreach ($this->noms as $idNomCourant => $nom) {
-
 
144
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
-
 
145
			$nom_min = strtolower($nom['nom_vernaculaire']);
134
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
146
			$nom_ss_accent = $this->supprimerAccents($nom_min);
135
			if (preg_match('/^'. strtolower($this->parametres->masqueRecherche).' |^'. strtolower($this->parametres->masqueRecherche).'$/',  strtolower($nom['nom_vernaculaire']))) {
147
			if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).' |^'.strtolower($this->parametres->masqueRecherche).'$/', $nom_ss_accent )) {
136
				//debute par
148
				//au moins un debute par la requête
137
				if (array_key_exists($nn, $taxons[0]) == false) { 
149
				if (isset($taxons) && array_key_exists($nn, $taxons[0]) == false) { 
138
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
150
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
139
				}
151
				}
140
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
152
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
141
			} else { 
153
			} else { 
142
				//contient
154
				//contient
143
				if (array_key_exists($nn, $taxons[1]) == false) {
155
				if (isset($taxons) && array_key_exists($nn, $taxons[1]) == false) {
144
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
156
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
145
				}
157
				}
146
				$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
158
				$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
147
			}
159
			}
148
		}
-
 
149
		ksort($taxons);
-
 
150
		
160
		}
151
		$this->infosPourTpl['noms'] = isset($taxons)  ? $taxons : false;
161
		$this->infosPourTpl['noms'] = isset($taxons)  ? $taxons : false;
Line 152... Line 162...
152
	}
162
	}
153
	
163
	
Line 184... Line 194...
184
		$this->trieur->setTableau($valeurs);
194
		$this->trieur->setTableau($valeurs);
185
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
195
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
186
		return $this->trieur->trier();
196
		return $this->trieur->trier();
187
	}
197
	}
Line 188... Line -...
188
	
-
 
189
	public function diviserResultats() {
-
 
190
		foreach ($this->infosPourTpl['noms'] as $nt => $valeurs) {
198
	
191
			
-
 
192
		}
-
 
Line 193... Line 199...
193
	}
199
	
194
 
200
 
195
	public function surligner() {
201
	public function surligner() {
196
		$this->definirMotsASurligner();
202
		$this->definirMotsASurligner();
Line 202... Line 208...
202
		}
208
		}
203
	}
209
	}
Line 204... Line 210...
204
 
210
 
205
	private function definirMotsASurligner() {
211
	private function definirMotsASurligner() {
206
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
-
 
207
		foreach ($this->motsASurligner as $mot) {
-
 
208
			if (preg_match_all('/[aeiou]+/', $mot, $retour)) {
-
 
209
				$retour = array_unique($retour);
-
 
210
				$this->motsASurligner = $this->ajouterAccents($mot,$retour);
-
 
211
			}
212
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
212
		}
213
 
Line 213... Line -...
213
	}
-
 
214
	
-
 
215
 
-
 
216
 
-
 
217
	//pour le surlignage si présence d'accents
-
 
218
	private function ajouterAccents($mot, $retour) {
-
 
219
		$mots = array($mot);
-
 
220
		$accents = array('a' => array('à', 'â', 'ä'),
-
 
221
						 'e' => array('é', 'è', 'ë', 'ê'),
-
 
222
						 'i' => array('î' , 'ï'),
-
 
223
						 'o' => array('ô', 'ö'),
-
 
224
						 'u' => array('û', 'ü')
-
 
225
						);
-
 
226
		foreach($accents as $voyelle => $accents) {
-
 
227
			$lettre = array_shift($retour[0]);
-
 
228
			if ($lettre == $voyelle ) {
-
 
229
				foreach ($accents as $ac) {
-
 
230
					$mots[] = str_replace($lettre, $ac, $mot);
-
 
231
				}
-
 
232
			}
-
 
233
			if (empty($retour[0])) {
-
 
234
				break;
214
	}
Line 235... Line 215...
235
			}
215
	
236
		}
216
 
237
		return $mots;
217
 
238
	}
218