Subversion Repositories eFlore/Applications.del

Rev

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

Rev 1820 Rev 1821
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Service fournissant des informations concernant les tags sur les images de DEL en fonction d'un protocole
4
 * Service fournissant des informations concernant les tags sur les images de DEL en fonction d'un protocole
5
 * au format RSS1, RSS2 ou ATOM.
5
 * au format RSS1, RSS2 ou ATOM.
6
 *
6
 *
7
 * @category   DEL
7
 * @category   DEL
8
 * @package    Services
8
 * @package    Services
9
 * @subpackage Syndication
9
 * @subpackage Syndication
10
 * @version    0.1
10
 * @version    0.1
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
11
 * @author     Mathias CHOUET <mathias@tela-botanica.org>
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
12
 * @author     Jean-Pascal MILCENT <jpm@tela-botanica.org>
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
13
 * @author     Aurelien PERONNET <aurelien@tela-botanica.org>
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
14
 * @license    GPL v3 <http://www.gnu.org/licenses/gpl.txt>
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
15
 * @license    CECILL v2 <http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt>
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
16
 * @copyright  1999-2014 Tela Botanica <accueil@tela-botanica.org>
17
 */
17
 */
18
class SyndicationTagsParProtocole {
18
class Tags {
19
 
-
 
20
	/**
-
 
21
	 * Paramètres du service
-
 
22
	 * */
19
 
23
	private $mappingFiltre = array();
20
	private $categorie = 'Tag';
24
	private $conteneur = null;
21
	private $conteneur;
25
	private $bdd = null;
22
	private $bdd;
-
 
23
	private $navigation;
26
	private $navigation = null;
24
	private $syndication;
27
	private $type_rss = null;
-
 
28
 
-
 
29
	/**
-
 
30
	 * Constructeur
-
 
31
	 * Initialiser les configurations
25
	private $mapping = array();
32
	 * */
26
 
33
	public function __construct(Conteneur $conteneur = null) {
-
 
34
		$this->conteneur = $conteneur == null ? new Conteneur() : $conteneur;
-
 
35
		$this->conteneur->chargerConfiguration('config_syndication_tagsparprotocole.ini');
27
	public function __construct(Conteneur $conteneur) {
36
		$this->mappingFiltre = $this->conteneur->getParametre('mapping_masque');
28
		$this->conteneur = $conteneur;
-
 
29
		$this->bdd = $this->conteneur->getBdd();
-
 
30
		$this->navigation = $this->conteneur->getNavigation();
37
		$this->bdd = $this->conteneur->getBdd();
31
		$this->syndication = $this->conteneur->getSyndicationOutils();
38
		$this->navigation = $this->conteneur->getNavigation();
-
 
39
	}
-
 
40
 
-
 
41
	/**
-
 
42
	 * Consulter
-
 
43
	 * Méthode par défaut pour récupérer l'ensemble des tags.
32
		$this->mapping = $this->conteneur->getParametreTableau('syndication.mapping');
44
	 * Vérifie la configuration et retourne les derniers tags formatés
-
 
45
	 * */
-
 
46
	public function consulter($params = array()) {
33
	}
47
		$this->verifierConfiguration();
34
 
48
		$this->type_rss = $params[1];
35
	public function consulter() {
49
		if ($this->fluxAdminDemande()) {
36
		if ($this->syndication->fluxAdminDemande()) {
50
			$this->demanderAutorisationAdmin();
37
			$this->syndication->demanderAutorisationAdmin();
51
		}
38
		}
52
 
39
 
53
		$donnees_brutes = $this->getDerniersVotesImage();
40
		$donnees_brutes = $this->getDerniersVotesImage();
54
		$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
41
		$commentaires_formates = $this->formaterPourRss($donnees_brutes) ;
55
		return $commentaires_formates;
42
		return $commentaires_formates;
56
	}
43
	}
57
 
44
 
58
	/**
45
	/**
59
	* Vérifier que le service est bien configuré
-
 
60
	* */
-
 
61
	public function verifierConfiguration() {
-
 
62
		$erreurs = array();
-
 
63
 
-
 
64
		if (empty($this->mappingFiltre)) {
-
 
65
			$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_masque] ou celui-ci est vide ;';
-
 
66
		} else {
-
 
67
			$champsMappingFiltre = array('image', 'protocole');
-
 
68
			foreach ($champsMappingFiltre as $champ) {
-
 
69
				if (!isset($this->mappingFiltre[$champ])) {
-
 
70
					$erreurs[] = '- le mapping du champ "'.$champ.'" pour le commentaire est manquant ;';
-
 
71
				}
-
 
72
			}
-
 
73
		}
-
 
74
 
-
 
75
		if (!empty($erreurs)) {
-
 
76
			$e = 'Erreur lors de la configuration : '."\n";
-
 
77
			$e .= implode("\n", $erreurs);
-
 
78
			throw new Exception($e, RestServeur::HTTP_CODE_ERREUR);
-
 
79
		}
-
 
80
	}
-
 
81
 
-
 
82
	/**
-
 
83
	 * Verifier si le flux admin est demandé
-
 
84
	 */
-
 
85
	private function fluxAdminDemande() {
-
 
86
		return $this->conteneur->getParametre('admin') != null && $this->conteneur->getParametre('admin') == 1;
-
 
87
	}
-
 
88
 
-
 
89
	/**
-
 
90
	 * Si le flux est un flux admin, demander un mot de passe
-
 
91
	 * */
-
 
92
	private function demanderAutorisationAdmin() {
-
 
93
		$verification = $this->conteneur->getControleAcces();
-
 
94
		$verification->demanderAuthentificationAdmin();
-
 
95
	}
-
 
96
 
-
 
97
	/**
-
 
98
	 * Formater les données pour mettre en page le RSS
46
	 * Formater les données pour mettre en page le RSS
99
	 * */
47
	 * */
100
	private function formaterPourRss($elements) {
48
	private function formaterPourRss($elements) {
101
		$donnees = $this->construireDonneesCommunesAuFlux($elements);
-
 
102
		foreach ($elements as $element) {
49
		$derniere_info_en_date = reset($elements);
103
			$identifiants[$element['id_tag']] = $element['id_tag'];
50
		$donnees = $this->syndication->construireDonneesCommunesAuFlux('tag', $derniere_info_en_date['date']);
104
		}
-
 
105
		foreach ($elements as $element) {
51
		foreach ($elements as $element) {
106
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
52
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
107
		}
53
		}
108
		return $donnees;
54
		return $donnees;
109
	}
55
	}
110
 
56
 
111
	/**
57
	/**
112
	 * Générer les métadonnées du flux (titre, dates, editeur etc.)
-
 
113
	 * */
-
 
114
	private function construireDonneesCommunesAuFlux($infos) {
-
 
115
		$donnees = array();
-
 
116
		$donnees['guid'] = htmlspecialchars($this->creerUrlService());
-
 
117
		$donnees['titre'] = 'pictoFlora : tags';
-
 
118
		$donnees['description'] = 'Ce flux regroupe les derniers tags des images de pictoFlora';
-
 
119
		$donnees['lien_service'] = htmlspecialchars($this->creerUrlService());
-
 
120
		$donnees['lien_del'] = $this->conteneur->getParametre('pictoAppliLien');
-
 
121
		$donnees['editeur'] = $this->conteneur->getParametre('editeur');
-
 
122
		$derniere_info_en_date = reset($infos);
-
 
123
		$date_modification_timestamp = strtotime($derniere_info_en_date['date']);
-
 
124
		$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
-
 
125
		$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
-
 
126
		$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
-
 
127
		$donnees['annee_courante'] = date('Y');
-
 
128
		$donnees['generateur'] = 'DEL - SyndicationCommentaire';
-
 
129
		$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ?  $match[1] : '0';
-
 
130
		return $donnees;
-
 
131
	}
-
 
132
 
-
 
133
	/**
-
 
134
	 * Générer le lien du flux RSS
-
 
135
	 * */
-
 
136
	private function creerUrlService() {
-
 
137
		$url_service = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
-
 
138
		return $url_service;
-
 
139
	}
-
 
140
 
-
 
141
	/**
-
 
142
	 * Générer les données communes & spécifiques à chaque item
58
	 * Générer les données communes & spécifiques à chaque item
143
	 * */
59
	 * */
144
	private function construireDonneesCommunesAuxItems($info) {
60
	private function construireDonneesCommunesAuxItems($info) {
145
		$item = array();
61
		$item = array();
146
		$date_modification_timestamp = strtotime($info['date']);
62
		$date_modification_timestamp = strtotime($info['date']);
147
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
63
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
148
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
64
		$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
149
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
65
		$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
150
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
66
		$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
151
		$item['titre'] = $this->creerTitre($info);
67
		$item['titre'] = $this->creerTitre($info);
152
		$item['guid'] = $this->creerGuidItem($info);
68
		$item['guid'] = $this->creerGuidItem($info);
153
		$item['lien'] = $this->creerLienItem($info);
69
		$item['lien'] = $this->creerLienItem($info);
154
		$item['categorie'] = $this->creerCategorie($item);
70
		$item['categorie'] = htmlentities($this->categorie);
155
		$item['description'] = $this->creerDescription($info, $item);
71
		$item['description'] = $this->creerDescription($info, $item);
156
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
72
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
157
		$item['modifier_par'] = $this->formaterNomTagueur($info);
73
		$item['modifier_par'] = $this->formaterNomTagueur($info);
158
		return $item;
74
		return $item;
159
	}
75
	}
160
 
-
 
161
	private function creerCategorie($element) {
-
 
162
		$categorie = 'Tag protocole';
-
 
163
		$categorie = htmlentities($categorie);
-
 
164
		return $categorie;
-
 
165
	}
-
 
166
 
76
 
167
	private function creerGuidItem($element) {
77
	private function creerGuidItem($element) {
168
		$guid = sprintf($this->conteneur->getParametre('tagGuidTpl'), $element['id_tag']);
78
		$guid = sprintf($this->conteneur->getParametre('syndication.tag_guid_tpl'), $element['id_tag']);
169
		return $guid;
79
		return $guid;
170
	}
80
	}
171
 
81
 
172
	private function creerLienItem($element) {
82
	private function creerLienItem($element) {
173
		// TODO : ajouter un lien vers la plateforme validation de picto lorsqu'elle sera dispo
83
		// TODO : ajouter un lien vers la plateforme validation de picto lorsqu'elle sera dispo
174
		$lien = sprintf($this->conteneur->getParametre('imgFicheTpl'), $element['id_image']);
84
		$lien = sprintf($this->conteneur->getParametre('img_fiche_tpl'), $element['id_image']);
175
		return $lien;
85
		return $lien;
176
	}
86
	}
177
 
87
 
178
	private function creerTitre($element) {
88
	private function creerTitre($element) {
179
		$tag = $element['tag'];
89
		$tag = $element['tag'];
180
		$nomSel = htmlspecialchars($element['nom_sel']);
90
		$nomSel = htmlspecialchars($element['nom_sel']);
181
		$tagueur = htmlspecialchars($this->formaterNomTagueur($element));
91
		$tagueur = htmlspecialchars($this->formaterNomTagueur($element));
182
		$auteurImg = $this->formaterNomAuteurImg($element);
92
		$auteurImg = $this->formaterNomAuteurImg($element);
183
		$titre = "Tag «{$tag}» par $tagueur pour $nomSel de $auteurImg";
93
		$titre = "Tag «{$tag}» par $tagueur pour $nomSel de $auteurImg";
184
		return $titre;
94
		return $titre;
185
	}
95
	}
186
 
96
 
187
	private function creerDescription($donnees, $item) {
97
	private function creerDescription($donnees, $item) {
188
		$idTag = htmlspecialchars($donnees['id_tag']);
98
		$idTag = htmlspecialchars($donnees['id_tag']);
189
		$idObs = htmlspecialchars($donnees['id_observation']);
99
		$idObs = htmlspecialchars($donnees['id_observation']);
190
		$idImg = htmlspecialchars($donnees['id_image']);
100
		$idImg = htmlspecialchars($donnees['id_image']);
191
		$urlImg = $this->getUrlImage($donnees['id_image']);
101
		$urlImg = $this->syndication->getUrlImage($donnees['id_image']);
192
		$miniatureUrl = $this->getUrlImage($donnees['id_image'], 'CRS');
102
		$miniatureUrl = $this->syndication->getUrlImage($donnees['id_image'], 'CRS');
193
		$nomSelActuel = htmlspecialchars($donnees['nom_sel']);
103
		$nomSelActuel = htmlspecialchars($donnees['nom_sel']);
194
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['date_observation']));
104
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['date_observation']));
195
		$lieuObs = htmlspecialchars($donnees['zone_geo']);
