Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 825 Rev 872
Line 40... Line 40...
40
	public function formater() {
40
	public function formater() {
41
		$this->obtenirUrlsImagesCoste();
41
		$this->obtenirUrlsImagesCoste();
42
		$this->obtenirUrlsPhotos();
42
		$this->obtenirUrlsPhotos();
43
		$this->chargerRepartition();
43
		$this->chargerRepartition();
44
		$this->extraireInfosNomsPourTplDetermination();
44
		$this->extraireInfosNomsPourTplDetermination();
45
			
-
 
46
	}
-
 
47
 
-
 
48
	private function obtenirUrlsPhotos() {
-
 
49
		$this->imagesService->setProjet('cel');
-
 
50
		$ids = $this->extraireIdDesNoms();
-
 
51
		$urls = $this->imagesService->getUrlsImagesParIdsNoms($ids);
-
 
52
		$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReftaxDesIds($urls);
-
 
53
	}
45
	}
Line -... Line 46...
-
 
46
	
54
	
47
	
55
	private function obtenirUrlsImagesCoste() {
48
	private function obtenirUrlsImagesCoste() {
56
		$this->extraireInfosTaxons();
49
		$this->extraireInfosTaxons();
57
		$this->imagesService->setProjet('coste');
50
		$this->imagesService->setProjet('coste');
58
		$tax = implode(',', $this->infosPourTpl['taxons']);
51
		$tax = implode(',', $this->infosPourTpl['taxons']);
Line 64... Line 57...
64
				$images[$num_taxon][] = $infos['binaire.href'];
57
				$images[$num_taxon][] = $infos['binaire.href'];
65
				$this->infosPourTpl['imagesCoste'] = $images;
58
				$this->infosPourTpl['imagesCoste'] = $images;
66
			}
59
			}
67
		}
60
		}
68
	}
61
	}
69
 
-
 
70
	private function extraireInfosTaxons() {
62
	private function extraireInfosTaxons() {
71
		foreach ($this->noms as $id => $nom ) {
63
		foreach ($this->noms as $id => $nom ) {
72
			if (array_key_exists('num_taxonomique', $nom)) {
64
			if (array_key_exists('num_taxonomique', $nom)) {
73
				$this->infosPourTpl['taxons'][$id] = $nom['num_taxonomique'];
65
				$this->infosPourTpl['taxons'][$id] = $nom['num_taxonomique'];
74
			}
66
			}
75
		}
67
		}
76
	}
68
	}
Line 77... Line -...
77
	
-
 
78
	// TODO : utiliser le conteneur pour charger tous les objets de cette classe
-
 
79
	private function chargerRepartition() {
-
 
80
		$conteneur = new Conteneur();
-
 
81
		$cartesWs = $conteneur->getApiCartes();
-
 
82
		$cartesWs->setProjet('chorodep');
-
 
83
		$cartesWs->setLargeur('108x101');
-
 
84
		$urls = array();
-
 
85
		foreach ($this->noms as $id => $nom) {
-
 
86
			if (array_key_exists('nom_retenu.id', $nom)) {
-
 
87
				$id = $nom['nom_retenu.id'];
-
 
88
				$cartesWs->setId("nn:$id");
-
 
89
				if (array_key_exists($id, $urls) == false) {
-
 
90
					$urls[$id] = $cartesWs->getUrlPng();
-
 
91
				}
-
 
92
			}
-
 
93
		}
-
 
94
		$this->infosPourTpl['repartition']['urls'] = $urls;
-
 
95
	}
-
 
96
 
-
 
97
 
-
 
Line -... Line 69...
-
 
69
	
-
 
70
	
-
 
71
	
-
 
72
	private function obtenirUrlsPhotos() {
-
 
73
		$this->imagesService->setProjet('cel');
-
 
74
		$ids = $this->extraireIdDesNoms();
-
 
75
		$urls = $this->imagesService->getUrlsImagesParIdsNoms($ids);
98
 
76
		$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReftaxDesIds($urls);
99
	
77
	}
