Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 523 Rev 524
1
<?php
1
<?php
2
/**
2
/**
3
 * Service fournissant des informations concernant les images du CEL au format RSS1, RSS2 ou ATOM.
3
 * Service fournissant des informations concernant les images du 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
 * 
6
 * 
7
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
7
 * @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
8
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.txt>
9
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
9
 * @license CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
10
 * @version $Id$
10
 * @version $Id$
11
 * @copyright 2010
11
 * @copyright 2010
12
 */
12
 */
13
class CelSyndicationImage extends Cel {
13
class CelSyndicationImage extends Cel {
14
	
14
	
15
	private $format = null;
15
	private $format = null;
16
	private $service = null;
16
	private $service = null;
17
	private $squelette = null;
17
	private $squelette = null;
18
	private $squelette_dossier = null;
18
	private $squelette_dossier = null;
19
	private $flux = array();
19
	private $flux = array();
20
	
20
	
21
	private $format_image = 'L';
21
	private $format_image = 'L';
22
	
22
	
23
	/**
23
	/**
24
	 * Méthode appelée avec une requête de type GET.
24
	 * Méthode appelée avec une requête de type GET.
25
	 */
25
	 */
26
	public function getElement($param = array()) {
26
	public function getElement($params = array()) {
27
		// Initialisation des variables
27
		// Initialisation des variables
28
		$info = array();
28
		$info = array();
29
		$contenu = '';
29
		$contenu = '';
30
		
30
		
31
		if (! $this->etreFluxAdmin() || $this->authentifier()) {
31
		if (! $this->etreFluxAdmin() || $this->authentifier()) {
32
			// Pré traitement des paramêtres
32
			// Pré traitement des paramêtres
33
			$pour_bdd = false;
33
			$pour_bdd = false;
34
			$p = $this->traiterParametres(array('service', 'format'), $param, $pour_bdd);
34
			$p = $this->traiterParametres(array('service', 'format'), $params, $pour_bdd);
35
			unset($param[0]);
-
 
36
			unset($param[1]);
-
 
37
			sort($param);
-
 
38
			extract($p);
35
			extract($p);
-
 
36
			$this->parametres = $params;
-
 
37
			$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR;
39
			
38
			
40
			// Récupération de la liste des flux
39
			// Récupération de la liste des flux
41
			$this->chargerListeDesFlux();
40
			$this->chargerListeDesFlux();
42
			
41
			
43
			// Chargement du bon type de service demandé
42
			// Chargement du bon type de service demandé
44
			if (isset($service)) {
43
			if (isset($service)) {
45
				$this->service = $service;
44
				$this->service = $this->traiterNomService($service);
46
				$methode = $this->getNomMethodeService();
45
				$methode = $this->getNomMethodeService();
47
				if (method_exists($this, $methode)) {
46
				if (method_exists($this, $methode)) {
48
					if ($this->service != 'liste_des_flux') {
-
 
49
						if (isset($format) && preg_match('/^(?:rss1|rss2|atom)$/i', $format)) {
47
					if (isset($format) && preg_match('/^(?:rss1|rss2|atom)$/i', $format)) {
50
							// Mise en minuscule de l'indication du format
48
						// Mise en minuscule de l'indication du format
51
							$this->format = strtolower($format);
49
						$this->format = strtolower($format);
52
							// Définition du fichier squelette demandé
50
						// Définition du fichier squelette demandé
53
							$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR;
-
 
54
							$this->squelette = $this->squelette_dossier.$this->format.'.tpl.xml';
51
						$this->squelette = $this->squelette_dossier.$this->format.'.tpl.xml';
55
						} else {
52
					} else if (isset($this->flux[$this->service])) {
56
							$this->format = '';
53
						$this->format = '';
57
							$this->messages[] = "Le service CEL Syndication nécessite d'indiquer en second paramètre le format : rss1, rss2 ou atom.";
54
						$this->messages[] = "Le service CEL Syndication nécessite d'indiquer en second paramètre le format : rss1, rss2 ou atom.";
58
						}
55
					}
-
 
56
					
-
 
57
					if (!isset($this->flux[$this->service]) || isset($this->format)) {
-
 
58
						// Suppression des paramêtres inutile pour le reste des méthodes
-
 
59
						array_shift($this->parametres);
-
 
60
						array_shift($this->parametres);
-
 
61
						
-
 
62
						// Récupération du contenu à renvoyer
-
 
63
						$contenu = $this->$methode();
59
					}
64
					}
60
					// Récupération du contenu à renvoyer
-
 
61
					$contenu = $this->$methode($param);
-
 
62
				} else {
65
				} else {
63
					$this->messages[] = "Le type d'information demandé '$this->service' n'est pas disponible.";
66
					$this->messages[] = "Le type d'information demandé '$this->service' n'est pas disponible.";
64
				}
67
				}
65
			} else {
68
			} else {
66
				$this->messages[] = "Le service CEL Syndication Image nécessite d'indiquer en premier paramètre le type d'information demandé.";
69
				$this->messages[] = "Le service CEL Syndication Image nécessite d'indiquer en premier paramètre le type d'information demandé.";
67
			}
70
			}
68
		}
71
		}
69
		
72
		
70
		// Envoie sur la sortie standard
73
		// Envoie sur la sortie standard
71
		$encodage = 'utf-8';
74
		$encodage = 'utf-8';
72
		$mime = $this->getTypeMime();
75
		$mime = $this->getTypeMime();
73
		$formatage_json = $this->getFormatageJson();
76
		$formatage_json = $this->getFormatageJson();
74
		$this->envoyer($contenu, $mime, $encodage, $formatage_json);
77
		$this->envoyer($contenu, $mime, $encodage, $formatage_json);
75
	}
78
	}
76
	
79
	
-
 
80
	private function chargerListeDesFlux() {
-
 
81
		$this->setFlux('simple', 'Nouvelles images liées à une observation dans le CEL', 
-
 
82
			"Ce flux fournit l'url des nouvelles images du CEL liées à une observation.");
-
 
83
		$this->setFlux('complet', 'Nouvelles images liées à une observation dans le CEL (détails)', 
-
 
84
			"Ce flux fournit les informations sur les nouvelles images du CEL liées à une observation.");
-
 
85
	}
-
 
86
	
77
	private function getUrlServiceBase() {
87
	private function setFlux($nom, $titre, $description) {
-
 
88
		$url_base = $this->config['settings']['baseURLAbsoluDyn'].'CoelSyndicationImage/';
-
 
89
		$formats = array('atom', 'rss2', 'rss1');
-
 
90
		$flux = array();
-
 
91
		foreach ($formats as $format) {
-
 
92
			$url = $url_base.$nom.'/'.$format;
-
 
93
			$flux[$format] = $url;
-
 
94
		}
-
 
95
		$this->flux[$nom] = array('titre' => $titre, 'description' => $description, 'urls' => $flux);
-
 
96
	}
-
 
97
 
-
 
98
	private function getFlux($nom) {
-
 
99
		return isset($this->flux[$nom]) ? $this->flux[$nom] : array();
-
 
100
	}
-
 
101
	
-
 
102
	private function traiterNomService($nom) {
78
		$url_service = $this->config['settings']['baseURLAbsoluDyn'].'CelSyndicationImage/'.$this->service.'/'.$this->format;
103
		$nom = strtolower($nom);
79
		return $url_service;
104
		return $nom;
80
	}
105
	}
81
	
106
	
82
	private function getNomMethodeService() {
107
	private function getNomMethodeService() {
83
		$methode = '';
108
		$methode = '';
84
		$service_formate = str_replace(' ', '', ucwords(implode(' ', explode('_', $this->service))));
109
		$service_formate = str_replace(' ', '', ucwords(implode(' ', explode('-', $this->service))));
85
		$methode = 'getService'.$service_formate;
110
		$methode = 'getService'.$service_formate;
86
		return $methode;
111
		return $methode;
87
	}
112
	}
-
 
113
	
-
 
114
	private function getUrlBase() {
-
 
115
		$url_base = sprintf($this->config['settings']['baseURLAbsoluDyn'], get_class($this).'/');
-
 
116
		return $url_base;
-
 
117
	}
-
 
118
	
-
 
119
	private function getUrlServiceBase() {
-
 
120
		$url_service = $this->getUrlBase().$this->service.'/'.$this->format;
-
 
121
		return $url_service;
-
 
122
	}
88
	
123
	
89
	private function getTypeMime() {
124
	private function getTypeMime() {
90
		$mime = '';
125
		$mime = '';
91
		switch ($this->format) {
126
		switch ($this->format) {
92
			case 'atom' :
127
			case 'atom' :
93
				$mime = 'application/atom+xml';
128
				$mime = 'application/atom+xml';
94
				break;
129
				break;
95
			case 'rss1' :
130
			case 'rss1' :
96
			case 'rss2' :
131
			case 'rss2' :
97
				$mime = 'application/rss+xml';
132
				$mime = 'application/rss+xml';
98
				break;
133
				break;
-
 
134
			case 'opml' :
-
 
135
				$mime = 'text/x-opml';
-
 
136
				break;
99
			default:
137
			default:
100
				$mime = 'text/html';
138
				$mime = 'text/html';
101
		}
139
		}
102
		return $mime;
140
		return $mime;
103
	}
141
	}
104
	
142
	
105
	private function getFormatageJson() {
143
	private function getFormatageJson() {
106
		$json = false;
144
		$json = false;
107
		switch ($this->service) {
145
		switch ($this->service) {
108
			case 'liste_des_flux' :
146
			case 'liste-des-flux' :
109
				$json = true;
147
				$json = true;
110
				break;
148
				break;
111
			default:
149
			default:
112
				$json = false;
150
				$json = false;
113
		}
151
		}
114
		return $json;
152
		return $json;
115
	}
153
	}
116
	
154
		
117
	private function getFlux($nom) {
-
 
118
		return isset($this->flux[$nom]) ? $this->flux[$nom] : array();
-
 
119
	}
-
 
120
 
-
 
121
	private function setFlux($nom, $titre, $description) {
-
 
122
		$url_base = $this->config['settings']['baseURLAbsoluDyn'].'CoelSyndicationImage/';
-
 
123
		$formats = array('atom', 'rss2', 'rss1');
-
 
124
		$flux = array();
-
 
125
		foreach ($formats as $format) {
-
 
126
			$url = $url_base.$nom.'/'.$format;
-
 
127
			$flux[$format] = $url;
-
 
128
		}
-
 
129
		$this->flux[$nom] = array('titre' => $titre, 'description' => $description, 'urls' => $flux);
-
 
130
	}
-
 
131
	
-
 
132
	private function chargerListeDesFlux() {
-
 
133
		$this->setFlux('Simple', 'Nouvelles images liées à une observation dans le CEL', 
-
 
134
			"Ce flux fournit l'url des nouvelles images du CEL liées à une observation.");
-
 
135
		$this->setFlux('Complet', 'Nouvelles images liées à une observation dans le CEL (détails)', 
-
 
136
			"Ce flux fournit les informations sur les nouvelles images du CEL liées à une observation.");
-
 
137
	}
-
 
138
	
-
 
139
	private function getServiceListeDesFlux() {
-
 
140
		return $this->flux;
-
 
141
	}
-
 
142
	
-
 
143
	private function etreFluxAdmin() {
155
	private function etreFluxAdmin() {
144
		return ($_GET['admin'] == '1') ? true : false;
156
		return ($_GET['admin'] == '1') ? true : false;
145
	}
157
	}
146
	
158
	
147
	private function creerUrlService() {
159
	private function creerUrlService() {
148
		$url_service = $this->getUrlServiceBase();
160
		$url_service = $this->getUrlServiceBase();
149
		if (isset($this->start) || isset($this->limit)) {
161
		if (isset($this->start) || isset($this->limit)) {
150
			$arguments = array();
162
			$arguments = array();
151
			if (isset($this->start) && isset($_GET['start'])) {
163
			if (isset($this->start) && isset($_GET['start'])) {
152
				$arguments[] = 'start='.$this->start;
164
				$arguments[] = 'start='.$this->start;
153
			}
165
			}
154
			if (isset($this->limit) && isset($_GET['limit'])) {
166
			if (isset($this->limit) && isset($_GET['limit'])) {
155
				$arguments[] = 'limit='.$this->limit;
167
				$arguments[] = 'limit='.$this->limit;
156
			}
168
			}
157
			if (count($arguments) > 0) {
169
			if (count($arguments) > 0) {
158
				$url_service .= '?'.implode('&', $arguments);
170
				$url_service .= '?'.implode('&', $arguments);
159
			}
171
			}
160
		}
172
		}
161
		return $url_service;
173
		return $url_service;
162
	}
174
	}
163
	
175
	
164
	protected function executerRequete($requete) {
176
	protected function executerRequete($requete) {
165
		try {
177
		try {
166
			$infos = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
178
			$infos = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
167
			if ($infos === false) {
179
			if ($infos === false) {
168
				$this->messages[] = "La requête suivante a retourné aucun résultat :\n$requete";
180
				$this->messages[] = "La requête suivante a retourné aucun résultat :\n$requete";
169
			}
181
			}
170
		} catch (PDOException $e) {
182
		} catch (PDOException $e) {
171
			$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage());
183
			$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage());
172
		}
184
		}
173
		return $infos;
185
		return $infos;
174
	}
186
	}
