Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1428 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1428 Rev 1468
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe gérant les images.
4
 * Classe gérant les images.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Images extends Eflore {
15
class Images extends Eflore {
16
	
16
	
17
	private $nntaxon;
17
	private $nntaxon;
18
	private $limite;
18
	private $limite;
19
	private $depart;
19
	private $depart;
20
 
20
 
21
	public function setNnTaxon($nntax) {
21
	public function setNnTaxon($nntax) {
22
		$this->nntaxon = $nntax;
22
		$this->nntaxon = $nntax;
23
	}
23
	}
24
	
24
	
25
	public function setLimite($limite) {
25
	public function setLimite($limite) {
26
		$this->limite = $limite;
26
		$this->limite = $limite;
27
	}
27
	}
28
	
28
	
29
	public function setDepart($depart) {
29
	public function setDepart($depart) {
30
		$this->depart = $depart;
30
		$this->depart = $depart;
31
	}
31
	}
32
	
32
	
33
	//TODO: créer des fonctions spécifiques cel et photoflora pour plus de clarté ?
33
	//TODO: créer des fonctions spécifiques cel et photoflora pour plus de clarté ?
34
	public function getUrlsImagesParIdsNoms(Array $idsNoms) {
34
	public function getUrlsImagesParIdsNoms(Array $idsNoms) {
35
		$infosImages = $this->getInfosImagesParIdsNoms($idsNoms);
35
		$infosImages = $this->getInfosImagesParIdsNoms($idsNoms);
36
		$urls = array();
36
		$urls = array();
37
		if (count($infosImages) > 0) {
37
		if (count($infosImages) > 0) {
38
			foreach ($infosImages as $img) {
38
			foreach ($infosImages as $img) {
39
				$id = $img['determination.nom_sci.code'];
39
				$id = $img['determination.nom_sci.code'];
40
				$urls[$id][] = $img['binaire.href'];
40
				$urls[$id][] = $img['binaire.href'];
41
			}
41
			}
42
		}
42
		}
43
		return $urls;
43
		return $urls;
44
	}
44
	}
45
 
45
 
46
	// retourne les urls d'une série d'images tirées de del, avec en premier les
46
	// retourne les urls d'une série d'images tirées de del, avec en premier les
47
	// images d'organes les mieux votées, et ensuite toute les autres images disponibles
47
	// images d'organes les mieux votées, et ensuite toute les autres images disponibles
48
	public function getUrlsImagesOrganesParIdsNom($idNom) {
48
	public function getUrlsImagesOrganesParIdsNom($idNom) {
49
		$infosImages0 = $this->getInfosMeilleuresImagesParTag($idNom, array('fleur', 'feuille', 'fruit', 'ecorce', 'port', 'rameau'), Eflore::PROTOCOLE_CAPITALISATION, 6);
49
		$infosImages0 = $this->getInfosMeilleuresImagesParTag($idNom, array('fleur', 'feuille', 'fruit', 'ecorce', 'port', 'rameau'), Eflore::PROTOCOLE_CAPITALISATION, 6);
50
		$infosImages1 = $this->getInfosImagesParIdsNoms(array($idNom));
50
		$infosImages1 = $this->getInfosImagesParIdsNoms(array($idNom));
51
		$urls = array();
51
		$urls = array();
52
		foreach ($infosImages0 as $imgs) {
52
		foreach ($infosImages0 as $imgs) {
53
			foreach ($imgs as $img) {
53
			foreach ($imgs as $img) {
54
				$id = $img['determination.nom_sci.code'];
54
				$id = $img['determination.nom_sci.code'];
55
				$urls[$id][] = $img['binaire.href'];
55
				$urls[$id][] = $img['binaire.href'];
56
			}
56
			}
57
		}
57
		}
58
		foreach ($infosImages1 as $img) {
58
		foreach ($infosImages1 as $img) {
59
			$id = $img['determination.nom_sci.code'];
59
			$id = $img['determination.nom_sci.code'];
60
			if (! in_array($img['binaire.href'], $urls[$id])) {
60
			if (! in_array($img['binaire.href'], $urls[$id])) {
61
				$urls[$id][] = $img['binaire.href'];
61
				$urls[$id][] = $img['binaire.href'];
62
			}
62
			}
63
		}
63
		}
64
		return $urls;
64
		return $urls;
65
	}
65
	}
66
 
66
 
67
	public function getInfosImagesParIdsNoms(Array $idsNoms) {
67
	public function getInfosImagesParIdsNoms(Array $idsNoms) {
68
		$pas = 800;
68
		$pas = 800;
69
		if(count($idsNoms) >= $pas) {
69
		if(count($idsNoms) >= $pas) {
70
			$images = array();
70
			$images = array();
71
			$idsPartages = array_chunk($idsNoms, $pas);
71
			$idsPartages = array_chunk($idsNoms, $pas);
72
			foreach ($idsPartages as $sousEnsembleIdsNoms) {
72
			foreach ($idsPartages as $sousEnsembleIdsNoms) {
73
				$url = $this->getUrlImagesParIdsNoms($sousEnsembleIdsNoms);
73
				$url = $this->getUrlImagesParIdsNoms($sousEnsembleIdsNoms);
74
				$donnees = $this->chargerDonnees($url);
74
				$donnees = $this->chargerDonnees($url);
75
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
75
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
76
				$images += $resultats;
76
				$images += $resultats;
77
			}
77
			}
78
		} else {
78
		} else {
79
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
79
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
80
			$donnees = $this->chargerDonnees($url);
80
			$donnees = $this->chargerDonnees($url);
81
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
81
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
82
		}
82
		}
83
		return $this->formaterResultatImages($images);
83
		return $this->formaterResultatImages($images);
84
	}
84
	}
85
	
85
	
86
	public function getInfosTrancheImagesParIdsNoms($idNom, $limite = 12) {
86
	public function getInfosTrancheImagesParIdsNoms($idNom, $limite = 12) {
87
		// 12 fait 4 lignes de 3 images donc bien pour l'affichage
87
		// 12 fait 4 lignes de 3 images donc bien pour l'affichage
88
		$url = $this->getUrlImagesParIdsNoms($idNom, $limite);
88
		$url = $this->getUrlImagesParIdsNoms($idNom, $limite);
89
		$donnees = $this->chargerDonnees($url);
89
		$donnees = $this->chargerDonnees($url);
90
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
90
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
91
		return $this->formaterResultatImages($images);
91
		return $this->formaterResultatImages($images);
92
	}
92
	}
93
 
93
 
94
	public function getInfosImageParIdImage($id_image) {
94
	public function getInfosImageParIdImage($id_image) {
95
		$tpl = $this->obtenirSqueletteSelonApi('imagesPopup');
95
		$tpl = $this->obtenirSqueletteSelonApi('imagesPopup');
96
		$url = $this->formaterUrl($tpl, array('id' => $id_image, 'referentiel' => Registre::get('parametres.referentiel')));
96
		$url = $this->formaterUrl($tpl, array('id' => $id_image, 'referentiel' => Registre::get('parametres.referentiel')));
97
		$image = $this->chargerDonnees($url);
97
		$image = $this->chargerDonnees($url);
98
		return $this->formaterResultatImages($image, true);
98
		return $this->formaterResultatImages($image, true);
99
	}
99
	}
100
	
100
	
101
	public function getInfosImages() {
101
	public function getInfosImages() {
102
		$url = $this->getUrlImages();
102
		$url = $this->getUrlImages();
103
		$donnees = $this->chargerDonnees($url);
103
		$donnees = $this->chargerDonnees($url);
104
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
104
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
105
		return $this->formaterResultatImages($images);
105
		return $this->formaterResultatImages($images);
106
	}
106
	}
107
 
107
 
108
	public function getInfosImagesTaxons() {
108
	public function getInfosImagesTaxons() {
109
		$pas = 800;
109
		$pas = 800;
110
		$idsTaxons = explode(',', $this->nntaxon);
110
		$idsTaxons = explode(',', $this->nntaxon);
111
		if(count($idsTaxons) >= $pas) {
111
		if(count($idsTaxons) >= $pas) {
112
			$images = array();
112
			$images = array();
113
			$idsPartages = array_chunk($idsTaxons, $pas);
113
			$idsPartages = array_chunk($idsTaxons, $pas);
114
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
114
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
115
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
115
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
116
				$donnees = $this->chargerDonnees($url);
116
				$donnees = $this->chargerDonnees($url);
117
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
117
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
118
				$images += $resultats;
118
				$images += $resultats;
119
			}
119
			}
120
		} else {
120
		} else {
121
			$url = $this->getUrlImagesTaxons($idsTaxons);
121
			$url = $this->getUrlImagesTaxons($idsTaxons);
122
			$donnees = $this->chargerDonnees($url);
122
			$donnees = $this->chargerDonnees($url);
123
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
123
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
124
		}
124
		}
125
		return $this->formaterResultatImages($images);
125
		return $this->formaterResultatImages($images);
126
	}
126
	}
