| Line 21... |
Line 21... |
| 21 |
* @version $Id$
|
21 |
* @version $Id$
|
| 22 |
* @copyright 2010
|
22 |
* @copyright 2010
|
| 23 |
*/
|
23 |
*/
|
| 24 |
class CelSyndicationObservation extends Cel {
|
24 |
class CelSyndicationObservation extends Cel {
|
| Line -... |
Line 25... |
| - |
|
25 |
|
| 25 |
|
26 |
private $parametres_origines = null;
|
| 26 |
private $format = null;
|
27 |
private $format = null;
|
| 27 |
private $service = null;
|
- |
|
| 28 |
public $parametres = null;
|
28 |
private $service = null;
|
| 29 |
private $squelette = null;
|
29 |
private $squelette = null;
|
| 30 |
private $squelette_dossier = null;
|
30 |
private $squelette_dossier = null;
|
| Line 31... |
Line 31... |
| 31 |
private $flux = array();
|
31 |
private $flux = array();
|
| 32 |
|
32 |
|
| 33 |
/**
|
33 |
/**
|
| 34 |
* Méthode appelée avec une requête de type GET.
|
34 |
* Méthode appelée avec une requête de type GET.
|
| 35 |
*/
|
35 |
*/
|
| - |
|
36 |
public function getElement($params = array()) {
|
| 36 |
public function getElement($params = array()) {
|
37 |
// Initialisation des variables
|
| 37 |
// Initialisation des variables
|
38 |
$this->parametres_origines = $params;
|
| Line 38... |
Line 39... |
| 38 |
$info = array();
|
39 |
$info = array();
|
| 39 |
$contenu = '';
|
40 |
$contenu = '';
|
| Line 91... |
Line 92... |
| 91 |
$url_base = sprintf($this->config['settings']['baseURLAbsoluDyn'], get_class($this).'/');
|
92 |
$url_base = sprintf($this->config['settings']['baseURLAbsoluDyn'], get_class($this).'/');
|
| 92 |
return $url_base;
|
93 |
return $url_base;
|
| 93 |
}
|
94 |
}
|
| Line 94... |
Line 95... |
| 94 |
|
95 |
|
| 95 |
private function getUrlServiceBase() {
|
96 |
private function getUrlServiceBase() {
|
| 96 |
$url_service = $this->getUrlBase().$this->service.'/'.$this->format;
|
97 |
$url_service = $this->getUrlBase().implode('/', $this->parametres_origines);
|
| 97 |
return $url_service;
|
98 |
return $url_service;
|
| Line 98... |
Line 99... |
| 98 |
}
|
99 |
}
|
| 99 |
|
100 |
|
| Line 192... |
Line 193... |
| 192 |
|
193 |
|
| 193 |
private function getServiceParDefaut() {
|
194 |
private function getServiceParDefaut() {
|
| 194 |
// Construction de la requête
|
195 |
// Construction de la requête
|
| 195 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
|
196 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
|
| 196 |
'FROM cel_inventory '.
|
197 |
'FROM cel_inventory '.
|
| 197 |
'WHERE transmission = 1 '.
|
- |
|
| 198 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification DESC').' '.
|
- |
|
| 199 |
"LIMIT $this->start,$this->limit ";
|
- |
|
| 200 |
|
- |
|
| 201 |
$elements = $this->executerRequete($requete);
|
- |
|
| 202 |
|
- |
|
| 203 |
// Création du contenu
|
- |
|
| 204 |
$contenu = $this->executerService($elements);
|
- |
|
| 205 |
return $contenu;
|
- |
|
| 206 |
}
|
- |
|
| 207 |
|
- |
|
| 208 |
private function getServicePourAdmin() {
|
- |
|
| 209 |
// Construction de la requête
|
- |
|
| 210 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
|
- |
|
| 211 |
'FROM cel_inventory '.
|
198 |
(($this->etreFluxAdmin()) ? '' : 'WHERE transmission = 1 ').
|
| 212 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification DESC').' '.
|
199 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification DESC').' '.
|
| Line 213... |
Line 200... |
| 213 |
"LIMIT $this->start,$this->limit ";
|
200 |
"LIMIT $this->start,$this->limit ";
|
| Line 241... |
Line 228... |
| 241 |
}
|
228 |
}
|
| Line 242... |
Line 229... |
| 242 |
|
229 |
|
| 243 |
// Construction de la requête
|
230 |
// Construction de la requête
|
| 244 |
$requete = 'SELECT * '.
|
231 |
$requete = 'SELECT * '.
|
| 245 |
'FROM cel_inventory '.
|
232 |
'FROM cel_inventory '.
|
| 246 |
'WHERE transmission = 1 '.
|
233 |
'WHERE '.implode(" \nOR ", $requete_where).' '.
|
| 247 |
'AND '.implode(" \nOR ", $requete_where).' '.
|
234 |
' '.(($this->etreFluxAdmin()) ? '' : 'AND transmission = 1 ').
|
| 248 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification, date_creation DESC').' '.
|
235 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification, date_creation DESC').' '.
|
| 249 |
"LIMIT $this->start,$this->limit ";
|
236 |
"LIMIT $this->start,$this->limit ";
|
| Line 250... |
Line 237... |
| 250 |
$elements = $this->executerRequete($requete);
|
237 |
$elements = $this->executerRequete($requete);
|
| Line 267... |
Line 254... |
| 267 |
$commune = $this->bdd->quote($commune);
|
254 |
$commune = $this->bdd->quote($commune);
|
| Line 268... |
Line 255... |
| 268 |
|
255 |
|
| 269 |
// Construction de la requête
|
256 |
// Construction de la requête
|
| 270 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
|
257 |
$requete = (($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' * '.
|
| 271 |
'FROM cel_inventory '.
|
258 |
'FROM cel_inventory '.
|
| 272 |
'WHERE transmission = 1 '.
|
259 |
"WHERE location = $commune ".
|
| 273 |
"AND location = $commune ".
|
260 |
' '.(($this->etreFluxAdmin()) ? '' : 'AND transmission = 1 ').
|
| 274 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification DESC, location ASC').' '.
|
261 |
'ORDER BY '.((!is_null($this->orderby)) ? $this->orderby : 'date_modification DESC, location ASC').' '.
|
| Line 275... |
Line 262... |
| 275 |
"LIMIT $this->start,$this->limit ";
|
262 |
"LIMIT $this->start,$this->limit ";
|
| Line 320... |
Line 307... |
| 320 |
return $donnees;
|
307 |
return $donnees;
|
| 321 |
}
|
308 |
}
|
| Line 322... |
Line 309... |
| 322 |
|
309 |
|
| 323 |
private function construireDonneesCommunesAuxItems($observation) {
|
310 |
private function construireDonneesCommunesAuxItems($observation) {
|
| 324 |
$item = array();
|
311 |
$item = array();
|
| 325 |
$date_modification_timestamp = strtotime($observation['date_modification']);
|
312 |
$date_modification_timestamp = $this->convertirDateHeureMysqlEnTimestamp($observation['date_modification']);
|
| 326 |
$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
|
313 |
$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
|
| 327 |
$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
|
314 |
$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
|
| 328 |
$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
|
315 |
$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
|
| 329 |
$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
|
316 |
$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
|
| 330 |
$item['date_creation_simple'] = strftime('%A %d %B %Y à %H:%M', strtotime($observation['date_creation']));
|
317 |
$item['date_creation_simple'] = strftime('%A %d %B %Y à %H:%M', strtotime($observation['date_creation']));
|
| 331 |
$item['titre'] = $this->creerTitre($observation);
|
318 |
$item['titre'] = $this->creerTitre($observation);
|
| 332 |
$item['guid'] = $this->creerGuidItem($observation);
|
319 |
$item['guid'] = $this->creerGuidItem($observation);
|
| 333 |
$item['lien'] = $this->creerLienItem($observation);
|
- |
|
| 334 |
$item['description'] = $this->creerDescription($observation, $item);
|
320 |
$item['lien'] = $this->creerLienItem($observation);
|
| - |
|
321 |
$item['categorie'] = $this->creerCategorie($item);
|
| 335 |
$item['categorie'] = $this->creerCategorie($item);
|
322 |
$item['description'] = $this->creerDescription($this->protegerCaracteresHtmlDansChamps($observation), $item);
|
| 336 |
$item['description_encodee'] = htmlspecialchars($item['description']);
|
323 |
$item['description_encodee'] = htmlspecialchars($this->creerDescription($observation, $item));
|
| 337 |
$item['modifier_par'] = $this->creerAuteur($observation['identifiant'], $this->etreFluxAdmin());
|
324 |
$item['modifier_par'] = $this->creerAuteur($observation['identifiant'], $this->etreFluxAdmin());
|
| 338 |
return $item;
|
325 |
return $item;
|
| Line 339... |
Line 326... |
| 339 |
}
|
326 |
}
|
| Line 359... |
Line 346... |
| 359 |
}
|
346 |
}
|
| 360 |
return $lien;
|
347 |
return $lien;
|
| 361 |
}
|
348 |
}
|
| Line 362... |
Line 349... |
| 362 |
|
349 |
|
| - |
|
350 |
private function creerDescription($obs, $item) {
|
| - |
|
351 |
$id_obs = $donnees['id'];
|
| - |
|
352 |
$famille = $obs['famille'];
|
| - |
|
353 |
$nom_saisi = $obs['nom_sel'];
|
| - |
|
354 |
$nom_retenu = $obs['nom_ret'];
|
| - |
|
355 |
$auteur = $this->creerAuteur($obs['identifiant'], $this->etreFluxAdmin());
|
| 363 |
private function creerDescription($obs, $item) {
|
356 |
$mots_cles_obs = $this->decoderMotsClesObs($obs['identifiant'], $obs['mots_cles']);
|
| - |
|
357 |
$lien_correction = sprintf($this->config['settings']['phpEditUrlTpl'], $obs['id']);
|
| 364 |
$lien_correction = sprintf($this->config['settings']['phpEditUrlTpl'], $obs['id']);
|
358 |
$lieu = $obs['location'].' ('.$obs['id_location'].') > '.$obs['lieudit'].' > '.$obs['station'];
|
| - |
|
359 |
$milieu = $obs['milieu'];
|
| - |
|
360 |
$coordonnees = ($this->etreNull($obs['coord_x']) && $this->etreNull($obs['coord_y'])) ? '' : $obs['coord_x'].'/'.$obs['coord_y'];
|
| - |
|
361 |
$commentaire = htmlspecialchars($obs['commentaire']);
|
| - |
|
362 |
$date_observation = $this->formaterDate($obs['date_observation'], '%A %d %B %Y');
|
| - |
|
363 |
$date_transmission = $this->formaterDate($obs['date_transmission']);
|
| - |
|
364 |
$date_modification = $this->formaterDate($obs['date_modification']);
|
| - |
|
365 |
$date_creation = $this->formaterDate($obs['date_creation']);
|
| - |
|
366 |
$transmission = $obs['transmission'] == 1 ? "oui ($date_transmission)" : 'non';
|
| - |
|
367 |
|
| 365 |
$description =
|
368 |
$description = '<h2>'."Observation #$id_obs de $nom_saisi".'</h2>'.
|
| - |
|
369 |
'<ul>'.
|
| 366 |
'<ul>'.
|
370 |
'<li>'.'Famille : '.$famille.'</li>'.
|
| 367 |
' <li>Nom saisi : '.$obs['nom_sel'].'</li>'.
|
371 |
'<li>'.'Nom saisi : '.$nom_saisi.'</li>'.
|
| 368 |
(($obs['nom_sel'] != $obs['nom_ret']) ? ' <li>Nom retenu : '.$obs['nom_ret'].'</li>' : '').
|
372 |
'<li>'.'Nom retenu : '.$nom_retenu.'</li>'.
|
| - |
|
373 |
'<li>'.'Observée le : '.$date_observation.'</li>'.
|
| 369 |
' <li>Lieu : '.$obs['location'].' ('.$obs['id_location'].')</li>'.
|
374 |
'<li>'.'Lieu : '.$lieu.'</li>'.
|
| 370 |
($this->etreNull($obs['station']) ? '': ' <li>Station : '.$obs['station'].'</li>').
|
375 |
'<li>'.'Milieu : '.$milieu.'</li>'.
|
| 371 |
($this->etreNull($obs['milieu']) ? '': ' <li>Milieu : '.$obs['milieu'].'</li>').
|
376 |
(($this->etreFluxAdmin()) ? '<li>Coordonnées (Lat/Long) : '.$coordonnees.'</li>' : '').
|
| - |
|
377 |
'<li>'.'Commentaire : '.$commentaire.'</li>'.
|
| 372 |
($this->etreNull($obs['commentaire']) ? '': ' <li>Commentaire : '.$obs['commentaire'].'</li>').
|
378 |
'<li>'.'Mots-clés : '.implode(', ', $mots_cles_obs).'</li>'.
|
| 373 |
(($this->etreFluxAdmin()) ? ' <li>Transmis (= public) : '.($obs['transmission'] == 1 ? 'oui' : 'non').'</li>' : '').
|
379 |
(($this->etreFluxAdmin()) ? '<li>Transmis (= public) : '.$transmission.'</li>' : '').
|
| 374 |
' <li>Modifiée le : '.$item['date_maj_simple'].'</li>'.
|
380 |
'<li>Modifiée le : '.$date_modification.'</li>'.
|
| 375 |
' <li>Créée le : '.$item['date_creation_simple'].'</li>'.
|
381 |
'<li>Créée le : '.$date_creation.'</li>'.
|
| 376 |
(($this->etreFluxAdmin()) ? ' <li><a href="'.$lien_correction.'">Corriger cette observation</a></li>' : '').
|
382 |
(($this->etreFluxAdmin()) ? '<li><a href="'.$lien_correction.'">Corriger cette observation</a></li>' : '').
|
| 377 |
'</ul>';
|
383 |
'</ul>';
|
| 378 |
$description = $this->nettoyerTexte($description);
|
384 |
$description = $this->nettoyerTexte($description);
|
| 379 |
return $description;
|
385 |
return $description;
|
| Line 385... |
Line 391... |
| 385 |
$categorie = $this->nettoyerTexte($categorie);
|
391 |
$categorie = $this->nettoyerTexte($categorie);
|
| 386 |
return $categorie;
|
392 |
return $categorie;
|
| 387 |
}
|
393 |
}
|
| Line 388... |
Line 394... |
| 388 |
|
394 |
|
| 389 |
private function etreFluxAdmin() {
|
395 |
private function etreFluxAdmin() {
|
| 390 |
return ($this->service == 'pour-admin' || $_GET['admin'] == '1') ? true : false;
|
396 |
return ($_GET['admin'] == '1') ? true : false;
|
| Line 391... |
Line 397... |
| 391 |
}
|
397 |
}
|
| 392 |
|
398 |
|
| 393 |
private function creerUrlService() {
|
- |
|
| 394 |
$url_service = $this->getUrlServiceBase();
|
- |
|
| 395 |
if (isset($this->start) || isset($this->limit)) {
|
- |
|
| 396 |
$arguments = array();
|
- |
|
| 397 |
if (isset($this->start) && isset($_GET['start'])) {
|
- |
|
| 398 |
$arguments[] = 'start='.$this->start;
|
- |
|
| 399 |
}
|
- |
|
| 400 |
if (isset($this->limit) && isset($_GET['limit'])) {
|
- |
|
| 401 |
$arguments[] = 'limit='.($this->limit);
|
399 |
private function creerUrlService() {
|
| 402 |
}
|
400 |
$url_service = $this->getUrlServiceBase();
|
| 403 |
if (count($arguments) > 0) {
|
- |
|
| 404 |
$url_service .= '?'.implode('&', $arguments);
|
401 |
if (count($_GET) > 0) {
|
| 405 |
}
|
402 |
$url_service .= '?'.implode('&', $_GET);
|
| 406 |
}
|
403 |
}
|
| 407 |
return $url_service;
|
404 |
return $url_service;
|
| 408 |
}
|
405 |
}
|