1 |
<?php
|
1 |
<?php
|
2 |
// declare(encoding='UTF-8');
|
2 |
// declare(encoding='UTF-8');
|
3 |
/**
|
3 |
/**
|
4 |
* Service fournissant une carte dynamique des obsertions publiques du CEL.
|
4 |
* Service fournissant une carte dynamique des obsertions publiques du CEL.
|
5 |
* Encodage en entrée : utf8
|
5 |
* Encodage en entrée : utf8
|
6 |
* Encodage en sortie : utf8
|
6 |
* Encodage en sortie : utf8
|
7 |
*
|
7 |
*
|
8 |
* Cas d'utilisation et documentation :
|
8 |
* Cas d'utilisation et documentation :
|
9 |
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetCarto
|
9 |
* @link http://www.tela-botanica.org/wikini/eflore/wakka.php?wiki=AideCELWidgetCarto
|
10 |
*
|
10 |
*
|
11 |
* Paramètres :
|
11 |
* Paramètres :
|
12 |
* ===> utilisateur = identifiant
|
12 |
* ===> utilisateur = identifiant
|
13 |
* Affiche seulement les observations d'un utilisateur donné. L'identifiant correspond au courriel de
|
13 |
* Affiche seulement les observations d'un utilisateur donné. L'identifiant correspond au courriel de
|
14 |
* l'utilisateur avec lequel il s'est inscrit sur Tela Botanica.
|
14 |
* l'utilisateur avec lequel il s'est inscrit sur Tela Botanica.
|
15 |
* ===> dept = code_du_département
|
15 |
* ===> dept = code_du_département
|
16 |
* Affiche seulement les observations pour le département français métropolitain indiqué. Les codes de département utilisables
|
16 |
* Affiche seulement les observations pour le département français métropolitain indiqué. Les codes de département utilisables
|
17 |
* sont : 01 à 19, 2A, 2B et 21 à 95.
|
17 |
* sont : 01 à 19, 2A, 2B et 21 à 95.
|
18 |
* ===> projet = mot-clé
|
18 |
* ===> projet = mot-clé
|
19 |
* Affiche seulement les observations pour le projet d'observations indiqué. Dans l'interface du CEL, vous pouvez taguer vos
|
19 |
* Affiche seulement les observations pour le projet d'observations indiqué. Dans l'interface du CEL, vous pouvez taguer vos
|
20 |
* observations avec un mot-clé de projet. Si vous voulez regrouper des observations de plusieurs utilisateurs, communiquez un
|
20 |
* observations avec un mot-clé de projet. Si vous voulez regrouper des observations de plusieurs utilisateurs, communiquez un
|
21 |
* mot-clé de projet à vos amis et visualisez les informations ainsi regroupées.
|
21 |
* mot-clé de projet à vos amis et visualisez les informations ainsi regroupées.
|
22 |
* ===> num_taxon = num_taxon
|
22 |
* ===> num_taxon = num_taxon
|
23 |
* Affiche seulement les observations pour la plante indiquée. Le num_taxon correspond au numéro taxonomique de la plante.
|
23 |
* Affiche seulement les observations pour la plante indiquée. Le num_taxon correspond au numéro taxonomique de la plante.
|
24 |
* Ce numéro est disponible dans les fiches d'eFlore. Par exemple, pour "Poa bulbosa L." le numéro taxonomique vaut 7080.
|
24 |
* Ce numéro est disponible dans les fiches d'eFlore. Par exemple, pour "Poa bulbosa L." le numéro taxonomique vaut 7080.
|
25 |
*
|
25 |
*
|
26 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
26 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
27 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
27 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
28 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
28 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
29 |
* @version $Id$
|
29 |
* @version $Id$
|
30 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
30 |
* @copyright Copyright (c) 2010, Tela Botanica (accueil@tela-botanica.org)
|
31 |
*/
|
31 |
*/
|
32 |
class Carto extends WidgetCommun {
|
32 |
class Carto extends WidgetCommun {
|
33 |
const DS = DIRECTORY_SEPARATOR;
|
33 |
const DS = DIRECTORY_SEPARATOR;
|
34 |
const SERVICE_DEFAUT = 'carte-defaut';
|
34 |
const SERVICE_DEFAUT = 'carte-defaut';
|
35 |
|
35 |
|
36 |
/**
|
36 |
/**
|
37 |
* Méthode appelée par défaut pour charger ce widget.
|
37 |
* Méthode appelée par défaut pour charger ce widget.
|
38 |
*/
|
38 |
*/
|
39 |
public function executer() {
|
39 |
public function executer() {
|
40 |
$retour = null;
|
40 |
$retour = null;
|
41 |
extract($this->parametres);
|
41 |
extract($this->parametres);
|
42 |
|
42 |
|
43 |
if (!isset($carte)) {
|
43 |
if (!isset($carte)) {
|
44 |
$carte = self::SERVICE_DEFAUT;
|
44 |
$carte = self::SERVICE_DEFAUT;
|
45 |
}
|
45 |
}
|
46 |
|
46 |
|
47 |
$methode = $this->traiterNomMethodeExecuter($carte);
|
47 |
$methode = $this->traiterNomMethodeExecuter($carte);
|
48 |
if (method_exists($this, $methode)) {
|
48 |
if (method_exists($this, $methode)) {
|
49 |
$retour = $this->$methode();
|
49 |
$retour = $this->$methode();
|
50 |
} else {
|
50 |
} else {
|
51 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
51 |
$this->messages[] = "Ce type de service '$methode' n'est pas disponible.";
|
52 |
}
|
52 |
}
|
53 |
|
53 |
|
54 |
if (is_null($retour)) {
|
54 |
if (is_null($retour)) {
|
55 |
$info = 'Un problème est survenu : '.print_r($this->messages, true);
|
55 |
$info = 'Un problème est survenu : '.print_r($this->messages, true);
|
56 |
$this->envoyer($info);
|
56 |
$this->envoyer($info);
|
57 |
} else {
|
57 |
} else {
|
58 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
|
58 |
$squelette = dirname(__FILE__).self::DS.'squelettes'.self::DS.$retour['squelette'].'.tpl.html';
|
59 |
$html = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
59 |
$html = $this->traiterSquelettePhp($squelette, $retour['donnees']);
|
60 |
$this->envoyer($html);
|
60 |
$this->envoyer($html);
|
61 |
}
|
61 |
}
|
62 |
}
|
62 |
}
|
63 |
|
63 |
|
64 |
/**
|
64 |
/**
|
65 |
* Carte par défaut
|
65 |
* Carte par défaut
|
66 |
*/
|
66 |
*/
|
67 |
public function executerCarteDefaut() {
|
67 |
public function executerCarteDefaut() {
|
68 |
$widget = null;
|
68 |
$widget = null;
|
69 |
extract($this->parametres);
|
69 |
extract($this->parametres);
|
70 |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*');
|
70 |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*');
|
71 |
$projet = (isset($projet) ? $projet : '*');
|
71 |
$projet = (isset($projet) ? $projet : '*');
|
72 |
$dept = (isset($dept) ? $dept : '*');
|
72 |
$dept = (isset($dept) ? $dept : '*');
|
73 |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*');
|
73 |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*');
|
74 |
|
74 |
|
75 |
// Création url données json
|
75 |
// Création url données json
|
76 |
$url_cel_carto = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelWidgetMap');
|
76 |
$url_cel_carto = sprintf($this->config['chemins']['baseURLServicesCelTpl'], 'CelWidgetMap');
|
77 |
$url_json = "$url_cel_carto/carte-defaut-json/$utilisateur/$projet/$dept/$num_taxon";
|
77 |
$url_json = "$url_cel_carto/carte-defaut-json/$utilisateur/$projet/$dept/$num_taxon";
|
78 |
|
78 |
|
79 |
$url_base = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
79 |
$url_base = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
80 |
|
80 |
|
81 |
// Création des infos du widget
|
81 |
// Création des infos du widget
|
82 |
$widget['donnees']['url_cel_carto'] = $url_cel_carto;
|
82 |
$widget['donnees']['url_cel_carto'] = $url_cel_carto;
|
83 |
$widget['donnees']['url_json'] = $url_json;
|
83 |
$widget['donnees']['url_json'] = $url_json;
|
84 |
$widget['donnees']['url_base'] = $url_base;
|
84 |
$widget['donnees']['url_base'] = $url_base;
|
85 |
$widget['donnees']['jquery_version'] = '1.4.4';
|
85 |
$widget['donnees']['jquery_version'] = '1.4.4';
|
86 |
$widget['donnees']['utilisateur'] = $utilisateur;
|
86 |
$widget['donnees']['utilisateur'] = $utilisateur;
|
87 |
$widget['donnees']['projet'] = $projet;
|
87 |
$widget['donnees']['projet'] = $projet;
|
88 |
$widget['donnees']['dept'] = $dept;
|
88 |
$widget['donnees']['dept'] = $dept;
|
89 |
$widget['donnees']['num_taxon'] = $num_taxon;
|
89 |
$widget['donnees']['num_taxon'] = $num_taxon;
|
90 |
$widget['donnees']['taxons'] = $this->chargerTaxons();
|
90 |
$widget['donnees']['taxons'] = $this->chargerTaxons();
|
91 |
if ($num_taxon != '*') {
|
91 |
if ($num_taxon != '*') {
|
92 |
$taxon_courrant = current($widget['donnees']['taxons']);
|
92 |
$taxon_courrant = current($widget['donnees']['taxons']);
|
93 |
$widget['donnees']['taxon_nom'] = $taxon_courrant['nom'];
|
93 |
$widget['donnees']['taxon_nom'] = $taxon_courrant['nom'];
|
94 |
}
|
94 |
}
|
95 |
$widget['squelette'] = 'carte_defaut';
|
95 |
$widget['squelette'] = 'carte_defaut';
|
96 |
|
96 |
|
97 |
if (isset($dept)) {
|
97 |
if (isset($dept)) {
|
98 |
// si on veut afficher les limites départemmentales on va compter et chercher les noms de fichiers
|
98 |
// si on veut afficher les limites départemmentales on va compter et chercher les noms de fichiers
|
99 |
$fichiersKml = $this->chercherFichierKml($dept);
|
99 |
$fichiersKml = $this->chercherFichierKml($dept);
|
100 |
foreach ($fichiersKml as $dossier => $kml){
|
100 |
foreach ($fichiersKml as $kml => $dossier){
|
101 |
$url_limites_communales = sprintf($this->config['carto']['limitesCommunaleUrlTpl'], $dossier, $kml);
|
101 |
$url_limites_communales = sprintf($this->config['carto']['limitesCommunaleUrlTpl'], $dossier, $kml);
|
102 |
$widget['donnees']['url_limites_communales'][] = $url_limites_communales;
|
102 |
$widget['donnees']['url_limites_communales'][] = $url_limites_communales;
|
103 |
}
|
103 |
}
|
104 |
}
|
104 |
}
|
105 |
|
105 |
|
106 |
return $widget;
|
106 |
return $widget;
|
107 |
}
|
107 |
}
|
108 |
|
108 |
|
109 |
private function chargerTaxons() {
|
109 |
private function chargerTaxons() {
|
110 |
extract($this->parametres);
|
110 |
extract($this->parametres);
|
111 |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*');
|
111 |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*');
|
112 |
$projet = (isset($projet) ? $projet : '*');
|
112 |
$projet = (isset($projet) ? $projet : '*');
|
113 |
$dept = (isset($dept) ? $dept : '*');
|
113 |
$dept = (isset($dept) ? $dept : '*');
|
114 |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*');
|
114 |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*');
|
115 |
|
115 |
|
116 |
// Récupération des données au format Json
|
116 |
// Récupération des données au format Json
|
117 |
$service = "CelWidgetMap/taxons/$utilisateur/$projet/$dept/$num_taxon";
|
117 |
$service = "CelWidgetMap/taxons/$utilisateur/$projet/$dept/$num_taxon";
|
118 |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
|
118 |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
|
119 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
119 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
120 |
$donnees = json_decode($json);
|
120 |
$donnees = json_decode($json);
|
121 |
|
121 |
|
122 |
// Post-traitement des données
|
122 |
// Post-traitement des données
|
123 |
$taxons = $this->traiterTaxons($donnees);
|
123 |
$taxons = $this->traiterTaxons($donnees);
|
124 |
|
124 |
|
125 |
return $taxons;
|
125 |
return $taxons;
|
126 |
}
|
126 |
}
|
127 |
|
127 |
|
128 |
private function traiterTaxons($donnees) {
|
128 |
private function traiterTaxons($donnees) {
|
129 |
$taxons = array();
|
129 |
$taxons = array();
|
130 |
if (is_array($donnees) && count($donnees) > 0) {
|
130 |
if (is_array($donnees) && count($donnees) > 0) {
|
131 |
foreach ($donnees as $donnee) {
|
131 |
foreach ($donnees as $donnee) {
|
132 |
if (!isset($taxons[$donnee->num_taxon]) && ! $this->etreVide($donnee->nom_ret)) {
|
132 |
if (!isset($taxons[$donnee->num_taxon]) && ! $this->etreVide($donnee->nom_ret)) {
|
133 |
$taxon = array();
|
133 |
$taxon = array();
|
134 |
$taxon['nn'] = $donnee->num_nom_ret;
|
134 |
$taxon['nn'] = $donnee->num_nom_ret;
|
135 |
$taxon['nt'] = $donnee->num_taxon;
|
135 |
$taxon['nt'] = $donnee->num_taxon;
|
136 |
$taxon['nom'] = $this->nettoyerTexte($donnee->nom_ret);
|
136 |
$taxon['nom'] = $this->nettoyerTexte($donnee->nom_ret);
|
137 |
$taxon['famille'] = $this->nettoyerTexte($donnee->famille);
|
137 |
$taxon['famille'] = $this->nettoyerTexte($donnee->famille);
|
138 |
$taxons[$donnee->num_taxon] = $taxon;
|
138 |
$taxons[$donnee->num_taxon] = $taxon;
|
139 |
}
|
139 |
}
|
140 |
}
|
140 |
}
|
141 |
}
|
141 |
}
|
142 |
return $taxons;
|
142 |
return $taxons;
|
143 |
}
|
143 |
}
|
144 |
|
144 |
|
145 |
private function chercherFichierKml($dept){
|
145 |
private function chercherFichierKml($dept){
|
146 |
$chemins = explode(',', $this->config['carto']['communesKmzChemin']);
|
146 |
$chemins = explode(',', $this->config['carto']['communesKmzChemin']);
|
- |
|
147 |
$departements = explode(',', $dept);// plrs code de départements peuvent être demandés séparés par des virgules
|
- |
|
148 |
$departements_trouves = array();
|
147 |
$fichiers = array();
|
149 |
$fichiers = array();
|
148 |
foreach ($chemins as $dossier_chemin) {
|
150 |
foreach ($chemins as $dossier_chemin) {
|
149 |
if ($dossier_ressource = opendir($dossier_chemin)) {
|
151 |
if ($dossier_ressource = opendir($dossier_chemin)) {
|
150 |
while ($element = readdir($dossier_ressource)) {
|
152 |
while ($element = readdir($dossier_ressource)) {
|
151 |
if ($element != '.' && $element != '..') {
|
153 |
if ($element != '.' && $element != '..') {
|
- |
|
154 |
foreach ($departements as $departement) {
|
- |
|
155 |
$nom_dossier = basename($dossier_chemin);
|
- |
|
156 |
if (!isset($departements_trouves[$departement]) || $departements_trouves[$departement] == $nom_dossier) {
|
152 |
$dept_protege = preg_quote($dept);
|
157 |
$dept_protege = preg_quote($departement);
|
153 |
if ((!is_dir($dossier_chemin.'/'.$element)) && (preg_match("/^$dept_protege(?:_[0-9]+|)\.km[lz]$/", $element))) {
|
158 |
if (!is_dir($dossier_chemin.'/'.$element) && preg_match("/^$dept_protege(?:_[0-9]+|)\.km[lz]$/", $element)) {
|
154 |
$fichiers[basename($dossier_chemin)] = $element;
|
159 |
$fichiers[$element] = $nom_dossier;
|
- |
|
160 |
$departements_trouves[$departement] = $nom_dossier;
|
- |
|
161 |
}
|
- |
|
162 |
}
|
155 |
}
|
163 |
}
|
156 |
}
|
164 |
}
|
157 |
}
|
165 |
}
|
158 |
closedir($dossier_ressource);
|
166 |
closedir($dossier_ressource);
|
159 |
if (count($fichiers) > 0) {
|
- |
|
160 |
break;
|
- |
|
161 |
}
|
- |
|
162 |
}
|
167 |
}
|
163 |
}
|
168 |
}
|
- |
|
169 |
|
164 |
return $fichiers;
|
170 |
return $fichiers;
|
165 |
}
|
171 |
}
|
166 |
|
172 |
|
167 |
/**
|
173 |
/**
|
168 |
* Tableau des observations d'une station
|
174 |
* Tableau des observations d'une station
|
169 |
*/
|
175 |
*/
|
170 |
public function executerObservations() {
|
176 |
public function executerObservations() {
|
171 |
$widget = null;
|
177 |
$widget = null;
|
172 |
extract($this->parametres);
|
178 |
extract($this->parametres);
|
173 |
|
179 |
|
174 |
$observations = $this->chargerObservation($station);
|
180 |
$observations = $this->chargerObservation($station);
|
175 |
|
181 |
|
176 |
// Création des infos du widget
|
182 |
// Création des infos du widget
|
177 |
if (isset($observations['commune'])) {
|
183 |
if (isset($observations['commune'])) {
|
178 |
$commune = $observations['commune'];
|
184 |
$commune = $observations['commune'];
|
179 |
unset($observations['commune']);
|
185 |
unset($observations['commune']);
|
180 |
$widget['donnees']['commune'] = $commune;
|
186 |
$widget['donnees']['commune'] = $commune;
|
181 |
}
|
187 |
}
|
182 |
|
188 |
|
183 |
$obs_ids = null;
|
189 |
$obs_ids = null;
|
184 |
if (isset($observations['ids'])) {
|
190 |
if (isset($observations['ids'])) {
|
185 |
$obs_ids = $observations['ids'];
|
191 |
$obs_ids = $observations['ids'];
|
186 |
unset($observations['ids']);
|
192 |
unset($observations['ids']);
|
187 |
}
|
193 |
}
|
188 |
$widget['squelette'] = $this->choisirFormatSortie(count($observations));
|
194 |
$widget['squelette'] = $this->choisirFormatSortie(count($observations));
|
189 |
|
195 |
|
190 |
if ($widget['squelette'] == 'obs_liste' && $obs_ids != null && count($obs_ids) > 0) {
|
196 |
if ($widget['squelette'] == 'obs_liste' && $obs_ids != null && count($obs_ids) > 0) {
|
191 |
$widget['donnees']['images'] = $this->chargerImages($obs_ids);
|
197 |
$widget['donnees']['images'] = $this->chargerImages($obs_ids);
|
192 |
}
|
198 |
}
|
193 |
|
199 |
|
194 |
$widget['donnees']['observations'] = $observations;
|
200 |
$widget['donnees']['observations'] = $observations;
|
195 |
$widget['donnees']['station_id'] = $station;
|
201 |
$widget['donnees']['station_id'] = $station;
|
196 |
|
202 |
|
197 |
return $widget;
|
203 |
return $widget;
|
198 |
}
|
204 |
}
|
199 |
|
205 |
|
200 |
private function chargerObservation($station) {
|
206 |
private function chargerObservation($station) {
|
201 |
extract($this->parametres);
|
207 |
extract($this->parametres);
|
202 |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*');
|
208 |
$utilisateur = (isset($utilisateur) ? $utilisateur : '*');
|
203 |
$projet = (isset($projet) ? $projet : '*');
|
209 |
$projet = (isset($projet) ? $projet : '*');
|
204 |
$dept = (isset($dept) ? $dept : '*');
|
210 |
$dept = (isset($dept) ? $dept : '*');
|
205 |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*');
|
211 |
$num_taxon = (isset($num_taxon) ? $num_taxon : '*');
|
206 |
|
212 |
|
207 |
// Récupération des données au format Json
|
213 |
// Récupération des données au format Json
|
208 |
$service = "CelWidgetMap/observations/$station/$utilisateur/$projet/$dept/$num_taxon";
|
214 |
$service = "CelWidgetMap/observations/$station/$utilisateur/$projet/$dept/$num_taxon";
|
209 |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
|
215 |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
|
210 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
216 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
211 |
$donnees = json_decode($json);
|
217 |
$donnees = json_decode($json);
|
212 |
|
218 |
|
213 |
// Post-traitement des données
|
219 |
// Post-traitement des données
|
214 |
$observations = $this->traiterObservations($donnees);
|
220 |
$observations = $this->traiterObservations($donnees);
|
215 |
|
221 |
|
216 |
return $observations;
|
222 |
return $observations;
|
217 |
}
|
223 |
}
|
218 |
|
224 |
|
219 |
private function traiterObservations($donnees) {
|
225 |
private function traiterObservations($donnees) {
|
220 |
$observations = array();
|
226 |
$observations = array();
|
221 |
if (is_array($donnees) && count($donnees) > 0) {
|
227 |
if (is_array($donnees) && count($donnees) > 0) {
|
222 |
foreach ($donnees as $donnee) {
|
228 |
foreach ($donnees as $donnee) {
|
223 |
$observation = array();
|
229 |
$observation = array();
|
224 |
$observation['id'] = $donnee->id;
|
230 |
$observation['id'] = $donnee->id;
|
225 |
$observation['nn'] = $this->etreVide($donnee->num_nom_sel) ? null : $donnee->num_nom_sel;
|
231 |
$observation['nn'] = $this->etreVide($donnee->num_nom_sel) ? null : $donnee->num_nom_sel;
|
226 |
$observation['nom'] = $this->nettoyerTexte($donnee->nom_sel);
|
232 |
$observation['nom'] = $this->nettoyerTexte($donnee->nom_sel);
|
227 |
$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y');
|
233 |
$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y');
|
228 |
$observation['lieu'] = $this->traiterLieu($donnee);
|
234 |
$observation['lieu'] = $this->traiterLieu($donnee);
|
229 |
$observation['observateur'] = $this->tronquerCourriel($donnee->identifiant);
|
235 |
$observation['observateur'] = $this->tronquerCourriel($donnee->identifiant);
|
230 |
|
236 |
|
231 |
$observations[] = $observation;
|
237 |
$observations[] = $observation;
|
232 |
$observations['commune'] = $this->nettoyerTexte($donnee->location);
|
238 |
$observations['commune'] = $this->nettoyerTexte($donnee->location);
|
233 |
$observations['ids'][] = $donnee->id;
|
239 |
$observations['ids'][] = $donnee->id;
|
234 |
}
|
240 |
}
|
235 |
}
|
241 |
}
|
236 |
return $observations;
|
242 |
return $observations;
|
237 |
}
|
243 |
}
|
238 |
|
244 |
|
239 |
private function traiterLieu($donnee) {
|
245 |
private function traiterLieu($donnee) {
|
240 |
$lieu = array();
|
246 |
$lieu = array();
|
241 |
if (isset($donnee->lieudit) && ! empty($donnee->lieudit)) {
|
247 |
if (isset($donnee->lieudit) && ! empty($donnee->lieudit)) {
|
242 |
$lieu[] = $donnee->lieudit;
|
248 |
$lieu[] = $donnee->lieudit;
|
243 |
}
|
249 |
}
|
244 |
if (isset($donnee->milieu) && ! empty($donnee->milieu)) {
|
250 |
if (isset($donnee->milieu) && ! empty($donnee->milieu)) {
|
245 |
$lieu[] = $donnee->milieu;
|
251 |
$lieu[] = $donnee->milieu;
|
246 |
}
|
252 |
}
|
247 |
return implode(', ', $lieu);
|
253 |
return implode(', ', $lieu);
|
248 |
}
|
254 |
}
|
249 |
|
255 |
|
250 |
private function choisirFormatSortie($observations_nbre) {
|
256 |
private function choisirFormatSortie($observations_nbre) {
|
251 |
extract($this->parametres);
|
257 |
extract($this->parametres);
|
252 |
$sortie = 'obs_tableau';
|
258 |
$sortie = 'obs_tableau';
|
253 |
if (isset($format) && $format != '*') {
|
259 |
if (isset($format) && $format != '*') {
|
254 |
$sortie = ($format == 'tableau' ) ? 'obs_tableau' : 'obs_liste';
|
260 |
$sortie = ($format == 'tableau' ) ? 'obs_tableau' : 'obs_liste';
|
255 |
} else {
|
261 |
} else {
|
256 |
$sortie = ($observations_nbre > 4) ? 'obs_tableau' : 'obs_liste';
|
262 |
$sortie = ($observations_nbre > 4) ? 'obs_tableau' : 'obs_liste';
|
257 |
}
|
263 |
}
|
258 |
return $sortie;
|
264 |
return $sortie;
|
259 |
}
|
265 |
}
|
260 |
|
266 |
|
261 |
private function chargerImages($obs_ids) {
|
267 |
private function chargerImages($obs_ids) {
|
262 |
// Récupération des données au format Json
|
268 |
// Récupération des données au format Json
|
263 |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids);
|
269 |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids);
|
264 |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
|
270 |
$url = sprintf($this->config['chemins']['baseURLServicesCelTpl'], $service);
|
265 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
271 |
$json = $this->getDao()->envoyerRequeteConsultation($url);
|
266 |
$donnees = json_decode($json);
|
272 |
$donnees = json_decode($json);
|
267 |
|
273 |
|
268 |
// Post-traitement des données
|
274 |
// Post-traitement des données
|
269 |
$images = $this->traiterImages($donnees);
|
275 |
$images = $this->traiterImages($donnees);
|
270 |
|
276 |
|
271 |
return $images;
|
277 |
return $images;
|
272 |
}
|
278 |
}
|
273 |
|
279 |
|
274 |
private function traiterImages($donnees) {
|
280 |
private function traiterImages($donnees) {
|
275 |
$images = array();
|
281 |
$images = array();
|
276 |
//echo '<br/><pre>'.print_r($donnees,true).'</pre>';
|
282 |
//echo '<br/><pre>'.print_r($donnees,true).'</pre>';
|
277 |
if (count($donnees) > 0) {
|
283 |
if (count($donnees) > 0) {
|
278 |
foreach ($donnees as $id_obs => $id_images) {
|
284 |
foreach ($donnees as $id_obs => $id_images) {
|
279 |
foreach ($id_images as $id_img) {
|
285 |
foreach ($id_images as $id_img) {
|
280 |
$urls['id'] = $id_img;
|
286 |
$urls['id'] = $id_img;
|
281 |
$urls['S'] = $this->getUrlImage($id_img, 'S');
|
287 |
$urls['S'] = $this->getUrlImage($id_img, 'S');
|
282 |
$urls['L'] = $this->getUrlImage($id_img, 'L');
|
288 |
$urls['L'] = $this->getUrlImage($id_img, 'L');
|
283 |
$images[$id_obs][] = $urls;
|
289 |
$images[$id_obs][] = $urls;
|
284 |
}
|
290 |
}
|
285 |
}
|
291 |
}
|
286 |
}
|
292 |
}
|
287 |
return $images;
|
293 |
return $images;
|
288 |
}
|
294 |
}
|
289 |
|
295 |
|
290 |
/**
|
296 |
/**
|
291 |
* Afficher message d'avertissement.
|
297 |
* Afficher message d'avertissement.
|
292 |
*/
|
298 |
*/
|
293 |
public function executerAvertissement() {
|
299 |
public function executerAvertissement() {
|
294 |
$widget = null;
|
300 |
$widget = null;
|
295 |
|
301 |
|
296 |
// Création des infos du widget
|
302 |
// Création des infos du widget
|
297 |
$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
303 |
$widget['donnees']['url_base'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], '');
|
298 |
$widget['squelette'] = 'avertissement';
|
304 |
$widget['squelette'] = 'avertissement';
|
299 |
|
305 |
|
300 |
return $widget;
|
306 |
return $widget;
|
301 |
}
|
307 |
}
|
302 |
}
|
308 |
}
|