Subversion Repositories eFlore/Applications.del

Rev

Rev 1290 | Rev 1294 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1290 Rev 1292
Line 47... Line 47...
47
 
47
 
48
	/**
48
	/**
49
	* Vérifier que le service est bien configuré
49
	* Vérifier que le service est bien configuré
50
	* */
50
	* */
51
	public function verifierConfiguration() {
-
 
52
 
51
	public function verifierConfiguration() {
53
		$erreurs = array();
-
 
Line 54... Line 52...
54
		$tableauImages = $this->conteneur->getParametre('mapping_masque');
52
		$erreurs = array();
55
 
53
 
56
		if (empty($this->mappingFiltre)) {
54
		if (empty($this->mappingFiltre)) {
57
			$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_masque] ou celui-ci est vide ;';
55
			$erreurs[] = '- le fichier de configuration ne contient pas le tableau [mapping_masque] ou celui-ci est vide ;';
Line 92... Line 90...
92
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
90
			$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
93
		}
91
		}
94
		return $donnees;
92
		return $donnees;
95
	}
93
	}
Line 96... Line -...
96
 
-
 
97
	private function creerCategorie($element) {
-
 
98
		$categorie = 'Commentaires';
-
 
99
		$categorie = htmlentities($categorie);
-
 
100
		return $categorie;
-
 
101
	}
-
 
102
 
-
 
103
	private function creerUrlService() {
-
 
104
		$url_service = '';
-
 
105
		if (count($_GET) > 0) {
-
 
106
			$parametres_get = array();
-
 
107
			foreach ($_GET as $cle => $valeur) {
-
 
108
				$parametres_get[] = $cle.'='.$valeur;
-
 
109
			}
-
 
110
			$url_service .= '?'.implode('&', $parametres_get);
-
 
111
		}
-
 
112
		return $url_service;
-
 
113
	}
-
 
114
 
94
 
115
	private function construireDonneesCommunesAuFlux($infos) {
95
	private function construireDonneesCommunesAuFlux($infos) {
116
		$donnees = array();
96
		$donnees = array();
117
		$donnees['guid'] = '';
97
		$donnees['guid'] = '';
118
		$donnees['titre'] = 'identiPlante : commentaires et propositions';
98
		$donnees['titre'] = 'identiPlante : commentaires et propositions';
Line 129... Line 109...
129
		$donnees['generateur'] = 'DEL - SyndicationCommentaire';
109
		$donnees['generateur'] = 'DEL - SyndicationCommentaire';
130
		$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ?  $match[1] : '0';
110
		$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ?  $match[1] : '0';
131
		return $donnees;
111
		return $donnees;
132
	}
112
	}
Line -... Line 113...
-
 
113
 
-
 
114
	private function creerUrlService() {
-
 
115
		$url_service = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
-
 
116
		return $url_service;
-
 
117
	}
133
 
118
 
134
	private function construireDonneesCommunesAuxItems($info) {
119
	private function construireDonneesCommunesAuxItems($info) {
135
		$item = array();
120
		$item = array();
136
		$date_modification_timestamp = strtotime($info['date']);
121
		$date_modification_timestamp = strtotime($info['date']);
137
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
122
		$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
Line 146... Line 131...
146
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
131
		$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
147
		$item['modifie_par'] = $this->creerAuteur($info);
132
		$item['modifie_par'] = $this->creerAuteur($info);
148
		return $item;
133
		return $item;
149
	}
134
	}
Line 150... Line -...
150
 
-
 
151
	private function creerGuidItem($element) {
-
 
152
		$guid = sprintf($this->conteneur->getParametre('guidObsTpl'), $element['id_commentaire']);
-
 
153
		return $guid;
-
 
154
	}
-
 
155
 
-
 
156
	private function creerLienItem($element) {
-
 
157
		$lien = sprintf($this->conteneur->getParametre('delFicheObsTpl'), $element['dob_id_observation']);
-
 
158
		return $lien;
-
 
159
	}
-
 
160
 
135
 
