Subversion Repositories eFlore/Applications.cel

Rev

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

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