Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1060 Rev 1068
Line 113... Line 113...
113
		$chaine = str_replace($codeReferentiel, '', $chaine);
113
		$chaine = str_replace($codeReferentiel, '', $chaine);
114
		return $chaine;
114
		return $chaine;
115
	}
115
	}
Line 116... Line 116...
116
	
116
	
117
	private function chargerRepartition() {
117
	private function chargerRepartition() {
118
		$numsNomsASynonymes = $this->extraireNumerosNomSynonymes();
118
		// $numsNomsASynonymes = $this->extraireNumerosNomSynonymes();
-
 
119
		if (Config::get(Registre::get('parametres.referentiel').'.baseRepartition') == "") {
-
 
120
			return;
-
 
121
		}
119
		if (Config::get(Registre::get('parametres.referentiel').'.baseRepartition') != "") {
122
 
120
			$this->apiCartes->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseRepartition'));
123
		$this->apiCartes->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseRepartition'));
121
			$this->apiCartes->setLargeur('108x101');
124
		$this->apiCartes->setLargeur('108x101');
122
			$urls = array();
125
		$urls = array();
123
			foreach ($this->noms as $nom) {
126
		foreach ($this->noms as $nom) {
124
				if (array_key_exists('nom_retenu.code', $nom)) {
-
 
125
					$id = $nom['nom_retenu.code'];
127
			if (array_key_exists('nom_retenu.code', $nom)) {
126
					$id = $this->supprimerCodeReferentielAvecNn($id);
-
 
127
					$idsNoms = $numsNomsASynonymes[$id];
128
				$id = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
128
					$this->apiCartes->setId("nn:".implode(',',$idsNoms)."");
129
				$this->apiCartes->setId("nn:" . $id); //  . ',' . implode(',', array_keys($numsNomsASynonymes[$id])));
129
					if (array_key_exists($id, $urls) == false) {
130
				if (array_key_exists($id, $urls) == false) {
130
						$urls[$id] = $this->apiCartes->getUrlPng();
-
 
131
					}
131
					$urls[$id] = $this->apiCartes->getUrlPng();
132
				}
132
				}
133
			}
-
 
134
			$this->infosPourTpl['repartition']['urls'] = $urls;
133
			}
-
 
134
		}
135
		}
135
		$this->infosPourTpl['repartition']['urls'] = $urls;
Line 136... Line 136...
136
	}
136
	}
137
	
137
	
138
	private function extraireNumerosNomSynonymes() {
-
 
139
		$numNomsASynonyme = array();
-
 
140
		//TODO: pourrait surement être bien plus efficace 
138
	private function extraireNumerosNomSynonymes() {
141
		// et ne faire qu'une seule boucle
139
		$numNomsASynonyme = array();
142
		foreach ($this->noms as $id => $nom) {
-
 
143
			$num_nom_retenu = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
-
 
144
			if(!isset($numNomsASynonyme[$num_nom_retenu])) {
140
		foreach ($this->noms as $id => $nom) {
145
				$numNomsASynonyme[$num_nom_retenu] = array();
141
			$num_nom_retenu = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
146
			}
-
 
147
			$numNomsASynonyme[$num_nom_retenu][] = $id;
-
 
148
			if(!in_array($num_nom_retenu,$numNomsASynonyme[$num_nom_retenu])) {
-
 
149
				$numNomsASynonyme[$num_nom_retenu][] = $num_nom_retenu;
-
 
150
			}
-
 
151
		}
-
 
152
		foreach($this->noms as $id => $nom) {
-
 
153
			$num_nom_retenu = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
-
 
154
			if($id != $num_nom_retenu) {
-
 
155
				$numNomsASynonyme[$id] = $numNomsASynonyme[$num_nom_retenu];
142
			// faux
156
			}
143
			$numNomsASynonyme[$num_nom_retenu][$id] = TRUE;
157
		}
144
		}
Line 158... Line -...
158
		return $numNomsASynonyme;
-
 
159
	}
-
 
160
	
-
 
161
	function supprimerAccents($chaine){
-
 
162
		return strtr($chaine,array('à' => 'a','á' => 'a','â' => 'a','ã' => 'a','ä' => 'a',
-
 
163
										'ç' => 'c',
-
 
164
										'è' => 'e','é' => 'e','ê' => 'e','ë' => 'e',
-
 
165
										'ì' => 'i','í' => 'i','î' => 'i','ï' => 'i',
-
 
166
										'ñ' => 'n',
-
 
167
										'ò' => 'o', 'ó' => 'o' , 'ô' => 'o', 'õ' => 'o', 'ö' => 'o', 
-
 
168
										'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ü' => 'u', 
-
 
169
										'ý' => 'y', 'ÿ' => 'y'));
-
 
170
	}
145
		return $numNomsASynonyme;
171
	
146
	}
172
 
147
	
173
	private function extraireInfosNomsPourTplDetermination() {
148
	private function extraireInfosNomsPourTplDetermination() {
174
		$taxons = array();
149
		$taxons = array();
175
		foreach ($this->noms as $idNomCourant => $nom) {
-
 
176
			$nn = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
150
		foreach ($this->noms as $idNomCourant => $nom) {
177
			$nom_min = strtolower($nom['nom_vernaculaire']);
151
			$nn = intval($this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']));
178
			$nom_ss_accent = $this->supprimerAccents($nom_min);
152
			$nomV = iconv('UTF-8', 'ASCII//TRANSLIT', strtolower($nom['nom_vernaculaire']));
179
			if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).' |^'.strtolower($this->parametres->masqueRecherche).'$/', $nom_ss_accent )) {
153
			if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).'(?: |$)/', $nomV)) {
180
				//au moins un debute par la requête
154
				// au moins un debute par la requête
181
				if (isset($taxons) && array_key_exists($nn, $taxons[0]) == false) { 
155
				if (isset($taxons) && array_key_exists($nn, $taxons[0]) == false) { 
182
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
156
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
183
				}
157
				}
184
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
158
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
185
			} else { 
159
			} else { 
186
				//contient
160
				// contient
187
				if (isset($taxons) && (!isset($taxons[1]) || array_key_exists($nn, $taxons[1]) == false)) {
161
				if (isset($taxons) && (!isset($taxons[1]) || array_key_exists($nn, $taxons[1]) == false)) {
188
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
162
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
Line 202... Line 176...
202
	
176
	
203
	private function renvoyerInfosTaxon($nomSci, $nn) {
177
	private function renvoyerInfosTaxon($nomSci, $nn) {
204
		$taxon = array();
178
		$taxon = array();
205
		$taxon['nomSci'] = $nomSci;
179
		$taxon['nomSci'] = $nomSci;
-
 
180
		$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
206
		$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
181
		$this->chargerRepartition($nn);
207
		$taxon['repartition_vignette'] = $this->chargerRepartition($nn);
182
		$taxon['repartition_vignette'] = $this->infosPourTpl['repartition']['urls'];
208
		return $taxon;
183
		return $taxon;
Line 209... Line 184...
209
	}
184
	}
210
 
185
 
211
	private function supprimerCodeReferentielAvecNn($nn) {
-
 
212
		$codeReferentiel = $this->parametres->referentielCourant.'.nn:';
186
	private function supprimerCodeReferentielAvecNn($nn) {
Line 213... Line 187...
213
		return str_replace($codeReferentiel, '', $nn);
187
		return str_replace($this->parametres->referentielCourant.'.nn:', '', $nn);
214
	}
188
	}
215
 
189