Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1383 Rev 1403
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
				echo $url;exit;
74
				echo $url;exit;
75
				$donnees = $this->chargerDonnees($url);
75
				$donnees = $this->chargerDonnees($url);
76
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
76
				$resultats = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
77
				$images += $resultats;
77
				$images += $resultats;
78
			}
78
			}
79
		} else {
79
		} else {
80
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
80
			$url = $this->getUrlImagesParIdsNoms($idsNoms);
81
			$donnees = $this->chargerDonnees($url);
81
			$donnees = $this->chargerDonnees($url);
82
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
82
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
83
		}
83
		}
84
		return $this->formaterResultatImages($images);
84
		return $this->formaterResultatImages($images);
85
	}
85
	}
86
	
86
	
87
	public function getInfosTrancheImagesParIdsNoms($idNom, $limite = 12) {
87
	public function getInfosTrancheImagesParIdsNoms($idNom, $limite = 12) {
88
		// 12 fait 4 lignes de 3 images donc bien pour l'affichage
88
		// 12 fait 4 lignes de 3 images donc bien pour l'affichage
89
		$url = $this->getUrlImagesParIdsNoms($idNom, $limite);
89
		$url = $this->getUrlImagesParIdsNoms($idNom, $limite);
90
		$donnees = $this->chargerDonnees($url);
90
		$donnees = $this->chargerDonnees($url);
91
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
91
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
92
		return $this->formaterResultatImages($images);
92
		return $this->formaterResultatImages($images);
93
	}
93
	}
94
 
94
 
95
	public function getInfosImageParIdImage($id_image) {
95
	public function getInfosImageParIdImage($id_image) {
96
		$tpl = $this->obtenirSqueletteSelonApi('imagesPopup');
96
		$tpl = $this->obtenirSqueletteSelonApi('imagesPopup');
97
		$url = $this->formaterUrl($tpl, array('id' => $id_image, 'referentiel' => Registre::get('parametres.referentiel')));
97
		$url = $this->formaterUrl($tpl, array('id' => $id_image, 'referentiel' => Registre::get('parametres.referentiel')));
98
		$image = $this->chargerDonnees($url);
98
		$image = $this->chargerDonnees($url);
99
		return $this->formaterResultatImages($image, true);
99
		return $this->formaterResultatImages($image, true);
100
	}
100
	}
101
	
101
	
102
	public function getInfosImages() {
102
	public function getInfosImages() {
103
		$url = $this->getUrlImages();
103
		$url = $this->getUrlImages();
104
		$donnees = $this->chargerDonnees($url);
104
		$donnees = $this->chargerDonnees($url);
105
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
105
		$images = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
106
		return $this->formaterResultatImages($images);
106
		return $this->formaterResultatImages($images);
107
	}
107
	}
108
 
108
 
109
	public function getInfosImagesTaxons() {
109
	public function getInfosImagesTaxons() {
110
		$pas = 800;
110
		$pas = 800;
111
		$idsTaxons = explode(',', $this->nntaxon);
111
		$idsTaxons = explode(',', $this->nntaxon);
112
		if(count($idsTaxons) >= $pas) {
112
		if(count($idsTaxons) >= $pas) {
113
			$images = array();
113
			$images = array();
114
			$idsPartages = array_chunk($idsTaxons, $pas);
114
			$idsPartages = array_chunk($idsTaxons, $pas);
115
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
115
			foreach ($idsPartages as $sousEnsembleIdsTaxons) {
116
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
116
				$url = $this->getUrlImagesTaxons(implode(',',$sousEnsembleIdsTaxons));
117
				$donnees = $this->chargerDonnees($url);
117
				$donnees = $this->chargerDonnees($url);
118
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
118
				$resultats = (empty($donnees['resultats']) == false) ? $donnees['resultats'] : array();
119
				$images += $resultats;
119
				$images += $resultats;
120
			}
120
			}
121
		} else {
121
		} else {
122
			$url = $this->getUrlImagesTaxons($idsTaxons);
122
			$url = $this->getUrlImagesTaxons($idsTaxons);
123
			$donnees = $this->chargerDonnees($url);
123
			$donnees = $this->chargerDonnees($url);
124
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
124
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
125
		}
125
		}
126
		return $this->formaterResultatImages($images);
126
		return $this->formaterResultatImages($images);
127
	}