127
 
127
 
128
	public function getInfosPremiereImageParIdsNoms($idsNoms) {
128
	public function getInfosPremiereImageParIdsNoms($idsNoms) {
129
		$url = $this->getUrlPremiereImageParIdsNoms($idsNoms);
129
		$url = $this->getUrlPremiereImageParIdsNoms($idsNoms);
130
		$donnees = $this->chargerDonnees($url);
130
		$donnees = $this->chargerDonnees($url);
131
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
131
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
132
		return $this->formaterResultatImages($images);
132
		return $this->formaterResultatImages($images);
133
	}
133
	}
134
 
134
 
135
	public function getInfosImagesGalerieMobile($nn) {
135
	public function getInfosImagesGalerieMobile($nn) {
136
		$url = $this->getUrlImagesGalerieMobile($nn);
136
		$url = $this->getUrlImagesGalerieMobile($nn);
137
		$donnees = $this->chargerDonnees($url);
137
		$donnees = $this->chargerDonnees($url);
138
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
138
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
139
		return $images;
139
		return $images;
140
	}
140
	}
141
 
141
 
142
	/**
142
	/**
143
	 * Retourne les $limite images ayant le plus de votes pour CHAQUE tag de $tags pour le protocole $protocole
143
	 * Retourne les $limite images ayant le plus de votes pour CHAQUE tag de $tags pour le protocole $protocole
144
	 */