161
	private function creerTitre($element) {
136
	private function creerTitre($element) {
162
		$nomPropose = htmlspecialchars($element['nom_sel']);
137
		$nomPropose = htmlspecialchars($element['nom_sel']);
163
		$intitule = ($element['nom_sel'] != '') ? "Proposition $nomPropose" : 'Commentaire';
138
		$intitule = ($element['nom_sel'] != '') ? "Proposition $nomPropose" : 'Commentaire';
164
		$auteur = htmlspecialchars($this->creerAuteur($element));
139
		$auteur = htmlspecialchars($this->creerAuteur($element));
Line 168... Line 143...
168
 
143
 
169
		$titre = "$intitule par $auteur pour $nomSelActuel à $zoneGeo le $dateObs";
144
		$titre = "$intitule par $auteur pour $nomSelActuel à $zoneGeo le $dateObs";
170
		return $titre;
145
		return $titre;
Line -... Line 146...
-
 
146
	}
-
 
147
 
-
 
148
	private function creerAuteur($info) {
-
 
149
		return $info['utilisateur_prenom'].' '.$info['utilisateur_nom'];
-
 
150
	}
-
 
151
 
-
 
152
	private function creerGuidItem($element) {
-
 
153
		$guid = sprintf($this->conteneur->getParametre('guidObsTpl'), $element['id_commentaire']);
-
 
154
		return $guid;
-
 
155
	}
-
 
156
 
-
 
157
	private function creerLienItem($element) {
-
 
158
		$lien = sprintf($this->conteneur->getParametre('delFicheObsTpl'), $element['dob_id_observation']);
-
 
159
		return $lien;
-
 
160
	}
-
 
161
 
-
 
162
	private function creerCategorie($element) {
-
 
163
		$categorie = 'Commentaires';
-
 
164
		$categorie = htmlentities($categorie);
-
 
165
		return $categorie;
171
	}
166
	}
172
 
167
 
173
	private function creerDescription($donnees, $item) {
168
	private function creerDescription($donnees, $item) {
174
		$idCommentaire = $donnees['id_commentaire'];
169
		$idCommentaire = $donnees['id_commentaire'];
-
 
170
		$idObs = $donnees['dob_id_observation'];
175
		$idObs = $donnees['dob_id_observation'];
171
		$nomPropose = ($donnees['nom_sel'] != '') ? htmlspecialchars($donnees['nom_sel']) : '';
176
		$nomPropose = ($donnees['nom_sel'] != '') ? htmlspecialchars($donnees['nom_sel']) : '';
172
		$dateCommentaire = htmlspecialchars(strftime('%A %d %B %Y à %H:%M', strtotime($donnees['date'])));
-
 
173
		$nomSelActuel = htmlspecialchars($donnees['dob_nom_sel']);
177
		$nomSelActuel = htmlspecialchars($donnees['dob_nom_sel']);
174
		$etreProposition = ($nomPropose != '') ? true : false;
178
		$etreProposition = ($nomPropose != '') ? true : false;
175
		$intitule = ($etreProposition) ? 'Proposition' : 'Commentaire';
179
		$txt = ($donnees['texte'] != '') ? htmlspecialchars($donnees['texte']) : '';
176
		$txt = ($donnees['texte'] != '') ? htmlspecialchars($donnees['texte']) : '';
180
		$auteur = htmlspecialchars($this->creerAuteur($donnees)).
177
		$auteur = htmlspecialchars($this->creerAuteur($donnees)).
181
			($this->fluxAdminDemande() ? ' ('.$donnees['utilisateur_courriel'].')' : '');
178
			($this->fluxAdminDemande() ? ' ('.$donnees['utilisateur_courriel'].')' : '');
-
 
179
		$lieuObs = htmlspecialchars((($donnees['dob_zone_geo'] != '') ? $donnees['dob_zone_geo'] : '?'));
Line 182... Line -...
182
		$zoneGeo = htmlspecialchars((($donnees['dob_zone_geo'] != '') ? $donnees['dob_zone_geo'] : '?'));
-
 
183
		$dateObs = htmlspecialchars(strftime('%d %B %Y', strtotime($donnees['dob_date_observation'])));
-
 
184
 
180
		$dateObs = htmlspecialchars(str_replace(' 00:00:00', '', $donnees['dob_date_observation']));
185
		$contenu = "<li>Observation #$idObs : <em>$nomSelActuel</em></li>".
181
		$observateur = htmlspecialchars($this->creerObservateur($donnees));
-
 
182
 
186
			"<li>Lieu observation : $zoneGeo</li>".
183
		$contenuCommentaire = '';
187
			"<li>Date observation : $dateObs</li>";
184
		if ($etreProposition) {
188
		if ($etreProposition) {
185
			$contenuCommentaire =
-
 
186
				'<li><span class="champ">'."Nom proposé :</span> <em>$nomPropose</em></li>".
189
			$contenu .= "<li>Proposition #$idCommentaire : <em>$nomPropose</em></li>".
187
				((!empty($txt)) ? '<li><span class="champ">'."Argumentaire :</span> $txt</li>" : '').
-
 
188
				'<li><span class="champ">'."Auteur de la proposition :</span> $auteur</li>".
190
				((!empty($txt)) ? "<li>Argumentaire : $txt</li>" : '').
189
				'<li><span class="champ">'."Proposé le :</span> $dateCommentaire</li>";
191
				"<li>Auteur de la proposition : $auteur</li>";
190
		} else {
-
 
191
			$contenuCommentaire =
192
		} else {
192
				'<li><span class="champ">'."Commentaire #$idCommentaire :</span> <pre>$txt</pre></li>".
-
 
193
				'<li><span class="champ">'."Auteur du commentaire :</span> $auteur</li>".
-
 
194
				'<li><span class="champ">'."Commenté le :</span> $dateCommentaire</li>";
-
 
195
		}
-
 
196
 
-
 
197
		$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
-
 
198
			'<h2>'."$intitule identiPlante #$idCommentaire pour l'observation #$idObs".'</h2>'.
-
 
199
			'<div class="gauche">'.
-
 
200
			"	<h3>Observation #$idObs</h3>".
-
 
201
			'	<ul>'.
-
 
202
			'		<li><span class="champ">'."Nom saisi actuel :</span> <em>$nomSelActuel</em></li>".
-
 
203
			'		<li><span class="champ">'."Lieu :</span> $lieuObs</li>".
-
 
204
			'		<li><span class="champ">'."Date :</span> $dateObs</li>".
-
 
205
			'		<li><span class="champ">'."Auteur :</span> $observateur</li>".
-
 
206
			'	</ul>'.
193
			$contenu .= "<li>Commentaire #$idCommentaire : <pre>$txt</pre></li>".
207
			'</div>'.
-
 
208
			'<div class="gauche">'.
194
					"<li>Auteur du commentaire : $auteur</li>";
209
			"	<h3>$intitule #$idCommentaire</h3>".
195
		}
210
			"	<ul>$contenuCommentaire</ul>".
Line 196... Line 211...
196
		$description = "<ul>$contenu</ul>";
211
			'</div>';
-
 
212
		return $description;
-
 
213
	}
197
		return $description;
214
 
-
 
215
	private function creerObservateur($info) {
-
 
216
		$observateur = 'Anonyme';
198
	}
217
		if ($info['observateur_prenom'] != '' && $info['observateur_nom'] != '') {
Line 199... Line 218...
199
 
218
			$observateur = $info['observateur_prenom'].' '.$info['observateur_nom'];
200
	private function creerAuteur($info) {
219
		}
201
		return $info['utilisateur_prenom'].' '.$info['utilisateur_nom'];
220
		return $observateur;
202
	}
221
	}
