Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 880 Rev 931
Line 32... Line 32...
32
		
32
		
33
		$this->conteneur = new Conteneur();
33
		$this->conteneur = new Conteneur();
34
		$this->apiCartes = $this->conteneur->getApiCartes();
34
		$this->apiCartes = $this->conteneur->getApiCartes();
Line 35... Line -...
35
	}
-
 
36
 
-
 
37
	private function chargerRepartition() {
-
 
38
		$this->apiCartes->setProjet('chorodep');
-
 
39
		$this->apiCartes->setLargeur('108x101');
-
 
40
		$urls = array();
-
 
41
		foreach ($this->noms as $nom) {
-
 
42
			if (array_key_exists('nom_retenu.code', $nom)) {
-
 
43
				$id = $nom['nom_retenu.code'];
-
 
44
				$id = $this->supprimerCodeReftaxAvecNn($id);
-
 
45
				$this->apiCartes->setId("nn:$id");
-
 
46
				if (array_key_exists($id, $urls) == false) {
-
 
47
					$urls[$id] = $this->apiCartes->getUrlPng();
-
 
48
				}
-
 
49
			}
-
 
50
		}
-
 
51
		$this->infosPourTpl['repartition']['urls'] = $urls;
-
 
52
	}
35
	}
53
 
36
 
54
	public function getTplInfos() {
37
	public function getTplInfos() {
Line 55... Line 38...
55
		return $this->infosPourTpl;
38
		return $this->infosPourTpl;
56
	}
39
	}
57
 
40
 
Line 58... Line 41...
58
	public function getTplNom() {
41
	public function getTplNom() {
-
 
42
		return self::TPL_VUE;
59
		return self::TPL_VUE;
43
	}
60
	}
-
 
61
 
-
 
62
	public function formater() {
44
 
-
 
45
	public function formater() {
63
		$this->obtenirUrlsPhotos();
46
		$this->obtenirUrlsDessins();
Line 64... Line 47...
64
		$this->extraireInfosNomsPourTplDetermination();
47
		$this->obtenirUrlsPhotos();
-
 
48
		$this->chargerRepartition();
65
		$this->obtenirUrlsImagesCoste();
49
		$this->extraireInfosNomsPourTplDetermination();
66
		$this->chargerRepartition();
50
	}
67
	}
51
	
68
	