175
	
187
	
176
	private function executerService($elements) {
188
	private function executerService($elements) {
177
		// Prétraitement des données
189
		// Prétraitement des données
178
		$donnees = $this->construireDonneesCommunesAuFlux($elements);
190
		$donnees = $this->construireDonneesCommunesAuFlux($elements);
179
		
191
		
180
		foreach ($elements as $element) {
192
		foreach ($elements as $element) {
181
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
193
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
182
		}
194
		}
183
		
195
		
184
		// Création du contenu à partir d'un template PHP
196
		// Création du contenu à partir d'un template PHP
185
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
197
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
186
		
198
		
187
		return $contenu;
199
		return $contenu;
188
	}
200
	}
189
	
201
	
190
	private function construireDonneesCommunesAuFlux($infos) {
202
	private function construireDonneesCommunesAuFlux($infos) {
191
		$donnees = $this->getFlux($this->service);
203
		$donnees = $this->getFlux($this->service);
192
		$donnees['guid'] = $this->getUrlServiceBase();
204
		$donnees['guid'] = $this->getUrlServiceBase();
193
		$donnees['lien_service'] = $this->creerUrlService();
205
		$donnees['lien_service'] = $this->creerUrlService();
194
		$donnees['lien_cel'] = sprintf($this->config['settings']['efloreUrlTpl'], $infos['num_nom_sel']);
206
		$donnees['lien_cel'] = sprintf($this->config['settings']['efloreUrlTpl'], $infos['num_nom_sel']);
195
		$donnees['editeur'] = $this->config['settings']['editeur'];
207
		$donnees['editeur'] = $this->config['settings']['editeur'];
196
		$derniere_info_en_date = reset($infos);
208
		$derniere_info_en_date = reset($infos);
197
		$date_modification_timestamp = strtotime($derniere_info_en_date['ci_meta_date_ajout']);
209
		$date_modification_timestamp = strtotime($derniere_info_en_date['ci_meta_date_ajout']);
198
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
210
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
199
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
211
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
200
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
212
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
201
		$donnees['annee_courante'] = date('Y');
213
		$donnees['annee_courante'] = date('Y');
202
		$donnees['generateur'] = 'CEL - Jrest - CelSyndicationImage';
214
		$donnees['generateur'] = 'CEL - Jrest - CelSyndicationImage';
203
		preg_match('/([0-9]+)/', '$Revision$', $match);
215
		preg_match('/([0-9]+)/', '$Revision$', $match);
204
		$donnees['generateur_version'] = $match[1];
216
		$donnees['generateur_version'] = $match[1];
205
		return $donnees; 
217
		return $donnees; 
206
	}
218
	}