144
	 */
145
	public function getInfosMeilleuresImagesParTag($nn, $tags, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
145
	public function getInfosMeilleuresImagesParTag($nn, $tags, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
146
		if (! is_array($tags)) {
146
		if (! is_array($tags)) {
147
			$tags = array($tags);
147
			$tags = array($tags);
148
		}
148
		}
149
		$images_tag = array();
149
		$images_tag = array();
150
		foreach ($tags as $tag) {
150
		foreach ($tags as $tag) {
151
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, $protocole, $limite, $format);
151
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, $protocole, $limite, $format);
152
			$donnees = $this->chargerDonnees($url);
152
			$donnees = $this->chargerDonnees($url);
153
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
153
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
154
			$images_tag[$tag] = $this->formaterResultatImagesDel($images);
154
			$images_tag[$tag] = $this->formaterResultatImagesDel($images);
155
		}
155
		}
156
		return $images_tag;
156
		return $images_tag;
157
	}
157
	}
158
 
158
 
159
	/**
159
	/**
160
	 * Retourne l'image ayant le plus de votes pour le pour capitalisation d'images, pour le premier tags de $tags. S'il
160
	 * Retourne l'image ayant le plus de votes pour le pour capitalisation d'images, pour le premier tags de $tags. S'il
161
	 * n'y a aucune image pour le premier tag, parcourt les autres tags jusqu'à en trouver une.
161
	 * n'y a aucune image pour le premier tag, parcourt les autres tags jusqu'à en trouver une.
162
	 */
162
	 */
