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