-
 
222
 
203
 
223
	private function getDerniersCommentaires() {
204
	private function getDerniersCommentaires() {
224
		$requete = 'SELECT DISTINCT dc.*, '.
205
		$requete = 'SELECT DISTINCT dc.*, '.
225
			'	dob.id_observation AS dob_id_observation, dob.ce_zone_geo AS dob_ce_zone_geo, '.
-
 
226
			'	dob.zone_geo AS dob_zone_geo, dob.date_observation AS dob_date_observation, dob.nom_sel AS dob_nom_sel, '.
-
 
227
			'	duo.prenom AS observateur_prenom, duo.nom AS observateur_nom, duo.courriel AS observateur_courriel '.
206
			'	dob.id_observation AS dob_id_observation, dob.ce_zone_geo AS dob_ce_zone_geo, '.
228
			'FROM del_commentaire AS dc '.
207
			'	dob.zone_geo AS dob_zone_geo, dob.date_observation AS dob_date_observation, dob.nom_sel AS dob_nom_sel '.
229
			'	INNER JOIN del_observation AS dob '.
208
			'FROM del_commentaire AS dc '.
230
			'		ON dob.id_observation = dc.ce_observation '.
209
			'	INNER JOIN del_observation AS dob '.
231
			'	LEFT JOIN del_utilisateur AS duo '.
210
			'		ON dob.id_observation = dc.ce_observation '.
232
			'		ON dob.ce_utilisateur = duo.id_utilisateur '.
Line 211... Line 233...
211
			'WHERE ((dob.ce_utilisateur = dc.ce_utilisateur AND dob.nom_sel != dc.nom_sel) '.
233
			'WHERE ((dob.ce_utilisateur = dc.ce_utilisateur AND dob.nom_sel != dc.nom_sel) '.