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 {
|
485 |
delphine |
26 |
|
416 |
aurelien |
27 |
/**
|
|
|
28 |
* Méthode appelée avec une requête de type GET.
|
|
|
29 |
*/
|
840 |
jpm |
30 |
public function getElement($ressources) {
|
416 |
aurelien |
31 |
$retour = null;
|
840 |
jpm |
32 |
extract($this->parametres);
|
485 |
delphine |
33 |
|
840 |
jpm |
34 |
$action = array_shift($ressources);
|
|
|
35 |
if (isset($action)) {
|
|
|
36 |
$methode = $this->traiterNomMethodeGet($action);
|
416 |
aurelien |
37 |
if (method_exists($this, $methode)) {
|
840 |
jpm |
38 |
$retour = $this->$methode($ressources);
|
416 |
aurelien |
39 |
} else {
|
840 |
jpm |
40 |
$this->messages[] = "Ce type de ressource '$methode' n'est pas disponible.";
|
416 |
aurelien |
41 |
}
|
|
|
42 |
} else {
|
840 |
jpm |
43 |
$this->messages[] = "Vous devez indiquer le type de ressource.";
|
416 |
aurelien |
44 |
}
|
|
|
45 |
|
|
|
46 |
if (is_null($retour)) {
|
|
|
47 |
$info = 'Un problème est survenu : '.print_r($this->messages, true);
|
|
|
48 |
$this->envoyer($info);
|
938 |
jpm |
49 |
} else if ($retour['type'] == 'jsonVar') {
|
|
|
50 |
|
694 |
jpm |
51 |
$this->envoyerJsonVar($retour['variable_js'], $retour['donnees']);
|
938 |
jpm |
52 |
} else if ($retour['type'] == 'jsonP') {
|
584 |
jpm |
53 |
$this->envoyerJsonp($retour['donnees']);
|
474 |
jpm |
54 |
} else {
|
938 |
jpm |
55 |
$this->envoyerJson($retour);
|
416 |
aurelien |
56 |
}
|
|
|
57 |
}
|
|
|
58 |
|
|
|
59 |
/**
|
938 |
jpm |
60 |
* Les stations de la carte par défaut
|
416 |
aurelien |
61 |
*/
|
938 |
jpm |
62 |
public function getStations($params) {
|
416 |
aurelien |
63 |
$json = null;
|
938 |
jpm |
64 |
$requete = 'SELECT sector, x_utm, y_utm, wgs84_latitude AS coord_x, wgs84_longitude AS coord_y '.
|
|
|
65 |
'FROM cel_inventory AS i '.
|
|
|
66 |
' LEFT JOIN locations AS l '.
|
|
|
67 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
68 |
"WHERE transmission = '1' ".
|
|
|
69 |
$this->construireWhereDept().
|
|
|
70 |
$this->construireWhereCommune().
|
|
|
71 |
$this->construireWhereUtilisateur().
|
|
|
72 |
$this->construireWhereNumTaxon().
|
|
|
73 |
$this->construireWhereNomTaxon().
|
|
|
74 |
$this->construireWhereDate().
|
940 |
jpm |
75 |
$this->construireWhereCommentaire().
|
938 |
jpm |
76 |
$this->construireWhereProjet().
|
|
|
77 |
$this->construireWhereTag();
|
940 |
jpm |
78 |
//die($requete);
|
840 |
jpm |
79 |
$resultats = $this->requeter($requete);
|
485 |
delphine |
80 |
|
416 |
aurelien |
81 |
// Traitement des résultats
|
938 |
jpm |
82 |
$obs_nbre = $this->traiterNbreObs($resultats);
|
|
|
83 |
$stations = $this->traiterStations($resultats);
|
|
|
84 |
|
|
|
85 |
// Création des infos du widget
|
|
|
86 |
$json['donnees']['points'] = $stations;
|
|
|
87 |
$json['donnees']['stats']['communes'] = count($stations);
|
|
|
88 |
$json['donnees']['stats']['observations'] = $obs_nbre;
|
|
|
89 |
|
|
|
90 |
$json['type'] = (isset($this->formatRetour)) ? $this->formatRetour : 'jsonVar';
|
|
|
91 |
$json['variable_js'] = 'stations';
|
|
|
92 |
|
|
|
93 |
return $json;
|
|
|
94 |
}
|
|
|
95 |
|
|
|
96 |
private function traiterNbreObs($resultats) {
|
|
|
97 |
$obs_nbre = 0;
|
|
|
98 |
if ($resultats !== false) {
|
|
|
99 |
$obs_nbre = count($resultats);
|
|
|
100 |
}
|
|
|
101 |
return $obs_nbre;
|
|
|
102 |
}
|
|
|
103 |
|
|
|
104 |
private function traiterStations($resultats) {
|
840 |
jpm |
105 |
$stations = array();
|
|
|
106 |
if ($resultats !== false) {
|
|
|
107 |
foreach ($resultats as $enrg) {
|
938 |
jpm |
108 |
if ($enrg['coord_x'] != null && $enrg['coord_y'] != null) {
|
840 |
jpm |
109 |
$id = $enrg['coord_x'].'-'.$enrg['coord_y'];
|
|
|
110 |
if (!isset($stations[$id])) {
|
938 |
jpm |
111 |
$enrg['id'] = 'UTM:'.$enrg['x_utm'].'-'.$enrg['y_utm'].'-'.$enrg['sector'];
|
|
|
112 |
unset($enrg['x_utm']);
|
|
|
113 |
unset($enrg['y_utm']);
|
|
|
114 |
unset($enrg['sector']);
|
840 |
jpm |
115 |
$stations[$id] = $enrg;
|
|
|
116 |
$stations[$id]['nbre'] = 1;
|
|
|
117 |
} else {
|
|
|
118 |
$stations[$id]['nbre']++;
|
|
|
119 |
}
|
499 |
jpm |
120 |
}
|
416 |
aurelien |
121 |
}
|
938 |
jpm |
122 |
$stations = array_values($stations);
|
416 |
aurelien |
123 |
}
|
938 |
jpm |
124 |
return $stations;
|
416 |
aurelien |
125 |
}
|
474 |
jpm |
126 |
|
|
|
127 |
/**
|
|
|
128 |
* Données pour l'affichage des obs d'une station
|
|
|
129 |
*/
|
|
|
130 |
public function getObservations($params) {
|
938 |
jpm |
131 |
$resultats = array();
|
|
|
132 |
$total = 0;
|
|
|
133 |
if (!$this->etreNull($this->parametres['station'])) {
|
|
|
134 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS id, identifiant, nom_sel, nom_ret, num_nom_sel, num_nom_ret, num_taxon, famille, '.
|
|
|
135 |
' lieudit, location, date_observation, milieu, commentaire, '.
|
|
|
136 |
' sector, x_utm, y_utm, insee_code, date_transmission '.
|
|
|
137 |
'FROM cel_inventory AS i '.
|
|
|
138 |
' LEFT JOIN locations AS l '.
|
|
|
139 |
" ON (l.name = i.location AND l.code = i.id_location) ".
|
|
|
140 |
"WHERE transmission = '1' ".
|
|
|
141 |
$this->construireWhereCoordonnees().
|
|
|
142 |
$this->construireWhereUtilisateur().
|
|
|
143 |
$this->construireWhereNumTaxon().
|
|
|
144 |
$this->construireWhereNomTaxon().
|
|
|
145 |
$this->construireWhereDate().
|
940 |
jpm |
146 |
$this->construireWhereCommentaire().
|
938 |
jpm |
147 |
$this->construireWhereProjet().
|
|
|
148 |
$this->construireWhereTag().
|
|
|
149 |
'ORDER BY nom_sel ASC '.
|
|
|
150 |
"LIMIT {$this->start},{$this->limit} ";
|
|
|
151 |
//die($requete);
|
|
|
152 |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
|
|
|
153 |
|
|
|
154 |
$requete = 'SELECT FOUND_ROWS()';
|
|
|
155 |
$total = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
|
474 |
jpm |
156 |
}
|
487 |
jpm |
157 |
|
474 |
jpm |
158 |
// Post-traitement
|
938 |
jpm |
159 |
$observations = $this->traiterObservations($resultats, $total);
|
|
|
160 |
$observations = $this->ajouterImagesAuxObs($observations);
|
|
|
161 |
$observations = $this->ajouterAuteursAuxObs($observations);
|
|
|
162 |
$observations = $this->supprimerIdDesObs($observations);
|
|
|
163 |
return $observations;
|
|
|
164 |
}
|
|
|
165 |
|
|
|
166 |
private function traiterObservations($donnees, $total) {
|
|
|
167 |
$observations = array('commune' => '', 'observations' => array(), 'observateurs' => array());
|
|
|
168 |
$observations['total'] = (isset($total)) ? $total : 0;
|
|
|
169 |
if (is_array($donnees) && count($donnees) > 0) {
|
|
|
170 |
foreach ($donnees as $donnee) {
|
|
|
171 |
$observation = array();
|
|
|
172 |
$observation['idObs'] = $donnee->id;
|
|
|
173 |
$observation['nn'] = $this->etreNull($donnee->num_nom_sel) ? null : $donnee->num_nom_sel;
|
|
|
174 |
$observation['nomSci'] = $this->nettoyerTexte($donnee->nom_sel);
|
|
|
175 |
$observation['date'] = $this->formaterDate($donnee->date_observation, '%d/%m/%Y');
|
|
|
176 |
$observation['datePubli'] = $this->formaterDate($donnee->date_transmission);
|
|
|
177 |
$observation['lieu'] = $this->traiterLieu($donnee);
|
|
|
178 |
$observation['observateur'] = $donnee->identifiant;
|
|
|
179 |
$observation['urlEflore'] = $this->getUrlEflore($donnee->num_nom_sel);
|
|
|
180 |
|
|
|
181 |
if (isset($donnee->location)) {
|
|
|
182 |
$observations['commune'] = $this->nettoyerTexte($donnee->location);
|
|
|
183 |
}
|
|
|
184 |
$observations['observations'][$donnee->id] = $observation;
|
|
|
185 |
|
|
|
186 |
if (! array_key_exists($donnee->identifiant, $observations['observateurs'])) {
|
|
|
187 |
$observations['observateurs'][$donnee->identifiant] = $donnee->identifiant;
|
|
|
188 |
}
|
|
|
189 |
}
|
487 |
jpm |
190 |
}
|
938 |
jpm |
191 |
return $observations;
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
private function getUrlEflore($nn) {
|
|
|
195 |
$urlEflore = null;
|
|
|
196 |
if (! $this->etreNull($nn)) {
|
|
|
197 |
$urlEflore = sprintf($this->config['settings']['efloreUrlTpl'], $nn, 'illustration');
|
|
|
198 |
}
|
|
|
199 |
return $urlEflore;
|
|
|
200 |
}
|
|
|
201 |
|
|
|
202 |
private function traiterLieu($donnee) {
|
|
|
203 |
$lieu = array();
|
|
|
204 |
if (!$this->etreNull($donnee->lieudit)) {
|
|
|
205 |
$lieu[] = $donnee->lieudit;
|
|
|
206 |
}
|
|
|
207 |
if (!$this->etreNull($donnee->milieu)) {
|
|
|
208 |
$lieu[] = $donnee->milieu;
|
|
|
209 |
}
|
|
|
210 |
return implode(', ', $lieu);
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
private function chargerImages(Array $obs_ids) {
|
|
|
214 |
// Récupération des données au format Json
|
|
|
215 |
$service = 'CelImage/liste-ids?obsId='.implode(',', $obs_ids);
|
|
|
216 |
$url = sprintf($this->config['settings']['baseURLServicesCelTpl'], $service);
|
|
|
217 |
$json = $this->getRestClient()->consulter($url);
|
|
|
218 |
$donnees = json_decode($json);
|
|
|
219 |
|
|
|
220 |
// Post-traitement des données
|
|
|
221 |
$images = $this->traiterImages($donnees);
|
474 |
jpm |
222 |
|
938 |
jpm |
223 |
return $images;
|
474 |
jpm |
224 |
}
|
478 |
jpm |
225 |
|
938 |
jpm |
226 |
private function traiterImages($donnees) {
|
|
|
227 |
$images = array();
|
|
|
228 |
if (count($donnees) > 0) {
|
|
|
229 |
foreach ($donnees as $id_obs => $id_images) {
|
|
|
230 |
foreach ($id_images as $id_img) {
|
|
|
231 |
$urls['idImg'] = $id_img;
|
|
|
232 |
$urls['guid'] = sprintf($this->config['settings']['guidImgTpl'], $id_img);
|
|
|
233 |
$urls['miniature'] = $this->getUrlImage($id_img, 'CXS');
|
|
|
234 |
$urls['normale'] = $this->getUrlImage($id_img, 'XL');
|
|
|
235 |
$images[$id_obs][] = $urls;
|
|
|
236 |
}
|
|
|
237 |
}
|
|
|
238 |
}
|
|
|
239 |
return $images;
|
|
|
240 |
}
|
|
|
241 |
|
|
|
242 |
private function ajouterImagesAuxObs($observations) {
|
|
|
243 |
$images = $this->chargerImages(array_keys($observations['observations']));
|
|
|
244 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
245 |
$infos['images'] = $images[$id];
|
|
|
246 |
$observations['observations'][$id] = $infos;
|
|
|
247 |
}
|
|
|
248 |
return $observations;
|
|
|
249 |
}
|
|
|
250 |
|
|
|
251 |
private function ajouterAuteursAuxObs($observations) {
|
|
|
252 |
$observateurs = $this->creerAuteurs(array_keys($observations['observateurs']));
|
|
|
253 |
unset($observations['observateurs']);
|
|
|
254 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
255 |
$courriel = $infos['observateur'];
|
|
|
256 |
$infos['observateur'] = $observateurs[$courriel];
|
|
|
257 |
$observations['observations'][$id] = $infos;
|
|
|
258 |
}
|
|
|
259 |
return $observations;
|
|
|
260 |
}
|
|
|
261 |
|
|
|
262 |
private function supprimerIdDesObs($observations) {
|
|
|
263 |
// Le tableau de sortie ne doit pas avoir les id des obs en clé car sinon Jquery Template ne fonctionne pas
|
|
|
264 |
$observationSansId = $observations;
|
|
|
265 |
unset($observationSansId['observations']);
|
|
|
266 |
foreach ($observations['observations'] as $id => $infos) {
|
|
|
267 |
$observationSansId['observations'][] = $infos;
|
|
|
268 |
}
|
|
|
269 |
return $observationSansId;
|
|
|
270 |
}
|
|
|
271 |
|
478 |
jpm |
272 |
/**
|
938 |
jpm |
273 |
* Liste des taxons présents sur la carte
|
840 |
jpm |
274 |
*/
|
938 |
jpm |
275 |
public function getTaxons($params) {
|
840 |
jpm |
276 |
$json = null;
|
|
|
277 |
|
938 |
jpm |
278 |
$requete = 'SELECT SQL_CALC_FOUND_ROWS DISTINCT nom_ret, num_nom_ret, num_taxon, famille '.
|
840 |
jpm |
279 |
'FROM cel_inventory AS i '.
|
|
|
280 |
' LEFT JOIN locations AS l '.
|
|
|
281 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
282 |
"WHERE transmission = '1' ".
|
938 |
jpm |
283 |
" AND nom_ret != '' ".
|
|
|
284 |
$this->construireWhereDept().
|
|
|
285 |
$this->construireWhereCommune().
|
|
|
286 |
$this->construireWhereUtilisateur().
|
|
|
287 |
$this->construireWhereNumTaxon().
|
|
|
288 |
$this->construireWhereNomTaxon().
|
|
|
289 |
$this->construireWhereDate().
|
940 |
jpm |
290 |
$this->construireWhereCommentaire().
|
938 |
jpm |
291 |
$this->construireWhereProjet().
|
|
|
292 |
$this->construireWhereTag();
|
|
|
293 |
'ORDER BY nom_ret ASC '.
|
|
|
294 |
"LIMIT {$this->start},{$this->limit} ";
|
|
|
295 |
//$this->debug[] = $requete;
|
|
|
296 |
$resultats = $this->requeter($requete, self::SQL_RETOUR_COMPLET, self::SQL_MODE_OBJET);
|
840 |
jpm |
297 |
|
938 |
jpm |
298 |
$requete = 'SELECT FOUND_ROWS()';
|
|
|
299 |
$taxons['total'] = (int) $this->requeter($requete, self::SQL_RETOUR_COLONNE);
|
840 |
jpm |
300 |
|
938 |
jpm |
301 |
// Post-traitement
|
|
|
302 |
$taxons['taxons'] = $this->traiterTaxons($resultats);
|
|
|
303 |
|
|
|
304 |
return $taxons;
|
840 |
jpm |
305 |
}
|
|
|
306 |
|
938 |
jpm |
307 |
private function traiterTaxons($donnees) {
|
|
|
308 |
$taxons = array();
|
|
|
309 |
if (is_array($donnees) && count($donnees) > 0) {
|
|
|
310 |
foreach ($donnees as $donnee) {
|
|
|
311 |
if (!isset($taxons[$donnee->num_taxon]) && ! $this->etreNull($donnee->nom_ret)) {
|
|
|
312 |
$taxon = array();
|
|
|
313 |
$taxon['nn'] = $donnee->num_nom_ret;
|
|
|
314 |
$taxon['nt'] = $donnee->num_taxon;
|
|
|
315 |
$taxon['nom'] = $this->nettoyerTexte($donnee->nom_ret);
|
|
|
316 |
$taxon['famille'] = $this->nettoyerTexte($donnee->famille);
|
|
|
317 |
$taxons[$donnee->num_taxon] = $taxon;
|
|
|
318 |
}
|
|
|
319 |
}
|
|
|
320 |
}
|
|
|
321 |
$taxons = array_values($taxons);
|
|
|
322 |
return $taxons;
|
|
|
323 |
}
|
|
|
324 |
|
|
|
325 |
private function construireWhereCoordonnees() {
|
|
|
326 |
$sql = '';
|
|
|
327 |
// Récupération des coordonnées depuis l'id station
|
940 |
jpm |
328 |
extract($this->decomposerParametreStation());
|
938 |
jpm |
329 |
if (isset($type)) {
|
|
|
330 |
if ($type == 'UTM') {
|
|
|
331 |
$secteur = $this->proteger($secteur);
|
|
|
332 |
$x_utm = $this->proteger($x_utm);
|
|
|
333 |
$y_utm = $this->proteger($y_utm);
|
|
|
334 |
|
|
|
335 |
$sql = " AND (sector = $secteur AND x_utm = $x_utm AND y_utm = $y_utm ) ";
|
|
|
336 |
} else if ($type == 'LngLat') {
|
|
|
337 |
$coord_x = $this->proteger($coord_x);
|
|
|
338 |
$coord_y = $this->proteger($coord_y);
|
|
|
339 |
|
|
|
340 |
$sql = " AND (coord_x = $coord_x AND coord_y = $coord_y ) ";
|
|
|
341 |
}
|
|
|
342 |
}
|
|
|
343 |
return $sql;
|
|
|
344 |
}
|
|
|
345 |
|
940 |
jpm |
346 |
private function construireWhereCommentaire() {
|
|
|
347 |
$sql = '';
|
|
|
348 |
list($type, $commentaire) = $this->decomposerParametreCommentaire();
|
|
|
349 |
if (!$this->etreNull($commentaire)) {
|
|
|
350 |
$commentaire = $this->proteger('%'.$commentaire.'%');
|
|
|
351 |
switch ($type) {
|
|
|
352 |
case '*' :
|
|
|
353 |
$sql = $this->obtenirConditionPourCommentaires($commentaire);
|
|
|
354 |
$sql = " AND (commentaire LIKE $commentaire OR ($sql)) ";
|
|
|
355 |
break;
|
|
|
356 |
case 'observation' :
|
|
|
357 |
$sql = " AND commentaire LIKE $commentaire ";
|
|
|
358 |
break;
|
|
|
359 |
case 'photo' :
|
|
|
360 |
$sql = ' AND '.$this->obtenirConditionPourCommentaires($commentaire).' ';
|
|
|
361 |
break;
|
|
|
362 |
case 'photo.meta' :
|
|
|
363 |
$sql = ' AND '.$this->obtenirConditionPourCommentaireMeta($commentaire).' ';
|
|
|
364 |
break;
|
|
|
365 |
case 'photo.utilisateur' :
|
|
|
366 |
$sql = ' AND '.$this->obtenirConditionPourCommentaireUtilisateur($commentaire).' ';
|
|
|
367 |
break;
|
|
|
368 |
default:
|
|
|
369 |
$sql = " AND commentaire LIKE $commentaire ";
|
|
|
370 |
}
|
|
|
371 |
}
|
|
|
372 |
return $sql;
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
|
938 |
jpm |
376 |
private function construireWhereNomTaxon() {
|
|
|
377 |
$sql = '';
|
940 |
jpm |
378 |
list($type, $nom) = $this->decomposerParametreTaxon();
|
|
|
379 |
if (!$this->etreNull($nom)) {
|
938 |
jpm |
380 |
$nom = $this->proteger($nom.'%');
|
|
|
381 |
switch ($type) {
|
|
|
382 |
case '*' :
|
|
|
383 |
$sql = " AND (nom_ret LIKE $nom OR nom_sel LIKE $nom OR famille LIKE $nom) ";
|
|
|
384 |
break;
|
940 |
jpm |
385 |
case 'retenu' :
|
938 |
jpm |
386 |
$sql = " AND nom_ret LIKE $nom ";
|
|
|
387 |
break;
|
940 |
jpm |
388 |
case 'selectionne' :
|
938 |
jpm |
389 |
$sql = " AND nom_sel LIKE $nom ";
|
|
|
390 |
break;
|
940 |
jpm |
391 |
case 'famille' :
|
938 |
jpm |
392 |
$sql = " AND famille LIKE $nom ";
|
|
|
393 |
break;
|
|
|
394 |
default:
|
|
|
395 |
$sql = " AND nom_ret LIKE $nom ";
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
return $sql;
|
|
|
399 |
}
|
|
|
400 |
|
|
|
401 |
private function construireWhereDate() {
|
|
|
402 |
$sql = '';
|
|
|
403 |
// Récupération des coordonnées depuis l'id station
|
940 |
jpm |
404 |
list($type, $date) = $this->decomposerParametreDate();
|
|
|
405 |
|
938 |
jpm |
406 |
if (!$this->etreNull($date)) {
|
|
|
407 |
$date = $this->proteger($date.'%');
|
|
|
408 |
switch ($type) {
|
|
|
409 |
case '*' :
|
|
|
410 |
$sql = " AND (
|
|
|
411 |
date_observation LIKE $date
|
|
|
412 |
OR date_creation LIKE $date
|
|
|
413 |
OR date_modification LIKE $date
|
|
|
414 |
OR date_transmission LIKE $date) ";
|
|
|
415 |
break;
|
|
|
416 |
case 'observation' :
|
|
|
417 |
$sql = " AND date_observation LIKE $date ";
|
|
|
418 |
break;
|
|
|
419 |
case 'creation' :
|
|
|
420 |
$sql = " AND date_creation LIKE $date ";
|
|
|
421 |
break;
|
|
|
422 |
case 'modification' :
|
|
|
423 |
$sql = " AND date_modification LIKE $date ";
|
|
|
424 |
break;
|
|
|
425 |
case 'transmission' :
|
|
|
426 |
$sql = " AND date_transmission LIKE $date ";
|
|
|
427 |
break;
|
940 |
jpm |
428 |
case 'photo' :
|
|
|
429 |
$sql = $this->obtenirConditionPourDatePhoto($date);
|
|
|
430 |
break;
|
|
|
431 |
case 'ajout' :
|
|
|
432 |
$sql = $this->obtenirConditionPourDateAjout($date);
|
|
|
433 |
break;
|
938 |
jpm |
434 |
case 'liaison' :
|
940 |
jpm |
435 |
$sql = $this->obtenirConditionPourDateLiaison($date);
|
938 |
jpm |
436 |
break;
|
|
|
437 |
default:
|
|
|
438 |
$sql = " AND date_observation LIKE $date ";
|
|
|
439 |
}
|
|
|
440 |
}
|
|
|
441 |
return $sql;
|
|
|
442 |
}
|
|
|
443 |
|
940 |
jpm |
444 |
private function obtenirConditionPourDatePhoto($date) {
|
|
|
445 |
$observations = $this->obtenirObsLieesImg('date.photo', $date);
|
|
|
446 |
if (is_null($observations)) {
|
|
|
447 |
$this->debug[] = "Aucune observation n'est liée à une photo prise à la date : $date";
|
|
|
448 |
}
|
|
|
449 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
450 |
return $sql;
|
|
|
451 |
}
|
|
|
452 |
|
|
|
453 |
private function obtenirConditionPourDateLiaison($date) {
|
|
|
454 |
$observations = $this->obtenirObsLieesImg('date.liaison', $date);
|
|
|
455 |
if (is_null($observations)) {
|
|
|
456 |
$this->debug[] = "Aucune observation n'a été liée à une image à à la date : $date";
|
|
|
457 |
}
|
|
|
458 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
459 |
return $sql;
|
|
|
460 |
}
|
|
|
461 |
|
|
|
462 |
private function obtenirConditionPourDateAjout($date) {
|
|
|
463 |
$observations = $this->obtenirObsLieesImg('date.ajout', $date);
|
|
|
464 |
if (is_null($observations)) {
|
|
|
465 |
$this->debug[] = "Aucune observation n'est liée à une image ajoutée à la date : $date";
|
|
|
466 |
}
|
|
|
467 |
$sql = $this->assemblerObsEnConditionSql($observations);
|
|
|
468 |
return $sql;
|
|
|
469 |
}
|
|
|
470 |
|
|
|
471 |
private function obtenirConditionPourCommentaireMeta($commentaire) {
|
|
|
472 |
$observations = $this->obtenirObsLieesImg('commentaire.meta', $commentaire);
|
|
|
473 |
if (is_null($observations)) {
|
|
|
474 |
$this->debug[] = "Aucune observation n'est liée à une image dont le commentaire des méta-données correspond à : $commmentaire";
|
|
|
475 |
}
|
|
|
476 |
$operateur = '';
|
|
|
477 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
478 |
return $sql;
|
|
|
479 |
}
|
|
|
480 |
|
|
|
481 |
private function obtenirConditionPourCommentaireUtilisateur($commentaire) {
|
|
|
482 |
$observations = $this->obtenirObsLieesImg('commentaire.utilisateur', $commentaire);
|
|
|
483 |
if (is_null($observations)) {
|
|
|
484 |
$this->debug[] = "Aucune observation n'est liée à une image dont le commentaire des utilisateur correspond à : $commmentaire";
|
|
|
485 |
}
|
|
|
486 |
$operateur = '';
|
|
|
487 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
488 |
return $sql;
|
|
|
489 |
}
|
|
|
490 |
|
|
|
491 |
private function obtenirConditionPourCommentaires($commentaire) {
|
|
|
492 |
$observations = $this->obtenirObsLieesImg('commentaire.*', $commentaire);
|
|
|
493 |
if (is_null($observations)) {
|
|
|
494 |
$this->debug[] = "Aucune observation n'est liée à une image dont un des commentaires correspond à : $commmentaire";
|
|
|
495 |
}
|
|
|
496 |
$operateur = '';
|
|
|
497 |
$sql = $this->assemblerObsEnConditionSql($observations, $operateur);
|
|
|
498 |
return $sql;
|
|
|
499 |
}
|
|
|
500 |
|
|
|
501 |
/**
|
|
|
502 |
* Récupération des identifiant d'utilisateur et des ordres des observations correspondant à une date.
|
|
|
503 |
* Retour sous forme de tableau : array[identifiant] = array(ordre, ordre...);
|
|
|
504 |
*/
|
|
|
505 |
private function obtenirObsLieesImg($type, $param) {
|
|
|
506 |
// Construction de la requête
|
|
|
507 |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '.
|
|
|
508 |
'FROM cel_images '.
|
|
|
509 |
' LEFT JOIN cel_obs_images '.
|
|
|
510 |
' ON (ci_id_image = coi_ce_image) '.
|
|
|
511 |
' LEFT JOIN cel_inventory AS i '.
|
|
|
512 |
' ON (coi_ce_utilisateur = i.identifiant AND coi_ce_observation = i.ordre) '.
|
|
|
513 |
' LEFT JOIN locations AS l '.
|
|
|
514 |
' ON (l.name = i.location AND l.code = i.id_location) '.
|
|
|
515 |
"WHERE transmission = '1' ".
|
|
|
516 |
($type == 'date.photo' ? " AND (ci_meta_date_time LIKE ".str_replace('-', ':', $param)." OR ci_meta_date LIKE $param) " : '').
|
|
|
517 |
($type == 'date.ajout' ? " AND ci_meta_date_ajout LIKE $param " : '').
|
|
|
518 |
($type == 'date.liaison' ? " AND coi_date_liaison LIKE $param " : '').
|
|
|
519 |
($type == 'commentaire.meta' ? " AND ci_meta_comment LIKE $param " : '').
|
|
|
520 |
($type == 'commentaire.utilisateur' ? " AND ci_meta_user_comment LIKE $param " : '').
|
|
|
521 |
($type == 'commentaire.*' ? " AND (ci_meta_comment LIKE $param OR ci_meta_user_comment LIKE $param) " : '').
|
|
|
522 |
$this->construireWhereCoordonnees().
|
|
|
523 |
$this->construireWhereDept().
|
|
|
524 |
$this->construireWhereCommune().
|
|
|
525 |
$this->construireWhereUtilisateur().
|
|
|
526 |
$this->construireWhereNumTaxon().
|
|
|
527 |
$this->construireWhereNomTaxon().
|
|
|
528 |
$this->construireWhereProjet().
|
|
|
529 |
$this->construireWhereTag().
|
|
|
530 |
'ORDER BY utilisateur ASC, ordre ASC';
|
|
|
531 |
//$this->debug[] = $requete;
|
|
|
532 |
//die($requete);
|
|
|
533 |
$resultats = $this->executerRequete($requete);
|
|
|
534 |
|
|
|
535 |
$observations = null;
|
|
|
536 |
if ($resultats != false) {
|
|
|
537 |
$observations = array();
|
|
|
538 |
foreach ($resultats as $occurence) {
|
|
|
539 |
$utilisateur = $occurence['utilisateur'];
|
|
|
540 |
$ordre = $occurence['ordre'];
|
|
|
541 |
if (!array_key_exists($utilisateur, $observations)) {
|
|
|
542 |
$observations[$utilisateur] = array();
|
|
|
543 |
}
|
|
|
544 |
if (!array_key_exists($ordre, $observations[$utilisateur])) {
|
|
|
545 |
$observations[$utilisateur][$ordre] = $ordre;
|
|
|
546 |
}
|
|
|
547 |
}
|
|
|
548 |
}
|
|
|
549 |
return $observations;
|
|
|
550 |
}
|
|
|
551 |
|
|
|
552 |
private function assemblerObsEnConditionSql($observations, $operateur = 'AND') {
|
|
|
553 |
$sql = '';
|
|
|
554 |
if ($observations != null) {
|
|
|
555 |
// Pré-construction du where de la requête
|
|
|
556 |
$tpl_where = "(identifiant = '%s' AND ordre IN (%s))";
|
|
|
557 |
foreach ($observations as $utilisateur => $ordres) {
|
|
|
558 |
$morceaux_requete[] = sprintf($tpl_where, $utilisateur, implode(',', $ordres));
|
|
|
559 |
}
|
|
|
560 |
if (count($morceaux_requete) > 0) {
|
|
|
561 |
$sql = implode(" \nOR ", $morceaux_requete);
|
|
|
562 |
}
|
|
|
563 |
} else {
|
|
|
564 |
// Nous voulons que la requête ne retourne rien
|
|
|
565 |
$sql = "identifiant = '' AND ordre = ''";
|
|
|
566 |
}
|
|
|
567 |
$sql = " $operateur ($sql) ";
|
|
|
568 |
return $sql;
|
|
|
569 |
}
|
|
|
570 |
|
938 |
jpm |
571 |
private function construireWhereDept() {
|
|
|
572 |
$sql = '';
|
|
|
573 |
// Récupération des coordonnées depuis l'id station
|
|
|
574 |
extract($this->parametres);
|
|
|
575 |
if (!$this->etreNull($dept)) {
|
|
|
576 |
$dept = $this->traiterValeursMultiples($dept);
|
|
|
577 |
$sql = " AND code IN ($dept) ";
|
|
|
578 |
}
|
|
|
579 |
return $sql;
|
|
|
580 |
}
|
|
|
581 |
|
|
|
582 |
private function construireWhereCommune() {
|
|
|
583 |
$sql = '';
|
|
|
584 |
// Récupération des coordonnées depuis l'id station
|
|
|
585 |
extract($this->parametres);
|
|
|
586 |
if (!$this->etreNull($commune)) {
|
|
|
587 |
$commune = $this->proteger($commune);
|
|
|
588 |
$sql = " AND location LIKE $commune ";
|
|
|
589 |
}
|
|
|
590 |
return $sql;
|
|
|
591 |
}
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
private function construireWhereUtilisateur() {
|
|
|
595 |
$sql = '';
|
|
|
596 |
// Récupération des coordonnées depuis l'id station
|
|
|
597 |
extract($this->parametres);
|
|
|
598 |
if (!$this->etreNull($utilisateur)) {
|
|
|
599 |
$utilisateur = $this->proteger($utilisateur);
|
|
|
600 |
$sql = " AND identifiant = $utilisateur ";
|
|
|
601 |
}
|
|
|
602 |
return $sql;
|
|
|
603 |
}
|
|
|
604 |
|
|
|
605 |
private function construireWhereNumTaxon() {
|
|
|
606 |
$sql = '';
|
|
|
607 |
// Récupération des coordonnées depuis l'id station
|
|
|
608 |
extract($this->parametres);
|
|
|
609 |
if (!$this->etreNull($num_taxon)) {
|
|
|
610 |
$num_taxon = $this->proteger($num_taxon);
|
|
|
611 |
$sql = " AND num_taxon = $num_taxon ";
|
|
|
612 |
}
|
|
|
613 |
return $sql;
|
|
|
614 |
}
|
|
|
615 |
|
|
|
616 |
private function construireWhereProjet() {
|
|
|
617 |
$sql = '';
|
|
|
618 |
// Récupération des coordonnées depuis l'id station
|
|
|
619 |
extract($this->parametres);
|
|
|
620 |
$projet_sql = $this->getSqlWhereProjet($projet);
|
|
|
621 |
if (!$this->etreNull($projet_sql)) {
|
|
|
622 |
$sql = " AND ($projet_sql) ";
|
|
|
623 |
}
|
|
|
624 |
return $sql;
|
|
|
625 |
}
|
|
|
626 |
|
840 |
jpm |
627 |
/**
|
938 |
jpm |
628 |
* Traitement de $projet pour construction du filtre dans la requête
|
478 |
jpm |
629 |
*/
|
938 |
jpm |
630 |
private function getSqlWhereProjet($projet) {
|
|
|
631 |
$sql = null;
|
|
|
632 |
if (! $this->etreNull($projet)) {
|
|
|
633 |
$mot_cle_encode = $this->bdd->quote($this->encoderMotCle($projet));
|
|
|
634 |
|
|
|
635 |
// Construction de la requête
|
|
|
636 |
$requete = 'SELECT * '.
|
|
|
637 |
'FROM cel_mots_cles_obs '.
|
|
|
638 |
"WHERE cmc_id_mot_cle_general = $mot_cle_encode ";
|
|
|
639 |
$elements_projet = $this->executerRequete($requete);
|
|
|
640 |
|
|
|
641 |
$requete_projet = array();
|
|
|
642 |
if ($elements_projet != false && count($elements_projet) > 0) {
|
|
|
643 |
// Pré-construction du where de la requête
|
|
|
644 |
$tpl_where = '(mots_cles LIKE "%%%s%%" AND identifiant = %s )';
|
|
|
645 |
|
|
|
646 |
foreach ($elements_projet as $occurence) {
|
|
|
647 |
$requete_projet[] = sprintf($tpl_where, $occurence['cmc_id_mot_cle_utilisateur'], $this->bdd->quote($occurence['cmc_id_proprietaire']));
|
|
|
648 |
}
|
|
|
649 |
} else {
|
|
|
650 |
$this->messages[] = "Aucune observation ne correspond à ce mot clé.";
|
|
|
651 |
}
|
|
|
652 |
if (count($requete_projet) > 0) {
|
|
|
653 |
$sql = implode(" \nOR ", $requete_projet);
|
|
|
654 |
}
|
|
|
655 |
}
|
|
|
656 |
return $sql;
|
|
|
657 |
}
|
|
|
658 |
|
|
|
659 |
private function construireWhereTag() {
|
|
|
660 |
$sql = '';
|
|
|
661 |
// Récupération des coordonnées depuis l'id station
|
840 |
jpm |
662 |
extract($this->parametres);
|
938 |
jpm |
663 |
$tag_sql = $this->getSqlWhereObsAvecImagesTaguees($tag);
|
|
|
664 |
if (!$this->etreNull($tag_sql)) {
|
|
|
665 |
$sql = " AND ($tag_sql) ";
|
489 |
jpm |
666 |
}
|
938 |
jpm |
667 |
return $sql;
|
|
|
668 |
}
|
|
|
669 |
|
|
|
670 |
/**
|
|
|
671 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
672 |
*/
|
|
|
673 |
private function getSqlWhereObsAvecImagesTaguees($tag) {
|
|
|
674 |
$sql = null;
|
|
|
675 |
if (! $this->etreNull($tag)) {
|
|
|
676 |
$tag_sql = $this->getSqlWhereMotsCles($tag);
|
|
|
677 |
// Construction de la requête
|
|
|
678 |
$requete = 'SELECT DISTINCT coi_ce_observation AS ordre, coi_ce_utilisateur AS utilisateur '.
|
|
|
679 |
'FROM cel_images '.
|
|
|
680 |
' LEFT JOIN cel_obs_images '.
|
|
|
681 |
' ON (ci_id_image = coi_ce_image) '.
|
|
|
682 |
' LEFT JOIN cel_inventory AS i '.
|
|
|
683 |
' ON (coi_ce_utilisateur = i.identifiant AND coi_ce_observation = i.ordre) '.
|
|
|
684 |
' LEFT JOIN locations AS l '.
|
|
|
685 |
" ON (l.name = i.location AND l.code = i.id_location) ".
|
|
|
686 |
"WHERE transmission = '1' ".
|
|
|
687 |
$this->construireWhereCoordonnees().
|
|
|
688 |
$this->construireWhereUtilisateur().
|
|
|
689 |
$this->construireWhereNumTaxon().
|
|
|
690 |
$this->construireWhereNomTaxon().
|
|
|
691 |
$this->construireWhereProjet().
|
|
|
692 |
(!$this->etreNull($tag_sql) ? "AND ($tag_sql) " : '').
|
|
|
693 |
'ORDER BY utilisateur ASC, ordre ASC';
|
|
|
694 |
//$this->debug[] = $requete;
|
|
|
695 |
//die($requete);
|
|
|
696 |
$elements_tag = $this->executerRequete($requete);
|
|
|
697 |
|
|
|
698 |
$requete_tag = array();
|
|
|
699 |
if ($elements_tag != false && count($elements_tag) > 0) {
|
|
|
700 |
|
|
|
701 |
$filtres = array();
|
|
|
702 |
foreach ($elements_tag as $occurence) {
|
|
|
703 |
$utilisateur = $occurence['utilisateur'];
|
|
|
704 |
$ordre = $occurence['ordre'];
|
|
|
705 |
if (!array_key_exists($utilisateur, $filtres)) {
|
|
|
706 |
$filtres[$utilisateur] = array();
|
|
|
707 |
}
|
|
|
708 |
if (!array_key_exists($ordre, $filtres[$utilisateur])) {
|
|
|
709 |
$filtres[$utilisateur][$ordre] = $ordre;
|
|
|
710 |
}
|
|
|
711 |
}
|
|
|
712 |
|
|
|
713 |
// Pré-construction du where de la requête
|
|
|
714 |
$tpl_where = "(identifiant = '%s' AND ordre IN (%s))";
|
|
|
715 |
foreach ($filtres as $utilisateur => $ordres) {
|
|
|
716 |
$requete_tag[] = sprintf($tpl_where, $utilisateur, implode(',', $ordres));
|
|
|
717 |
}
|
|
|
718 |
|
|
|
719 |
} else {
|
|
|
720 |
$this->messages[] = "Aucune observation ne possède d'images avec ce mot-clé.";
|
|
|
721 |
}
|
|
|
722 |
if (count($requete_tag) > 0) {
|
|
|
723 |
$sql = implode(" \nOR ", $requete_tag);
|
|
|
724 |
}
|
489 |
jpm |
725 |
}
|
938 |
jpm |
726 |
return $sql;
|
478 |
jpm |
727 |
}
|
|
|
728 |
|
487 |
jpm |
729 |
/**
|
938 |
jpm |
730 |
* Traitement de $tag pour construction du filtre dans la requête
|
487 |
jpm |
731 |
*/
|
938 |
jpm |
732 |
private function getSqlWhereMotsCles($tag) {
|
|
|
733 |
$sql = null;
|
940 |
jpm |
734 |
$mots_cles = $this->decomposerParametreTag($tag);
|
487 |
jpm |
735 |
|
|
|
736 |
// Construction de la requête
|
938 |
jpm |
737 |
$requete = 'SELECT cmc_id_proprietaire AS utilisateur, cmc_id_mot_cle_general AS mot_cle_general, '.
|
|
|
738 |
' cmc_id_mot_cle_utilisateur AS mot_cle_utilisateur '.
|
|
|
739 |
'FROM cel_mots_cles_images '.
|
|
|
740 |
'WHERE '.$this->getSqlWhereMotsClesImages($mots_cles['motsClesEncodesProteges']);
|
487 |
jpm |
741 |
$elements_projet = $this->executerRequete($requete);
|
938 |
jpm |
742 |
//$this->debug[] = $requete;
|
487 |
jpm |
743 |
|
|
|
744 |
$requete_projet = array();
|
|
|
745 |
if ($elements_projet != false && count($elements_projet) > 0) {
|
|
|
746 |
// Pré-construction du where de la requête
|
938 |
jpm |
747 |
if ($mots_cles['type'] == 'OR') {
|
|
|
748 |
$tpl_where = '(ci_meta_mots_cles LIKE "%%%s,%%" AND ci_ce_utilisateur = %s )';
|
|
|
749 |
foreach ($elements_projet as $occurence) {
|
|
|
750 |
$requete_projet[] = sprintf($tpl_where, $occurence['mot_cle_utilisateur'], $this->bdd->quote($occurence['utilisateur']));
|
|
|
751 |
}
|
|
|
752 |
} else {
|
|
|
753 |
$tpl_where_mc = "ci_meta_mots_cles LIKE '%%%s,%%'";
|
|
|
754 |
$tpl_where = '((%s) AND ci_ce_utilisateur = %s)';
|
|
|
755 |
$utilisateur_mc = array();
|
|
|
756 |
foreach ($elements_projet as $occurence) {
|
|
|
757 |
if (!isset($utilisateur_mc[$occurence['utilisateur']][$occurence['mot_cle_general']])) {
|
|
|
758 |
$utilisateur_mc[$occurence['utilisateur']][$occurence['mot_cle_general']] = $occurence['mot_cle_utilisateur'];
|
|
|
759 |
}
|
|
|
760 |
}
|
|
|
761 |
|
|
|
762 |
foreach ($utilisateur_mc as $utilisateur => $mots_cles_utilisateur) {
|
|
|
763 |
if (count($mots_cles_utilisateur) == count($mots_cles['motsCles'])) {
|
|
|
764 |
$where_mots_cles_utilisateur = array();
|
|
|
765 |
foreach ($mots_cles_utilisateur as $mot_cle) {
|
|
|
766 |
$where_mots_cles_utilisateur[] = sprintf($tpl_where_mc, $mot_cle);
|
|
|
767 |
}
|
|
|
768 |
$where_mots_cles_utilisateur = implode(' AND ', $where_mots_cles_utilisateur);
|
|
|
769 |
$utilisateur = $this->bdd->quote($utilisateur);
|
|
|
770 |
$requete_projet[] = sprintf($tpl_where, $where_mots_cles_utilisateur, $utilisateur);
|
|
|
771 |
}
|
|
|
772 |
}
|
487 |
jpm |
773 |
}
|
|
|
774 |
} else {
|
|
|
775 |
$this->messages[] = "Aucune observation ne correspond à ce mot clé.";
|
|
|
776 |
}
|
|
|
777 |
|
|
|
778 |
$sql = implode(" \nOR ", $requete_projet);
|
938 |
jpm |
779 |
//$this->debug[] = $sql;
|
487 |
jpm |
780 |
return $sql;
|
840 |
jpm |
781 |
}
|
938 |
jpm |
782 |
|
|
|
783 |
/**
|
|
|
784 |
* Traitement de $tag pour construction du filtre dans la requête
|
|
|
785 |
*/
|
|
|
786 |
private function getSqlWhereMotsClesImages($mots_cles_encodes) {
|
|
|
787 |
$where_mots_cles_images = array();
|
|
|
788 |
foreach ($mots_cles_encodes as $mot_cle_encode) {
|
|
|
789 |
$where_mots_cles_images[] = "cmc_id_mot_cle_general = $mot_cle_encode";
|
|
|
790 |
}
|
|
|
791 |
$where_mots_cles_images = implode(' OR ', $where_mots_cles_images);
|
|
|
792 |
return $where_mots_cles_images;
|
|
|
793 |
}
|
|
|
794 |
|
940 |
jpm |
795 |
private function decomposerParametreTag($tags) {
|
938 |
jpm |
796 |
$mots_cles = array('type' => null, 'motsCles' => null, 'motsClesEncodesProteges' => null);
|
|
|
797 |
if (preg_match('/.+OU.+/', $tags)) {
|
|
|
798 |
$mots_cles['type'] = 'OR';
|
|
|
799 |
$mots_cles['motsCles'] = explode('OU', $tags);
|
|
|
800 |
} else if (preg_match('/.+ET.+/', $tags)) {
|
|
|
801 |
$mots_cles['type'] = 'AND';
|
|
|
802 |
$mots_cles['motsCles'] = explode('ET', $tags);
|
|
|
803 |
} else {
|
|
|
804 |
$mots_cles['motsCles'][] = $tags;
|
|
|
805 |
}
|
|
|
806 |
|
|
|
807 |
foreach ($mots_cles['motsCles'] as $mot) {
|
|
|
808 |
$mots_cles['motsClesEncodesProteges'][] = $this->bdd->quote($this->encoderMotCle($mot));
|
|
|
809 |
}
|
|
|
810 |
$this->debug[] = $mots_cles;
|
|
|
811 |
return $mots_cles;
|
|
|
812 |
}
|
|
|
813 |
|
940 |
jpm |
814 |
private function decomposerParametreStation() {
|
938 |
jpm |
815 |
$station_infos = array();
|
|
|
816 |
if (isset($this->parametres['station'])) {
|
|
|
817 |
$station = $this->parametres['station'];
|
|
|
818 |
$this->debug[] = $station;
|
|
|
819 |
list($type, $coord) = explode(':', $station);
|
|
|
820 |
|
|
|
821 |
if ($type == 'UTM') {
|
|
|
822 |
list($x_utm, $y_utm, $secteur) = explode('-', $coord);
|
|
|
823 |
$station_infos = array('x_utm' => $x_utm, 'y_utm' => $y_utm, 'secteur' => $secteur);
|
|
|
824 |
} else if ($type == 'LngLat') {
|
|
|
825 |
list($coord_y, $coord_x) = explode('-', $coord);
|
|
|
826 |
$station_infos = array('coord_y' => $coord_y, 'coord_x' => $coord_x);
|
|
|
827 |
}
|
|
|
828 |
$station_infos['type'] = $type;
|
|
|
829 |
}
|
|
|
830 |
return $station_infos;
|
|
|
831 |
}
|
940 |
jpm |
832 |
|
|
|
833 |
private function decomposerParametreDate() {
|
|
|
834 |
$date_infos = array();
|
|
|
835 |
if (isset($this->parametres['date'])) {
|
|
|
836 |
$date = $this->parametres['date'];
|
|
|
837 |
if (strpos($date, ':')) {
|
|
|
838 |
list($type, $date) = explode(':', $date);
|
|
|
839 |
} else {
|
|
|
840 |
$type = 'observation';
|
|
|
841 |
}
|
|
|
842 |
|
|
|
843 |
$date = str_replace('/', '-', $date);
|
|
|
844 |
if (preg_match('/(^[0-9]{2})-([0-9]{2})-([0-9]{4}$)/', $date, $matches)) {
|
|
|
845 |
$date = $matches[3].'-'.$matches[2].'-'.$matches[1];
|
|
|
846 |
}
|
|
|
847 |
|
|
|
848 |
$date_infos = array($type, $date);
|
|
|
849 |
}
|
|
|
850 |
return $date_infos;
|
|
|
851 |
}
|
|
|
852 |
|
|
|
853 |
private function decomposerParametreTaxon() {
|
|
|
854 |
$nom_infos = array();
|
|
|
855 |
if (isset($this->parametres['taxon'])) {
|
|
|
856 |
$taxon = $this->parametres['taxon'];
|
|
|
857 |
if (strpos($taxon, ':')) {
|
|
|
858 |
$nom_infos = explode(':', $taxon);
|
|
|
859 |
} else {
|
|
|
860 |
$nom_infos = array('retenu', $taxon);
|
|
|
861 |
}
|
|
|
862 |
}
|
|
|
863 |
return $nom_infos;
|
|
|
864 |
}
|
|
|
865 |
|
|
|
866 |
private function decomposerParametreCommentaire() {
|
|
|
867 |
$commentaire_infos = array();
|
|
|
868 |
if (isset($this->parametres['commentaire'])) {
|
|
|
869 |
$commentaire = $this->parametres['commentaire'];
|
|
|
870 |
if (strpos($commentaire, ':')) {
|
|
|
871 |
$commentaire_infos = explode(':', $commentaire);
|
|
|
872 |
} else {
|
|
|
873 |
$commentaire_infos = array('observation', $commentaire);
|
|
|
874 |
}
|
|
|
875 |
}
|
|
|
876 |
return $commentaire_infos;
|
|
|
877 |
}
|
416 |
aurelien |
878 |
}
|