52
	private function obtenirUrlsDessins() {
69
	private function obtenirUrlsImagesCoste() {
53
		if (Config::get(Registre::get('parametres.referentiel').'.baseDessins') != "") {
70
		$this->extraireInfosTaxons();
54
			$this->extraireInfosTaxons();
71
		$this->imagesService->setProjet('coste');
55
			$this->imagesService->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseDessins'));
72
		$tax = implode(',', $this->infosPourTpl['taxons']);
56
			$tax = implode(',', $this->infosPourTpl['taxons']);
73
		$this->imagesService->setNnTaxon($tax);
57
			$this->imagesService->setNnTaxon($tax);
74
		$costeImg = $this->imagesService->getInfosImagesTaxons();
58
			$costeImg = $this->imagesService->getInfosImagesTaxons();
-
 
59
			if (!empty($costeImg)) {
75
		if (!empty($costeImg)) {
60
				foreach ($costeImg as  $infos) {
76
			foreach ($costeImg as  $infos) {
61
					$num_taxon = $infos['num_taxonomique'];
77
				$num_taxon = $infos['num_taxonomique'];
62
					$images[$num_taxon][] = $infos['binaire.href'];
Line 78... Line 63...
78
				$images[$num_taxon][] = $infos['binaire.href'];
63
					$this->infosPourTpl['imagesCoste'] = $images;
Line 91... Line 76...
91
	}
76
	}
Line 92... Line 77...
92
 
77
 
93
	private function obtenirUrlsPhotos() {
78
	private function obtenirUrlsPhotos() {
94
		$nns = $this->extraireNnDesNoms();
79
		$nns = $this->extraireNnDesNoms();
95
		$urls = $this->imagesService->getUrlsImagesParIdsNoms($nns);
80
		$urls = $this->imagesService->getUrlsImagesParIdsNoms($nns);
96
		$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReftaxDesUrls($urls);
81
		$this->infosPourTpl['imagesUrls'] = $this->supprimerCodeReferentielDesUrls($urls);
Line 97... Line 82...
97
	}
82
	}
98
 
83
 
99
	private function extraireNnDesNoms() {
84
	private function extraireNnDesNoms() {
100
		$nns = array();
85
		$nns = array();
101
		foreach ($this->noms as $id => $nom) {
86
		foreach ($this->noms as $id => $nom) {
102
			if (array_key_exists('nom_retenu.code', $nom)) {
87
			if (array_key_exists('nom_retenu.code', $nom)) {
103
				if (in_array($nom['nom_retenu.code'], $nns) == false) {
88
				if (in_array($nom['nom_retenu.code'], $nns) == false) {
104
					$idAAjouter = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
89
					$idAAjouter = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
105
					if (is_numeric($idAAjouter)) {
90
					if (is_numeric($idAAjouter)) {
106
						$nns[] = $idAAjouter;
91
						$nns[] = $idAAjouter;
107
					}
92
					}
108
				}
93
				}
109
			}
94
			}
110
		}
95
		}
Line 111... Line 96...
111
		return $nns;
96
		return $nns;
112
	}
97
	}
113
 
98
 
114
	private function supprimerCodeReftaxDesUrls($urls) {
99
	private function supprimerCodeReferentielDesUrls($urls) {
115
		$urlsNettoyees = array();
100
		$urlsNettoyees = array();
116
		foreach ($urls as $id => $url) {
101
		foreach ($urls as $id => $url) {
117
			$id = $this->supprimerCodeReftax($id);
102
			$id = $this->supprimerCodeReferentiel($id);
118
			$urlsNettoyees[$id] = $url;
103
			$urlsNettoyees[$id] = $url;
Line 119... Line 104...
119
		}
104
		}
120
		return $urlsNettoyees;
105
		return $urlsNettoyees;
121
	}
106
	}
122
 
107
 
123
	private function supprimerCodeReftax($chaine) {
108
	private function supprimerCodeReferentiel($chaine) {
Line -... Line 109...
-
 
109
		$codeReferentiel = $this->parametres->referentielCourant.'.';
-
 
110
		$chaine = str_replace($codeReferentiel, '', $chaine);
-
 
111
		return $chaine;
-
 
112
	}
-
 
113
	
-
 
114
	private function chargerRepartition() {
-
 
115
		if (Config::get(Registre::get('parametres.referentiel').'.baseRepartition') != "") {
-
 
116
			$this->apiCartes->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseRepartition'));
-
 
117
			$this->apiCartes->setLargeur('108x101');
-
 
118
			$urls = array();
-
 
119
			foreach ($this->noms as $nom) {
-
 
120
				if (array_key_exists('nom_retenu.code', $nom)) {
-
 
121
					$id = $nom['nom_retenu.code'];
-
 
122
					$id = $this->supprimerCodeReferentielAvecNn($id);
-
 
123
					$this->apiCartes->setId("nn:$id");
-
 
124
					if (array_key_exists($id, $urls) == false) {
-
 
125
						$urls[$id] = $this->apiCartes->getUrlPng();
-
 
126
					}
-
 
127
				}
124
		$codeReftax = $this->parametres->reftaxCourant.'.';
128
			}
125
		$chaine = str_replace($codeReftax, '', $chaine);
129
			$this->infosPourTpl['repartition']['urls'] = $urls;
126
		return $chaine;
130
		}
127
	}
131
	}
128
	
132
	
Line 139... Line 143...
139
	
143
	
140
 
144
 
141
	private function extraireInfosNomsPourTplDetermination() {
145
	private function extraireInfosNomsPourTplDetermination() {
142
		$taxons = array();
146
		$taxons = array();
143
		foreach ($this->noms as $idNomCourant => $nom) {
147
		foreach ($this->noms as $idNomCourant => $nom) {
144
			$nn = $this->supprimerCodeReftaxAvecNn($nom['nom_retenu.code']);
148
			$nn = $this->supprimerCodeReferentielAvecNn($nom['nom_retenu.code']);
145
			$nom_min = strtolower($nom['nom_vernaculaire']);
149
			$nom_min = strtolower($nom['nom_vernaculaire']);
146
			$nom_ss_accent = $this->supprimerAccents($nom_min);
150
			$nom_ss_accent = $this->supprimerAccents($nom_min);
147
			if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).' |^'.strtolower($this->parametres->masqueRecherche).'$/', $nom_ss_accent )) {
151
			if (preg_match('/^'.strtolower($this->parametres->masqueRecherche).' |^'.strtolower($this->parametres->masqueRecherche).'$/', $nom_ss_accent )) {
148
				//au moins un debute par la requête
152
				//au moins un debute par la requête
149
				if (isset($taxons) && array_key_exists($nn, $taxons[0]) == false) { 
153
				if (isset($taxons) && array_key_exists($nn, $taxons[0]) == false) { 
150
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
154
					$taxons[0][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
151
				}
155
				}
152
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
156
				$taxons[0][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
153
			} else { 
157
			} else { 
154
				//contient
158
				//contient
155
				if (isset($taxons) && array_key_exists($nn, $taxons[1]) == false) {
159
				if (isset($taxons) && (!isset($taxons[1]) || array_key_exists($nn, $taxons[1]) == false)) {
156
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
160
					$taxons[1][$nn] = $this->renvoyerInfosTaxon($nom['taxon'], $nn);
157
				}
161
				}
158
				$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
162
				$taxons[1][$nn]['nomVerna'][] = $this->renvoyerInfosNomVerna($nom);
Line 174... Line 178...
174
		$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
178
		$taxon['urlFiche'] = $this->urls->obtenirUrlFiche($nn, $this->parametres->typeNom, $this->parametres->masqueRecherche);
175
		$taxon['repartition_vignette'] = $this->chargerRepartition($nn);
179
		$taxon['repartition_vignette'] = $this->chargerRepartition($nn);
176
		return $taxon;
180
		return $taxon;
177
	}
181
	}
Line 178... Line 182...
178
 
182
 
179
	private function supprimerCodeReftaxAvecNn($nn) {
183
	private function supprimerCodeReferentielAvecNn($nn) {
180
		$codeReftax = $this->parametres->reftaxCourant.'.nn:';
184
		$codeReferentiel = $this->parametres->referentielCourant.'.nn:';
181
		return str_replace($codeReftax, '', $nn);
185
		return str_replace($codeReferentiel, '', $nn);
Line 182... Line 186...
182
	}
186
	}
183
 
187
 
184
	//tri alphabétique des noms scientifiques par catégorie (débute par , contient )
188
	//tri alphabétique des noms scientifiques par catégorie (débute par , contient )
Line 190... Line 194...
190
		$this->infosPourTpl['noms'] = $verna;
194
		$this->infosPourTpl['noms'] = $verna;
191
	}
195
	}
Line 192... Line 196...
192
	
196
	
193
	private function classerAlphabetiquement($champs, $valeurs) {
197
	private function classerAlphabetiquement($champs, $valeurs) {
194
		$this->trieur->setTableau($valeurs);
198
		$this->trieur->setTableau($valeurs);
195
		$this->trieur->setChampsEtOrdres(array($champs => SORT_NATURAL));
199
		$this->trieur->setChampsEtOrdres(array($champs => 'nat'));
196
		return $this->trieur->trier();
200
		return $this->trieur->trier();