163
	public function getInfosMeilleureImageParPrioriteTags($nn, $tags, $format = 'CRS') {
163
	public function getInfosMeilleureImageParPrioriteTags($nn, $tags, $format = 'CRS') {
164
		if (! is_array($tags)) {
164
		if (! is_array($tags)) {
165
			$tags = array($tags);
165
			$tags = array($tags);
166
		}
166
		}
167
		$image = null;
167
		$image = null;
168
		foreach ($tags as $tag) {
168
		foreach ($tags as $tag) {
169
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, Eflore::PROTOCOLE_CAPITALISATION, 1, $format);
169
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, Eflore::PROTOCOLE_CAPITALISATION, 1, $format);
170
			$donnees = $this->chargerDonnees($url);
170
			$donnees = $this->chargerDonnees($url);
171
			$image = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
171
			$image = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
172
			$image = $this->formaterResultatImagesDel($image);
172
			$image = $this->formaterResultatImagesDel($image);
173
			if (empty($image) == false) {
173
			if (empty($image) == false) {
174
				break;
174
				break;
175
			}
175
			}
176
		}
176
		}
177
		//echo "<pre>" . print_r($image, true) . "</pre>";
177
		//echo "<pre>" . print_r($image, true) . "</pre>";
178
		if (is_array($image)) {
178
		if (is_array($image)) {
179
			$image = array_pop($image);
179
			$image = array_pop($image);
180
		}
180
		}
181
		return $image;
181
		return $image;
182
	}
182
	}
183
 
183
 
184
	private function getUrlImagesParIdsNoms($idsNoms, $limite = 801) {
184
	private function getUrlImagesParIdsNoms($idsNoms, $limite = 801) {
185
		$tpl = $this->obtenirSqueletteSelonApi('imagesResultatsDetermination');
185
		$tpl = $this->obtenirSqueletteSelonApi('imagesResultatsDetermination');
186
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'), 'limite' => $limite);
186
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'), 'limite' => $limite);
187
		$url = $this->formaterUrl($tpl, $params);
187
		$url = $this->formaterUrl($tpl, $params);
188
		return $url;
188
		return $url;
189
	}
189
	}
190
 
190
 
191
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
191
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
192
		$tpl = $this->obtenirSqueletteSelonApi('imagesPremiere');
192
		$tpl = $this->obtenirSqueletteSelonApi('imagesPremiere');
193
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'));
193
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'));
194
		$url = $this->formaterUrl($tpl, $params);
194
		$url = $this->formaterUrl($tpl, $params);
195
		return $url;
195
		return $url;
196
	}
196
	}
197
 
197
 
198
	private function getUrlImages($nn = false) {
198
	private function getUrlImages($nn = false) {
199
		$tpl = $this->obtenirSqueletteSelonApi('images');
199
		$tpl = $this->obtenirSqueletteSelonApi('images');
200
		if ($this->getApi() == Eflore::API_EFLORE) {
200
		if ($this->getApi() == Eflore::API_EFLORE) {
201
			$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart, 'referentiel' => Registre::get('parametres.referentiel'));
201
			$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart, 'referentiel' => Registre::get('parametres.referentiel'));
202
		}
202
		}
203
		$url = $this->formaterUrl($tpl, $params);
203
		$url = $this->formaterUrl($tpl, $params);
204
		return $url;
204
		return $url;
205
	}
205
	}
206
 
206
 
207
	private function getUrlImagesTaxons($idsTaxons) {
207
	private function getUrlImagesTaxons($idsTaxons) {
208
		$tpl = $this->obtenirSqueletteSelonApi('imagesTaxons');
208
		$tpl = $this->obtenirSqueletteSelonApi('imagesTaxons');
209
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons, 'referentiel' => Registre::get('parametres.referentiel'));
209
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons, 'referentiel' => Registre::get('parametres.referentiel'));
210
		$url = $this->formaterUrl($tpl, $params);
210
		$url = $this->formaterUrl($tpl, $params);
211
		return $url;
211
		return $url;
212
	}
212
	}
213
 
213
 
