Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 747 Rev 790
Line 125... Line 125...
125
		$chaine = str_replace($codeReftax, '', $chaine);
125
		$chaine = str_replace($codeReftax, '', $chaine);
126
		return $chaine;
126
		return $chaine;
127
	}
127
	}
Line -... Line 128...
-
 
128
 
128
 
129
 
129
 
130
 
130
	private function extraireInfosNomsPourTplDetermination() {
131
	private function extraireInfosNomsPourTplDetermination() {
131
		$taxons = array();
132
		$taxons = array();
-
 
133
		foreach ($this->noms as $idNomCourant => $nom) {
-
 
134
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
132
		foreach ($this->noms as $idNomCourant => $nom) {
135
			if (preg_match('/^'. strtolower($this->parametres->masqueRecherche).' |^'. strtolower($this->parametres->masqueRecherche).'$/',  strtolower($nom['nom_vernaculaire']))) {
133
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
136
				//debute par
-
 
137
				if (array_key_exists($nn, $taxons[0]) == false) { 
134
			if (array_key_exists($nn, $taxons) == false) {
138
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
-
 
139
				}
-
 
140
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
135
				$taxon = array();
141
			} else { 
136
				$taxon['nomSci'] = $nom['taxon'];
142
				//contient
-
 
143
				if (array_key_exists($nn, $taxons[1]) == false) {
137
				$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
144
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
138
				$taxon['repartition_vignette'] = $this->chargerRepartition($nn);
145
				}
139
				$taxons[$nn] = $taxon;
-
 
140
			}
-
 
141
			$nom_verna = array();
-
 
142
			$nom_verna['nn'] = $nom['id'];
-
 
143
			$nom_verna['nom_vernaculaire'] = $nom['nom_vernaculaire'];
146
				$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
-
 
147
			}
-
 
148
		}
144
			$taxons[$nn]['nomVerna'][] = $nom_verna;
149
		ksort($taxons);
-
 
150
		
-
 
151
		$this->infosPourTpl['noms'] = isset($taxons)  ? $taxons : false;
-
 
152
	}
-
 
153
	
-
 
154
	private function renvoyerInfosNomVerna($valeurs) {
-
 
155
		$nom_verna = array();
-
 
156
		$nom_verna['nn'] = $valeurs['id'];
-
 
157
		$nom_verna['nom_vernaculaire'] = $valeurs['nom_vernaculaire'];
-
 
158
		return $nom_verna;
-
 
159
	}
-
 
160
	
-
 
161
	private function renvoyerInfosTaxon($nomSci, $nn) {
-
 
162
		$taxon = array();
-
 
163
		$taxon['nomSci'] = $nomSci;
-
 
164
		$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
145
		}
165
		$taxon['repartition_vignette'] = $this->chargerRepartition($nn);
Line 146... Line 166...
146
		$this->infosPourTpl['noms'] = (count($taxons) > 0) ? $taxons : false;
166
		return $taxon;
147
	}
167
	}
148
 
168
 
149
	private function supprimerCodeReftaxAvecNn($nn) {
169
	private function supprimerCodeReftaxAvecNn($nn) {
Line 150... Line -...
150
		$codeReftax = $this->parametres->reftaxCourant.'.nn:';
-
 
-
 
170
		$codeReftax = $this->parametres->reftaxCourant.'.nn:';
151
		return str_replace($codeReftax, '', $nn);
171
		return str_replace($codeReftax, '', $nn);
-
 
172
	}
-
 
173
 
-
 
174
	//tri alphabétique des noms scientifiques par catégorie (débute par , contient )
-
 
175
	public function trier() {
-
 
176
		$verna = array();
-
 
177
		foreach ($this->infosPourTpl['noms'] as $categorie => $valeurs) {
152
	}
178
			$verna += $this->classerAlphabetiquement('nomSci', $valeurs);
-
 
179
		}
-
 
180
		$this->infosPourTpl['noms'] = $verna;
-
 
181
	}
-
 
182
	
-
 
183
	private function classerAlphabetiquement($champs, $valeurs) {
-
 
184
		$this->trieur->setTableau($valeurs);
-
 
185
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
-
 
186
		return $this->trieur->trier();
-
 
187
	}
-
 
188
	
153
 
189
	public function diviserResultats() {
Line 154... Line 190...
154
 
190
		foreach ($this->infosPourTpl['noms'] as $nt => $valeurs) {
155
	public function trier() {
191
			
156
 
192
		}
Line 166... Line 202...
166
		}
202
		}
167
	}
203
	}
Line 168... Line 204...
168
 
204
 
169
	private function definirMotsASurligner() {
205
	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
			}
170
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
212
		}
-
 
213
	}
-
 
214
	
Line -... Line 215...
-
 
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;
-
 
235
			}
-
 
236
		}
-
 
237
		return $mots;
171
	}
238
	}
172
 
239
	
173
	private function surlignerMotsMasqueRecherche($nom) {
240
	private function surlignerMotsMasqueRecherche($nom) {
174
		$this->surligneur->setTexte($nom);
241
		$this->surligneur->setTexte($nom);
175
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);
242
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);