105
		$lieuObs = htmlspecialchars($donnees['zone_geo']);
196
		$tag = htmlspecialchars($donnees['tag']);
106
		$tag = htmlspecialchars($donnees['tag']);
197
		$dateTag = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', strtotime($donnees['date'])));
107
		$dateTag = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', strtotime($donnees['date'])));
198
		$auteurImg = htmlspecialchars($this->creerAuteurImg($donnees));
108
		$auteurImg = htmlspecialchars($this->creerAuteurImg($donnees));
199
		$tagueur = htmlspecialchars($this->creerTagueur($donnees));
109
		$tagueur = htmlspecialchars($this->creerTagueur($donnees));
200
 
110
 
201
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
111
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
202
			'<h2>'."Tag pictoFlora #$idTag pour l'image #$idImg de l'observation #$idObs".'</h2>'.
112
			'<h2>'."Tag pictoFlora #$idTag pour l'image #$idImg de l'observation #$idObs".'</h2>'.
203
			'<div class="gauche">'.
113
			'<div class="gauche">'.
204
			'	<a href="'.$urlImg.'">'.
114
			'	<a href="'.$urlImg.'">'.
205
			'		<img src="'.$miniatureUrl.'" alt="Img #'.$idImg.'"/>'.
115
			'		<img src="'.$miniatureUrl.'" alt="Img #'.$idImg.'"/>'.