207
	
219
	
208
	private function construireDonneesCommunesAuxItems($info) {
220
	private function construireDonneesCommunesAuxItems($info) {
209
		$item = array();
221
		$item = array();
210
		$date_modification_timestamp = strtotime($info['ci_meta_date_ajout']);
222
		$date_modification_timestamp = strtotime($info['ci_meta_date_ajout']);
211
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
223
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
212
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
224
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
213
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
225
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
214
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
226
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
215
		$item['titre'] = $this->creerTitre($info);
227
		$item['titre'] = $this->creerTitre($info);
216
		$item['guid'] = $this->creerGuidItem($info);
228
		$item['guid'] = $this->creerGuidItem($info);
217
		$item['lien'] = $this->creerLienItem($info);
229
		$item['lien'] = $this->creerLienItem($info);
218
		$item['description'] = $this->creerDescription($info, $item);
230
		$item['description'] = $this->creerDescription($info, $item);
219
		$item['description_encodee'] = htmlspecialchars($item['description']);
231
		$item['description_encodee'] = htmlspecialchars($item['description']);
220
		return $item;
232
		return $item;
221
	}
233
	}
222
	
234
	
223
	private function creerGuidItem($element) {
235
	private function creerGuidItem($element) {
224
		$guid = sprintf($this->config['settings']['guidImgTpl'], $element['ci_id_image']);
236
		$guid = sprintf($this->config['settings']['guidImgTpl'], $element['ci_id_image']);
225
		return $guid;
237
		return $guid;
226
	}
238
	}
