Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 841 Rev 915
Line 198... Line 198...
198
		
198
		
199
		return $fichiers;
199
		return $fichiers;
Line 200... Line 200...
200
	}
200
	}
201
	
-
 
202
	/**
-
 
203
	 * Tableau des observations d'une station
-
 
204
	 */
-
 
205
	public function executerStation() {
-
 
206
		$widget = null;
-
 
207
		$observations = $this->chargerObservations();
-
 
208
		$nbre_obs = $this->chargerObservationsNbre();
-
 
209
				
-
 
210
		// Création des infos du widget
-
 
211
		if (isset($observations['commune'])) {
-
 
212
			$commune = $observations['commune'];
-
 
213
			unset($observations['commune']);
-
 
214
			$widget['donnees']['commune'] = $commune;
-
 
215
		}
-
 
216
		
-
 
217
		$obs_ids = null;
-
 
218
		if (isset($observations['ids'])) {
-
 
219
			$obs_ids = $observations['ids'];
-
 
220
			unset($observations['ids']);
-
 
221
		}
-
 
222
		$widget['squelette'] = $this->choisirFormatSortie(count($observations));
-
 
223
		
-
 
224
		if ($widget['squelette'] == 'obs_liste' && $obs_ids != null && count($obs_ids) > 0) {
-
 
225
			$widget['donnees']['images'] = $this->chargerImages($obs_ids);
-
 
226
		}
-
 
227
		
-
 
228
		$widget['donnees']['observations'] = $observations;
-
 
229
		$widget['donnees']['station_id'] = $this->station;
-
 
230
		$widget['donnees']['nbre_obs_total'] = $nbre_obs;
-
 
231
		
-
 
232
		return $widget;
-
 
233
	}
-
 
234
	
-
 
235
	
-
 
236
	/**
-
 
237
	 * Tableau des observations d'une station
-
 
238
	 */
-
 
239
	public function executerObservations() {
-
 
240
		$widget = null;
-
 
241
		$observations = $this->chargerObservations();
-
 
242
		$nbre_obs = $this->chargerObservationsNbre();
-
 
243
				
-
 
244
		// Création des infos du widget
-
 
245
		if (isset($observations['commune'])) {
-
 
246
			$commune = $observations['commune'];
-
 
247
			unset($observations['commune']);
-
 
248
			$widget['donnees']['commune'] = $commune;
-
 
249
		}
-
 
250
		
-
 
251
		$obs_ids = null;
-
 
252
		if (isset($observations['ids'])) {
-
 
253
			$obs_ids = $observations['ids'];
-
 
254
			unset($observations['ids']);
-
 
255
		}
-
 
256
		$widget['squelette'] = $this->choisirFormatSortie(count($observations)).'_contenu';
-
 
257
		
-
 
258
		if ($widget['squelette'] == 'obs_liste_contenu' && $obs_ids != null && count($obs_ids) > 0) {
-
 
259
			$widget['donnees']['images'] = $this->chargerImages($obs_ids);
-
 
260
		}
-
 
261
		$widget['donnees']['observations'] = $observations;
-
 
262
		
-
 
263
		return $widget;
-
 
264
	}
-
 
265
	
-
 
266
	private function chargerPagination($url_tpl, $nbre) {
-
 
267
		
-
 
268
	}	
-
 
269
	
-
 
270
	private function chargerObservationsNbre() {
-
 
271
		// Récupération des données au format Json
-
 
272
		$url = $this->contruireUrlServiceCarto('observations-nombre');
-
 
273
		$json = $this->getDao()->consulter($url);
-
 
274
		$nbre = json_decode($json);
-
 
275
		return $nbre;
-
 
276
	}
-
 
277
	
-
 
278
	private function chargerObservations() {
-
 
279
		// Récupération des données au format Json
-
 
280
		$url = $this->contruireUrlServiceCarto('observations');
-
 
281
		$this->debug[] = $url;
-
 
282
		$json = $this->getDao()->consulter($url);
-
 
283
		$donnees = json_decode($json);
-
 
284
		
-
 
285
		// Post-traitement des données
-
 
286
		$observations = $this->traiterObservations($donnees);
-
 
287
		
-
 
288
		return $observations;
-
 
289
	}