206
			'	</a>'.
116
			'	</a>'.
207
			'</div>'.
117
			'</div>'.
208
			'<div class="gauche">'.
118
			'<div class="gauche">'.
209
			"	<h3>Image #$idImg de l'observation #$idObs</h3>".
119
			"	<h3>Image #$idImg de l'observation #$idObs</h3>".
210
			'	<ul>'.
120
			'	<ul>'.
211
			'		<li><span class="champ">'."Auteur de l'image :</span> $auteurImg</li>".
121
			'		<li><span class="champ">'."Auteur de l'image :</span> $auteurImg</li>".
212
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
122
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
213
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
123
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
214
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
124
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
215
			'	</ul>'.
125
			'	</ul>'.
216
			'</div>'.
126
			'</div>'.
217
			'<div class="gauche">'.
127
			'<div class="gauche">'.
218
			"	<h3>Tag #$idTag</h3>".
128
			"	<h3>Tag #$idTag</h3>".
219
			'	<ul>'.
129
			'	<ul>'.
220
			'		<li><span class="champ">'."Tag :</span> <strong>$tag</strong></li>".
130
			'		<li><span class="champ">'."Tag :</span> <strong>$tag</strong></li>".
221
			'		<li><span class="champ">'."Auteur :</span> $tagueur</li>".