127
	}
128
 
128
 
129
	public function getInfosPremiereImageParIdsNoms($idsNoms) {
129
	public function getInfosPremiereImageParIdsNoms($idsNoms) {
130
		$url = $this->getUrlPremiereImageParIdsNoms($idsNoms);
130
		$url = $this->getUrlPremiereImageParIdsNoms($idsNoms);
131
		$donnees = $this->chargerDonnees($url);
131
		$donnees = $this->chargerDonnees($url);
132
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
132
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
133
		return $this->formaterResultatImages($images);
133
		return $this->formaterResultatImages($images);
134
	}
134
	}
135
 
135
 
136
	public function getInfosImagesGalerieMobile($nn) {
136
	public function getInfosImagesGalerieMobile($nn) {
137
		$url = $this->getUrlImagesGalerieMobile($nn);
137
		$url = $this->getUrlImagesGalerieMobile($nn);
138
		$donnees = $this->chargerDonnees($url);
138
		$donnees = $this->chargerDonnees($url);
139
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
139
		$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
140
		return $images;
140
		return $images;
141
	}
141
	}
142
 
142
 
143
	/**
143
	/**
144
	 * Retourne les $limite images ayant le plus de votes pour CHAQUE tag de $tags pour le protocole $protocole
144
	 * Retourne les $limite images ayant le plus de votes pour CHAQUE tag de $tags pour le protocole $protocole
145
	 */
145
	 */
146
	public function getInfosMeilleuresImagesParTag($nn, $tags, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
146
	public function getInfosMeilleuresImagesParTag($nn, $tags, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
147
		if (! is_array($tags)) {
147
		if (! is_array($tags)) {
148
			$tags = array($tags);
148
			$tags = array($tags);
149
		}
149
		}
150
		$images_tag = array();
150
		$images_tag = array();
151
		foreach ($tags as $tag) {
151
		foreach ($tags as $tag) {
152
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, $protocole, $limite, $format);
152
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, $protocole, $limite, $format);
153
			$donnees = $this->chargerDonnees($url);
153
			$donnees = $this->chargerDonnees($url);
154
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
154
			$images = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
155
			$images_tag[$tag] = $this->formaterResultatImagesDel($images);
155
			$images_tag[$tag] = $this->formaterResultatImagesDel($images);
156
		}
156
		}
157
		return $images_tag;
157
		return $images_tag;
158
	}
158
	}
159
 
159
 
160
	/**
160
	/**
161
	 * Retourne l'image ayant le plus de votes pour le pour capitalisation d'images, pour le premier tags de $tags. S'il
161
	 * Retourne l'image ayant le plus de votes pour le pour capitalisation d'images, pour le premier tags de $tags. S'il
162
	 * n'y a aucune image pour le premier tag, parcourt les autres tags jusqu'à en trouver une.
162
	 * n'y a aucune image pour le premier tag, parcourt les autres tags jusqu'à en trouver une.
163
	 */
163
	 */