227
	
239
	
228
	private function creerTitre($element) {
240
	private function creerTitre($element) {
229
		$methode = 'creerTitre'.$this->service;
241
		$methode = 'creerTitre'.$this->service;
230
		$methode = (method_exists($this, $methode)) ? $methode : 'creerTitreSimple';
242
		$methode = (method_exists($this, $methode)) ? $methode : 'creerTitreSimple';
231
		$titre = $this->$methode($element);
243
		$titre = $this->$methode($element);
232
		$titre = $this->nettoyerTexte($titre);
244
		$titre = $this->nettoyerTexte($titre);
233
		return $titre;
245
		return $titre;
234
	}
246
	}
235
	
247
	
236
	private function creerDescription($donnees, $item) {
248
	private function creerDescription($donnees, $item) {
237
		$methode = 'creerDescription'.$this->service;
249
		$methode = 'creerDescription'.$this->service;
238
		$methode = (method_exists($this, $methode)) ? $methode : 'creerDescriptionSimple';
250
		$methode = (method_exists($this, $methode)) ? $methode : 'creerDescriptionSimple';
239
		$description = $this->$methode($donnees, $item);
251
		$description = $this->$methode($donnees, $item);
240
		$description = $this->nettoyerTexte($description);
252
		$description = $this->nettoyerTexte($description);
241
		return $description;
253
		return $description;
242
	}
254
	}