131
			'		<li><span class="champ">'."Auteur :</span> $tagueur</li>".
222
			'		<li><span class="champ">'."Taguée le :</span> $dateTag</li>".
132
			'		<li><span class="champ">'."Taguée le :</span> $dateTag</li>".
223
			'	</ul>'.
133
			'	</ul>'.
224
			'</div>';
134
			'</div>';
225
		return $description;
135
		return $description;
226
	}
136
	}
227
 
-
 
228
	private function getUrlImage($id, $format = 'L') {
-
 
229
		$url_tpl = $this->conteneur->getParametre('celImgUrlTpl');
-
 
230
		$id = sprintf('%09s', $id).$format;
-
 
231
		$url = sprintf($url_tpl, $id);
-
 
232
		return $url;
-
 
233
	}
-
 
234
 
137
 
235
	private function creerAuteurImg($info) {
138
	private function creerAuteurImg($info) {
236
		$auteur = $this->formaterNomAuteurImg($info).
139
		$auteur = $this->formaterNomAuteurImg($info).
237
			($this->fluxAdminDemande() ? ' ('.$info['auteur_courriel'].')' : '');
140
			($this->syndication->fluxAdminDemande() ? ' ('.$info['auteur_courriel'].')' : '');
238
		return $auteur;
141
		return $auteur;
239
	}
142
	}