-
 
290
	
-
 
291
	private function traiterObservations($donnees) {
-
 
292
		$observations = array();
-
 
293
		if (is_array($donnees) && count($donnees) > 0) {
-
 
294
			foreach ($donnees as $donnee) {
-
 
295
				$observation = array();
-
 
296
				$observation['id'] = $donnee->id;
-
 
297
				$observation['nn'] = $this->etreVide($donnee->num_nom_sel) ? null : $donnee->num_nom_sel;
-
 
298
				$observation['nom'] = $this->nettoyerTexte($donnee->nom_sel);
-
 
299
				$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y');
-
 
300
				$observation['lieu'] = $this->traiterLieu($donnee);
-
 
301
				$observation['observateur'] = $this->tronquerCourriel($donnee->identifiant);
-
 
302
				
-
 
303
				$observations[] = $observation;
-
 
304
				$observations['commune'] = $this->nettoyerTexte($donnee->location);
-
 
305
				$observations['ids'][] = $donnee->id;
-
 
306
			}
-
 
307
		}
-
 
308
		return $observations;
-
 
309
	}
-
 
310
	
-
 
311
	private function traiterLieu($donnee) {
-
 
312
		$lieu = array();
-
 
313
		if (isset($donnee->lieudit) && ! empty($donnee->lieudit)) {
-
 
314
			$lieu[] = $donnee->lieudit;
-
 
315
		}
-
 
316
		if (isset($donnee->milieu) && ! empty($donnee->milieu)) {
-
 
317
			$lieu[] = $donnee->milieu;
-
 
318
		}
-
 
319
		return implode(', ', $lieu);
-
 
320
	}
-
 
321
	
-
 
322
	private function choisirFormatSortie($observations_nbre) {
-
 
323
		$sortie = 'obs_tableau';
-
 
324
		if (isset($this->format) && $this->format != '*') {
-
 
325
			$sortie = ($this->format == 'tableau' ) ? 'obs_tableau' : 'obs_liste';
-
 
326
		} else {
-
 
327
			$sortie = ($observations_nbre > 4) ? 'obs_tableau' : 'obs_liste';
-
 
328
		}
-
 
329
		return $sortie;
-
 
330
	}
-
 
331
	
-
 
332
	private function chargerImages($obs_ids) {
-
 
333
		// Récupération des données au format Json
-
 
334
		$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids);
-
 
335
		$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
-
 
336
		
-
 
337
		$json = $this->getDao()->consulter($url);
-
 
338
		$donnees = json_decode($json);
-
 
339
			
-
 
340
		// Post-traitement des données
-
 
341
		$images = $this->traiterImages($donnees);
-
 
342
		
-
 
343
		return $images;
-
 
344
	}
-
 
345
	
-
 
346
	private function traiterImages($donnees) {
-
 
347
		$images = array();
-
 
348
		//echo '<br/><pre>'.print_r($donnees,true).'</pre>';
-
 
349
		if (count($donnees) > 0) {
-
 
350
			foreach ($donnees as $id_obs => $id_images) {
-
 
351
				foreach ($id_images as $id_img) {
-
 
352
					$urls['id'] = $id_img;
-
 
353
					$urls['miniature'] = $this->getUrlImage($id_img, 'CXS');
-
 
354
					$urls['normale'] = $this->getUrlImage($id_img, 'XL');
-
 
355
					$images[$id_obs][] = $urls;
-
 
356
				} 
-
 
357
			}
-
 
358
		}
-
 
359
		return $images;
-
 
360
	}
-
 
361
	
201
	
362
	/**
202
	/**
363
	 * Afficher message d'avertissement.
203
	 * Afficher message d'avertissement.
364
	 */
204
	 */