Subversion Repositories eFlore/Applications.cel

Rev

Rev 1464 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1464 Rev 1477
1
<?php
1
<?php
2
/**
2
/**
3
 * Service fournissant des informations concernant le CEL au format RSS1, RSS2 ou ATOM.
3
 * Service fournissant des informations concernant le CEL au format RSS1, RSS2 ou ATOM.
4
 * Encodage en entrée : utf8
4
 * Encodage en entrée : utf8
5
 * Encodage en sortie : utf8
5
 * Encodage en sortie : utf8
6
 * Format du service :
6
 * Format du service :
7
 * /CelSyndicationObservation/liste-des-flux
7
 * /CelSyndicationObservation/liste-des-flux
8
 * /CelSyndicationObservation/opml
8
 * /CelSyndicationObservation/opml
9
 * /CelSyndicationObservation/par-defaut/(rss1|rss2|atom)?start=0&limit=150
9
 * /CelSyndicationObservation/par-defaut/(rss1|rss2|atom)?start=0&limit=150
10
 * /CelSyndicationObservation/pour-admin/(rss1|rss2|atom)?start=0&limit=150
10
 * /CelSyndicationObservation/pour-admin/(rss1|rss2|atom)?start=0&limit=150
11
 * /CelSyndicationObservation/par-mots-cles/(rss1|rss2|atom)/mot-cle?start=0&limit=150
11
 * /CelSyndicationObservation/par-mots-cles/(rss1|rss2|atom)/mot-cle?start=0&limit=150
12
 * /CelSyndicationObservation/par-commune/(rss1|rss2|atom)/nom-commune?start=0&limit=150
12
 * /CelSyndicationObservation/par-commune/(rss1|rss2|atom)/nom-commune?start=0&limit=150
13
 *
13
 *
14
 * Les paramêtres :
14
 * Les paramêtres :
15
 *  - "start" indique le numéro du premier item à afficher
15
 *  - "start" indique le numéro du premier item à afficher
16
 *  - "limit" nombre d'items à afficher
16
 *  - "limit" nombre d'items à afficher
17
 *
17
 *
18
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
18
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
19
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
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>
20
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
21
 * @version $Id$
21
 * @version $Id$
22
 * @copyright 2010
22
 * @copyright 2010
23
 */
23
 */