240
 
143
 
241
	private function formaterNomAuteurImg($info) {
144
	private function formaterNomAuteurImg($info) {
242
		$auteur = 'Anonyme';
145
		$auteur = 'Anonyme';
243
		if ($info['auteur_prenom'] != '' && $info['auteur_nom'] != '') {
146
		if ($info['auteur_prenom'] != '' && $info['auteur_nom'] != '') {
244
			$auteur = $info['auteur_prenom'].' '.$info['auteur_nom'];
147
			$auteur = $info['auteur_prenom'].' '.$info['auteur_nom'];
245
		}
148
		}
246
		return $auteur;
149
		return $auteur;
247
	}
150
	}
248
 
151
 
249
	private function creerTagueur($info) {
152
	private function creerTagueur($info) {
250
		$tagueur = $this->formaterNomTagueur($info).
153
		$tagueur = $this->formaterNomTagueur($info).
251
			($this->fluxAdminDemande() ? ' ('.$info['tagueur_courriel'].')' : '');
154
			($this->syndication->fluxAdminDemande() ? ' ('.$info['tagueur_courriel'].')' : '');
252
		return $tagueur;
155
		return $tagueur;
253
	}
156
	}
254
 
157
 
255
	private function formaterNomTagueur($info) {
158
	private function formaterNomTagueur($info) {
256
		$tagueur = 'Anonyme';
159
		$tagueur = 'Anonyme';
257
		if ($info['tagueur_prenom'] != '' && $info['tagueur_nom'] != '') {
160
		if ($info['tagueur_prenom'] != '' && $info['tagueur_nom'] != '') {
258
			$tagueur = $info['tagueur_prenom'].' '.$info['tagueur_nom'];
161
			$tagueur = $info['tagueur_prenom'].' '.$info['tagueur_nom'];
259
		}
162
		}
260
		return $tagueur;
163
		return $tagueur;
261
	}
164
	}
262
 
165
 
263
	/**
166
	/**
264
	 * Retrouver les derniers votes image
167
	 * Retrouver les derniers votes image
265
	 * */
168
	 * */