100
	private function extraireIdDesNoms() {
78
	private function extraireIdDesNoms() {
101
		$ids = array();
79
		$ids = array();
102
		foreach ($this->noms as $id => $nom) {
80
		foreach ($this->noms as $id => $nom) {
Line 113... Line 91...
113
				}
91
				}
114
			}
92
			}
115
		}
93
		}
116
		return $ids;
94
		return $ids;
117
	}
95
	}
118
 
-
 
119
	private function supprimerCodeReftaxDesIds($urls) {
96
	private function supprimerCodeReftaxDesIds($urls) {
120
		$urlsNettoyees = array();
97
		$urlsNettoyees = array();
121
		foreach ($urls as $id => $url) {
98
		foreach ($urls as $id => $url) {
122
			$id = $this->supprimerCodeReftax($id);
99
			$id = $this->supprimerCodeReftax($id);
123
			$urlsNettoyees[$id] = $url;
100
			$urlsNettoyees[$id] = $url;
124
		}
101
		}
125
		return $urlsNettoyees;
102
		return $urlsNettoyees;
126
	}
103
	}
127
 
-
 
128
	private function supprimerCodeReftax($chaine) {
104
	private function supprimerCodeReftax($chaine) {
129
		$codeReftax = $this->parametres->reftaxCourant.'.';
105
		$codeReftax = $this->parametres->reftaxCourant.'.';
130
		$chaine = str_replace($codeReftax, '', $chaine);
106
		$chaine = str_replace($codeReftax, '', $chaine);
131
		return $chaine;
107
		return $chaine;
132
	}
108
	}
-
 
109
	
-
 
110
	
-
 
111
	
-
 
112
	// TODO : utiliser le conteneur pour charger tous les objets de cette classe
-
 
113
	private function chargerRepartition() {
-
 
114
		$conteneur = new Conteneur();
-
 
115
		$cartesWs = $conteneur->getApiCartes();
-
 
116
		$cartesWs->setProjet('chorodep');
-
 
117
		$cartesWs->setLargeur('108x101');
-
 
118
		$urls = array();
-
 
119
		foreach ($this->noms as $id => $nom) {
-
 
120
			if (array_key_exists('nom_retenu.id', $nom)) {
-
 
121
				$id = $nom['nom_retenu.id'];
-
 
122
				$cartesWs->setId("nn:$id");
-
 
123
				if (array_key_exists($id, $urls) == false) {
-
 
124
					$urls[$id] = $cartesWs->getUrlPng();
-
 
125
				}
-
 
126
			}
-
 
127
		}
-
 
128
		$this->infosPourTpl['repartition']['urls'] = $urls;
-
 
129
	}
-
 
130
 
Line -... Line 131...
-
 
131
 
-
 
132
	private function extraireInfosNomsPourTplDetermination() {
-
 
133
		$tri = $this->diviserResultats();
-
 
134
		$this->infosPourTpl['nomsSansCorrespondance'] = isset($tri['sansCorres']) ? $tri['sansCorres'] : false;
-
 
135
		$this->infosPourTpl['noms'] = isset($tri['retenus'])  ? $tri['retenus'] : false;
-
 
136
		$this->infosPourTpl['synonymes'] = isset($tri['synonymes'] ) ?  $tri['synonymes']  : false;
133
 
137
	}