24
class CelSyndicationObservation extends Cel {
24
class CelSyndicationObservation extends Cel {
25
 
25
 
26
	private $parametres_origines = null;
26
	private $parametres_origines = null;
27
	private $format = null;
27
	private $format = null;
28
	private $service = null;
28
	private $service = null;
29
	private $squelette = null;
29
	private $squelette = null;
30
	private $squelette_dossier = null;
30
	private $squelette_dossier = null;
31
	private $auteurs = array();
31
	private $auteurs = array();
32
	private $flux = array();
32
	private $flux = array();
33
	private $criteres = array(
33
	private $criteres = array(
34
		'utilisateur' => 'courriel_utilisateur',
34
		'utilisateur' => 'courriel_utilisateur',
35
		'commune' => 'zone_geo',
35
		'commune' => 'zone_geo',
36
		'dept' => 'ce_zone_geo',
36
		'dept' => 'ce_zone_geo',
37
		'taxon' => 'nom_ret',
37
		'taxon' => 'nom_ret',
38
		'num_taxon' => 'nt',
38
		'num_taxon' => 'nt',
39
		'commentaire' => 'commentaire',
39
		'commentaire' => 'commentaire',
40
		'date' => 'date_observation',
40
		'date' => 'date_observation',
-
 
41
		'motcle' => 'tags',
41
		'projet' => 'mots-cles');
42
		'projet' => 'mots-cles');
42
 
43
 
43
	/**
44
	/**
44
	 * Méthode appelée avec une requête de type GET.
45
	 * Méthode appelée avec une requête de type GET.
45
	 */
46
	 */
46
	public function getElement($params = array()) {
47
	public function getElement($params = array()) {
47
		// Initialisation des variables
48
		// Initialisation des variables
48
		$this->parametres_origines = $params;
49
		$this->parametres_origines = $params;
49
		$info = array();
50
		$info = array();
50
		$contenu = '';
51
		$contenu = '';
51
 
52
 
52
		if (! $this->etreFluxAdmin() || $this->authentifierAdmin()) {
53
		if (! $this->etreFluxAdmin() || $this->authentifierAdmin()) {
53
			// Pré traitement des paramêtres
54
			// Pré traitement des paramêtres
54
			$pour_bdd = false;
55
			$pour_bdd = false;
55
			$p = $this->traiterParametres(array('service', 'format'), $params, $pour_bdd);
56
			$p = $this->traiterParametres(array('service', 'format'), $params, $pour_bdd);
56
			extract($p);
57
			extract($p);
57
			$this->parametres = $params;
58
			$this->parametres = $params;
58
			$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR;
59
			$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR;
59
 
60
 
60
			// Récupération de la liste des flux
61
			// Récupération de la liste des flux
61
			$this->chargerListeDesFlux();
62
			$this->chargerListeDesFlux();
62
 
63
 
63
			// Chargement du bon type de service demandé
64
			// Chargement du bon type de service demandé
64
			if (isset($service)) {
65
			if (isset($service)) {
65
				$this->service = $this->traiterNomService($service);
66
				$this->service = $this->traiterNomService($service);
66
				$methode = $this->getNomMethodeService();
67
				$methode = $this->getNomMethodeService();
67
				if (method_exists($this, $methode)) {
68
				if (method_exists($this, $methode)) {
68
					if (isset($format) && preg_match('/^(?:rss1|rss2|atom)$/i', $format)) {
69
					if (isset($format) && preg_match('/^(?:rss1|rss2|atom)$/i', $format)) {
69
						// Mise en minuscule de l'indication du format
70
						// Mise en minuscule de l'indication du format
70
						$this->format = strtolower($format);
71
						$this->format = strtolower($format);
71
						// Définition du fichier squelette demandé
72
						// Définition du fichier squelette demandé
72
						$this->squelette = $this->squelette_dossier.$this->format.'.tpl.xml';
73
						$this->squelette = $this->squelette_dossier.$this->format.'.tpl.xml';
73
					} else if (isset($this->flux[$this->service])) {
74
					} else if (isset($this->flux[$this->service])) {
74
						$this->format = '';
75
						$this->format = '';
75
						$this->messages[] = "Le service CEL Syndication nécessite d'indiquer en second paramètre le format : rss1, rss2 ou atom.";
76
						$this->messages[] = "Le service CEL Syndication nécessite d'indiquer en second paramètre le format : rss1, rss2 ou atom.";
76
					}
77
					}
77
 
78
 
78
					if (!isset($this->flux[$this->service]) || isset($this->format)) {
79
					if (!isset($this->flux[$this->service]) || isset($this->format)) {
79
						// Suppression des paramêtres inutile pour le reste des méthodes
80
						// Suppression des paramêtres inutile pour le reste des méthodes
80
						array_shift($this->parametres);
81
						array_shift($this->parametres);
81
						array_shift($this->parametres);
82
						array_shift($this->parametres);
82
 
83
 
83
						// Récupération du contenu à renvoyer
84
						// Récupération du contenu à renvoyer
84
						$contenu = $this->$methode();
85
						$contenu = $this->$methode();
85
					}
86
					}
86
				} else {
87
				} else {
87
					$this->messages[] = "Le type d'information demandé '$this->service' n'est pas disponible.";
88
					$this->messages[] = "Le type d'information demandé '$this->service' n'est pas disponible.";
88
				}
89
				}
89
			} else {
90
			} else {
90
				$this->messages[] = "Le service CEL Syndication Observation nécessite d'indiquer en premier paramètre le type d'information demandé.";
91
				$this->messages[] = "Le service CEL Syndication Observation nécessite d'indiquer en premier paramètre le type d'information demandé.";
91
			}
92
			}
92
		}
93
		}
93
 
94
 
94
		// Envoie sur la sortie standard
95
		// Envoie sur la sortie standard
95
		$encodage = 'utf-8';
96
		$encodage = 'utf-8';
96
		$mime = $this->getTypeMime();
97
		$mime = $this->getTypeMime();
97
		$formatage_json = $this->getFormatageJson();
98
		$formatage_json = $this->getFormatageJson();
98
		$this->envoyer($contenu, $mime, $encodage, $formatage_json);
99
		$this->envoyer($contenu, $mime, $encodage, $formatage_json);
99
	}
100
	}
100
 
101
 
101
	private function getUrlBase() {
102
	private function getUrlBase() {
102
		$url_base = sprintf($this->config['settings']['baseURLAbsolu'], get_class($this).'/');
103
		$url_base = sprintf($this->config['settings']['baseURLAbsolu'], get_class($this).'/');
103
		return $url_base;
104
		return $url_base;
104
	}
105
	}
105
 
106
 
106
	private function getUrlServiceBase() {
107
	private function getUrlServiceBase() {
107
		$url_service = $this->getUrlBase().implode('/', $this->parametres_origines);
108
		$url_service = $this->getUrlBase().implode('/', $this->parametres_origines);
108
		return $url_service;
109
		return $url_service;
109
	}
110
	}
110
 
111
 
111
	private function traiterNomService($nom) {
112
	private function traiterNomService($nom) {
112
		$nom = strtolower($nom);
113
		$nom = strtolower($nom);
113
		return $nom;
114
		return $nom;
114
	}
115
	}
115
 
116
 
116
	private function getNomMethodeService() {
117
	private function getNomMethodeService() {
117
		$methode = '';
118
		$methode = '';
118
		$service_formate = str_replace(' ', '', ucwords(implode(' ', explode('-', $this->service))));
119
		$service_formate = str_replace(' ', '', ucwords(implode(' ', explode('-', $this->service))));
119
		$methode = 'getService'.$service_formate;
120
		$methode = 'getService'.$service_formate;
120
		return $methode;
121
		return $methode;
121
	}
122
	}
122
 
123
 
123
	private function getTypeMime() {
124
	private function getTypeMime() {
124
		$mime = '';
125
		$mime = '';
125
		$test = isset($this->format) ? $this->format : $this->service;
126
		$test = isset($this->format) ? $this->format : $this->service;
126
		switch ($test) {
127
		switch ($test) {
127
			case 'atom' :
128
			case 'atom' :
128
				$mime = 'application/atom+xml';
129
				$mime = 'application/atom+xml';
129
				break;
130
				break;
130
			case 'rss1' :
131
			case 'rss1' :
131
			case 'rss2' :
132
			case 'rss2' :
132
				$mime = 'application/rss+xml';
133
				$mime = 'application/rss+xml';
133
				break;
134
				break;
134
			case 'opml' :
135
			case 'opml' :
135
				$mime = 'text/x-opml';
136
				$mime = 'text/x-opml';
136
				break;
137
				break;
137
			default:
138
			default:
138
				$mime = 'text/html';
139
				$mime = 'text/html';
139
		}
140
		}
140
		return $mime;
141
		return $mime;
141
	}
142
	}
142
 
143
 
143
	private function getFormatageJson() {
144
	private function getFormatageJson() {
144
		$json = false;
145
		$json = false;
145
		switch ($this->service) {
146
		switch ($this->service) {
146
			case 'liste-des-flux' :
147
			case 'liste-des-flux' :
147
				$json = true;
148
				$json = true;
148
				break;
149
				break;
149
			default:
150
			default:
150
				$json = false;
151
				$json = false;
151
		}
152
		}
152
		return $json;
153
		return $json;
153
	}
154
	}
154
 
155
 
155
	private function getFlux($nom) {
156
	private function getFlux($nom) {
156
		return isset($this->flux[$nom]) ? $this->flux[$nom] : array();
157
		return isset($this->flux[$nom]) ? $this->flux[$nom] : array();
157
	}
158
	}
158
 
159
 
159
	private function setFlux($nom, $titre, $description) {
160
	private function setFlux($nom, $titre, $description) {
160
		$url_base = $this->getUrlBase();
161
		$url_base = $this->getUrlBase();
161
		$formats = array('atom', 'rss2', 'rss1');
162
		$formats = array('atom', 'rss2', 'rss1');
162
		$flux = array();
163
		$flux = array();
163
		foreach ($formats as $format) {
164
		foreach ($formats as $format) {
164
			$url = $url_base.$nom.'/'.$format;
165
			$url = $url_base.$nom.'/'.$format;
165
			$flux[$format] = $url;
166
			$flux[$format] = $url;
166
		}
167
		}
167
		$this->flux[$nom] = array('titre' => $titre, 'description' => $description, 'urls' => $flux);
168
		$this->flux[$nom] = array('titre' => $titre, 'description' => $description, 'urls' => $flux);
168
	}
169
	}
169
 
170
 
170
	private function chargerListeDesFlux() {
171
	private function chargerListeDesFlux() {
171
		$this->setFlux('par-defaut', 'Flux de syndication des observations publiques du CEL',
172
		$this->setFlux('par-defaut', 'Flux de syndication des observations publiques du CEL',
172
			'Ce flux fournit des informations sur les observations du CEL.');
173
			'Ce flux fournit des informations sur les observations du CEL.');
173
		$this->setFlux('par-mots-cles', 'Flux de syndication obsolète',
174
		$this->setFlux('par-mots-cles', 'Flux de syndication obsolète',
174
			"Ce flux est désormais accessible via le flux multicriteres/atom/M?tag='mot-cle'.");
175
			"Ce flux est désormais accessible via le flux multicriteres/atom/M?tag='mot-cle'.");
175
		$this->setFlux('par-commune','Flux de syndication obsolète',
176
		$this->setFlux('par-commune','Flux de syndication obsolète',
176
			"Ce flux  est désormais accessible via le flux multicriteres/atom/M?commune='commune'.");
177
			"Ce flux  est désormais accessible via le flux multicriteres/atom/M?commune='commune'.");
177
		$this->setFlux('multicriteres','Flux de syndication des nouvelles observations publiques du CEL '.
178
		$this->setFlux('multicriteres','Flux de syndication des nouvelles observations publiques du CEL '.
178
			'filtrées par un ou plusieurs critères',
179
			'filtrées par un ou plusieurs critères',
179
			"Ce flux fournit des informations sur les nouvelles observations du CEL filtrées par ".
180
			"Ce flux fournit des informations sur les nouvelles observations du CEL filtrées par ".
180
			"auteur (mail), commune (nom), departement (code postal), taxon (nom scientifique), commentaire, projet ".
181
			"auteur (mail), commune (nom), departement (code postal), taxon (nom scientifique), commentaire, projet ".
181
			"et/ou date.");
182
			"et/ou date.");
182
	}
183
	}
183
 
184
 
184
	private function getServiceListeDesFlux() {
185
	private function getServiceListeDesFlux() {
185
		return $this->flux;
186
		return $this->flux;
186
	}
187
	}
187
 
188
 
188
	private function getServiceOpml() {
189
	private function getServiceOpml() {
189
		$donnees = array();
190
		$donnees = array();
190
		$id = 1;
191
		$id = 1;
191
		foreach ($this->flux as $flux_nom => $flux){
192
		foreach ($this->flux as $flux_nom => $flux){
192
			$info = array();
193
			$info = array();
193
			$info['type'] = 'atom';
194
			$info['type'] = 'atom';
194
			$info['titre'] = $flux['titre'];
195
			$info['titre'] = $flux['titre'];
195
			$info['texte'] = "CEL - Obs - $flux_nom";
196
			$info['texte'] = "CEL - Obs - $flux_nom";
196
			$info['description'] = $flux['description'];
197
			$info['description'] = $flux['description'];
197
			$info['url_xml'] = $this->getUrlBase().$flux_nom.'/atom';
198
			$info['url_xml'] = $this->getUrlBase().$flux_nom.'/atom';
198
			$info['url_html'] = $this->config['settings']['aideCelUrl'].'FluxSyndication';
199
			$info['url_html'] = $this->config['settings']['aideCelUrl'].'FluxSyndication';
199
			$donnees['liste_flux'][] = $info;
200
			$donnees['liste_flux'][] = $info;
200
		}
201
		}
201
 
202
 
202
		$this->squelette = $this->squelette_dossier.'opml.tpl.xml';
203
		$this->squelette = $this->squelette_dossier.'opml.tpl.xml';
203
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
204
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
204
		return $contenu;
205
		return $contenu;
205
	}
206
	}
206
 
207
 
207
	private function getServiceParDefaut() {
208
	private function getServiceParDefaut() {
208
		// Construction de la requête
209
		// Construction de la requête
209
		$requete = 	(isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
210
		$requete = 	(isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
210
			'FROM cel_obs '.
211
			'FROM cel_obs '.
211
			(($this->etreFluxAdmin()) ? '' : 'WHERE transmission = 1 ').
212
			(($this->etreFluxAdmin()) ? '' : 'WHERE transmission = 1 ').
212
			'ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby  : 'date_modification DESC').' '.
213
			'ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby  : 'date_modification DESC').' '.
213
			"LIMIT $this->start,$this->limit ";
214
			"LIMIT $this->start,$this->limit ";
214
 
215
 
215
		$elements = $this->executerRequete($requete);
216
		$elements = $this->executerRequete($requete);
216
 
217
 
217
		// Création du contenu
218
		// Création du contenu
218
		$contenu = $this->executerService($elements);
219
		$contenu = $this->executerService($elements);
219
		return $contenu;
220
		return $contenu;
220
	}
221
	}
221
 
222
 
222
	private function getServiceParMotsCles() {
223
	private function getServiceParMotsCles() {
223
		$infos=array();
224
		$infos=array();
224
		$infos[0]['nom_sel_nn'] = '';
225
		$infos[0]['nom_sel_nn'] = '';
225
		$infos[0]['date_modification'] = '2011-06-28';
226
		$infos[0]['date_modification'] = '2011-06-28';
226
		$donnees = $this->construireDonneesCommunesAuFlux($infos);
227
		$donnees = $this->construireDonneesCommunesAuFlux($infos);
227
		$donnees['items'][0]['guid'] = 0;
228
		$donnees['items'][0]['guid'] = 0;
228
		$donnees['items'][0]['description'] =  'Ce flux est devenu obsolète. Veuillez utiliser le flux '.
229
		$donnees['items'][0]['description'] =  'Ce flux est devenu obsolète. Veuillez utiliser le flux '.
229
			'<b>http://www.tela-botanica.org/eflore/cel2/jrest/CelSyndicationObservation/multicriteres/atom?projet=';
230
			'<b>http://www.tela-botanica.org/eflore/cel2/jrest/CelSyndicationObservation/multicriteres/atom?projet=';
230
		if (isset($this->parametres[0])) {
231
		if (isset($this->parametres[0])) {
231
			$donnees['items'][0]['description'] .= $this->parametres[0].'</b>';
232
			$donnees['items'][0]['description'] .= $this->parametres[0].'</b>';
232
		} else {
233
		} else {
233
			$donnees['items'][0]['description'] .= '</b>';
234
			$donnees['items'][0]['description'] .= '</b>';
234
		}
235
		}
235
		$donnees['items'][0]['titre'] = '';
236
		$donnees['items'][0]['titre'] = '';
236
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
237
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
237
		return $contenu;
238
		return $contenu;
238
	}
239
	}
239
 
240
 
240
	private function getServiceParCommune() {
241
	private function getServiceParCommune() {
241
		$infos=array();
242
		$infos=array();
242
		$infos[0]['nom_sel_nn'] = '';
243
		$infos[0]['nom_sel_nn'] = '';
243
		$infos[0]['date_modification'] = '2011-06-28';
244
		$infos[0]['date_modification'] = '2011-06-28';
244
		$donnees = $this->construireDonneesCommunesAuFlux($infos);
245
		$donnees = $this->construireDonneesCommunesAuFlux($infos);
245
		$donnees['items'][0]['guid'] = 0;
246
		$donnees['items'][0]['guid'] = 0;
246
		$donnees['items'][0]['description'] = 'Ce flux est devenu obsolète. Veuillez utiliser le flux '.
247
		$donnees['items'][0]['description'] = 'Ce flux est devenu obsolète. Veuillez utiliser le flux '.
247
			'<b>http://www.tela-botanica.org/eflore/cel2/jrest/CelSyndicationObservation/multicriteres/atom?commune=';
248
			'<b>http://www.tela-botanica.org/eflore/cel2/jrest/CelSyndicationObservation/multicriteres/atom?commune=';
248
		if (isset($this->parametres[0])) {
249
		if (isset($this->parametres[0])) {
249
			$donnees['items'][0]['description'] .= $this->parametres[0].'</b>';
250
			$donnees['items'][0]['description'] .= $this->parametres[0].'</b>';
250
		} else {
251
		} else {
251
			$donnees['items'][0]['description'] .= '</b>';
252
			$donnees['items'][0]['description'] .= '</b>';
252
		}
253
		}
253
		$donnees['items'][0]['titre'] = '';
254
		$donnees['items'][0]['titre'] = '';
254
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
255
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
255
		return $contenu;
256
		return $contenu;
256
	}
257
	}
257
 
258
 
258
	private function getServiceMultiCriteres() {
259
	private function getServiceMultiCriteres() {
259
		$contenu = '';
260
		$contenu = '';
260
		if (isset($_GET['debut'])) $this->start = $_GET['debut'];
261
		if (isset($_GET['debut'])) $this->start = $_GET['debut'];
261
		if (isset($_GET['limite'])) $this->limite = $_GET['limite'];
262
		if (isset($_GET['limite'])) $this->limite = $_GET['limite'];
262
 
263
 
263
		// Construction de la requête
264
		// Construction de la requête
264
		$requete = (isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
265
		$requete = (isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
265
				'FROM cel_obs '.
266
				'FROM cel_obs '.
266
				'WHERE 1 AND '.(($this->etreFluxAdmin()) ? '' : ' transmission = 1 AND ');
267
				'WHERE 1 AND '.(($this->etreFluxAdmin()) ? '' : ' transmission = 1 AND ');
267
 
268
 
268
		if ($this->estUneRechercheGenerale()) {
269
		if ($this->estUneRechercheGenerale()) {
269
			$chaine_requete = $_GET['recherche'];
270
			$chaine_requete = $_GET['recherche'];
270
			$requete .= $this->creerSousRequeteRechercheGenerale($chaine_requete);
271
			$requete .= $this->creerSousRequeteRechercheGenerale($chaine_requete);
271
		} else {
272
		} else {
272
			$criteres = $this->traiterCriteresMultiples($_GET) ;
273
			$criteres = $this->traiterCriteresMultiples($_GET) ;
273
			if (!empty($criteres)) {
274
			if (!empty($criteres)) {
274
				$requete .= $this->creerSousRequeteRechercheParCriteres($criteres);
275
				$requete .= $this->creerSousRequeteRechercheParCriteres($criteres);
275
			}
276
			}
276
		}
277
		}
277
		$requete = rtrim($requete, 'AND ');
278
		$requete = rtrim($requete, 'AND ');
278
		$requete .= ' ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby  :
279
		$requete .= ' ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby  :
279
			'date_modification DESC, zone_geo ASC').' '.
280
			'date_modification DESC, zone_geo ASC').' '.
280
				"LIMIT $this->start,$this->limit ";
281
				"LIMIT $this->start,$this->limit ";
281
 
282
 
282
		$elements = $this->executerRequete($requete);
283
		$elements = $this->executerRequete($requete);
283
 
284
 
284
		// Création du contenu
285
		// Création du contenu
285
		if ($elements != false && count($elements) > 0) {
286
		if ($elements != false && count($elements) > 0) {
286
			$contenu = $this->executerService($elements);
287
			$contenu = $this->executerService($elements);
287
		} else {
288
		} else {
288
			$this->messages[] = "Aucune observation disponible.";
289
			$this->messages[] = "Aucune observation disponible.";
289
		}
290
		}
290
 
291
 
291
        return $contenu;
292
        return $contenu;
292
	}
293
	}
293
 
294
 
294
	private function creerSousRequeteRechercheParCriteres($criteres) {
295
	private function creerSousRequeteRechercheParCriteres($criteres) {
295
		$requete = '';
296
		$requete = '';
296
		foreach ($criteres as $pair) {
297
		foreach ($criteres as $pair) {
297
			$nom_valeur = explode("=",$pair);
298
			$nom_valeur = explode("=",$pair);
298
			if (sizeof($nom_valeur) != 0) {
299
			if (sizeof($nom_valeur) != 0) {
299
				switch ($nom_valeur[0]) {
300
				switch ($nom_valeur[0]) {
300
					case "ci_limite" : $this->limite = $this->bdd->quote($nom_valeur[1]); break;
301
					case "ci_limite" : $this->limite = $this->bdd->quote($nom_valeur[1]); break;
301
					case "commentaire" : $mots_comment_liste = explode(" " , $nom_valeur[1]);
302
					case "commentaire" : $mots_comment_liste = explode(" " , $nom_valeur[1]);
302
						foreach($mots_comment_liste as $mot_comment) {
303
						foreach($mots_comment_liste as $mot_comment) {
303
							$mot_comment = trim($mot_comment) ;
304
							$mot_comment = trim($mot_comment) ;
304
							$requete .= $nom_valeur[0].' LIKE '.$this->bdd->quote('%'.$mot_comment.'%').' AND ';
305
							$requete .= $nom_valeur[0].' LIKE '.$this->bdd->quote('%'.$mot_comment.'%').' AND ';
305
						}
306
						}
306
						break;
307
						break;
307
					case "date_observation" :
308
					case "date_observation" :
308
						$nom_valeur[1] = str_replace('/', '-', $nom_valeur[1]);
309
						$nom_valeur[1] = str_replace('/', '-', $nom_valeur[1]);
309
						if (preg_match('/(^[0-9]{2})-([0-9]{2})-([0-9]{4}$)/', $nom_valeur[1], $matches)) {
310
						if (preg_match('/(^[0-9]{2})-([0-9]{2})-([0-9]{4}$)/', $nom_valeur[1], $matches)) {
310
							$nom_valeur[1] = $matches[3].'-'.$matches[2].'-'.$matches[1];
311
							$nom_valeur[1] = $matches[3].'-'.$matches[2].'-'.$matches[1];
311
						}
312
						}
312
						$requete .= $nom_valeur[0].'='.$this->bdd->quote($nom_valeur[1]).' AND '; break;
313
						$requete .= $nom_valeur[0].'='.$this->bdd->quote($nom_valeur[1]).' AND '; break;
313
					case "ce_zone_geo" :
314
					case "ce_zone_geo" :
314
						$requete .= ' ('.$nom_valeur[0].' LIKE "INSEE-C:'.$nom_valeur[1].'%") AND '; break;
315
						$requete .= ' ('.$nom_valeur[0].' LIKE "INSEE-C:'.$nom_valeur[1].'%") AND '; break;
315
					case "nom_ret" :
316
					case "nom_ret" :
316
						if ($nom_valeur[1] == "indetermine") $nom_valeur[1] = 'null';
317
						if ($nom_valeur[1] == "indetermine") $nom_valeur[1] = 'null';
317
						$requete .= ' ('.$nom_valeur[0].' LIKE "%'.$nom_valeur[1].'%" OR nom_sel LIKE "%'.
318
						$requete .= ' ('.$nom_valeur[0].' LIKE "%'.$nom_valeur[1].'%" OR nom_sel LIKE "%'.
318
							$nom_valeur[1].'%") AND '; break;
319
							$nom_valeur[1].'%") AND '; break;
319
					case "mots-cles" : $requete .= $this->creerSousRequeteMotsCles($nom_valeur[1]).' AND '; break;
320
					case "mots-cles" : $requete .= $this->creerSousRequeteMotsCles($nom_valeur[1]).' AND '; break;
-
 
321
					case "tags" : $requete .= $this->creerSousRequeteTags($nom_valeur[1]).' AND '; break;
320
					default : $requete .= $nom_valeur[0].' = "'.$nom_valeur[1].'" AND '; break;
322
					default : $requete .= $nom_valeur[0].' = "'.$nom_valeur[1].'" AND '; break;
321
				}
323
				}
322
			}
324
			}
323
		}
325
		}
324
		$requete = rtrim($requete,' AND ');
326
		$requete = rtrim($requete,' AND ');
325
		return $requete;
327
		return $requete;
326
	}
328
	}
327
 
329
 
328
	private function creerSousRequeteMotsCles($mot_cle) {
330
	private function creerSousRequeteMotsCles($mot_cle) {
329
		$requete = '';
331
		$requete = '';
330
		if (preg_match('/.*OU.*/', $mot_cle)) {
332
		if (preg_match('/.*OU.*/', $mot_cle)) {
331
			$mots_cles_tab = explode('OU',$mot_cle);
333
			$mots_cles_tab = explode('OU',$mot_cle);
332
			foreach($mots_cles_tab as $mot_cle_item) {
334
			foreach($mots_cles_tab as $mot_cle_item) {
333
				$requete .= '(mots_cles_texte LIKE '.$this->proteger('%'.$mot_cle_item.'%').') OR ';
335
				$requete .= '(mots_cles_texte LIKE '.$this->proteger('%'.$mot_cle_item.'%').') OR ';
334
			}
336
			}
335
			$requete = '('.rtrim($requete,'OR ').') ';
337
			$requete = '('.rtrim($requete,'OR ').') ';
336
		} else if (preg_match('/.*ET.*/', $mot_cle)) {
338
		} else if (preg_match('/.*ET.*/', $mot_cle)) {
337
			$mots_cles_tab = explode('ET',$mot_cle);
339
			$mots_cles_tab = explode('ET',$mot_cle);
338
			foreach($mots_cles_tab as $mot_cle_item) {
340
			foreach($mots_cles_tab as $mot_cle_item) {
339
				$requete .= '(mots_cles_texte LIKE '.$this->proteger('%'.$mot_cle_item.'%').') AND ';
341
				$requete .= '(mots_cles_texte LIKE '.$this->proteger('%'.$mot_cle_item.'%').') AND ';
340
			}
342
			}
341
			$requete = '('.rtrim($requete, 'AND ').') ';
343
			$requete = '('.rtrim($requete, 'AND ').') ';
342
		} else {
344
		} else {
343
			$requete = "(mots_cles_texte LIKE ".$this->proteger('%'.$mot_cle.'%').') ';
345
			$requete = "(mots_cles_texte LIKE ".$this->proteger('%'.$mot_cle.'%').') ';
344
		}
346
		}
345
		return $requete;
347
		return $requete;
-
 
348
	}
-
 
349
	
-
 
350
	private function creerSousRequeteTags($tag) {
-
 
351
		$requete = '(id_observation IN (SELECT id_observation FROM cel_obs_images coi INNER JOIN cel_images ci ON coi.id_image = ci.id_image WHERE ';
-
 
352
		$where = '';
-
 
353
		if (preg_match('/.*OU.*/', $tag)) {
-
 
354
			$mots_cles_tab = explode('OU',$tag);
-
 
355
			foreach($mots_cles_tab as $mot_cle_item) {
-
 
356
				$where .= '(ci.mots_cles_texte LIKE '.$this->proteger('%'.$mot_cle_item.'%').') OR ';
-
 
357
			}
-
 
358
			$where .= '('.rtrim($where,'OR ').') ';
-
 
359
		} else if (preg_match('/.*ET.*/', $tag)) {
-
 
360
			$mots_cles_tab = explode('ET',$tag);
-
 
361
			foreach($mots_cles_tab as $mot_cle_item) {
-
 
362
				$where .= '(ci.mots_cles_texte LIKE '.$this->proteger('%'.$mot_cle_item.'%').') AND ';
-
 
363
			}
-
 
364
			$where .= '('.rtrim($where, 'AND ').') ';
-
 
365
		} else {
-
 
366
			$where .= "(ci.mots_cles_texte LIKE ".$this->proteger('%'.$tag.'%').') ';
-
 
367
		}
-
 
368
		$requete .= $where.' ))';
-
 
369
		return $requete;
346
	}
370
	}
347
 
371
 
348
	private function traiterCriteresMultiples($tableau_criteres) {
372
	private function traiterCriteresMultiples($tableau_criteres) {
349
		$tableau_criteres_pour_bdd = array();
373
		$tableau_criteres_pour_bdd = array();
350
 
374
 
351
		foreach($tableau_criteres as $nom_critere => $valeur_critere) {
375
		foreach($tableau_criteres as $nom_critere => $valeur_critere) {
352
			if (isset($this->criteres[$nom_critere])) {
376
			if (isset($this->criteres[$nom_critere])) {
353
				$tableau_criteres_pour_bdd[] = $this->criteres[$nom_critere].'='.$valeur_critere;
377
				$tableau_criteres_pour_bdd[] = $this->criteres[$nom_critere].'='.$valeur_critere;
354
			}
378
			}
355
		}
379
		}
356
		return $tableau_criteres_pour_bdd;
380
		return $tableau_criteres_pour_bdd;
357
	}
381
	}
358
 
382
 
359
	private function creerSousRequeteRechercheGenerale($chaine_requete) {
383
	private function creerSousRequeteRechercheGenerale($chaine_requete) {
360
		$requete = '';
384
		$requete = '';
361
		if (trim($chaine_requete) != '') {
385
		if (trim($chaine_requete) != '') {
362
			$chaine_requete = strtolower($chaine_requete);
386
			$chaine_requete = strtolower($chaine_requete);
363
			$chaine_requete = str_replace(' ', '_', $chaine_requete);
387
			$chaine_requete = str_replace(' ', '_', $chaine_requete);
364
			$requete = ' ('.
388
			$requete = ' ('.
365
				'nom_ret LIKE "'.$chaine_requete.'%"'.
389
				'nom_ret LIKE "'.$chaine_requete.'%"'.
366
				' OR '.
390
				' OR '.
367
				'nom_sel LIKE "'.$chaine_requete.'%"'.
391
				'nom_sel LIKE "'.$chaine_requete.'%"'.
368
				' OR '.
392
				' OR '.
369
				'zone_geo LIKE "'.$chaine_requete.'%" '.
393
				'zone_geo LIKE "'.$chaine_requete.'%" '.
370
				' OR '.
394
				' OR '.
371
				'ce_zone_geo LIKE "'.$chaine_requete.'%" '.
395
				'ce_zone_geo LIKE "'.$chaine_requete.'%" '.
372
				' OR '.
396
				' OR '.
373
				'ce_zone_geo LIKE "INSEE-C:'.$chaine_requete.'%" '.
397
				'ce_zone_geo LIKE "INSEE-C:'.$chaine_requete.'%" '.
374
				' OR '.
398
				' OR '.
375
				'courriel_utilisateur LIKE "'.$chaine_requete.'%" '.
399
				'courriel_utilisateur LIKE "'.$chaine_requete.'%" '.
376
				' OR '.
400
				' OR '.
377
				'mots_cles_texte LIKE "'.$chaine_requete.'%" '.
401
				'mots_cles_texte LIKE "'.$chaine_requete.'%" '.
378
				') ';
402
				') ';
379
		}
403
		}
380
		return $requete;
404
		return $requete;
381
	}
405
	}
382
 
406
 
383
	private function estUneRechercheGenerale() {
407
	private function estUneRechercheGenerale() {
384
		return isset($_GET['recherche']);
408
		return isset($_GET['recherche']);
385
	}
409
	}
386
 
410
 
387
	private function executerService($elements) {
411
	private function executerService($elements) {
388
		$contenu = '';
412
		$contenu = '';
389
		if (is_array($elements)) {
413
		if (is_array($elements)) {
390
			// Prétraitement des données
414
			// Prétraitement des données
391
			$donnees = $this->construireDonneesCommunesAuFlux($elements);
415
			$donnees = $this->construireDonneesCommunesAuFlux($elements);
392
			foreach ($elements as $element) {
416
			foreach ($elements as $element) {
393
				$identifiants[$element['courriel_utilisateur']] = $element['courriel_utilisateur'];
417
				$identifiants[$element['courriel_utilisateur']] = $element['courriel_utilisateur'];
394
			}
418
			}
395
			$this->auteurs = $this->creerAuteurs($identifiants);
419
			$this->auteurs = $this->creerAuteurs($identifiants);
396
			foreach ($elements as $element) {
420
			foreach ($elements as $element) {
397
				$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
421
				$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
398
			}
422
			}
399
 
423
 
400
			// Création du contenu à partir d'un template PHP
424
			// Création du contenu à partir d'un template PHP
401
			if (isset($this->squelette)) {
425
			if (isset($this->squelette)) {
402
				$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
426
				$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
403
			}
427
			}
404
		}
428
		}
405
		return $contenu;
429
		return $contenu;
406
	}
430
	}
407
 
431
 
408
	private function construireDonneesCommunesAuFlux($observations) {
432
	private function construireDonneesCommunesAuFlux($observations) {
409
		$donnees = $this->getFlux($this->service);
433
		$donnees = $this->getFlux($this->service);
410
		$donnees['guid'] = $this->getUrlServiceBase();
434
		$donnees['guid'] = $this->getUrlServiceBase();
411
		$donnees['titre'] = 'Flux des observations du CEL';
435
		$donnees['titre'] = 'Flux des observations du CEL';
412
		$donnees['lien_service'] = $this->creerUrlService();
436
		$donnees['lien_service'] = $this->creerUrlService();
413
		$donnees['lien_cel'] = $this->config['settings']['baseURLAbsolu'];
437
		$donnees['lien_cel'] = $this->config['settings']['baseURLAbsolu'];
414
		$donnees['editeur'] = $this->config['settings']['editeur'];
438
		$donnees['editeur'] = $this->config['settings']['editeur'];
415
		$derniere_info_en_date = reset($observations);
439
		$derniere_info_en_date = reset($observations);
416
		$date_modification_timestamp = strtotime($derniere_info_en_date['date_modification']);
440
		$date_modification_timestamp = strtotime($derniere_info_en_date['date_modification']);
417
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
441
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
418
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
442
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
419
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
443
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
420
		$donnees['annee_courante'] = date('Y');
444
		$donnees['annee_courante'] = date('Y');
421
		$donnees['generateur'] = 'CEL - Jrest - CelSyndicationObservation';
445
		$donnees['generateur'] = 'CEL - Jrest - CelSyndicationObservation';
422
		$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ?  $match[1] : '0';
446
		$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ?  $match[1] : '0';
423
		return $donnees;
447
		return $donnees;
424
	}
448
	}
425
 
449
 
426
	private function construireDonneesCommunesAuxItems($observation) {
450
	private function construireDonneesCommunesAuxItems($observation) {
427
		$item = array();
451
		$item = array();
428
		$date_modification_timestamp = $this->convertirDateHeureMysqlEnTimestamp($observation['date_modification']);
452
		$date_modification_timestamp = $this->convertirDateHeureMysqlEnTimestamp($observation['date_modification']);
429
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
453
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
430
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
454
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
431
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
455
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
432
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
456
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
433
		$item['date_creation_simple'] = strftime('%A %d %B %Y à %H:%M', strtotime($observation['date_creation']));
457
		$item['date_creation_simple'] = strftime('%A %d %B %Y à %H:%M', strtotime($observation['date_creation']));
434
		$item['titre'] = $this->creerTitre($observation);
458
		$item['titre'] = $this->creerTitre($observation);
435
		$item['guid'] = $this->creerGuidItem($observation);
459
		$item['guid'] = $this->creerGuidItem($observation);
436
		$item['lien'] = $this->creerLienItem($observation);
460
		$item['lien'] = $this->creerLienItem($observation);
437
		$item['categorie'] = $this->creerCategorie($item);
461
		$item['categorie'] = $this->creerCategorie($item);
438
		$item['description'] = $this->creerDescription($this->protegerCaracteresHtmlDansChamps($observation), $item);
462
		$item['description'] = $this->creerDescription($this->protegerCaracteresHtmlDansChamps($observation), $item);
439
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($observation, $item));
463
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($observation, $item));
440
		$item['modifier_par'] = $observation['id_observation'];
464
		$item['modifier_par'] = $observation['id_observation'];
441
		return $item;
465
		return $item;
442
	}
466
	}
443
 
467
 
444
	private function creerTitre($obs) {
468
	private function creerTitre($obs) {
445
		$date = ($obs['date_observation'] != '0000-00-00 00:00:00') ? 'le '.date("d/m/Y", strtotime($obs['date_observation'])) : '' ;
469
		$date = ($obs['date_observation'] != '0000-00-00 00:00:00') ? 'le '.date("d/m/Y", strtotime($obs['date_observation'])) : '' ;
446
		$nom_plante = $obs['nom_sel'].' [nn'.$obs['nom_sel_nn'].']';
470
		$nom_plante = $obs['nom_sel'].' [nn'.$obs['nom_sel_nn'].']';
447
		$lieu = $obs['zone_geo'].' ('.$obs['ce_zone_geo'].')';
471
		$lieu = $obs['zone_geo'].' ('.$obs['ce_zone_geo'].')';
448
		$utilisateur = $this->getIntituleAuteur($obs['courriel_utilisateur']);
472
		$utilisateur = $this->getIntituleAuteur($obs['courriel_utilisateur']);
449
		$titre = "$nom_plante à $lieu par $utilisateur $date";
473
		$titre = "$nom_plante à $lieu par $utilisateur $date";
450
		$titre = $this->nettoyerTexte($titre);
474
		$titre = $this->nettoyerTexte($titre);
451
		return $titre;
475
		return $titre;
452
	}
476
	}
453
 
477
 
454
	private function creerGuidItem($element) {
478
	private function creerGuidItem($element) {
455
		$guid = sprintf($this->config['settings']['guidObsTpl'], $element['id_observation']);
479
		$guid = sprintf($this->config['settings']['guidObsTpl'], $element['id_observation']);
456
		return $guid;
480
		return $guid;
457
	}
481
	}
458
 
482
 
459
	private function creerLienItem($element) {
483
	private function creerLienItem($element) {
460
		$lien = null;
484
		$lien = null;
461
		if ($element['nom_sel_nn'] != 0) {
485
		if ($element['nom_sel_nn'] != 0) {
462
			$lien = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($element['nom_sel_nn']), 'cel');
486
			$lien = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($element['nom_sel_nn']), 'cel');
463
		}
487
		}
464
		return $lien;
488
		return $lien;
465
	}
489
	}
