Subversion Repositories eFlore/Applications.cel

Rev

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

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