164
	public function getInfosMeilleureImageParPrioriteTags($nn, $tags, $format = 'CRS') {
164
	public function getInfosMeilleureImageParPrioriteTags($nn, $tags, $format = 'CRS') {
165
		if (! is_array($tags)) {
165
		if (! is_array($tags)) {
166
			$tags = array($tags);
166
			$tags = array($tags);
167
		}
167
		}
168
		$image = null;
168
		$image = null;
169
		foreach ($tags as $tag) {
169
		foreach ($tags as $tag) {
170
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, Eflore::PROTOCOLE_CAPITALISATION, 1, $format);
170
			$url = $this->getUrlMeilleuresImagesParTag($nn, $tag, Eflore::PROTOCOLE_CAPITALISATION, 1, $format);
171
			$donnees = $this->chargerDonnees($url);
171
			$donnees = $this->chargerDonnees($url);
172
			$image = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
172
			$image = (isset($donnees['resultats'])) ? $donnees['resultats'] : array();
173
			$image = $this->formaterResultatImagesDel($image);
173
			$image = $this->formaterResultatImagesDel($image);
174
			if (empty($image) == false) {
174
			if (empty($image) == false) {
175
				break;
175
				break;
176
			}
176
			}
177
		}
177
		}
178
		//echo "<pre>" . print_r($image, true) . "</pre>";
178
		//echo "<pre>" . print_r($image, true) . "</pre>";
179
		if (is_array($image)) {
179
		if (is_array($image)) {
180
			$image = array_pop($image);
180
			$image = array_pop($image);
181
		}
181
		}
182
		return $image;
182
		return $image;
183
	}
183
	}
184
 
184
 
185
	private function getUrlImagesParIdsNoms($idsNoms, $limite = 801) {
185
	private function getUrlImagesParIdsNoms($idsNoms, $limite = 801) {
186
		$tpl = $this->obtenirSqueletteSelonApi('imagesResultatsDetermination');
186
		$tpl = $this->obtenirSqueletteSelonApi('imagesResultatsDetermination');
187
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'), 'limite' => $limite);
187
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'), 'limite' => $limite);
188
		$url = $this->formaterUrl($tpl, $params);
188
		$url = $this->formaterUrl($tpl, $params);
189
		return $url;
189
		return $url;
190
	}
190
	}
191
 
191
 
192
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
192
	public function getUrlPremiereImageParIdsNoms($idsNoms) {
193
		$tpl = $this->obtenirSqueletteSelonApi('imagesPremiere');
193
		$tpl = $this->obtenirSqueletteSelonApi('imagesPremiere');
194
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'));
194
		$params = array('idsNoms' => implode(',', $idsNoms), 'referentiel' => Registre::get('parametres.referentiel'));
195
		return $this->formaterUrl($tpl, $params);
195
		$url = $this->formaterUrl($tpl, $params);
-
 
196
		return $url;
196
	}
197
	}
197
 
198
 
198
	private function getUrlImages($nn = false) {
199
	private function getUrlImages($nn = false) {
199
		$tpl = $this->obtenirSqueletteSelonApi('images');
200
		$tpl = $this->obtenirSqueletteSelonApi('images');
200
		if ($this->getApi() == Eflore::API_EFLORE) {
201
		if ($this->getApi() == Eflore::API_EFLORE) {
201
			$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart, 'referentiel' => Registre::get('parametres.referentiel'));
202
			$params = array('projet' => $this->getProjet(), 'limite' => $this->limite, 'depart' => $this->depart, 'referentiel' => Registre::get('parametres.referentiel'));
202
		}
203
		}
203
		$url = $this->formaterUrl($tpl, $params);
204
		$url = $this->formaterUrl($tpl, $params);
204
		return $url;
205
		return $url;
205
	}
206
	}
206
 
207
 
207
	private function getUrlImagesTaxons($idsTaxons) {
208
	private function getUrlImagesTaxons($idsTaxons) {
208
		$tpl = $this->obtenirSqueletteSelonApi('imagesTaxons');
209
		$tpl = $this->obtenirSqueletteSelonApi('imagesTaxons');
209
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons, 'referentiel' => Registre::get('parametres.referentiel'));
210
		$params = array('projet' => $this->getProjet(),'nntaxon'=> $idsTaxons, 'referentiel' => Registre::get('parametres.referentiel'));
210
		$url = $this->formaterUrl($tpl, $params);
211
		$url = $this->formaterUrl($tpl, $params);
211
		return $url;
212
		return $url;
212
	}
213
	}
213
 
214
 