466
 
490
 
467
	private function creerDescription($obs, $item) {
491
	private function creerDescription($obs, $item) {
468
		$id_obs = $obs['id_observation'];
492
		$id_obs = $obs['id_observation'];
469
		$famille = $obs['famille'];
493
		$famille = $obs['famille'];
470
		$nom_saisi = $obs['nom_sel'];
494
		$nom_saisi = $obs['nom_sel'];
471
		$nom_retenu = $obs['nom_ret'];
495
		$nom_retenu = $obs['nom_ret'];
472
		$auteur = $this->getIntituleAuteur($obs['courriel_utilisateur']);
496
		$auteur = $this->getIntituleAuteur($obs['courriel_utilisateur']);
473
		$auteur_mail = $obs['courriel_utilisateur'];
497
		$auteur_mail = $obs['courriel_utilisateur'];
474
		$mots_cles_obs = $obs['mots_cles_texte'];
498
		$mots_cles_obs = $obs['mots_cles_texte'];
475
		$lien_correction = sprintf($this->config['settings']['phpEditUrlTpl'], $obs['id_observation']);
499
		$lien_correction = sprintf($this->config['settings']['phpEditUrlTpl'], $obs['id_observation']);
476
		$lieu = $obs['zone_geo'].' ('.$this->convertirCodeZoneGeoVersCodeInsee($obs['ce_zone_geo']).') > '.$obs['lieudit'].' > '.$obs['station'];
500
		$lieu = $obs['zone_geo'].' ('.$this->convertirCodeZoneGeoVersCodeInsee($obs['ce_zone_geo']).') > '.$obs['lieudit'].' > '.$obs['station'];
477
		$milieu = $obs['milieu'];
501
		$milieu = $obs['milieu'];
478
		$coordonnees = ($this->etreNull($obs['latitude']) && $this->etreNull($obs['longitude'])) ? '' : $obs['latitude'].'/'.$obs['longitude'];
502
		$coordonnees = ($this->etreNull($obs['latitude']) && $this->etreNull($obs['longitude'])) ? '' : $obs['latitude'].'/'.$obs['longitude'];
479
		$commentaire = $obs['commentaire'];
503
		$commentaire = $obs['commentaire'];
480
		$date_observation = ($obs['date_observation'] != '0000-00-00 00:00:00') ? $this->formaterDate($obs['date_observation'], '%A %d %B %Y') : '';
504
		$date_observation = ($obs['date_observation'] != '0000-00-00 00:00:00') ? $this->formaterDate($obs['date_observation'], '%A %d %B %Y') : '';
481
		$date_transmission = $this->formaterDate($obs['date_transmission']);
505
		$date_transmission = $this->formaterDate($obs['date_transmission']);
482
		$date_modification = $this->formaterDate($obs['date_modification']);
506
		$date_modification = $this->formaterDate($obs['date_modification']);
483
		$date_creation = $this->formaterDate($obs['date_creation']);
507
		$date_creation = $this->formaterDate($obs['date_creation']);
484
		$transmission = $obs['transmission'] == 1 ? "oui ($date_transmission)" : 'non';
508
		$transmission = $obs['transmission'] == 1 ? "oui ($date_transmission)" : 'non';
485
 
509
 
486
		$description = '<h2>'."Observation #$id_obs de $nom_saisi".'</h2>'.
510
		$description = '<h2>'."Observation #$id_obs de $nom_saisi".'</h2>'.
487
			'<ul>'.
511
			'<ul>'.
488
			'<li>'.'Famille : '.$famille.'</li>'.
512
			'<li>'.'Famille : '.$famille.'</li>'.
489
			'<li>'.'Nom saisi : '.$nom_saisi.'</li>'.
513
			'<li>'.'Nom saisi : '.$nom_saisi.'</li>'.
490
			'<li>'.'Nom retenu : '.$nom_retenu.'</li>'.
514
			'<li>'.'Nom retenu : '.$nom_retenu.'</li>'.
491
			'<li>'.'Observée le : '.$date_observation.'</li>'.
515
			'<li>'.'Observée le : '.$date_observation.'</li>'.
492
			'<li>'.'Lieu : '.$lieu.'</li>'.
516
			'<li>'.'Lieu : '.$lieu.'</li>'.
493
			'<li>'.'Milieu : '.$milieu.'</li>'.
517
			'<li>'.'Milieu : '.$milieu.'</li>'.
494
			(($this->etreFluxAdmin()) ? '<li>Coordonnées (Lat/Long) : '.$coordonnees.'</li>' : '').
518
			(($this->etreFluxAdmin()) ? '<li>Coordonnées (Lat/Long) : '.$coordonnees.'</li>' : '').
495
			'<li>'.'Commentaire : '.$commentaire.'</li>'.
519
			'<li>'.'Commentaire : '.$commentaire.'</li>'.
496
			'<li>'.'Mots-clés : '.$mots_cles_obs.'</li>'.
520
			'<li>'.'Mots-clés : '.$mots_cles_obs.'</li>'.
497
			(($this->etreFluxAdmin()) ? '<li>Transmis (= public) : '.$transmission.'</li>' : '').
521
			(($this->etreFluxAdmin()) ? '<li>Transmis (= public) : '.$transmission.'</li>' : '').
498
			'<li>Modifiée le : '.$date_modification.'</li>'.
522
			'<li>Modifiée le : '.$date_modification.'</li>'.
499
			'<li>Créée le : '.$date_creation.'</li>'.
523
			'<li>Créée le : '.$date_creation.'</li>'.
500
			'<li>'.'Par : '.
524
			'<li>'.'Par : '.
501
				(($this->etreFluxAdmin()) ? '<a href="mailto:'.$auteur_mail.'">'.$auteur.'</a>' : $auteur).
525
				(($this->etreFluxAdmin()) ? '<a href="mailto:'.$auteur_mail.'">'.$auteur.'</a>' : $auteur).
502
			'</li>'.
526
			'</li>'.
503
			(($this->etreFluxAdmin()) ? '<li><a href="'.$lien_correction.'">Corriger cette observation</a></li>' : '').
527
			(($this->etreFluxAdmin()) ? '<li><a href="'.$lien_correction.'">Corriger cette observation</a></li>' : '').
504
			'</ul>';
528
			'</ul>';
505
		$description = $this->nettoyerTexte($description);
529
		$description = $this->nettoyerTexte($description);
506
		return $description;
530
		return $description;
507
	}
531
	}
