Subversion Repositories eFlore/Applications.cel

Rev

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

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