243
 
255
 
244
	private function creerLienItem($element) {
256
	private function creerLienItem($element) {
245
		$lien = $this->getUrlImage($element['ci_id_image'], $this->format_image);
257
		$lien = $this->getUrlImage($element['ci_id_image'], $this->format_image);
246
		return $lien;
258
		return $lien;
247
	}
259
	}
248
	
260
	
-
 
261
	private function getServiceListeDesFlux() {
-
 
262
		return $this->flux;
-
 
263
	}
-
 
264
	
249
	private function getServiceSimple($params) {
265
	private function getServiceOpml() {
-
 
266
		$donnees = array();
-
 
267
		$id = 1;
-
 
268
		foreach ($this->flux as $flux_nom => $flux){
250
		if (isset($params[0])) {
269
			$info = array();
-
 
270
			$info['type'] = 'atom';
-
 
271
			$info['titre'] = $flux['titre'];
-
 
272
			$info['texte'] = "CEL - Images - $flux_nom";
-
 
273
			$info['description'] = $flux['description'];
-
 
274
			$info['url_xml'] = $this->getUrlBase().$flux_nom.'/atom';
-
 
275
			$info['url_html'] = $this->config['settings']['aideCelUrl'].'FluxSyndication';
251
			$this->format_image = $params[0];
276
			$donnees['liste_flux'][] = $info;
-
 
277
		}
-
 
278
		
252
		}
279
		$this->squelette = $this->squelette_dossier.'opml.tpl.xml';
-
 
280
		$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
-
 
281
		return $contenu;
-
 
282
	}
253
		
283
	
-
 
284
	private function getServiceSimple() {
-
 
285
		if (isset($this->parametres[0])) {
254
		$this->start = 0;
286
			$this->format_image = $this->parametres[0];
255
		$this->limit = 10;
287
		}
256
		
288
		
257
		// Construction de la requête
289
		// Construction de la requête
258
		$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, ci_id_image, ci_nom_original '.
290
		$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, ci_id_image, ci_nom_original '.
259
			'FROM cel_obs_images AS coi '.
291
			'FROM cel_obs_images AS coi '.
260
			'LEFT JOIN cel_inventory AS ci '.
292
			'LEFT JOIN cel_inventory AS ci '.
261
				'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
293
				'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
262
			'LEFT JOIN cel_images AS cim '.
294
			'LEFT JOIN cel_images AS cim '.
263
				'ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.  
295
				'ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.  
264
			'WHERE ci.transmission = 1 '.
296
			'WHERE ci.transmission = 1 '.
265
			'	AND ci.identifiant = cim.ci_ce_utilisateur '.
297
			'	AND ci.identifiant = cim.ci_ce_utilisateur '.
266
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
298
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
267
			"LIMIT $this->start, $this->limit ";
299
			"LIMIT $this->start, $this->limit ";
268
		
300
		
269
		$elements = $this->executerRequete($requete);
301
		$elements = $this->executerRequete($requete);
270
		
302
		
271
		// Création du contenu
303
		// Création du contenu
272
		$contenu = $this->executerService($elements);
304
		$contenu = $this->executerService($elements);
273
		return $contenu;
305
		return $contenu;
274
	}
306
	}
