1121 |
aurelien |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Service fournissant une carte dynamique des obsertions publiques du CEL.
|
|
|
5 |
* Encodage en entrée : utf8
|
|
|
6 |
* Encodage en sortie : utf8
|
|
|
7 |
*
|
|
|
8 |
* Cas d'utilisation :
|
|
|
9 |
* /CelWidgetMap/Carte/Utilisateur : carte des observations publiques d'un utilisateur.
|
|
|
10 |
* /CelWidgetMap/Carte/Utilisateur/Projet : carte des observations publiques d'un utilisateur pour un projet.
|
|
|
11 |
* /CelWidgetMap/Carte/Utilisateur/Projet/dept : carte des observations publiques d'un utilisateur pour un projet sur un département.
|
|
|
12 |
* /CelWidgetMap/Carte/Utilisateur/Projet/dept/num_taxon : carte des observations publiques d'un utilisateur pour un projet sur un département pour un taxon.
|
|
|
13 |
*
|
|
|
14 |
* Carte = Type de carte. Valeurs possible : defaut,
|
|
|
15 |
* Utilisateur = identifiant (= courriel) de l'utilisateur ou * pour tous les utilisateurs.
|
|
|
16 |
* Projet = mot-clé du projet
|
|
|
17 |
*
|
|
|
18 |
* @author Jean-Pascal MILCENT <jpm@clapas.org>
|
|
|
19 |
* @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
|
|
|
20 |
* @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
|
|
|
21 |
* @version $Id$
|
|
|
22 |
* @copyright © 2010, Jean-Pascal MILCENT
|
|
|
23 |
*/
|
|
|
24 |
// TODO : supprimer le TRIM quand les obs seront reliées correctements aux localisations (sur le code INSEE par exemple)
|
|
|
25 |
class CelWidgetMapPoint extends Cel {
|
|
|
26 |
const MARQUEUR_GROUPE = 'GROUPE';
|
|
|
27 |
const MARQUEUR_COMMUNE = 'COMMUNE';
|
|
|
28 |
const MARQUEUR_STATION = 'STATION';
|
|
|
29 |
/**
|
|
|
30 |
* Méthode appelée avec une requête de type GET.
|
|
|
31 |
*/
|
|
|
32 |
public function getElement($ressources) {
|
|
|
33 |
$retour = null;
|
1131 |
aurelien |
34 |
if($this->parametres == null) {
|
|
|
35 |
$this->parametres = array();
|
|
|
36 |
}
|
1121 |
aurelien |
37 |
extract($this->parametres);
|
|
|
38 |
//Chronometre::chrono("Avant groupage");
|
|
|
39 |
|
|
|
40 |
$action = array_shift($ressources);
|
|
|
41 |
if (isset($action)) {
|
|
|
42 |
$methode = $this->traiterNomMethodeGet($action);
|
|
|
43 |
if (method_exists($this, $methode)) {
|
|
|
44 |
$retour = $this->$methode($ressources);
|
|
|
45 |
} else {
|
|
|
46 |
$this->messages[] = "Ce type de ressource '$methode' n'est pas disponible.";
|
|
|
47 |
}
|
|
|
48 |
} else {
|
|
|
49 |
$this->messages[] = "Vous devez indiquer le type de ressource.";
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
//Chronometre::chrono("Apres traitement");
|
|
|
53 |
//echo Chronometre::afficherChrono();
|
|
|
54 |
if (is_null($retour)) {
|
|
|
55 |
$info = 'Un problème est survenu : '.print_r($this->messages, true);
|
|
|
56 |
$this->envoyer($info);
|
|
|
57 |
} else if (isset($retour['type']) && $retour['type'] == 'jsonVar') {
|
|
|
58 |
$this->envoyerJsonVar($retour['variable_js'], $retour['donnees']);
|
|
|
59 |
} else if (isset($retour['type']) && $retour['type'] == 'jsonP') {
|
|
|
60 |
$this->envoyerJsonp($retour['donnees']);
|
|
|
61 |
} else if (isset($retour['type']) && $retour['type'] == 'png') {
|
|
|
62 |
header("Content-type: image/png");
|
|
|
63 |
imagepng($retour['img']);
|
|
|
64 |
imagedestroy($retour['img']);
|
|
|
65 |
} else {
|
|
|
66 |
$this->envoyerJson($retour);
|
|
|
67 |
}
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* Les icones des groupes de stations
|
|
|
72 |
*/
|
|
|
73 |
public function getIconeGroupe($params) {
|
|
|
74 |
extract($this->parametres);
|
|
|
75 |
|
|
|
76 |
$chemin_marqueur = sprintf($this->config['settings']['cheminCelMarkerObsTpl'], $type);
|
|
|
77 |
$img = imagecreatefrompng($chemin_marqueur);
|
|
|
78 |
|
|
|
79 |
$noir = imagecolorallocate($img, 0, 0, 0);
|
|
|
80 |
$texte = (String) $nbre;
|
|
|
81 |
$x = (imagesx($img) - 6.0 * strlen($texte)) / 2;
|
|
|
82 |
$y = (imagesy($img) - 16) / 2;
|
|
|
83 |
|
|
|
84 |
imagestring($img, 3, $x, $y, $texte, $noir);
|
|
|
85 |
|
|
|
86 |
imagealphablending($img, false);
|
|
|
87 |
imagesavealpha($img, true);
|
|
|
88 |
|
|
|
89 |
return array('type' => 'png', 'img' => $img);
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
/**
|
|
|
93 |
* Les stations de la carte par défaut
|
|
|
94 |
*/
|
|
|
95 |
public function getStations($params) {
|
|
|
96 |
$stations = null;
|
|
|
97 |
$requete = 'SELECT wgs84_latitude AS lat, wgs84_longitude AS lng, location AS nom '.
|
|
|
98 |
'FROM cel_inventory AS i '.
|
|
|
99 |
' LEFT JOIN locations AS l '.
|
|
|
100 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
101 |
"WHERE transmission = '1' ".
|
|
|
102 |
" AND (( ".
|
|
|
103 |
" (coord_x = '' OR coord_x IS NULL OR coord_x = '000null') ".
|
|
|
104 |
" AND (coord_y = '' OR coord_y IS NULL OR coord_y = '000null') ".
|
|
|
105 |
" ) OR mots_cles_texte LIKE '%sensible%') ".
|
|
|
106 |
$this->construireWhereRectangleCommune().
|
|
|
107 |
$this->construireWhereDept().
|
|
|
108 |
$this->construireWhereCommune().
|
|
|
109 |
$this->construireWhereUtilisateur().
|
|
|
110 |
$this->construireWhereNumTaxon().
|
|
|
111 |
$this->construireWhereNomTaxon().
|
|
|
112 |
$this->construireWhereDate().
|
|
|
113 |
$this->construireWhereCommentaire().
|
|
|
114 |
$this->construireWhereProjet().
|
|
|
115 |
$this->construireWhereTag();
|
|
|
116 |
|
|
|
117 |
$resultats_communes = $this->requeter($requete);
|
|
|
118 |
|
|
|
119 |
$requete = 'SELECT coord_x AS lat, coord_y AS lng, location AS nom '.
|
|
|
120 |
'FROM cel_inventory AS i '.
|
|
|
121 |
' LEFT JOIN locations AS l '.
|
|
|
122 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
123 |
"WHERE transmission = '1' ".
|
|
|
124 |
" AND coord_x != '' AND coord_x IS NOT NULL AND coord_x != '000null' ".
|
|
|
125 |
" AND coord_y != '' AND coord_y IS NOT NULL AND coord_y != '000null' ".
|
|
|
126 |
" AND (mots_cles_texte IS NULL OR mots_cles_texte NOT LIKE '%sensible%') ".
|
|
|
127 |
$this->construireWhereRectangleStation().
|
|
|
128 |
$this->construireWhereDept().
|
|
|
129 |
$this->construireWhereCommune().
|
|
|
130 |
$this->construireWhereUtilisateur().
|
|
|
131 |
$this->construireWhereNumTaxon().
|
|
|
132 |
$this->construireWhereNomTaxon().
|
|
|
133 |
$this->construireWhereDate().
|
|
|
134 |
$this->construireWhereCommentaire().
|
|
|
135 |
$this->construireWhereProjet().
|
|
|
136 |
$this->construireWhereTag();
|
|
|
137 |
|
|
|
138 |
$resultats_stations = $this->requeter($requete);
|
|
|
139 |
$stations = $this->traiterStations($resultats_communes, $resultats_stations);
|
|
|
140 |
|
|
|
141 |
return $stations;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
public function getTout($params) {
|
|
|
145 |
|
1138 |
aurelien |
146 |
$emplacements = null;
|
|
|
147 |
$concatenation_id = 'CONCAT(coord_x,coord_y, wgs84_latitude,wgs84_longitude) ';
|
1122 |
aurelien |
148 |
|
|
|
149 |
$requete = 'SELECT DISTINCT *, location AS nom, '.
|
1138 |
aurelien |
150 |
"mots_cles_texte, ".
|
1121 |
aurelien |
151 |
"coord_x, ".
|
1138 |
aurelien |
152 |
"wgs84_latitude, ".
|
1121 |
aurelien |
153 |
"coord_y, ".
|
1138 |
aurelien |
154 |
"wgs84_longitude, ".
|
|
|
155 |
$concatenation_id." as id_coord ".
|
1121 |
aurelien |
156 |
'FROM cel_inventory AS i '.
|
|
|
157 |
' LEFT JOIN locations AS l '.
|
|
|
158 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
159 |
"WHERE transmission = '1' ".
|
|
|
160 |
" AND (".
|
1138 |
aurelien |
161 |
$this->construireWhereRectangleStationOR()." OR ".
|
|
|
162 |
$this->construireWhereRectangleCommuneOR().") ".
|
1121 |
aurelien |
163 |
$this->construireWhereDept().
|
|
|
164 |
$this->construireWhereCommune().
|
|
|
165 |
$this->construireWhereUtilisateur().
|
|
|
166 |
$this->construireWhereNumTaxon().
|
|
|
167 |
$this->construireWhereNomTaxon().
|
|
|
168 |
$this->construireWhereDate().
|
|
|
169 |
$this->construireWhereCommentaire().
|
|
|
170 |
$this->construireWhereProjet().
|
1138 |
aurelien |
171 |
$this->construireWhereTag().' GROUP BY id_coord';
|
1121 |
aurelien |
172 |
$resultats_emplacements = $this->executerRequete($requete);
|
|
|
173 |
$emplacements = $this->traiterEmplacements($resultats_emplacements, $this->compterObservations($params));
|
|
|
174 |
return $emplacements;
|
|
|
175 |
}
|
1122 |
aurelien |
176 |
|
|
|
177 |
private function afficherRequeteFormatee($requete) {
|
|
|
178 |
$requete = str_replace(')',')<br />',$requete);
|
|
|
179 |
$requete = str_replace('(',' <br /> (',$requete);
|
|
|
180 |
echo '<pre>'.$requete.'</pre>';
|
|
|
181 |
exit;
|
|
|
182 |
}
|
1121 |
aurelien |
183 |
|
|
|
184 |
private $nb_obs = 0;
|
|
|
185 |
|
|
|
186 |
private function compterObservations($params) {
|
|
|
187 |
$requete = 'SELECT COUNT(*) AS nb '.
|
|
|
188 |
'FROM cel_inventory AS i '.
|
|
|
189 |
' LEFT JOIN locations AS l '.
|
|
|
190 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
191 |
"WHERE transmission = '1' ".
|
1138 |
aurelien |
192 |
" AND ".
|
|
|
193 |
"(".$this->construireWhereRectangleStationOR()." OR ".
|
|
|
194 |
$this->construireWhereRectangleCommuneOR().
|
1121 |
aurelien |
195 |
$this->construireWhereDept().
|
|
|
196 |
$this->construireWhereCommune().
|
|
|
197 |
$this->construireWhereUtilisateur().
|
|
|
198 |
$this->construireWhereNumTaxon().
|
|
|
199 |
$this->construireWhereNomTaxon().
|
|
|
200 |
$this->construireWhereDate().
|
|
|
201 |
$this->construireWhereCommentaire().
|
|
|
202 |
$this->construireWhereProjet().
|
|
|
203 |
$this->construireWhereTag();
|
|
|
204 |
|
|
|
205 |
$resultats_nb_obs = $this->executerRequete($requete);
|
|
|
206 |
return $resultats_nb_obs[0]['nb'];
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
private function traiterEmplacements(&$emplacements, $nb_total_observation) {
|
|
|
210 |
$zoom = (int) array_key_exists('zoom', $this->parametres) ? $this->parametres['zoom'] : 11;
|
|
|
211 |
$distance = (int) array_key_exists('distance', $this->parametres) ? $this->parametres['distance'] : 20;
|
|
|
212 |
|
|
|
213 |
$marqueurs = array(
|
|
|
214 |
'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0),
|
|
|
215 |
'points' => null
|
|
|
216 |
);
|
|
|
217 |
|
1131 |
aurelien |
218 |
if (isset($this->parametres['ne']) && $this->parametres['sw'] && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
1121 |
aurelien |
219 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
220 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
221 |
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree($emplacements, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
|
|
|
222 |
|
|
|
223 |
// laisser la classe cartoGroupage compter les élements simplifie le comptage
|
|
|
224 |
// et permet de ne pas reparser le tableau pour compter les différents éléments
|
|
|
225 |
$nb_elements = CartoGroupage::getNbElements();
|
1138 |
aurelien |
226 |
// les bornes servent à centrer la carte dans le cas ou l'on demande des paramètres précis
|
1122 |
aurelien |
227 |
$marqueurs['stats']['coordmax'] = CartoGroupage::getBornes();
|
1121 |
aurelien |
228 |
$marqueurs['stats']['stations'] = $nb_elements['stations'];
|
|
|
229 |
$marqueurs['stats']['communes'] = $nb_elements['communes'];
|
|
|
230 |
$marqueurs['stats']['observations'] = (int)$nb_total_observation;
|
|
|
231 |
} else {
|
|
|
232 |
$marqueurs['points'] = $emplacements;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
return $marqueurs;
|
|
|
236 |
}
|
|
|
237 |
|
|
|
238 |
private function traiterStations($communes, $stations) {
|
|
|
239 |
$zoom = (int) array_key_exists('zoom', $this->parametres) ? $this->parametres['zoom'] : 11;
|
|
|
240 |
$distance = (int) array_key_exists('distance', $this->parametres) ? $this->parametres['distance'] : 20;
|
|
|
241 |
|
|
|
242 |
$marqueurs = array(
|
|
|
243 |
'stats' => array('stations' => 0, 'communes' => 0, 'observations' => 0),
|
|
|
244 |
'points' => null
|
|
|
245 |
);
|
|
|
246 |
$marqueurs['stats']['observations'] = $this->traiterNbreObs($communes) + $this->traiterNbreObs($stations);
|
|
|
247 |
|
|
|
248 |
$points = array();
|
|
|
249 |
if ($communes !== false) {
|
|
|
250 |
foreach ($communes as $commune) {
|
|
|
251 |
if (is_numeric($commune['lat']) && is_numeric($commune['lng'])) {
|
|
|
252 |
extract($commune);
|
|
|
253 |
$id = self::MARQUEUR_COMMUNE.':'.$lat.'|'.$lng;
|
|
|
254 |
$lata = round($lat, 5);
|
|
|
255 |
$lnga = round($lng, 5);
|
|
|
256 |
|
|
|
257 |
if (!isset($points[$id])) {
|
|
|
258 |
$points[$id]['id'] = $id;
|
|
|
259 |
$points[$id]['nom'] = $nom;
|
|
|
260 |
$points[$id]['lat'] = $lata;
|
|
|
261 |
$points[$id]['lng'] = $lnga;
|
|
|
262 |
$points[$id]['nbre'] = 1;
|
|
|
263 |
$marqueurs['stats']['communes']++;
|
|
|
264 |
} else {
|
|
|
265 |
$points[$id]['nbre']++;
|
|
|
266 |
}
|
|
|
267 |
}
|
|
|
268 |
}
|
|
|
269 |
}
|
|
|
270 |
if ($stations !== false) {
|
|
|
271 |
foreach ($stations as $station) {
|
|
|
272 |
if (is_numeric($station['lat']) && is_numeric($station['lng'])) {
|
|
|
273 |
extract($station);
|
|
|
274 |
$id = self::MARQUEUR_STATION.':'.$lat.'|'.$lng;
|
|
|
275 |
//$this->definirLatLngMaxMin($marqueurs, $lat, $lng);
|
|
|
276 |
$lata = round($lat, 5);
|
|
|
277 |
$lnga = round($lng, 5);
|
|
|
278 |
$nom = $this->etreNull($nom) ? $lata.','.$lnga : $nom;
|
|
|
279 |
|
|
|
280 |
if (!isset($points[$id])) {
|
|
|
281 |
$points[$id]['id'] = $id;
|
|
|
282 |
$points[$id]['nom'] = $nom;
|
|
|
283 |
$points[$id]['lat'] = $lata;
|
|
|
284 |
$points[$id]['lng'] = $lnga;
|
|
|
285 |
$points[$id]['nbre'] = 1;
|
|
|
286 |
$marqueurs['stats']['stations']++;
|
|
|
287 |
} else {
|
|
|
288 |
$points[$id]['nbre']++;
|
|
|
289 |
}
|
|
|
290 |
}
|
|
|
291 |
}
|
|
|
292 |
}
|
|
|
293 |
|
1131 |
aurelien |
294 |
if (isset($this->parametres['ne']) && $this->parametres['sw'] && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
1121 |
aurelien |
295 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
296 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
297 |
$marqueurs['points'] = CartoGroupage::creerGroupesQuadtree(&$points, $ne['lat'], $ne['lng'], $sw['lat'], $sw['lng'], $zoom);
|
|
|
298 |
} else {
|
|
|
299 |
$marqueurs['points'] = $points;
|
|
|
300 |
}
|
|
|
301 |
//$marqueurs['stats']['latDiff'] = abs($marqueurs['stats']['latMin'] - $marqueurs['stats']['latMax']);
|
|
|
302 |
//$marqueurs['stats']['lngDiff'] = abs($marqueurs['stats']['lngMin'] - $marqueurs['stats']['lngMax']);
|
|
|
303 |
|
|
|
304 |
return $marqueurs;
|
|
|
305 |
}
|
|
|
306 |
|
|
|
307 |
private function definirLatLngMaxMin(&$marqueurs, $lat, $lng) {
|
|
|
308 |
if ($lat != null && $lng != null) {
|
|
|
309 |
$marqueurs['stats']['latMin'] = $marqueurs['stats']['latMin'] > $lat ? $lat : $marqueurs['stats']['latMin'];
|
|
|
310 |
$marqueurs['stats']['lngMin'] = $marqueurs['stats']['lngMin'] > $lng ? $lng : $marqueurs['stats']['lngMin'];
|
|
|
311 |
$marqueurs['stats']['latMax'] = $marqueurs['stats']['latMax'] < $lat ? $lat : $marqueurs['stats']['latMax'];
|
|
|
312 |
$marqueurs['stats']['lngMax'] = $marqueurs['stats']['lngMax'] < $lng ? $lng : $marqueurs['stats']['lngMax'];
|
|
|
313 |
}
|
|
|
314 |
}
|
|
|
315 |
|
|
|
316 |
private function traiterNbreObs($resultats) {
|
|
|
317 |
$obs_nbre = 0;
|
|
|
318 |
if ($resultats !== false) {
|
|
|
319 |
$obs_nbre = count($resultats);
|
|
|
320 |
}
|
|
|
321 |
return $obs_nbre;
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
private function verifierLatLng($lat, $lng) {
|
|
|
325 |
$ok_lat = $this->etreLatitude($lat) ? true : false;
|
|
|
326 |
$ok_lng = $this->etreLongitude($lng) ? true : false;
|
|
|
327 |
$ok = $ok_lat && $ok_lng;
|
|
|
328 |
return $ok;
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
private function etreLatitude($lat) {
|
|
|
332 |
$ok = false;
|
|
|
333 |
//$format = preg_match('/^[-]?[0-9]+(?:[.][0-9]+|)$/', $lat) ? true : false;
|
|
|
334 |
$ok = ($lat >= -90 && $lat <= 90) ? true : false;
|
|
|
335 |
return $ok;
|
|
|
336 |
}
|
|
|
337 |
|
|
|
338 |
private function etreLongitude($lng) {
|
|
|
339 |
$ok = false;
|
|
|
340 |
//$format = preg_match('/^[-]?[0-9]+(?:[.][0-9]+|)$/', $lng) ? true : false;
|
|
|
341 |
$ok = ($lng >= -180 && $lng <= 180) ? true : false;
|
|
|
342 |
return $ok;
|
|
|
343 |
}
|
|
|
344 |
|
|
|
345 |
private function etreObsSensible($tags) {
|
|
|
346 |
$sensible = true;
|
|
|
347 |
if (stristr($tags, 'sensible') === FALSE) {
|
|
|
348 |
$sensible = false;
|
|
|
349 |
}
|
|
|
350 |
return $sensible;
|
|
|
351 |
}
|
|
|
352 |
|
|
|
353 |
/**
|
|
|
354 |
* Données pour l'affichage des obs d'une station
|
|
|
355 |
*/
|
|
|
356 |
public function getObservations($params) {
|
|
|
357 |
$resultats = array();
|
|
|
358 |
$total = 0;
|
1131 |
aurelien |
359 |
if (isset($this->parametres['station']) && !$this->etreNull($this->parametres['station'])) {
|
1121 |
aurelien |
360 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS id, identifiant, nom_sel, nom_ret, num_nom_sel, num_nom_ret, num_taxon, famille, '.
|
|
|
361 |
' lieudit, location, date_observation, milieu, commentaire, '.
|
|
|
362 |
' sector, x_utm, y_utm, insee_code, date_transmission '.
|
|
|
363 |
'FROM cel_inventory AS i '.
|
|
|
364 |
' LEFT JOIN locations AS l '.
|
|
|
365 |
" ON (l.name = i.location AND l.code = i.id_location) ".
|
|
|
366 |
"WHERE transmission = '1' ".
|
1122 |
aurelien |
367 |
((!$this->etreNull($this->parametres['commune'])) ? $this->construireWhereCommuneSansCoordonneesAvecSensibles() : $this->construireWhereCoordonneesSansSensibles()).
|
1138 |
aurelien |
368 |
$this->construireWhereDept().
|
1121 |
aurelien |
369 |
$this->construireWhereUtilisateur().
|
|
|
370 |
$this->construireWhereNumTaxon().
|
|
|
371 |
$this->construireWhereNomTaxon().
|
|
|
372 |
$this->construireWhereDate().
|
|
|
373 |
$this->construireWhereCommentaire().
|
|
|
374 |
$this->construireWhereProjet().
|
|
|
375 |
$this->construireWhereTag().
|
|
|
376 |
'ORDER BY nom_sel ASC '.
|
|
|
377 |
"LIMIT {$this->start},{$this->limit} ";
|
|
|
378 |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
|
|
|
379 |
$requete = 'SELECT FOUND_ROWS()';
|
|
|
380 |
$total = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
// Post-traitement
|
|
|
384 |
$observations = $this->traiterObservations($resultats, $total);
|
|
|
385 |
$observations = $this->ajouterImagesAuxObs($observations);
|
|
|
386 |
$observations = $this->ajouterAuteursAuxObs($observations);
|
|
|
387 |
$observations = $this->supprimerIdDesObs($observations);
|
|
|
388 |
|
|
|
389 |
return $observations;
|
|
|
390 |
}
|
|
|
391 |
|
|
|
392 |
private function traiterObservations($donnees, $total) {
|
|
|
393 |
$observations = array('commune' => '', 'observations' => array(), 'observateurs' => array());
|
|
|
394 |
$observations['total'] = (isset($total)) ? $total : 0;
|
|
|
395 |
if (is_array($donnees) && count($donnees) > 0) {
|
|
|
396 |
foreach ($donnees as $donnee) {
|
|
|
397 |
$observation = array();
|
|
|
398 |
$observation['idObs'] = $donnee->id;
|
|
|
399 |
$observation['nn'] = $this->etreNull($donnee->num_nom_sel) ? null : $donnee->num_nom_sel;
|
|
|
400 |
$observation['nomSci'] = $this->nettoyerTexte($donnee->nom_sel);
|
|
|
401 |
$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y');
|
|
|
402 |
$observation['datePubli'] = $this->formaterDate($donnee->date_transmission);
|
|
|
403 |
$observation['lieu'] = $this->traiterLieu($donnee);
|
|
|
404 |
$observation['observateur'] = $donnee->identifiant;
|
|
|
405 |
$observation['urlEflore'] = $this->getUrlEflore($donnee->num_nom_sel);
|
|
|
406 |
|
|
|
407 |
if (isset($donnee->location)) {
|
|
|
408 |
$observations['commune'] = $this->nettoyerTexte($donnee->location);
|
|
|
409 |
}
|
|
|
410 |
$observations['observations'][$donnee->id] = $observation;
|
|
|
411 |
|
|
|
412 |
if (! array_key_exists($donnee->identifiant, $observations['observateurs'])) {
|
|
|
413 |
$observations['observateurs'][$donnee->identifiant] = $donnee->identifiant;
|
|
|
414 |
}
|
|
|
415 |
}
|
|
|
416 |
}
|
|
|
417 |
return $observations;
|
|
|
418 |
}
|
|
|
419 |
|
|
|
420 |
private function getUrlEflore($nn) {
|
|
|
421 |
$urlEflore = null;
|
|
|
422 |
if (! $this->etreNull($nn)) {
|
|
|
423 |
$urlEflore = sprintf($this->config['settings']['efloreUrlTpl'], $nn, 'illustration');
|
|
|
424 |
}
|
|
|
425 |
return $urlEflore;
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
private function traiterLieu($donnee) {
|
|
|
429 |
$lieu = array();
|
|
|
430 |
if (!$this->etreNull($donnee->lieudit)) {
|
|
|
431 |
$lieu[] = $donnee->lieudit;
|
|
|
432 |
}
|
|
|
433 |
if (!$this->etreNull($donnee->milieu)) {
|
|
|
434 |
$lieu[] = $donnee->milieu;
|
|
|
435 |
}
|
|
|
436 |
return implode(', ', $lieu);
|
|
|
437 |
}
|
|
|
438 |
|
|
|
439 |
private function chargerImages(Array $obs_ids) {
|
|
|
440 |
// Récupération des données au format Json
|
|
|
441 |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids);
|
|
|
442 |
$url = sprintf($this->config['settings']['baseURLServicesCelTpl'], $service);
|
|
|
443 |
$json = $this->getRestClient()->consulter($url);
|
|
|
444 |
$donnees = json_decode($json);
|
|
|
445 |
|
|
|
446 |
// Post-traitement des données
|
|
|
447 |
$images = $this->traiterImages($donnees);
|
|
|
448 |
|
|
|
449 |
return $images;
|
|
|
450 |
}
|
|
|
451 |
|
|
|
452 |
private function traiterImages($donnees) {
|
|
|
453 |
$images = array();
|
|
|
454 |
if (count($donnees) > 0) {
|
|
|
455 |
foreach ($donnees as $id_obs => $id_images) {
|
|
|
456 |
foreach ($id_images as $id_img) {
|
|
|
457 |
$urls['idImg'] = $id_img;
|
|
|
458 |
$urls['guid'] = sprintf($this->config['settings']['guidImgTpl'], $id_img);
|
|
|
459 |
$urls['miniature'] = $this->getUrlImage($id_img, 'CXS');
|
|
|
460 |
$urls['normale'] = $this->getUrlImage($id_img, 'XL');
|
|
|
461 |
$images[$id_obs][] = $urls;
|
|
|
462 |
}
|
|
|
463 |
}
|
|
|
464 |
}
|
|
|
465 |
return $images;
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
private function ajouterImagesAuxObs($observations) {
|
|
|
469 |
$images = $this->chargerImages(array_keys($observations['observations']));
|
|
|
470 |
foreach ($observations['observations'] as $id => $infos) {
|
1122 |
aurelien |
471 |
if(isset($images[$id])) {
|
|
|
472 |
$infos['images'] = $images[$id];
|
|
|
473 |
$observations['observations'][$id] = $infos;
|
|
|
474 |
}
|
1121 |
aurelien |
475 |
}
|
|
|
476 |
return $observations;
|
|
|
477 |
}
|
|
|
478 |
|
|
|
479 |
private function ajouterAuteursAuxObs($observations) {
|
|
|
480 |
$observateurs = $this->recupererUtilisateursIdentite(array_keys($observations['observateurs']));
|
|
|
481 |
unset($observations['observateurs']);
|
|
|
482 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
483 |
$courriel = $infos['observateur'];
|
|
|
484 |
$infos['observateur'] = $observateurs[$courriel]['intitule'];
|
|
|
485 |
$infos['observateurId'] = $observateurs[$courriel]['id'];
|
|
|
486 |
$observations['observations'][$id] = $infos;
|
|
|
487 |
}
|
|
|
488 |
return $observations;
|
|
|
489 |
}
|
|
|
490 |
|
|
|
491 |
private function supprimerIdDesObs($observations) {
|
|
|
492 |
// Le tableau de sortie ne doit pas avoir les id des obs en clé car sinon Jquery Template ne fonctionne pas
|
|
|
493 |
$observationSansId = $observations;
|
|
|
494 |
unset($observationSansId['observations']);
|
|
|
495 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
496 |
$observationSansId['observations'][] = $infos;
|
|
|
497 |
}
|
|
|
498 |
return $observationSansId;
|
|
|
499 |
}
|
|
|
500 |
|
|
|
501 |
/**
|
|
|
502 |
* Liste des taxons présents sur la carte
|
|
|
503 |
*/
|
|
|
504 |
public function getTaxons($params) {
|
|
|
505 |
$json = null;
|
|
|
506 |
|
|
|
507 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, num_nom_ret, num_taxon, famille '.
|
|
|
508 |
'FROM cel_inventory AS i '.
|
|
|
509 |
' LEFT JOIN locations AS l '.
|
|
|
510 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
511 |
"WHERE transmission = '1' ".
|
|
|
512 |
" AND nom_ret != '' ".
|
|
|
513 |
$this->construireWhereDept().
|
|
|
514 |
$this->construireWhereCommune().
|
|
|
515 |
$this->construireWhereUtilisateur().
|
|
|
516 |
$this->construireWhereNumTaxon().
|
|
|
517 |
$this->construireWhereNomTaxon().
|
|
|
518 |
$this->construireWhereDate().
|
|
|
519 |
$this->construireWhereCommentaire().
|
|
|
520 |
$this->construireWhereProjet().
|
|
|
521 |
$this->construireWhereTag().
|
|
|
522 |
'ORDER BY nom_ret ASC '.
|
|
|
523 |
"LIMIT {$this->start},{$this->limit} ";
|
|
|
524 |
//$this->debug[] = $requete;
|
|
|
525 |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
|
|
|
526 |
|
|
|
527 |
$requete = 'SELECT FOUND_ROWS()';
|
|
|
528 |
$taxons['total'] = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
|
|
|
529 |
|
|
|
530 |
// Post-traitement
|
|
|
531 |
$taxons['taxons'] = $this->traiterTaxons($resultats);
|
|
|
532 |
|
|
|
533 |
return $taxons;
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
private function traiterTaxons($donnees) {
|
|
|
537 |
$taxons = array();
|
|
|
538 |
if (is_array($donnees) && count($donnees) > 0) {
|
|
|
539 |
foreach ($donnees as $donnee) {
|
|
|
540 |
if (!isset($taxons[$donnee->num_taxon]) && ! $this->etreNull($donnee->nom_ret)) {
|
|
|
541 |
$taxon = array();
|
|
|
542 |
$taxon['nn'] = $donnee->num_nom_ret;
|
|
|
543 |
$taxon['nt'] = $donnee->num_taxon;
|
|
|
544 |
$taxon['nom'] = $this->nettoyerTexte($donnee->nom_ret);
|
|
|
545 |
$taxon['famille'] = $this->nettoyerTexte($donnee->famille);
|
|
|
546 |
$taxons[$donnee->num_taxon] = $taxon;
|
|
|
547 |
}
|
|
|
548 |
}
|
|
|
549 |
}
|
|
|
550 |
$taxons = array_values($taxons);
|
|
|
551 |
return $taxons;
|
|
|
552 |
}
|
|
|
553 |
|
|
|
554 |
private function construireWhereCoordonnees() {
|
|
|
555 |
$sql = '';
|
|
|
556 |
// Récupération des coordonnées depuis l'id station
|
|
|
557 |
extract($this->decomposerParametreStation());
|
|
|
558 |
if (isset($type)) {
|
|
|
559 |
if ($type == self::MARQUEUR_COMMUNE) {
|
|
|
560 |
$lat = $this->proteger($lat);
|
|
|
561 |
$lng = $this->proteger($lng);
|
|
|
562 |
$sql = " AND (ROUND(wgs84_latitude,5) = ROUND($lat,5) AND ROUND(wgs84_longitude,5) = ROUND($lng,5)) ";
|
|
|
563 |
} else if ($type == self::MARQUEUR_STATION) {
|
|
|
564 |
$lat = $this->proteger($lat);
|
|
|
565 |
$lng = $this->proteger($lng);
|
|
|
566 |
$sql = " AND (coord_x = $lat AND coord_y = $lng) ";
|
|
|
567 |
}
|
|
|
568 |
}
|
|
|
569 |
return $sql;
|
|
|
570 |
}
|
1122 |
aurelien |
571 |
|
|
|
572 |
private function construireWhereCoordonneesSansSensibles() {
|
|
|
573 |
$sql = '(';
|
|
|
574 |
// Récupération des coordonnées depuis l'id station
|
|
|
575 |
extract($this->decomposerParametreStation());
|
|
|
576 |
if (isset($type)) {
|
|
|
577 |
if ($type == self::MARQUEUR_COMMUNE) {
|
|
|
578 |
$lat = $this->proteger($lat);
|
|
|
579 |
$lng = $this->proteger($lng);
|
|
|
580 |
$sql = " AND (ROUND(wgs84_latitude,5) = ROUND($lat,5) AND ROUND(wgs84_longitude,5) = ROUND($lng,5)) ";
|
|
|
581 |
} else if ($type == self::MARQUEUR_STATION) {
|
|
|
582 |
$lat = $this->proteger($lat);
|
|
|
583 |
$lng = $this->proteger($lng);
|
|
|
584 |
$sql = " AND (coord_x = $lat AND coord_y = $lng) ";
|
|
|
585 |
}
|
|
|
586 |
}
|
1138 |
aurelien |
587 |
$sql .= ' AND mots_cles_texte NOT LIKE "%sensible%" ';
|
1122 |
aurelien |
588 |
return $sql;
|
|
|
589 |
}
|
1121 |
aurelien |
590 |
|
|
|
591 |
private function construireWhereCommentaire() {
|
|
|
592 |
$sql = '';
|
|
|
593 |
list($type, $commentaire) = $this->decomposerParametreCommentaire();
|
|
|
594 |
if (!$this->etreNull($commentaire)) {
|
|
|
595 |
$commentaire = $this->proteger('%'.$commentaire.'%');
|
|
|
596 |
switch ($type) {
|
|
|
597 |
case '*' :
|
|
|
598 |
$sql = $this->obtenirConditionPourCommentaires($commentaire);
|
|
|
599 |
$sql = " AND (commentaire LIKE $commentaire OR ($sql)) ";
|
|
|
600 |
break;
|
|
|
601 |
case 'observation' :
|
|
|
602 |
$sql = " AND commentaire LIKE $commentaire ";
|
|
|
603 |
break;
|
|
|
604 |
case 'photo' :
|
|
|
605 |
$sql = ' AND '.$this->obtenirConditionPourCommentaires($commentaire).' ';
|
|
|
606 |
break;
|
|
|
607 |
case 'photo.meta' :
|
|
|
608 |
$sql = ' AND '.$this->obtenirConditionPourCommentaireMeta($commentaire).' ';
|
|
|
609 |
break;
|
|
|
610 |
case 'photo.utilisateur' :
|
|
|
611 |
$sql = ' AND '.$this->obtenirConditionPourCommentaireUtilisateur($commentaire).' ';
|
|
|
612 |
break;
|
|
|
613 |
default:
|
|
|
614 |
$sql = " AND commentaire LIKE $commentaire ";
|
|
|
615 |
}
|
|
|
616 |
}
|
|
|
617 |
return $sql;
|
|
|
618 |
}
|
|
|
619 |
|
|
|
620 |
|
|
|
621 |
private function construireWhereNomTaxon() {
|
|
|
622 |
$sql = '';
|
|
|
623 |
list($type, $nom) = $this->decomposerParametreTaxon();
|
|
|
624 |
if (!$this->etreNull($nom)) {
|
|
|
625 |
$nom = $this->proteger($nom.'%');
|
|
|
626 |
switch ($type) {
|
|
|
627 |
case '*' :
|
|
|
628 |
$sql = " AND (nom_ret LIKE $nom OR nom_sel LIKE $nom OR famille LIKE $nom) ";
|
|
|
629 |
break;
|
|
|
630 |
case 'retenu' :
|
|
|
631 |
$sql = " AND nom_ret LIKE $nom ";
|
|
|
632 |
break;
|
|
|
633 |
case 'selectionne' :
|
|
|
634 |
$sql = " AND nom_sel LIKE $nom ";
|
|
|
635 |
break;
|
|
|
636 |
case 'famille' :
|
|
|
637 |
$sql = " AND famille LIKE $nom ";
|
|
|
638 |
break;
|
|
|
639 |
default:
|
|
|
640 |
$sql = " AND nom_ret LIKE $nom ";
|
|
|
641 |
}
|
|
|
642 |
}
|
|
|
643 |
return $sql;
|
|
|
644 |
}
|
|
|
645 |
|
|
|
646 |
private function construireWhereDate() {
|
|
|
647 |
$sql = '';
|
|
|
648 |
// Récupération des coordonnées depuis l'id station
|
|
|
649 |
list($type, $date) = $this->decomposerParametreDate();
|
|
|
650 |
|
|
|
651 |
if (!$this->etreNull($date)) {
|
|
|
652 |
$date = $this->proteger($date.'%');
|
|
|
653 |
switch ($type) {
|
|
|
654 |
case '*' :
|
|
|
655 |
$sql = " AND (
|
|
|
656 |
date_observation LIKE $date
|
|
|
657 |
OR date_creation LIKE $date
|
|
|
658 |
OR date_modification LIKE $date
|
|
|
659 |
OR date_transmission LIKE $date) ";
|
|
|
660 |
break;
|
|
|
661 |
case 'observation' :
|
|
|
662 |
$sql = " AND date_observation LIKE $date ";
|
|
|
663 |
break;
|
|
|
664 |
case 'creation' :
|
|
|
665 |
$sql = " AND date_creation LIKE $date ";
|
|
|
666 |
break;
|
|
|
667 |
case 'modification' :
|
|
|
668 |
$sql = " AND date_modification LIKE $date ";
|
|
|
669 |
break;
|
|
|
670 |
case 'transmission' :
|
|
|
671 |
$sql = " AND date_transmission LIKE $date ";
|
|
|
672 |
break;
|
|
|
673 |
case 'photo' :
|
|
|
674 |
$sql = $this->obtenirConditionPourDatePhoto($date);
|
|
|
675 |
break;
|
|
|
676 |
case 'ajout' :
|
|
|
677 |
$sql = $this->obtenirConditionPourDateAjout($date);
|
|
|
678 |
break;
|
|
|
679 |
case 'liaison' :
|
|
|
680 |
$sql = $this->obtenirConditionPourDateLiaison($date);
|
|
|
681 |
break;
|
|
|
682 |
default:
|
|
|
683 |
$sql = " AND date_observation LIKE $date ";
|
|
|
684 |
}
|
|
|
685 |
}
|
|
|
686 |
return $sql;
|
|
|
687 |
}
|
|
|
688 |
|
|
|
689 |
private function obtenirConditionPourDatePhoto($date) {
|
|
|
690 |
$observations = $this->obtenirObsLieesImg('date.photo', $date);
|
|
|
691 |
if (is_null($observations)) {
|
|
|
692 |
$this->debug[] = "Aucune observation n'est liée à une photo prise à la date : $date";
|
|
|
693 |
}
|
|
|
694 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
695 |
return $sql;
|
|
|
696 |
}
|
|
|
697 |
|
|
|
698 |
private function obtenirConditionPourDateLiaison($date) {
|
|
|
699 |
$observations = $this->obtenirObsLieesImg('date.liaison', $date);
|
|
|
700 |
if (is_null($observations)) {
|
|
|
701 |
$this->debug[] = "Aucune observation n'a été liée à une image à à la date : $date";
|
|
|
702 |
}
|
|
|
703 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
704 |
return $sql;
|
|
|
705 |
}
|
|
|
706 |
|
|
|
707 |
private function obtenirConditionPourDateAjout($date) {
|
|
|
708 |
$observations = $this->obtenirObsLieesImg('date.ajout', $date);
|
|
|
709 |
if (is_null($observations)) {
|
|
|
710 |
$this->debug[] = "Aucune observation n'est liée à une image ajoutée à la date : $date";
|
|
|
711 |
}
|
|
|
712 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
713 |
return $sql;
|
|
|
714 |
}
|
|
|
715 |
|
|
|
716 |
private function obtenirConditionPourCommentaireMeta($commentaire) {
|
|
|
717 |
$observations = $this->obtenirObsLieesImg('commentaire.meta', $commentaire);
|
|
|
718 |
if (is_null($observations)) {
|
|
|
719 |
$this->debug[] = "Aucune observation n'est liée à une image dont le commentaire des méta-données correspond à : $commmentaire";
|
|
|
720 |
}
|
|
|
721 |
$operateur = '';
|
|
|
722 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
723 |
return $sql;
|
|
|
724 |
}
|
|
|
725 |
|
|
|
726 |
private function obtenirConditionPourCommentaireUtilisateur($commentaire) {
|
|
|
727 |
$observations = $this->obtenirObsLieesImg('commentaire.utilisateur', $commentaire);
|
|
|
728 |
if (is_null($observations)) {
|
|
|
729 |
$this->debug[] = "Aucune observation n'est liée à une image dont le commentaire des utilisateur correspond à : $commmentaire";
|
|
|
730 |
}
|
|
|
731 |
$operateur = '';
|
|
|
732 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
733 |
return $sql;
|
|
|
734 |
}
|
|
|
735 |
|
|
|
736 |
private function obtenirConditionPourCommentaires($commentaire) {
|
|
|
737 |
$observations = $this->obtenirObsLieesImg('commentaire.*', $commentaire);
|
|
|
738 |
if (is_null($observations)) {
|
|
|
739 |
$this->debug[] = "Aucune observation n'est liée à une image dont un des commentaires correspond à : $commmentaire";
|
|
|
740 |
}
|
|
|
741 |
$operateur = '';
|
|
|
742 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
743 |
return $sql;
|
|
|
744 |
}
|
|
|
745 |
|
|
|
746 |
/**
|
|
|
747 |
* Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
|
|
|
748 |
* Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
|
|
|
749 |
*/
|
|
|
750 |
private function obtenirObsLieesImg($type, $param) {
|
|
|
751 |
// Construction de la requête
|
|
|
752 |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '.
|
|
|
753 |
'FROM cel_images '.
|
|
|
754 |
' LEFT JOIN cel_obs_images '.
|
|
|
755 |
' ON (ci_id_image = coi_ce_image) '.
|
|
|
756 |
' LEFT JOIN cel_inventory AS i '.
|
|
|
757 |
' ON (coi_ce_utilisateur = i.identifiant AND coi_ce_observation = i.ordre) '.
|
|
|
758 |
' LEFT JOIN locations AS l '.
|
|
|
759 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
760 |
"WHERE transmission = '1' ".
|
|
|
761 |
($type == 'date.photo' ? " AND (ci_meta_date_time LIKE ".str_replace('-', ':', $param)." OR ci_meta_date LIKE $param) " : '').
|
|
|
762 |
($type == 'date.ajout' ? " AND ci_meta_date_ajout LIKE $param " : '').
|
|
|
763 |
($type == 'date.liaison' ? " AND coi_date_liaison LIKE $param " : '').
|
|
|
764 |
($type == 'commentaire.meta' ? " AND ci_meta_comment LIKE $param " : '').
|
|
|
765 |
($type == 'commentaire.utilisateur' ? " AND ci_meta_user_comment LIKE $param " : '').
|
|
|
766 |
($type == 'commentaire.*' ? " AND (ci_meta_comment LIKE $param OR ci_meta_user_comment LIKE $param) " : '').
|
|
|
767 |
$this->construireWhereCoordonnees().
|
|
|
768 |
$this->construireWhereDept().
|
|
|
769 |
$this->construireWhereCommune().
|
|
|
770 |
$this->construireWhereUtilisateur().
|
|
|
771 |
$this->construireWhereNumTaxon().
|
|
|
772 |
$this->construireWhereNomTaxon().
|
|
|
773 |
$this->construireWhereProjet().
|
|
|
774 |
$this->construireWhereTag().
|
|
|
775 |
'ORDER BY utilisateur ASC, ordre ASC';
|
|
|
776 |
//$this->debug[] = $requete;
|
|
|
777 |
//die($requete);
|
|
|
778 |
$resultats = $this->executerRequete($requete);
|
|
|
779 |
|
|
|
780 |
$observations = null;
|
|
|
781 |
if ($resultats != false) {
|
|
|
782 |
$observations = array();
|
|
|
783 |
foreach ($resultats as $occurence) {
|
|
|
784 |
$utilisateur = $occurence['utilisateur'];
|
|
|
785 |
$ordre = $occurence['ordre'];
|
|
|
786 |
if (!array_key_exists($utilisateur, $observations)) {
|
|
|
787 |
$observations[$utilisateur] = array();
|
|
|
788 |
}
|
|
|
789 |
if (!array_key_exists($ordre, $observations[$utilisateur])) {
|
|
|
790 |
$observations[$utilisateur][$ordre] = $ordre;
|
|
|
791 |
}
|
|
|
792 |
}
|
|
|
793 |
}
|
|
|
794 |
return $observations;
|
|
|
795 |
}
|
|
|
796 |
|
|
|
797 |
private function assemblerObsEnConditionSql($observations, $operateur = 'AND') {
|
|
|
798 |
$sql = '';
|
|
|
799 |
if ($observations != null) {
|
|
|
800 |
// Pré-construction du where de la requête
|
|
|
801 |
$tpl_where = "(identifiant = '%s' AND ordre IN (%s))";
|
|
|
802 |
foreach ($observations as $utilisateur => $ordres) {
|
|
|
803 |
$morceaux_requete[] = sprintf($tpl_where, $utilisateur, implode(',', $ordres));
|
|
|
804 |
}
|
|
|
805 |
if (count($morceaux_requete) > 0) {
|
|
|
806 |
$sql = implode(" \nOR ", $morceaux_requete);
|
|
|
807 |
}
|
|
|
808 |
} else {
|
|
|
809 |
// Nous voulons que la requête ne retourne rien
|
|
|
810 |
$sql = "identifiant = '' AND ordre = ''";
|
|
|
811 |
}
|
|
|
812 |
$sql = " $operateur ($sql) ";
|
|
|
813 |
return $sql;
|
|
|
814 |
}
|
|
|
815 |
|
|
|
816 |
private function construireWhereRectangleStation() {
|
|
|
817 |
$sql = '';
|
1131 |
aurelien |
818 |
if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
1121 |
aurelien |
819 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
820 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
821 |
|
|
|
822 |
$latMin = $sw['lat'];
|
|
|
823 |
$lngMin = $sw['lng'];
|
|
|
824 |
|
|
|
825 |
$latMax = $ne['lat'];
|
|
|
826 |
$lngMax = $ne['lng'];
|
|
|
827 |
|
|
|
828 |
// ATTENTION : coord_x correspond bien à la LATITUDE!
|
|
|
829 |
$sql = " AND (coord_x != 0 AND coord_y != 0) ".
|
|
|
830 |
" AND coord_x > $latMin ".
|
|
|
831 |
" AND coord_x < $latMax ".
|
|
|
832 |
" AND coord_y > $lngMin ".
|
|
|
833 |
" AND coord_y < $lngMax ";
|
|
|
834 |
}
|
|
|
835 |
return $sql;
|
|
|
836 |
}
|
|
|
837 |
|
|
|
838 |
private function construireWhereRectangleStationOR() {
|
|
|
839 |
$sql = '';
|
1131 |
aurelien |
840 |
if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
1121 |
aurelien |
841 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
842 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
843 |
|
|
|
844 |
$latMin = $sw['lat'];
|
|
|
845 |
$lngMin = $sw['lng'];
|
|
|
846 |
|
|
|
847 |
$latMax = $ne['lat'];
|
|
|
848 |
$lngMax = $ne['lng'];
|
|
|
849 |
|
|
|
850 |
// ATTENTION : coord_x correspond bien à la LATITUDE!
|
|
|
851 |
$sql = "( (coord_x != 0 AND coord_y != 0) ".
|
|
|
852 |
" AND coord_x > $latMin ".
|
|
|
853 |
" AND coord_x < $latMax ".
|
|
|
854 |
" AND coord_y > $lngMin ".
|
|
|
855 |
" AND coord_y < $lngMax )";
|
|
|
856 |
}
|
|
|
857 |
return $sql;
|
|
|
858 |
}
|
|
|
859 |
|
|
|
860 |
private function construireWhereRectangleCommune() {
|
|
|
861 |
$sql = '';
|
1131 |
aurelien |
862 |
if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
1121 |
aurelien |
863 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
864 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
865 |
|
|
|
866 |
$latMin = $sw['lat'];
|
|
|
867 |
$lngMin = $sw['lng'];
|
|
|
868 |
|
|
|
869 |
$latMax = $ne['lat'];
|
|
|
870 |
$lngMax = $ne['lng'];
|
|
|
871 |
|
|
|
872 |
$sql = "AND wgs84_longitude != 0 AND wgs84_latitude != 0 ".
|
|
|
873 |
" AND wgs84_latitude > $latMin ".
|
|
|
874 |
" AND wgs84_latitude < $latMax ".
|
|
|
875 |
" AND wgs84_longitude > $lngMin ".
|
|
|
876 |
" AND wgs84_longitude < $lngMax ";
|
|
|
877 |
}
|
|
|
878 |
return $sql;
|
|
|
879 |
}
|
|
|
880 |
|
|
|
881 |
private function construireWhereRectangleCommuneOR() {
|
|
|
882 |
$sql = '';
|
1131 |
aurelien |
883 |
if (isset($this->parametres['ne']) && isset($this->parametres['sw']) && ! $this->etreNull($this->parametres['ne']) && ! $this->etreNull($this->parametres['sw'])) {
|
1121 |
aurelien |
884 |
$ne = $this->decomposerLatLng($this->parametres['ne']);
|
|
|
885 |
$sw = $this->decomposerLatLng($this->parametres['sw']);
|
|
|
886 |
|
|
|
887 |
$latMin = $sw['lat'];
|
|
|
888 |
$lngMin = $sw['lng'];
|
|
|
889 |
|
|
|
890 |
$latMax = $ne['lat'];
|
|
|
891 |
$lngMax = $ne['lng'];
|
|
|
892 |
|
|
|
893 |
$sql = "( wgs84_longitude != 0 AND wgs84_latitude != 0 ".
|
|
|
894 |
" AND wgs84_latitude > $latMin ".
|
|
|
895 |
" AND wgs84_latitude < $latMax ".
|
|
|
896 |
" AND wgs84_longitude > $lngMin ".
|
|
|
897 |
" AND wgs84_longitude < $lngMax )";
|
|
|
898 |
}
|
|
|
899 |
return $sql;
|
|
|
900 |
}
|
|
|
901 |
|
|
|
902 |
private function construireWhereDept() {
|
|
|
903 |
$sql = '';
|
|
|
904 |
// Récupération des coordonnées depuis l'id station
|
|
|
905 |
extract($this->parametres);
|
1131 |
aurelien |
906 |
if (isset($this->parametres['dept']) && !$this->etreNull($dept)) {
|
1121 |
aurelien |
907 |
$dept = $this->traiterValeursMultiples($dept);
|
|
|
908 |
$sql = " AND code IN ($dept) ";
|
|
|
909 |
}
|
|
|
910 |
return $sql;
|
|
|
911 |
}
|
|
|
912 |
|
|
|
913 |
private function construireWhereCommune() {
|
|
|
914 |
$sql = '';
|
|
|
915 |
// Récupération des coordonnées depuis l'id station
|
|
|
916 |
extract($this->parametres);
|
1131 |
aurelien |
917 |
if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
|
1121 |
aurelien |
918 |
$commune = $this->proteger($commune);
|
|
|
919 |
$sql = " AND location LIKE $commune ";
|
|
|
920 |
}
|
|
|
921 |
return $sql;
|
|
|
922 |
}
|
|
|
923 |
|
1122 |
aurelien |
924 |
private function construireWhereCommuneSansCoordonneesAvecSensibles() {
|
|
|
925 |
$sql = '';
|
|
|
926 |
// Récupération des coordonnées depuis l'id station
|
|
|
927 |
extract($this->parametres);
|
1131 |
aurelien |
928 |
if (isset($this->parametres['commune']) && !$this->etreNull($commune)) {
|
1122 |
aurelien |
929 |
$commune = $this->proteger($commune);
|
|
|
930 |
$sql = " AND location LIKE $commune ";
|
|
|
931 |
$sql .= " AND (
|
|
|
932 |
(
|
|
|
933 |
(coord_x = '000null' OR coord_x = '') ".
|
|
|
934 |
" AND (coord_y = '000null' OR coord_y = '')".
|
|
|
935 |
')'.
|
|
|
936 |
' OR mots_cles_texte LIKE "%sensible%"'.
|
|
|
937 |
') ';
|
|
|
938 |
|
|
|
939 |
}
|
|
|
940 |
return $sql;
|
|
|
941 |
}
|
1121 |
aurelien |
942 |
|
|
|
943 |
private function construireWhereUtilisateur() {
|
|
|
944 |
$sql = '';
|
|
|
945 |
// Récupération des coordonnées depuis l'id station
|
|
|
946 |
extract($this->parametres);
|
1131 |
aurelien |
947 |
if (isset($this->parametres['utilisateur']) && !$this->etreNull($utilisateur)) {
|
1121 |
aurelien |
948 |
$utilisateur = $this->proteger($utilisateur);
|
|
|
949 |
$sql = " AND identifiant = $utilisateur ";
|
|
|
950 |
}
|
|
|
951 |
return $sql;
|
|
|
952 |
}
|
|
|
953 |
|
|
|
954 |
private function construireWhereNumTaxon() {
|
|
|
955 |
$sql = '';
|
|
|
956 |
// Récupération des coordonnées depuis l'id station
|
|
|
957 |
extract($this->parametres);
|
1131 |
aurelien |
958 |
if (isset($this->parametres['num_taxon']) && !$this->etreNull($num_taxon)) {
|
1121 |
aurelien |
959 |
$num_taxon = $this->proteger($num_taxon);
|
|
|
960 |
$sql = " AND num_taxon = $num_taxon ";
|
|
|
961 |
}
|
|
|
962 |
return $sql;
|
|
|
963 |
}
|
|
|
964 |
|
|
|
965 |
private function construireWhereProjet() {
|
|
|
966 |
$sql = '';
|
|
|
967 |
// Récupération des coordonnées depuis l'id station
|
|
|
968 |
extract($this->parametres);
|
1131 |
aurelien |
969 |
if(isset($this->parametres['projet']) ) {
|
|
|
970 |
$projet_sql = $this->getSqlWhereProjet($projet);
|
|
|
971 |
if (!$this->etreNull($projet_sql)) {
|
|
|
972 |
$sql = " AND ($projet_sql) ";
|
|
|
973 |
}
|
1121 |
aurelien |
974 |
}
|
|
|
975 |
return $sql;
|
|
|
976 |
}
|
|
|
977 |
|
|
|
978 |
/**
|
|
|
979 |
* Traitement de $projet pour construction du filtre dans la requête
|
|
|
980 |
*/
|
|
|
981 |
private function getSqlWhereProjet($projet) {
|
|
|
982 |
$sql = null;
|
|
|
983 |
if (! $this->etreNull($projet)) {
|
|
|
984 |
$mot_cle_encode = $this->bdd->quote($this->encoderMotCle($projet));
|
|
|
985 |
|
|
|
986 |
// Construction de la requête
|
|
|
987 |
$requete = 'SELECT * '.
|
|
|
988 |
'FROM cel_mots_cles_obs '.
|
|
|
989 |
"WHERE cmc_id_mot_cle_general = $mot_cle_encode ";
|
|
|
990 |
$elements_projet = $this->executerRequete($requete);
|
|
|
991 |
|
|
|
992 |
$requete_projet = array();
|
|
|
993 |
if ($elements_projet != false && count($elements_projet) > 0) {
|
|
|
994 |
// Pré-construction du where de la requête
|
|
|
995 |
$tpl_where = '(mots_cles LIKE "%%%s%%" AND identifiant = %s )';
|
|
|
996 |
|
|
|
997 |
foreach ($elements_projet as $occurence) {
|
|
|
998 |
$requete_projet[] = sprintf($tpl_where, $occurence['cmc_id_mot_cle_utilisateur'], $this->bdd->quote($occurence['cmc_id_proprietaire']));
|
|
|
999 |
}
|
|
|
1000 |
} else {
|
|
|
1001 |
$this->messages[] = "Aucune observation ne correspond à ce mot clé.";
|
|
|
1002 |
}
|
|
|
1003 |
if (count($requete_projet) > 0) {
|
|
|
1004 |
$sql = implode(" \nOR ", $requete_projet);
|
|
|
1005 |
}
|
|
|
1006 |
}
|
|
|
1007 |
return $sql;
|
|
|
1008 |
}
|
|
|
1009 |
|
|
|
1010 |
private function construireWhereTag() {
|
|
|
1011 |
$sql = '';
|
|
|
1012 |
// Récupération des coordonnées depuis l'id station
|
|
|
1013 |
extract($this->parametres);
|
1131 |
aurelien |
1014 |
if(isset($this->parametres['tag']) ) {
|
|
|
1015 |
$tag_sql = $this->getSqlWhereObsAvecImagesTaguees($tag);
|
|
|
1016 |
if (!$this->etreNull($tag_sql)) {
|
|
|
1017 |
$sql = " AND ($tag_sql) ";
|
|
|
1018 |
}
|
1121 |
aurelien |
1019 |
}
|
|
|
1020 |
return $sql;
|
|
|
1021 |
}
|
|
|
1022 |
|
|
|
1023 |
/**
|
|
|
1024 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
1025 |
*/
|
|
|
1026 |
private function getSqlWhereObsAvecImagesTaguees($tag) {
|
|
|
1027 |
$sql = null;
|
|
|
1028 |
if (! $this->etreNull($tag)) {
|
|
|
1029 |
$tag_sql = $this->getSqlWhereMotsCles($tag);
|
|
|
1030 |
// Construction de la requête
|
|
|
1031 |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '.
|
|
|
1032 |
'FROM cel_images '.
|
|
|
1033 |
' LEFT JOIN cel_obs_images '.
|
|
|
1034 |
' ON (ci_id_image = coi_ce_image) '.
|
|
|
1035 |
' LEFT JOIN cel_inventory AS i '.
|
|
|
1036 |
' ON (coi_ce_utilisateur = i.identifiant AND coi_ce_observation = i.ordre) '.
|
|
|
1037 |
' LEFT JOIN locations AS l '.
|
|
|
1038 |
" ON (l.name = i.location AND l.code = i.id_location) ".
|
|
|
1039 |
"WHERE transmission = '1' ".
|
|
|
1040 |
$this->construireWhereCoordonnees().
|
|
|
1041 |
$this->construireWhereUtilisateur().
|
|
|
1042 |
$this->construireWhereNumTaxon().
|
|
|
1043 |
$this->construireWhereNomTaxon().
|
|
|
1044 |
$this->construireWhereProjet().
|
|
|
1045 |
(!$this->etreNull($tag_sql) ? "AND ($tag_sql) " : '').
|
|
|
1046 |
'ORDER BY utilisateur ASC, ordre ASC';
|
|
|
1047 |
//$this->debug[] = $requete;
|
|
|
1048 |
//die($requete);
|
|
|
1049 |
$elements_tag = $this->executerRequete($requete);
|
|
|
1050 |
|
|
|
1051 |
$requete_tag = array();
|
|
|
1052 |
if ($elements_tag != false && count($elements_tag) > 0) {
|
|
|
1053 |
|
|
|
1054 |
$filtres = array();
|
|
|
1055 |
foreach ($elements_tag as $occurence) {
|
|
|
1056 |
$utilisateur = $occurence['utilisateur'];
|
|
|
1057 |
$ordre = $occurence['ordre'];
|
|
|
1058 |
if (!array_key_exists($utilisateur, $filtres)) {
|
|
|
1059 |
$filtres[$utilisateur] = array();
|
|
|
1060 |
}
|
|
|
1061 |
if (!array_key_exists($ordre, $filtres[$utilisateur])) {
|
|
|
1062 |
$filtres[$utilisateur][$ordre] = $ordre;
|
|
|
1063 |
}
|
|
|
1064 |
}
|
|
|
1065 |
|
|
|
1066 |
// Pré-construction du where de la requête
|
|
|
1067 |
$tpl_where = "(identifiant = '%s' AND ordre IN (%s))";
|
|
|
1068 |
foreach ($filtres as $utilisateur => $ordres) {
|
|
|
1069 |
$requete_tag[] = sprintf($tpl_where, $utilisateur, implode(',', $ordres));
|
|
|
1070 |
}
|
|
|
1071 |
|
|
|
1072 |
} else {
|
|
|
1073 |
$this->messages[] = "Aucune observation ne possède d'images avec ce mot-clé.";
|
|
|
1074 |
}
|
|
|
1075 |
if (count($requete_tag) > 0) {
|
|
|
1076 |
$sql = implode(" \nOR ", $requete_tag);
|
|
|
1077 |
}
|
|
|
1078 |
}
|
|
|
1079 |
return $sql;
|
|
|
1080 |
}
|
|
|
1081 |
|
|
|
1082 |
/**
|
|
|
1083 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
1084 |
*/
|
|
|
1085 |
private function getSqlWhereMotsCles($tag) {
|
|
|
1086 |
$sql = null;
|
|
|
1087 |
$mots_cles = $this->decomposerParametreTag($tag);
|
|
|
1088 |
|
|
|
1089 |
// Construction de la requête
|
|
|
1090 |
$requete = 'SELECT cmc_id_proprietaire AS utilisateur, cmc_id_mot_cle_general AS mot_cle_general, '.
|
|
|
1091 |
' cmc_id_mot_cle_utilisateur AS mot_cle_utilisateur '.
|
|
|
1092 |
'FROM cel_mots_cles_images '.
|
|
|
1093 |
'WHERE '.$this->getSqlWhereMotsClesImages($mots_cles['motsClesEncodesProteges']);
|
|
|
1094 |
$elements_projet = $this->executerRequete($requete);
|
|
|
1095 |
//$this->debug[] = $requete;
|
|
|
1096 |
|
|
|
1097 |
$requete_projet = array();
|
|
|
1098 |
if ($elements_projet != false && count($elements_projet) > 0) {
|
|
|
1099 |
// Pré-construction du where de la requête
|
|
|
1100 |
if ($mots_cles['type'] == 'OR') {
|
|
|
1101 |
$tpl_where = '(ci_meta_mots_cles LIKE "%%%s,%%" AND ci_ce_utilisateur = %s )';
|
|
|
1102 |
foreach ($elements_projet as $occurence) {
|
|
|
1103 |
$requete_projet[] = sprintf($tpl_where, $occurence['mot_cle_utilisateur'], $this->bdd->quote($occurence['utilisateur']));
|
|
|
1104 |
}
|
|
|
1105 |
} else {
|
|
|
1106 |
$tpl_where_mc = "ci_meta_mots_cles LIKE '%%%s,%%'";
|
|
|
1107 |
$tpl_where = '((%s) AND ci_ce_utilisateur = %s)';
|
|
|
1108 |
$utilisateur_mc = array();
|
|
|
1109 |
foreach ($elements_projet as $occurence) {
|
|
|
1110 |
if (!isset($utilisateur_mc[$occurence['utilisateur']][$occurence['mot_cle_general']])) {
|
|
|
1111 |
$utilisateur_mc[$occurence['utilisateur']][$occurence['mot_cle_general']] = $occurence['mot_cle_utilisateur'];
|
|
|
1112 |
}
|
|
|
1113 |
}
|
|
|
1114 |
|
|
|
1115 |
foreach ($utilisateur_mc as $utilisateur => $mots_cles_utilisateur) {
|
|
|
1116 |
if (count($mots_cles_utilisateur) == count($mots_cles['motsCles'])) {
|
|
|
1117 |
$where_mots_cles_utilisateur = array();
|
|
|
1118 |
foreach ($mots_cles_utilisateur as $mot_cle) {
|
|
|
1119 |
$where_mots_cles_utilisateur[] = sprintf($tpl_where_mc, $mot_cle);
|
|
|
1120 |
}
|
|
|
1121 |
$where_mots_cles_utilisateur = implode(' AND ', $where_mots_cles_utilisateur);
|
|
|
1122 |
$utilisateur = $this->bdd->quote($utilisateur);
|
|
|
1123 |
$requete_projet[] = sprintf($tpl_where, $where_mots_cles_utilisateur, $utilisateur);
|
|
|
1124 |
}
|
|
|
1125 |
}
|
|
|
1126 |
}
|
|
|
1127 |
} else {
|
|
|
1128 |
$this->messages[] = "Aucune observation ne correspond à ce mot clé.";
|
|
|
1129 |
}
|
|
|
1130 |
|
|
|
1131 |
$sql = implode(" \nOR ", $requete_projet);
|
|
|
1132 |
//$this->debug[] = $sql;
|
|
|
1133 |
return $sql;
|
|
|
1134 |
}
|
|
|
1135 |
|
|
|
1136 |
/**
|
|
|
1137 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
1138 |
*/
|
|
|
1139 |
private function getSqlWhereMotsClesImages($mots_cles_encodes) {
|
|
|
1140 |
$where_mots_cles_images = array();
|
|
|
1141 |
foreach ($mots_cles_encodes as $mot_cle_encode) {
|
|
|
1142 |
$where_mots_cles_images[] = "cmc_id_mot_cle_general = $mot_cle_encode";
|
|
|
1143 |
}
|
|
|
1144 |
$where_mots_cles_images = implode(' OR ', $where_mots_cles_images);
|
|
|
1145 |
return $where_mots_cles_images;
|
|
|
1146 |
}
|
|
|
1147 |
|
|
|
1148 |
private function decomposerParametreTag($tags) {
|
|
|
1149 |
$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
|
|
|
1150 |
if (preg_match('/.+OU.+/', $tags)) {
|
|
|
1151 |
$mots_cles['type'] = 'OR';
|
|
|
1152 |
$mots_cles['motsCles'] = explode('OU', $tags);
|
|
|
1153 |
} else if (preg_match('/.+ET.+/', $tags)) {
|
|
|
1154 |
$mots_cles['type'] = 'AND';
|
|
|
1155 |
$mots_cles['motsCles'] = explode('ET', $tags);
|
|
|
1156 |
} else {
|
|
|
1157 |
$mots_cles['motsCles'][] = $tags;
|
|
|
1158 |
}
|
|
|
1159 |
|
|
|
1160 |
foreach ($mots_cles['motsCles'] as $mot) {
|
|
|
1161 |
$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote($this->encoderMotCle($mot));
|
|
|
1162 |
}
|
|
|
1163 |
$this->debug[] = $mots_cles;
|
|
|
1164 |
return $mots_cles;
|
|
|
1165 |
}
|
|
|
1166 |
|
|
|
1167 |
private function decomposerLatLng($coord) {
|
|
|
1168 |
$lat_lng = array();
|
|
|
1169 |
if (isset($coord)) {
|
|
|
1170 |
list($lat, $lng) = explode('|', $coord);
|
|
|
1171 |
$lat_lng = array('lat' => $lat, 'lng' => $lng);
|
|
|
1172 |
}
|
|
|
1173 |
return $lat_lng;
|
|
|
1174 |
}
|
|
|
1175 |
|
|
|
1176 |
private function decomposerParametreStation() {
|
|
|
1177 |
$station_infos = array();
|
|
|
1178 |
if (isset($this->parametres['station'])) {
|
|
|
1179 |
$station = $this->parametres['station'];
|
|
|
1180 |
$this->debug[] = $station;
|
|
|
1181 |
@list($type, $coord) = explode(':', $station);
|
|
|
1182 |
@list($lat, $lng) = explode('|', $coord);
|
|
|
1183 |
|
|
|
1184 |
$station_infos = array('type' => $type, 'lat' => $lat, 'lng' => $lng);
|
|
|
1185 |
}
|
|
|
1186 |
return $station_infos;
|
|
|
1187 |
}
|
|
|
1188 |
|
|
|
1189 |
private function decomposerParametreDate() {
|
1131 |
aurelien |
1190 |
$date_infos = array(null,null);
|
1121 |
aurelien |
1191 |
if (isset($this->parametres['date'])) {
|
|
|
1192 |
$date = $this->parametres['date'];
|
|
|
1193 |
if (strpos($date, ':')) {
|
|
|
1194 |
list($type, $date) = explode(':', $date);
|
|
|
1195 |
} else {
|
|
|
1196 |
$type = 'observation';
|
|
|
1197 |
}
|
|
|
1198 |
|
|
|
1199 |
$date = str_replace('/', '-', $date);
|
|
|
1200 |
if (preg_match('/(^[0-9]{2})-([0-9]{2})-([0-9]{4}$)/', $date, $matches)) {
|
|
|
1201 |
$date = $matches[3].'-'.$matches[2].'-'.$matches[1];
|
|
|
1202 |
}
|
|
|
1203 |
|
|
|
1204 |
$date_infos = array($type, $date);
|
|
|
1205 |
}
|
|
|
1206 |
return $date_infos;
|
|
|
1207 |
}
|
|
|
1208 |
|
|
|
1209 |
private function decomposerParametreTaxon() {
|
1131 |
aurelien |
1210 |
$nom_infos = array(null,null);
|
1121 |
aurelien |
1211 |
if (isset($this->parametres['taxon'])) {
|
|
|
1212 |
$taxon = $this->parametres['taxon'];
|
|
|
1213 |
if (strpos($taxon, ':')) {
|
|
|
1214 |
$nom_infos = explode(':', $taxon);
|
|
|
1215 |
} else {
|
|
|
1216 |
$nom_infos = array('retenu', $taxon);
|
|
|
1217 |
}
|
|
|
1218 |
}
|
|
|
1219 |
return $nom_infos;
|
|
|
1220 |
}
|
|
|
1221 |
|
|
|
1222 |
private function decomposerParametreCommentaire() {
|
1131 |
aurelien |
1223 |
$commentaire_infos = array(null,null);
|
1121 |
aurelien |
1224 |
if (isset($this->parametres['commentaire'])) {
|
|
|
1225 |
$commentaire = $this->parametres['commentaire'];
|
|
|
1226 |
if (strpos($commentaire, ':')) {
|
|
|
1227 |
$commentaire_infos = explode(':', $commentaire);
|
|
|
1228 |
} else {
|
|
|
1229 |
$commentaire_infos = array('observation', $commentaire);
|
|
|
1230 |
}
|
|
|
1231 |
}
|
|
|
1232 |
return $commentaire_infos;
|
|
|
1233 |
}
|
|
|
1234 |
}
|