214
	private function getUrlImagesGalerieMobile($nn) {
215
	private function getUrlImagesGalerieMobile($nn) {
215
		$tpl = Config::get('delGalerieMobileTpl');
216
		$tpl = Config::get('delGalerieMobileTpl');
216
		$params = array('nn' => $nn, 'referentiel' => Registre::get('parametres.referentiel'));
217
		$params = array('nn' => $nn, 'referentiel' => Registre::get('parametres.referentiel'));
217
		$url = $this->formaterUrl($tpl, $params);
218
		$url = $this->formaterUrl($tpl, $params);
218
		return $url;
219
		return $url;
219
	}
220
	}
220
 
221
 
221
	private function getUrlMeilleuresImagesParTag($nn, $tag, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
222
	private function getUrlMeilleuresImagesParTag($nn, $tag, $protocole = Eflore::PROTOCOLE_CAPITALISATION, $limite = 10, $format = 'CRS') {
222
		$tpl = Config::get('delMeilleuresImagesParTagTpl');
223
		$tpl = Config::get('delMeilleuresImagesParTagTpl');
223
		$params = array('nn'=> $nn,
224
		$params = array('nn'=> $nn,
224
						'tag'=> $tag,
225
						'tag'=> $tag,
225
						'protocole' => $protocole,
226
						'protocole' => $protocole,
226
						'referentiel' => Registre::get('parametres.referentiel'),
227
						'referentiel' => Registre::get('parametres.referentiel'),
227
						'limite' => $limite,
228
						'limite' => $limite,
228
						'format' => $format);
229
						'format' => $format);
229
		$url = $this->formaterUrl($tpl, $params);
230
		$url = $this->formaterUrl($tpl, $params);
230
		return $url;
231
		return $url;
231
	}
232
	}
232
 
233
 
233
	/**
234
	/**
234
	 * Transforme les résultats issus des Webservices autres que eflore/cel afin de conserver un format homogène
235
	 * Transforme les résultats issus des Webservices autres que eflore/cel afin de conserver un format homogène
235
	 * @param mixed $images
236
	 * @param mixed $images
236
	 */
237
	 */
237
	private function formaterResultatImages($images, $seulementUne = false) {
238
	private function formaterResultatImages($images, $seulementUne = false) {
238
		switch ($this->getApi()) {
239
		switch ($this->getApi()) {
239
			case Eflore::API_DEL:
240
			case Eflore::API_DEL:
240
				return $this->formaterResultatImagesDel($images, $seulementUne);
241
				return $this->formaterResultatImagesDel($images, $seulementUne);
241
			break;
242
			break;
242
			default:
243
			default:
243
				return $images;
244
				return $images;
244
		}
245
		}
245
	}
246
	}
246
 
247
 
247
	private function formaterResultatImagesDel($images, $seulementUne = false) {
248
	private function formaterResultatImagesDel($images, $seulementUne = false) {
248
		if ($seulementUne) {
249
		if ($seulementUne) {
249
			return $this->formaterUnResultatImagesDel($images);
250
			return $this->formaterUnResultatImagesDel($images);
250
		} else {
251
		} else {
251
			$retour = array();
252
			$retour = array();
252
			foreach ($images as $idObsImage => $image) {
253
			foreach ($images as $idObsImage => $image) {
253
				$retour[$image['id_image']] = array_merge($images[$idObsImage], $this->formaterUnResultatImagesDel($image));
254
				$retour[$image['id_image']] = array_merge($images[$idObsImage], $this->formaterUnResultatImagesDel($image));
254
			}
255
			}
255
			return $retour;
256
			return $retour;
256
		}
257
		}
257
	}
258
	}
258
 
259
 
259
	/**
260
	/**
260
	 * Convertit un array venant d'un Webservice del vers le format retourné par eflore/cel
261
	 * Convertit un array venant d'un Webservice del vers le format retourné par eflore/cel
261
	 * @param array $image
262
	 * @param array $image
262
	 * @return array
263
	 * @return array
263
	 */
264
	 */