275
	
307
	
276
	private function creerTitreSimple($element) {
308
	private function creerTitreSimple($element) {
277
		$titre = $element['nom_sel'].' [nn'.$element['num_nom_sel'].'] par '.$this->creerAuteur($element['identifiant'], $this->etreFluxAdmin());
309
		$titre = $element['nom_sel'].' [nn'.$element['num_nom_sel'].'] par '.$this->creerAuteur($element['identifiant'], $this->etreFluxAdmin());
278
		return $titre;
310
		return $titre;
279
	}
311
	}
280
	
312
	
281
	private function creerDescriptionSimple($donnees, $item) {
313
	private function creerDescriptionSimple($donnees, $item) {
282
		$description = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($donnees['num_nom_sel']));
314
		$description = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($donnees['num_nom_sel']));
283
		return $description;
315
		return $description;
284
	}
316
	}
285
	
317
	
286
	private function getServiceComplet($params) {
318
	private function getServiceComplet() {
287
		// Construction de la requête
319
		// Construction de la requête
288
		$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, ci_id_image, ci_nom_original, ci_meta_date_ajout, ci_meta_user_comment, ci_note_image '.
320
		$requete = 	(($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, ci_id_image, ci_nom_original, ci_meta_date_ajout, ci_meta_user_comment, ci_note_image '.
289
			'FROM cel_obs_images AS coi '.
321
			'FROM cel_obs_images AS coi '.
290
			'LEFT JOIN cel_inventory AS ci '.
322
			'LEFT JOIN cel_inventory AS ci '.
291
				'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
323
				'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
292
			'LEFT JOIN cel_images AS cim '.
324
			'LEFT JOIN cel_images AS cim '.
293
				'ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.  
325
				'ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.  
294
			'WHERE ci.transmission = 1 '.
326
			'WHERE ci.transmission = 1 '.
295
			'	AND ci.identifiant = cim.ci_ce_utilisateur '.
327
			'	AND ci.identifiant = cim.ci_ce_utilisateur '.
296
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
328
			'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby  : 'ci_meta_date_ajout DESC').' '.
297
			"LIMIT $this->start, $this->limit ";
329
			"LIMIT $this->start, $this->limit ";
298
		
330
		
299
		$elements = $this->executerRequete($requete);
331
		$elements = $this->executerRequete($requete);
300
		
332
		
301
		// Création du contenu
333
		// Création du contenu
302
		$contenu = $this->executerService($elements);
334
		$contenu = $this->executerService($elements);
303
		return $contenu;
335
		return $contenu;
304
	}
336
	}
305
 
337
 
306
	private function creerDescriptionComplet($donnees, $item) {
338
	private function creerDescriptionComplet($donnees, $item) {
307
		$url_img = $this->getUrlImage($donnees['ci_id_image'], 'M');
339
		$url_img = $this->getUrlImage($donnees['ci_id_image'], 'M');
308
		$description .= '<style>.champ{color:grey} img{float:left;padding:0 20px 0 0;}</style>';
340
		$description .= '<style>.champ{color:grey} img{float:left;padding:0 20px 0 0;}</style>';
309
		$description .= '<img src="'.$url_img.'" alt="'.$donnees['ci_nom_original'].'" />';
341
		$description .= '<img src="'.$url_img.'" alt="'.$donnees['ci_nom_original'].'" />';
310
		$description .= '<ul>';
342
		$description .= '<ul>';
311
		$description .= '<li>'."Image liée à l'observation ".$donnees['id'].'</li>';
343
		$description .= '<li>'."Image liée à l'observation ".$donnees['id'].'</li>';
312
		$description .= '<li>'.'<span class="champ">Importée le :</span> '.$item['date_maj_simple'].'</li>';
344
		$description .= '<li>'.'<span class="champ">Importée le :</span> '.$item['date_maj_simple'].'</li>';
313
		$description .= '<li>'.'<span class="champ">Nom du fichier :</span> '.$donnees['ci_nom_original'].'</li>';
345
		$description .= '<li>'.'<span class="champ">Nom du fichier :</span> '.$donnees['ci_nom_original'].'</li>';
314
		$description .= '<li>'.'<span class="champ">Note qualité image :</span> '.($donnees['ci_note_image'] +1).'/5</li>';
346
		$description .= '<li>'.'<span class="champ">Note qualité image :</span> '.($donnees['ci_note_image'] +1).'/5</li>';
315
		// TODO :traiter le problème du champ commentaire.
347
		// TODO :traiter le problème du champ commentaire.
316
		//$description .= '<li>'.'<span class="champ">Commentaire :</span> '.$donnees['ci_meta_user_comment'].'</li>';
348
		//$description .= '<li>'.'<span class="champ">Commentaire :</span> '.$donnees['ci_meta_user_comment'].'</li>';
317
		
349
		
318
		$description .= '<li>'.'<span class="champ">Nom saisi :</span> '.$donnees['nom_sel'].'</li>';
350
		$description .= '<li>'.'<span class="champ">Nom saisi :</span> '.$donnees['nom_sel'].'</li>';
319
		$description .= '<li>'.'<span class="champ">Nom retenu :</span> '.$donnees['nom_ret'].'</li>';
351
		$description .= '<li>'.'<span class="champ">Nom retenu :</span> '.$donnees['nom_ret'].'</li>';
320
		$description .= '<li>'.'<span class="champ">Observée le :</span> '.strftime('%A %d %B %Y', strtotime($donnees['date_observation'])).'</li>';
352
		$description .= '<li>'.'<span class="champ">Observée le :</span> '.strftime('%A %d %B %Y', strtotime($donnees['date_observation'])).'</li>';
321
		$description .= '<li>'.'<span class="champ">Lieu :</span> '.$donnees['location'].' ('.$donnees['id_location'].') '.$donnees['station'].' '.$donnees['lieudit'].'</li>';
353
		$description .= '<li>'.'<span class="champ">Lieu :</span> '.$donnees['location'].' ('.$donnees['id_location'].') '.$donnees['station'].' '.$donnees['lieudit'].'</li>';
322
		$description .= '</ul>';
354
		$description .= '</ul>';
323
		$description = $this->nettoyerTexte($description);
355
		$description = $this->nettoyerTexte($description);
324
		return $description;
356
		return $description;
325
	}
357
	}
326
}	
358
}