508
 
532
 
509
	private function creerCategorie($element) {
533
	private function creerCategorie($element) {
510
		$categorie = '';
534
		$categorie = '';
511
		$categorie = 'Observation';
535
		$categorie = 'Observation';
512
		$categorie = $this->nettoyerTexte($categorie);
536
		$categorie = $this->nettoyerTexte($categorie);
513
		return $categorie;
537
		return $categorie;
514
	}
538
	}
515
 
539
 
516
	private function etreFluxAdmin() {
540
	private function etreFluxAdmin() {
517
		return (isset($_GET['admin']) && $_GET['admin'] == '1') ? true : false;
541
		return (isset($_GET['admin']) && $_GET['admin'] == '1') ? true : false;
518
	}
542
	}
519
 
543
 
520
	private function creerUrlService() {
544
	private function creerUrlService() {
521
		$url_service = $this->getUrlServiceBase();
545
		$url_service = $this->getUrlServiceBase();
522
		if (count($_GET) > 0) {
546
		if (count($_GET) > 0) {
523
			$parametres_get = array();
547
			$parametres_get = array();
524
			foreach ($_GET as $cle => $valeur) {
548
			foreach ($_GET as $cle => $valeur) {
525
				$parametres_get[] = $cle.'='.$valeur;
549
				$parametres_get[] = $cle.'='.$valeur;
526
			}
550
			}
527
			$url_service .= '?'.implode('&amp;', $parametres_get);
551
			$url_service .= '?'.implode('&amp;', $parametres_get);
528
		}
552
		}
529
		return $url_service;
553
		return $url_service;
530
	}
554
	}
531
 
555
 
532
	private function getIntituleAuteur($courriel) {
556
	private function getIntituleAuteur($courriel) {
533
		$courriel = strtolower($courriel);
557
		$courriel = strtolower($courriel);
534
		if(isset($this->auteurs[$courriel])) {
558
		if(isset($this->auteurs[$courriel])) {
535
			$intitule = $this->auteurs[$courriel];
559
			$intitule = $this->auteurs[$courriel];
536
		} else {
560
		} else {
537
			$intitule = $courriel;
561
			$intitule = $courriel;
538
		}
562
		}
539
		return $intitule;
563
		return $intitule;
540
	}
564
	}
541
}
565
}