214
	private function getUrlImagesGalerieMobile($nn) {
214
	private function getUrlImagesGalerieMobile($nn) {
215
		$tpl = Config::get('delGalerieMobileTpl');
215
		$tpl = Config::get('delGalerieMobileTpl');
216
		$params = array('nn' => $nn, 'referentiel' => Registre::get('parametres.referentiel'));
216
		$params = array('nn' => $nn, 'referentiel' => Registre::get('parametres.referentiel'));
217
		$url = $this->formaterUrl($tpl, $params);
217
		$url = $this->formaterUrl($tpl, $params);
218
		return $url;
218
		return $url;
219
	}
219
	}
220
 
220
 
221
	private function getUrlMeilleuresImagesParTag($nn, $tag, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
221
	private function getUrlMeilleuresImagesParTag($nn, $tag, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
222
		$tpl = Config::get('delMeilleuresImagesParTagTpl');
222
		$tpl = Config::get('delMeilleuresImagesParTagTpl');
223
		$params = array('nn'=> $nn,
223
		$params = array('nn'=> $nn,
224
						'tag'=> $tag,
224
						'tag'=> $tag,
225
						'protocole' => $protocole,
225
						'protocole' => $protocole,
226
						'referentiel' => Registre::get('parametres.referentiel'),
226
						'referentiel' => Registre::get('parametres.referentiel'),
227
						'limite' => $limite,
227
						'limite' => $limite,
228
						'format' => $format);
228
						'format' => $format);
229
		$url = $this->formaterUrl($tpl, $params);
229
		$url = $this->formaterUrl($tpl, $params);
230
		return $url;
230
		return $url;
231
	}
231
	}
232
 
232
 
233
	/**
233
	/**
234
	 * Transforme les résultats issus des Webservices autres que eflore/cel afin de conserver un format homogène
234
	 * Transforme les résultats issus des Webservices autres que eflore/cel afin de conserver un format homogène
235
	 * @param mixed $images
235
	 * @param mixed $images
236
	 */
236
	 */
237
	private function formaterResultatImages($images, $seulementUne = false) {
237
	private function formaterResultatImages($images, $seulementUne = false) {
238
		switch ($this->getApi()) {
238
		switch ($this->getApi()) {
239
			case Eflore::API_DEL:
239
			case Eflore::API_DEL:
240
				return $this->formaterResultatImagesDel($images, $seulementUne);
240
				return $this->formaterResultatImagesDel($images, $seulementUne);
241
			break;
241
			break;
242
			default:
242
			default:
243
				return $images;
243
				return $images;
244
		}
244
		}
245
	}
245
	}
246
 
246
 
247
	private function formaterResultatImagesDel($images, $seulementUne = false) {
247
	private function formaterResultatImagesDel($images, $seulementUne = false) {
248
		if ($seulementUne) {
248
		if ($seulementUne) {
249
			return $this->formaterUnResultatImagesDel($images);
249
			return $this->formaterUnResultatImagesDel($images);
250
		} else {
250
		} else {
251
			$retour = array();
251
			$retour = array();
252
			foreach ($images as $idObsImage => $image) {
252
			foreach ($images as $idObsImage => $image) {
253
				$retour[$image['id_image']] = array_merge($images[$idObsImage], $this->formaterUnResultatImagesDel($image));
253
				$retour[$image['id_image']] = array_merge($images[$idObsImage], $this->formaterUnResultatImagesDel($image));
254
			}
254
			}
255
			return $retour;
255
			return $retour;
256
		}
256
		}
257
	}
257
	}
258
 
258
 
259
	/**
259
	/**
260
	 * Convertit un array venant d'un Webservice del vers le format retourné par eflore/cel
260
	 * Convertit un array venant d'un Webservice del vers le format retourné par eflore/cel
261
	 * @param array $image
261
	 * @param array $image
262
	 * @return array
262
	 * @return array
263
	 */
263
	 */