264
	private function formaterUnResultatImagesDel(array $image) {
265
	private function formaterUnResultatImagesDel(array $image) {
265
		$libelleAuteur = $image['observation']['auteur.prenom'].' '.$image['observation']['auteur.nom'];
266
		$libelleAuteur = $image['observation']['auteur.prenom'].' '.$image['observation']['auteur.nom'];
266
		$codeReferentiel = substr($image['observation']['determination.referentiel'], 0, strpos($image['observation']['determination.referentiel'], ':'));
267
		$codeReferentiel = substr($image['observation']['determination.referentiel'], 0, strpos($image['observation']['determination.referentiel'], ':'));
267
		$localiteLibelle = array($image['observation']['zone_geo'],
268
		$localiteLibelle = array($image['observation']['zone_geo'],
268
				$image['observation']['lieudit'],
269
				$image['observation']['lieudit'],
269
				$image['observation']['station'],
270
				$image['observation']['station'],
270
				$image['observation']['milieu']);
271
				$image['observation']['milieu']);
271
		$retourImage = array(
272
		$retourImage = array(
272
				'date' => $image['observation']['date_observation'],
273
				'date' => $image['observation']['date_observation'],
273
				'mime' => 'image/jpeg',
274
				'mime' => 'image/jpeg',
274
				'auteur.libelle' => $libelleAuteur,
275
				'auteur.libelle' => $libelleAuteur,
275
				'auteur.id' => $image['observation']['auteur.id'],
276
				'auteur.id' => $image['observation']['auteur.id'],
276
				'binaire.href' => $image['binaire.href'],
277
				'binaire.href' => $image['binaire.href'],
277
				'observation.id' => $image['observation']['id_observation'],
278
				'observation.id' => $image['observation']['id_observation'],
278
				'determination.libelle' => $image['observation']['determination.ns'].'[Dét. : '.$libelleAuteur.']',
279
				'determination.libelle' => $image['observation']['determination.ns'].'[Dét. : '.$libelleAuteur.']',
279
				'determination.nom_sci' => $image['observation']['determination.ns'],
280
				'determination.nom_sci' => $image['observation']['determination.ns'],
280
				'determination.nom_sci.code' => $codeReferentiel.'.'.$image['observation']['determination.nn'],
281
				'determination.nom_sci.code' => $codeReferentiel.'.'.$image['observation']['determination.nn'],
281
				'station.commune' => $image['observation']['zone_geo'],
282
				'station.commune' => $image['observation']['zone_geo'],
282
				'station.lieudit' => $image['observation']['lieudit'],
283
				'station.lieudit' => $image['observation']['lieudit'],
283
				'station.station' => $image['observation']['station'],
284
				'station.station' => $image['observation']['station'],
284
				'station.milieu' => $image['observation']['milieu'],
285
				'station.milieu' => $image['observation']['milieu'],
285
				'station.libelle' => $this->formaterLocalite($localiteLibelle)
286
				'station.libelle' => $this->formaterLocalite($localiteLibelle)
286
		);
287
		);
287
		return $retourImage;
288
		return $retourImage;
288
	}
289
	}
289
	
290
	
290
	private function formaterLocalite($infosLocalite) {
291
	private function formaterLocalite($infosLocalite) {
291
		$localiteFmt = array();
292
		$localiteFmt = array();
292
		foreach ($infosLocalite as $localite) {
293
		foreach ($infosLocalite as $localite) {
293
			if($localite != '') {
294
			if($localite != '') {
294
				$localiteFmt[] = $localite;
295
				$localiteFmt[] = $localite;
295
			}
296
			}
296
		}
297
		}
297
		if (empty($localiteFmt)) {
298
		if (empty($localiteFmt)) {
298
			$localiteFmt[0] = 'localité inconnue';
299
			$localiteFmt[0] = 'localité inconnue';
299
		}
300
		}
300
		return implode(" > ", $localiteFmt);
301
		return implode(" > ", $localiteFmt);
301
	}
302
	}
302
}
303
}
303
?>
304
?>