266
	private function getDerniersVotesImage() {
169
	private function getDerniersVotesImage() {
-
 
170
		$clauseWhere = $this->chargerClauseWhere();
267
		$requete = 'SELECT DISTINCT id_tag, tag, date, '.
171
		$requete = 'SELECT DISTINCT id_tag, tag, date, '.
268
				'	do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, doi.id_image, '.
172
				'	do.id_observation, do.nom_sel, do.zone_geo, do.date_observation, doi.id_image, '.
269
				'	duo.prenom AS auteur_prenom, duo.nom AS auteur_nom, duo.courriel AS auteur_courriel, '.
173
				'	duo.prenom AS auteur_prenom, duo.nom AS auteur_nom, duo.courriel AS auteur_courriel, '.
270
				'	du.prenom AS tagueur_prenom, du.nom AS tagueur_nom, du.courriel AS tagueur_courriel '.
174
				'	du.prenom AS tagueur_prenom, du.nom AS tagueur_nom, du.courriel AS tagueur_courriel '.
271
				'FROM del_image_tag AS dit '.
175
				'FROM del_image_tag AS dit '.
272
				'	INNER JOIN del_obs_image AS doi '.
176
				'	INNER JOIN del_obs_image AS doi '.
273
				'		ON ce_image = id_image '.
177
				'		ON ce_image = id_image '.
274
				'	INNER JOIN del_observation AS do '.
178
				'	INNER JOIN del_observation AS do '.
275
				'			ON doi.id_observation = do.id_observation '.
179
				'			ON doi.id_observation = do.id_observation '.
276
				'	LEFT JOIN del_utilisateur AS duo '.
180
				'	LEFT JOIN del_utilisateur AS duo '.
277
				'		ON do.ce_utilisateur = duo.id_utilisateur '.
181
				'		ON do.ce_utilisateur = duo.id_utilisateur '.
278
				'	LEFT JOIN del_utilisateur AS du '.
182
				'	LEFT JOIN del_utilisateur AS du '.
279
				'		ON if((CHAR_LENGTH(dit.ce_utilisateur) <> 32),CAST(dit.ce_utilisateur AS unsigned),0) '.
183
				'		ON if((CHAR_LENGTH(dit.ce_utilisateur) <> 32),CAST(dit.ce_utilisateur AS unsigned),0) '.
280
				'			= du.id_utilisateur '.
184
				'			= du.id_utilisateur '.
281
				'WHERE actif = 1 '.
185
				'WHERE actif = 1 '.
282
				$this->chargerClauseWhere().' '.
186
				($clauseWhere != '' ? "AND $clauseWhere " : '').
283
				'ORDER BY date DESC '.
187
				'ORDER BY date DESC '.
284
				'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite();
188
				'LIMIT '.$this->navigation->getDepart().','.$this->navigation->getLimite().' '.
-
 
189
				' -- '.__FILE__.' : '.__LINE__;
285
		$elements = $this->bdd->recupererTous($requete);
190
		$elements = $this->bdd->recupererTous($requete);
286
		return $elements;
191
		return $elements;
287
	}
192
	}
288
 
-
 
289
	/**
-
 
290
	* Charger la clause WHERE en fonction des paramètres de masque
-
 
291
	* */
193
 
292
	private function chargerClauseWhere() {
194
	private function chargerClauseWhere() {
293
		$where = array();
195
		$where = array();
294
		$tableauMasque = $this->navigation->getFiltre();
196
		$filtres = $this->navigation->getFiltre();
-
 
197
		if (!empty($filtres)) {
295
		if (!empty($tableauMasque)) {
198
			$filtrePossibles = $this->conteneur->getParametreTableau('syndication.tag_filtres');
296
			foreach ($tableauMasque as $idMasque => $valeurMasque) {
199
			foreach ($filtres as $cleFiltre => $valeur) {
297
				$idMasque = str_replace('masque.', '', $idMasque);
200
				if (in_array($cleFiltre, $filtrePossibles)) {
298
				$champMasque = $this->mappingFiltre[$idMasque];
201
					$champ = $this->mapping[$cleFiltre];
299
				$masqueMotif = $this->bdd->proteger($valeurMasque);
-
 
300
 
-
 
301
				switch ($idMasque) {
-
 
302
					case 'image':
-
 
303
					//TODO : ajouter le protocole ? case 'protocole':
-
 
304
					default:
202
					$valeurP = $this->bdd->proteger($valeur);
305
						$where[] = " $champMasque = $masqueMotif ";
203
					$where[] = " $champ = $valeurP ";
306
				}
204
				}
307
			}
205
			}
308
		}
206
		}
309
 
207
 
310
		$conditionsTxt = (!empty($where)) ? ' AND '.implode('AND', $where) : '';
-
 
311
		return $conditionsTxt;
208
		return (!empty($where)) ? implode('AND', $where) : '';
312
	}
-
 
313
}
-
 
314
?>
209
	}
-
 
210
}
315
211