264
	private function formaterUnResultatImagesDel(array $image) {
264
	private function formaterUnResultatImagesDel(array $image) {
265
		$libelleAuteur = $image['observation']['auteur.prenom'].' '.$image['observation']['auteur.nom'];
265
		$libelleAuteur = $image['observation']['auteur.prenom'].' '.$image['observation']['auteur.nom'];
-
 
266
		$codeReferentiel = $image['observation']['determination.referentiel'];
-
 
267
		if (strpos($codeReferentiel, ':') !== false) {
266
		$codeReferentiel = substr($image['observation']['determination.referentiel'], 0, strpos($image['observation']['determination.referentiel'], ':'));
268
			$codeReferentiel = substr($image['observation']['determination.referentiel'], 0, strpos($image['observation']['determination.referentiel'], ':'));
-
 
269
		}
267
		$localiteLibelle = array($image['observation']['zone_geo'],
270
		$localiteLibelle = array($image['observation']['zone_geo'],
268
				$image['observation']['lieudit'],
271
				$image['observation']['lieudit'],
269
				$image['observation']['station'],
272
				$image['observation']['station'],
270
				$image['observation']['milieu']);
273
				$image['observation']['milieu']);
271
		$retourImage = array(
274
		$retourImage = array(
272
				'date' => $image['observation']['date_observation'],
275
				'date' => $image['observation']['date_observation'],
273
				'mime' => 'image/jpeg',
276
				'mime' => 'image/jpeg',
274
				'auteur.libelle' => $libelleAuteur,
277
				'auteur.libelle' => $libelleAuteur,
275
				'auteur.id' => $image['observation']['auteur.id'],
278
				'auteur.id' => $image['observation']['auteur.id'],
276
				'binaire.href' => $image['binaire.href'],
279
				'binaire.href' => $image['binaire.href'],
277
				'observation.id' => $image['observation']['id_observation'],
280
				'observation.id' => $image['observation']['id_observation'],
278
				'determination.libelle' => $image['observation']['determination.ns'].'[Dét. : '.$libelleAuteur.']',
281
				'determination.libelle' => $image['observation']['determination.ns'].'[Dét. : '.$libelleAuteur.']',
279
				'determination.nom_sci' => $image['observation']['determination.ns'],
282
				'determination.nom_sci' => $image['observation']['determination.ns'],
280
				'determination.nom_sci.code' => $codeReferentiel.'.'.$image['observation']['determination.nn'],
283
				'determination.nom_sci.code' => $codeReferentiel.'.'.$image['observation']['determination.nn'],
281
				'station.commune' => $image['observation']['zone_geo'],
284
				'station.commune' => $image['observation']['zone_geo'],
282
				'station.lieudit' => $image['observation']['lieudit'],
285
				'station.lieudit' => $image['observation']['lieudit'],
283
				'station.station' => $image['observation']['station'],
286
				'station.station' => $image['observation']['station'],
284
				'station.milieu' => $image['observation']['milieu'],
287
				'station.milieu' => $image['observation']['milieu'],
285
				'station.libelle' => $this->formaterLocalite($localiteLibelle)
288
				'station.libelle' => $this->formaterLocalite($localiteLibelle)
286
		);
289
		);
287
		return $retourImage;
290
		return $retourImage;
288
	}
291
	}
289
	
292
	
290
	private function formaterLocalite($infosLocalite) {
293
	private function formaterLocalite($infosLocalite) {
291
		$localiteFmt = array();
294
		$localiteFmt = array();
292
		foreach ($infosLocalite as $localite) {
295
		foreach ($infosLocalite as $localite) {
293
			if($localite != '') {
296
			if($localite != '') {
294
				$localiteFmt[] = $localite;
297
				$localiteFmt[] = $localite;
295
			}
298
			}
296
		}
299
		}
297
		if (empty($localiteFmt)) {
300
		if (empty($localiteFmt)) {
298
			$localiteFmt[0] = 'localité inconnue';
301
			$localiteFmt[0] = 'localité inconnue';
299
		}
302
		}
300
		return implode(" > ", $localiteFmt);
303
		return implode(" > ", $localiteFmt);
301
	}
304
	}
302
}
305
}
303
?>
306
?>