134
	/**
138
	/**
135
	 * division ordonnée par  
139
	 * division ordonnée par  
136
	 * 1 - noms retenus qui commencent par la requete  
140
	 * 1 - noms retenus qui commencent par la requete  
137
	 * 2 - requete contenue dans un synonyme dont le nom retenu ne contient pas la requete
141
	 * 2 - requete contenue dans un synonyme dont le nom retenu ne contient pas la requete
Line 173... Line 177...
173
		$tri['retenus'] = $retenus;
177
		$tri['retenus'] = $retenus;
174
		$tri['synonymes'] = $synonymes;
178
		$tri['synonymes'] = $synonymes;
175
		$tri['sansCorres'] = $sansCorres;
179
		$tri['sansCorres'] = $sansCorres;
176
		return $tri;
180
		return $tri;
177
	}
181
	}
178
	
-
 
179
	private  function retournerInfosNomRetenu($cle, $nom_sci, $rang) {
182
	private  function retournerInfosNomRetenu($cle, $nom_sci, $rang) {
180
		$infos = array();
183
		$infos = array();
181
		$infos['nomSciRetenu'] = $nom_sci;
184
		$infos['nomSciRetenu'] = $nom_sci;
182
		$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom,  strtolower($this->parametres->masqueRecherche), $nom_sci);
185
		$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom,  strtolower($this->parametres->masqueRecherche), $nom_sci);
183
		$infos['rang'] = $rang;
186
		$infos['rang'] = $rang;
184
		return $infos;
187
		return $infos;
185
	}	
188
	}	
186
	
-
 
187
	
-
 
188
	private  function retournerInfosSynonyme($cle, $valeurs) {
189
	private  function retournerInfosSynonyme($cle, $valeurs) {
189
		$infos = array();
190
		$infos = array();
190
		$infos['nn'] = $cle;
191
		$infos['nn'] = $cle;
191
		$infos['nomSci'] = $valeurs['nom_sci'];
192
		$infos['nomSci'] = $valeurs['nom_sci'];
192
		$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, $this->parametres->masqueRecherche, $valeurs['nom_retenu.libelle']);
193
		$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, $this->parametres->masqueRecherche, $valeurs['nom_retenu.libelle']);
193
		return $infos;
194
		return $infos;
194
	}
195
	}
195
	
-
 
196
	private function classerAlphabetiquement($champs, $valeurs) {
-
 
197
		$this->trieur->setTableau($valeurs);
-
 
198
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
-
 
199
		return $this->trieur->trier();
-
 
200
	}
-
 
201
	
-
 
202
	
-
 
203
	private function extraireInfosNomsPourTplDetermination() {	
-
 
204
		$tri = $this->diviserResultats();
-
 
205
		$this->infosPourTpl['nomsSansCorrespondance'] = isset($tri['sansCorres']) ? $tri['sansCorres'] : false;
-
 
206
		$this->infosPourTpl['noms'] = isset($tri['retenus'])  ? $tri['retenus'] : false;
-
 
207
		$this->infosPourTpl['synonymes'] = isset($tri['synonymes'] ) ?  $tri['synonymes']  : false;
-
 
208
	
-
 
209
	}
-
 
210
	
-
 
211
	private function donnerNombreResultatRetenus() {
-
 
212
		$nbre = 0;
-
 
213
		foreach ($this->infosPourTpl['noms'] as $lignes) {
-
 
214
			$nbre += count($lignes);
-
 
215
			if ($nbre >= 3 ) {
-
 
216
				break;
-
 
217
			}
-
 
218
		}
-
 
219
		return $nbre;
-
 
220
	}
-
 
221
 
-
 
222
	public function trier() {		
196
	public function trier() {		
223
		if ($this->donnerNombreResultatRetenus() <= 3) { // classement par score
197
		if ($this->donnerNombreResultatRetenus() <= 3) { // classement par score
224
			$nomsRetenus = array();
198
			$nomsRetenus = array();
225
			foreach ($this->infosPourTpl['noms'] as $categorie) { //ote la division des retenus
199
			foreach ($this->infosPourTpl['noms'] as $categorie) { //ote la division des retenus
226
				$nomsRetenus += $categorie;
200
				$nomsRetenus += $categorie;
Line 239... Line 213...
239
			$this->infosPourTpl['noms'] = $nomsRetenus;
213
			$this->infosPourTpl['noms'] = $nomsRetenus;
240
			$this->infosPourTpl['nomsSansCorrespondance'] = 
214
			$this->infosPourTpl['nomsSansCorrespondance'] = 
241
			$this->classerAlphabetiquement('nomSciRetenu', $this->infosPourTpl['nomsSansCorrespondance'] );
215
			$this->classerAlphabetiquement('nomSciRetenu', $this->infosPourTpl['nomsSansCorrespondance'] );
242
		}
216
		}
243
	}
217
	}
-
 
218
	private function donnerNombreResultatRetenus() {
-
 
219
		$nbre = 0;
-
 
220
		foreach ($this->infosPourTpl['noms'] as $lignes) {
-
 
221
			$nbre += count($lignes);
-
 
222
			if ($nbre >= 3 ) {
-
 
223
				break;
-
 
224
			}
-
 
225
		}
-
 
226
		return $nbre;
-
 
227
	}
Line 244... Line 228...
244
	
228
	
245
	private function ajouterAuxNomsScoreSimilariteAvec($masque) {
229
	private function ajouterAuxNomsScoreSimilariteAvec($masque) {
246
		$nom_demande_ss = strtolower($this->manipulateurDeChaine->supprimerAccents($masque));
230
		$nom_demande_ss = strtolower($this->manipulateurDeChaine->supprimerAccents($masque));
247
		foreach ($this->infosPourTpl['noms'] as $id => $nom) {
231
		foreach ($this->infosPourTpl['noms'] as $id => $nom) {
Line 253... Line 237...
253
			$score = $score + (similar_text($nom_demande_ss, $nom_flou_ss) * 3);
237
			$score = $score + (similar_text($nom_demande_ss, $nom_flou_ss) * 3);
254
			$nom['score'] = $score;
238
			$nom['score'] = $score;
255
			$this->infosPourTpl['noms'][$id] = $nom;
239
			$this->infosPourTpl['noms'][$id] = $nom;
256
		}
240
		}
257
	}
241
	}
-
 
242
	private function classerAlphabetiquement($champs, $valeurs) {
-
 
243
		$this->trieur->setTableau($valeurs);
-
 
244
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
-
 
245
		return $this->trieur->trier();
-
 
246
	}
Line -... Line 247...
-
 
247
 
-
 
248
	
258
 
249
	
259
	public function surligner() {
250
	public function surligner() {
260
		$this->definirMotsASurligner();
251
		$this->definirMotsASurligner();
261
		foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
252
		foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
262
			$this->infosPourTpl['noms'][$idNom]['nomSciRetenu'] = $this->surlignerMotsMasqueRecherche($nom['nomSciRetenu']);
253
			$this->infosPourTpl['noms'][$idNom]['nomSciRetenu'] = $this->surlignerMotsMasqueRecherche($nom['nomSciRetenu']);
Line 265... Line 256...
265
					$this->infosPourTpl['synonymes'][$idNom][$idSyn]['nomSci'] = $this->surlignerMotsMasqueRecherche($synonyme['nomSci']);
256
					$this->infosPourTpl['synonymes'][$idNom][$idSyn]['nomSci'] = $this->surlignerMotsMasqueRecherche($synonyme['nomSci']);
266
				}
257
				}
267
			}
258
			}
268
		}
259
		}
269
	}
260
	}
270
 
-
 
271
	private function definirMotsASurligner() {
261
	private function definirMotsASurligner() {
272
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
262
		$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
273
	}
263
	}
274
 
-
 
275
	private function surlignerMotsMasqueRecherche($nom) {
264
	private function surlignerMotsMasqueRecherche($nom) {
276
		$this->surligneur->setTexte($nom);
265
		$this->surligneur->setTexte($nom);
277
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);
266
		$nom = $this->surligneur->surlignerMots($this->motsASurligner);
278
		return $nom;
267
		return $nom;
279
	}
268
	}