416 |
aurelien |
1 |
<?php
|
|
|
2 |
/**
|
522 |
jpm |
3 |
* Service fournissant des informations concernant les images du CEL au format RSS1, RSS2 ou ATOM.
|
416 |
aurelien |
4 |
* Encodage en entrée : utf8
|
|
|
5 |
* Encodage en sortie : utf8
|
1269 |
jpm |
6 |
*
|
416 |
aurelien |
7 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org>
|
|
|
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>
|
|
|
10 |
* @version $Id$
|
|
|
11 |
* @copyright 2010
|
|
|
12 |
*/
|
528 |
jpm |
13 |
// TODO : résoudre le problème des images liées à plusieurs obs. Cela créé plusieurs item avec le même id pour atom...
|
416 |
aurelien |
14 |
class CelSyndicationImage extends Cel {
|
1269 |
jpm |
15 |
|
528 |
jpm |
16 |
private $parametres_origines = null;
|
416 |
aurelien |
17 |
private $format = null;
|
|
|
18 |
private $service = null;
|
|
|
19 |
private $squelette = null;
|
|
|
20 |
private $squelette_dossier = null;
|
790 |
delphine |
21 |
private $auteurs = array();
|
416 |
aurelien |
22 |
private $flux = array();
|
1269 |
jpm |
23 |
|
630 |
jpm |
24 |
private $format_image = 'XL';
|
1269 |
jpm |
25 |
|
593 |
aurelien |
26 |
private $criteres = array(
|
1269 |
jpm |
27 |
'utilisateur' => 'c.ci_ce_utilisateur',
|
|
|
28 |
'commune' => 'b.location',
|
741 |
delphine |
29 |
'dept' => 'b.id_location',
|
710 |
delphine |
30 |
'taxon' => 'b.nom_ret',
|
|
|
31 |
'commentaire' => 'c.ci_meta_comment',
|
714 |
delphine |
32 |
'date' => 'c.ci_meta_date',
|
750 |
delphine |
33 |
'tag' => 'tag',
|
|
|
34 |
'projet' => 'projet');
|
1269 |
jpm |
35 |
|
416 |
aurelien |
36 |
/**
|
|
|
37 |
* Méthode appelée avec une requête de type GET.
|
|
|
38 |
*/
|
524 |
jpm |
39 |
public function getElement($params = array()) {
|
416 |
aurelien |
40 |
// Initialisation des variables
|
528 |
jpm |
41 |
$this->parametres_origines = $params;
|
416 |
aurelien |
42 |
$info = array();
|
|
|
43 |
$contenu = '';
|
1269 |
jpm |
44 |
|
536 |
jpm |
45 |
if (! $this->etreFluxAdmin() || $this->authentifierAdmin()) {
|
522 |
jpm |
46 |
// Pré traitement des paramêtres
|
|
|
47 |
$pour_bdd = false;
|
524 |
jpm |
48 |
$p = $this->traiterParametres(array('service', 'format'), $params, $pour_bdd);
|
522 |
jpm |
49 |
extract($p);
|
524 |
jpm |
50 |
$this->parametres = $params;
|
|
|
51 |
$this->squelette_dossier = dirname(__FILE__).DIRECTORY_SEPARATOR.'squelettes'.DIRECTORY_SEPARATOR;
|
1269 |
jpm |
52 |
|
522 |
jpm |
53 |
// Récupération de la liste des flux
|
|
|
54 |
$this->chargerListeDesFlux();
|
1269 |
jpm |
55 |
|
522 |
jpm |
56 |
// Chargement du bon type de service demandé
|
|
|
57 |
if (isset($service)) {
|
524 |
jpm |
58 |
$this->service = $this->traiterNomService($service);
|
522 |
jpm |
59 |
$methode = $this->getNomMethodeService();
|
|
|
60 |
if (method_exists($this, $methode)) {
|
524 |
jpm |
61 |
if (isset($format) && preg_match('/^(?:rss1|rss2|atom)$/i', $format)) {
|
|
|
62 |
// Mise en minuscule de l'indication du format
|
|
|
63 |
$this->format = strtolower($format);
|
|
|
64 |
// Définition du fichier squelette demandé
|
|
|
65 |
$this->squelette = $this->squelette_dossier.$this->format.'.tpl.xml';
|
|
|
66 |
} else if (isset($this->flux[$this->service])) {
|
|
|
67 |
$this->format = '';
|
|
|
68 |
$this->messages[] = "Le service CEL Syndication nécessite d'indiquer en second paramètre le format : rss1, rss2 ou atom.";
|
416 |
aurelien |
69 |
}
|
1269 |
jpm |
70 |
|
524 |
jpm |
71 |
if (!isset($this->flux[$this->service]) || isset($this->format)) {
|
710 |
delphine |
72 |
// Suppression des deux premiers paramètres (service et format) pour le reste des méthodes
|
524 |
jpm |
73 |
array_shift($this->parametres);
|
|
|
74 |
array_shift($this->parametres);
|
1269 |
jpm |
75 |
|
524 |
jpm |
76 |
// Récupération du contenu à renvoyer
|
|
|
77 |
$contenu = $this->$methode();
|
|
|
78 |
}
|
522 |
jpm |
79 |
} else {
|
|
|
80 |
$this->messages[] = "Le type d'information demandé '$this->service' n'est pas disponible.";
|
416 |
aurelien |
81 |
}
|
|
|
82 |
} else {
|
522 |
jpm |
83 |
$this->messages[] = "Le service CEL Syndication Image nécessite d'indiquer en premier paramètre le type d'information demandé.";
|
416 |
aurelien |
84 |
}
|
|
|
85 |
}
|
1269 |
jpm |
86 |
|
416 |
aurelien |
87 |
// Envoie sur la sortie standard
|
|
|
88 |
$encodage = 'utf-8';
|
|
|
89 |
$mime = $this->getTypeMime();
|
|
|
90 |
$formatage_json = $this->getFormatageJson();
|
|
|
91 |
$this->envoyer($contenu, $mime, $encodage, $formatage_json);
|
|
|
92 |
}
|
1269 |
jpm |
93 |
|
524 |
jpm |
94 |
private function chargerListeDesFlux() {
|
1269 |
jpm |
95 |
$this->setFlux('simple', 'Nouvelles images liées à une observation dans le CEL',
|
524 |
jpm |
96 |
"Ce flux fournit l'url des nouvelles images du CEL liées à une observation.");
|
1269 |
jpm |
97 |
$this->setFlux('complet', 'Nouvelles images liées à une observation dans le CEL (détails)',
|
524 |
jpm |
98 |
"Ce flux fournit les informations sur les nouvelles images du CEL liées à une observation.");
|
742 |
delphine |
99 |
$this->setFlux('par-mots-cles', 'Flux de syndication obsolète',
|
|
|
100 |
"Ce flux est désormais accessible via le flux multicriteres/atom/M?tag='mot-cle'.");
|
|
|
101 |
$this->setFlux('par-commune','Flux de syndication obsolète',
|
|
|
102 |
"Ce flux est désormais accessible via le flux multicriteres/atom/M?commune='commune'.");
|
710 |
delphine |
103 |
$this->setFlux('multicriteres','Flux de syndication des nouvelles images liées à une observation publique du CEL '.
|
|
|
104 |
'filtrées par un ou plusieurs critères',
|
|
|
105 |
"Ce flux fournit des informations sur les nouvelles images liées à une observation du CEL filtrées par ".
|
742 |
delphine |
106 |
"auteur (mail), commune (nom), departement (code postal), taxon (nom scientifique), commentaire, tag ".
|
|
|
107 |
"et/ou date.");
|
416 |
aurelien |
108 |
}
|
1269 |
jpm |
109 |
|
524 |
jpm |
110 |
private function setFlux($nom, $titre, $description) {
|
710 |
delphine |
111 |
$url_base = $this->config['settings']['baseURLAbsoluDyn'].'CelSyndicationImage/';
|
524 |
jpm |
112 |
$formats = array('atom', 'rss2', 'rss1');
|
|
|
113 |
$flux = array();
|
|
|
114 |
foreach ($formats as $format) {
|
|
|
115 |
$url = $url_base.$nom.'/'.$format;
|
|
|
116 |
$flux[$format] = $url;
|
|
|
117 |
}
|
|
|
118 |
$this->flux[$nom] = array('titre' => $titre, 'description' => $description, 'urls' => $flux);
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
private function getFlux($nom) {
|
|
|
122 |
return isset($this->flux[$nom]) ? $this->flux[$nom] : array();
|
|
|
123 |
}
|
1269 |
jpm |
124 |
|
524 |
jpm |
125 |
private function traiterNomService($nom) {
|
|
|
126 |
$nom = strtolower($nom);
|
|
|
127 |
return $nom;
|
|
|
128 |
}
|
1269 |
jpm |
129 |
|
416 |
aurelien |
130 |
private function getNomMethodeService() {
|
|
|
131 |
$methode = '';
|
524 |
jpm |
132 |
$service_formate = str_replace(' ', '', ucwords(implode(' ', explode('-', $this->service))));
|
416 |
aurelien |
133 |
$methode = 'getService'.$service_formate;
|
|
|
134 |
return $methode;
|
|
|
135 |
}
|
1269 |
jpm |
136 |
|
524 |
jpm |
137 |
private function getUrlBase() {
|
636 |
jpm |
138 |
$url_base = sprintf($this->config['settings']['baseURLAbsolu'], get_class($this).'/');
|
524 |
jpm |
139 |
return $url_base;
|
|
|
140 |
}
|
1269 |
jpm |
141 |
|
524 |
jpm |
142 |
private function getUrlServiceBase() {
|
528 |
jpm |
143 |
$url_service = $this->getUrlBase().implode('/', $this->parametres_origines);
|
524 |
jpm |
144 |
return $url_service;
|
|
|
145 |
}
|
1269 |
jpm |
146 |
|
416 |
aurelien |
147 |
private function getTypeMime() {
|
|
|
148 |
$mime = '';
|
|
|
149 |
switch ($this->format) {
|
|
|
150 |
case 'atom' :
|
|
|
151 |
$mime = 'application/atom+xml';
|
|
|
152 |
break;
|
|
|
153 |
case 'rss1' :
|
|
|
154 |
case 'rss2' :
|
|
|
155 |
$mime = 'application/rss+xml';
|
|
|
156 |
break;
|
524 |
jpm |
157 |
case 'opml' :
|
|
|
158 |
$mime = 'text/x-opml';
|
|
|
159 |
break;
|
416 |
aurelien |
160 |
default:
|
|
|
161 |
$mime = 'text/html';
|
|
|
162 |
}
|
|
|
163 |
return $mime;
|
|
|
164 |
}
|
1269 |
jpm |
165 |
|
416 |
aurelien |
166 |
private function getFormatageJson() {
|
|
|
167 |
$json = false;
|
|
|
168 |
switch ($this->service) {
|
524 |
jpm |
169 |
case 'liste-des-flux' :
|
416 |
aurelien |
170 |
$json = true;
|
|
|
171 |
break;
|
|
|
172 |
default:
|
|
|
173 |
$json = false;
|
|
|
174 |
}
|
|
|
175 |
return $json;
|
|
|
176 |
}
|
1269 |
jpm |
177 |
|
528 |
jpm |
178 |
private function creerCategorie($element) {
|
|
|
179 |
$categorie = '';
|
|
|
180 |
$categorie = 'Image';
|
|
|
181 |
$categorie = $this->nettoyerTexte($categorie);
|
|
|
182 |
return $categorie;
|
|
|
183 |
}
|
1269 |
jpm |
184 |
|
522 |
jpm |
185 |
private function etreFluxAdmin() {
|
710 |
delphine |
186 |
return (isset($_GET['admin']) && $_GET['admin'] == '1') ? true : false;
|
416 |
aurelien |
187 |
}
|
1269 |
jpm |
188 |
|
522 |
jpm |
189 |
private function creerUrlService() {
|
|
|
190 |
$url_service = $this->getUrlServiceBase();
|
528 |
jpm |
191 |
if (count($_GET) > 0) {
|
636 |
jpm |
192 |
$parametres_get = array();
|
|
|
193 |
foreach ($_GET as $cle => $valeur) {
|
|
|
194 |
$parametres_get[] = $cle.'='.$valeur;
|
|
|
195 |
}
|
|
|
196 |
$url_service .= '?'.implode('&', $parametres_get);
|
416 |
aurelien |
197 |
}
|
522 |
jpm |
198 |
return $url_service;
|
416 |
aurelien |
199 |
}
|
1269 |
jpm |
200 |
|
710 |
delphine |
201 |
protected function executerRequete($requete, $retour = 'All', $mode = PDO::FETCH_ASSOC) {
|
416 |
aurelien |
202 |
try {
|
|
|
203 |
$infos = $this->bdd->query($requete)->fetchAll(PDO::FETCH_ASSOC);
|
|
|
204 |
if ($infos === false) {
|
|
|
205 |
$this->messages[] = "La requête suivante a retourné aucun résultat :\n$requete";
|
|
|
206 |
}
|
|
|
207 |
} catch (PDOException $e) {
|
|
|
208 |
$this->messages[] = sprintf($this->getTxt('sql_erreur'), $e->getFile(), $e->getLine(), $e->getMessage());
|
|
|
209 |
}
|
|
|
210 |
return $infos;
|
|
|
211 |
}
|
1269 |
jpm |
212 |
|
416 |
aurelien |
213 |
private function executerService($elements) {
|
|
|
214 |
// Prétraitement des données
|
|
|
215 |
$donnees = $this->construireDonneesCommunesAuFlux($elements);
|
|
|
216 |
foreach ($elements as $element) {
|
1269 |
jpm |
217 |
$identifiants[$element['ci_ce_utilisateur']] = $element['ci_ce_utilisateur'];
|
790 |
delphine |
218 |
}
|
|
|
219 |
$this->auteurs = $this->creerAuteurs($identifiants);
|
|
|
220 |
foreach ($elements as $element) {
|
416 |
aurelien |
221 |
$donnees['items'][] = $this->construireDonneesCommunesAuxItems($element);
|
|
|
222 |
}
|
1269 |
jpm |
223 |
|
416 |
aurelien |
224 |
// Création du contenu à partir d'un template PHP
|
|
|
225 |
$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
|
1269 |
jpm |
226 |
|
416 |
aurelien |
227 |
return $contenu;
|
|
|
228 |
}
|
1269 |
jpm |
229 |
|
416 |
aurelien |
230 |
private function construireDonneesCommunesAuFlux($infos) {
|
|
|
231 |
$donnees = $this->getFlux($this->service);
|
|
|
232 |
$donnees['guid'] = $this->getUrlServiceBase();
|
|
|
233 |
$donnees['lien_service'] = $this->creerUrlService();
|
1269 |
jpm |
234 |
$donnees['lien_cel'] = (isset($infos['num_nom_sel'])) ?
|
710 |
delphine |
235 |
sprintf($this->config['settings']['efloreUrlTpl'], $infos['num_nom_sel'], 'illustration') : '';
|
416 |
aurelien |
236 |
$donnees['editeur'] = $this->config['settings']['editeur'];
|
|
|
237 |
$derniere_info_en_date = reset($infos);
|
|
|
238 |
$date_modification_timestamp = strtotime($derniere_info_en_date['ci_meta_date_ajout']);
|
|
|
239 |
$donnees['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
|
|
|
240 |
$donnees['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
|
|
|
241 |
$donnees['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
|
|
|
242 |
$donnees['annee_courante'] = date('Y');
|
|
|
243 |
$donnees['generateur'] = 'CEL - Jrest - CelSyndicationImage';
|
710 |
delphine |
244 |
$donnees['generateur_version'] = (preg_match('/([0-9]+)/', '$Revision$', $match)) ? $match[1] : '0';
|
1269 |
jpm |
245 |
return $donnees;
|
416 |
aurelien |
246 |
}
|
1269 |
jpm |
247 |
|
416 |
aurelien |
248 |
private function construireDonneesCommunesAuxItems($info) {
|
|
|
249 |
$item = array();
|
528 |
jpm |
250 |
$date_modification_timestamp = $this->convertirDateHeureMysqlEnTimestamp($info['ci_meta_date_ajout']);
|
416 |
aurelien |
251 |
$item['date_maj_simple'] = strftime('%A %d %B %Y à %H:%M', $date_modification_timestamp);
|
|
|
252 |
$item['date_maj_RSS'] = date(DATE_RSS, $date_modification_timestamp);
|
|
|
253 |
$item['date_maj_ATOM'] = date(DATE_ATOM, $date_modification_timestamp);
|
|
|
254 |
$item['date_maj_W3C'] = date(DATE_W3C, $date_modification_timestamp);
|
|
|
255 |
$item['titre'] = $this->creerTitre($info);
|
|
|
256 |
$item['guid'] = $this->creerGuidItem($info);
|
|
|
257 |
$item['lien'] = $this->creerLienItem($info);
|
528 |
jpm |
258 |
$item['categorie'] = $this->creerCategorie($item);
|
|
|
259 |
$item['description'] = $this->creerDescription($this->protegerCaracteresHtmlDansChamps($info), $item);
|
|
|
260 |
$item['description_encodee'] = htmlspecialchars($this->creerDescription($info, $item));
|
1336 |
jpm |
261 |
$item['modifier_par'] = $this->getIntituleAuteur($info['ci_ce_utilisateur']);
|
416 |
aurelien |
262 |
return $item;
|
|
|
263 |
}
|
1269 |
jpm |
264 |
|
416 |
aurelien |
265 |
private function creerGuidItem($element) {
|
528 |
jpm |
266 |
$guid = $this->getUrlImage($element['ci_id_image']);
|
416 |
aurelien |
267 |
return $guid;
|
|
|
268 |
}
|
1269 |
jpm |
269 |
|
522 |
jpm |
270 |
private function creerTitre($element) {
|
|
|
271 |
$methode = 'creerTitre'.$this->service;
|
|
|
272 |
$methode = (method_exists($this, $methode)) ? $methode : 'creerTitreSimple';
|
|
|
273 |
$titre = $this->$methode($element);
|
|
|
274 |
$titre = $this->nettoyerTexte($titre);
|
|
|
275 |
return $titre;
|
416 |
aurelien |
276 |
}
|
1269 |
jpm |
277 |
|
523 |
jpm |
278 |
private function creerDescription($donnees, $item) {
|
522 |
jpm |
279 |
$methode = 'creerDescription'.$this->service;
|
525 |
jpm |
280 |
$methode = (method_exists($this, $methode)) ? $methode : 'creerDescriptionComplet';
|
523 |
jpm |
281 |
$description = $this->$methode($donnees, $item);
|
416 |
aurelien |
282 |
$description = $this->nettoyerTexte($description);
|
|
|
283 |
return $description;
|
|
|
284 |
}
|
522 |
jpm |
285 |
|
|
|
286 |
private function creerLienItem($element) {
|
630 |
jpm |
287 |
if ($this->etreNull($element['id'])) {
|
|
|
288 |
// Lien vers image grand format
|
|
|
289 |
$lien = $this->getUrlImage($element['ci_id_image'], $this->format_image);
|
|
|
290 |
} else {
|
|
|
291 |
// Lien vers fiche eFlore onglet Illustration
|
|
|
292 |
$lien = sprintf($this->config['settings']['efloreUrlTpl'], $element['num_nom_sel'], 'illustration');
|
|
|
293 |
}
|
522 |
jpm |
294 |
return $lien;
|
416 |
aurelien |
295 |
}
|
1269 |
jpm |
296 |
|
524 |
jpm |
297 |
private function getServiceListeDesFlux() {
|
|
|
298 |
return $this->flux;
|
|
|
299 |
}
|
1269 |
jpm |
300 |
|
524 |
jpm |
301 |
private function getServiceOpml() {
|
|
|
302 |
$donnees = array();
|
|
|
303 |
$id = 1;
|
|
|
304 |
foreach ($this->flux as $flux_nom => $flux){
|
|
|
305 |
$info = array();
|
|
|
306 |
$info['type'] = 'atom';
|
|
|
307 |
$info['titre'] = $flux['titre'];
|
|
|
308 |
$info['texte'] = "CEL - Images - $flux_nom";
|
|
|
309 |
$info['description'] = $flux['description'];
|
|
|
310 |
$info['url_xml'] = $this->getUrlBase().$flux_nom.'/atom';
|
|
|
311 |
$info['url_html'] = $this->config['settings']['aideCelUrl'].'FluxSyndication';
|
|
|
312 |
$donnees['liste_flux'][] = $info;
|
522 |
jpm |
313 |
}
|
1269 |
jpm |
314 |
|
524 |
jpm |
315 |
$this->squelette = $this->squelette_dossier.'opml.tpl.xml';
|
|
|
316 |
$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
|
|
|
317 |
return $contenu;
|
|
|
318 |
}
|
1269 |
jpm |
319 |
|
524 |
jpm |
320 |
private function getServiceSimple() {
|
|
|
321 |
if (isset($this->parametres[0])) {
|
|
|
322 |
$this->format_image = $this->parametres[0];
|
|
|
323 |
}
|
1269 |
jpm |
324 |
|
522 |
jpm |
325 |
// Construction de la requête
|
716 |
delphine |
326 |
$requete = (isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
|
613 |
jpm |
327 |
' ci_id_image, ci_ce_utilisateur, ci_nom_original, ci_meta_date_ajout, ci_meta_mots_cles, ci_meta_comment, ci_note_image '.
|
522 |
jpm |
328 |
'FROM cel_obs_images AS coi '.
|
|
|
329 |
'LEFT JOIN cel_inventory AS ci '.
|
|
|
330 |
'ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
|
|
|
331 |
'LEFT JOIN cel_images AS cim '.
|
1269 |
jpm |
332 |
'ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.
|
522 |
jpm |
333 |
'WHERE ci.transmission = 1 '.
|
|
|
334 |
' AND ci.identifiant = cim.ci_ce_utilisateur '.
|
716 |
delphine |
335 |
'ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby : 'ci_meta_date_ajout DESC').' '.
|
522 |
jpm |
336 |
"LIMIT $this->start, $this->limit ";
|
1269 |
jpm |
337 |
|
522 |
jpm |
338 |
$elements = $this->executerRequete($requete);
|
1269 |
jpm |
339 |
|
522 |
jpm |
340 |
// Création du contenu
|
|
|
341 |
$contenu = $this->executerService($elements);
|
|
|
342 |
return $contenu;
|
416 |
aurelien |
343 |
}
|
1269 |
jpm |
344 |
|
522 |
jpm |
345 |
private function creerTitreSimple($element) {
|
1320 |
aurelien |
346 |
$date = $element['date_observation'];
|
|
|
347 |
$date = date("d/m/Y", strtotime($date));
|
603 |
jpm |
348 |
if ($this->etreNull($element['nom_sel']) && $this->etreNull($element['num_nom_sel'])) {
|
1336 |
jpm |
349 |
$titre = "Ajout d'une photo par ".$this->getIntituleAuteur($element['ci_ce_utilisateur']).' le '.$date;
|
603 |
jpm |
350 |
} else {
|
1336 |
jpm |
351 |
$titre = $element['nom_sel'].' [nn'.$element['num_nom_sel'].'] par '.$this->getIntituleAuteur($element['ci_ce_utilisateur']).' le '.$date;
|
603 |
jpm |
352 |
}
|
522 |
jpm |
353 |
return $titre;
|
416 |
aurelien |
354 |
}
|
1269 |
jpm |
355 |
|
523 |
jpm |
356 |
private function creerDescriptionSimple($donnees, $item) {
|
585 |
jpm |
357 |
$description = sprintf($this->config['settings']['efloreUrlTpl'], urlencode($donnees['num_nom_sel']), 'illustration');
|
522 |
jpm |
358 |
return $description;
|
416 |
aurelien |
359 |
}
|
1269 |
jpm |
360 |
|
524 |
jpm |
361 |
private function getServiceComplet() {
|
522 |
jpm |
362 |
// Construction de la requête
|
710 |
delphine |
363 |
$requete = (isset($this->distinct) ? 'SELECT DISTINCT' : 'SELECT').' ci.*, '.
|
603 |
jpm |
364 |
' ci_id_image, ci_ce_utilisateur, ci_nom_original, ci_meta_date_ajout, ci_meta_mots_cles, ci_meta_comment, ci_note_image '.
|
525 |
jpm |
365 |
'FROM cel_images AS cim '.
|
|
|
366 |
' LEFT JOIN cel_obs_images AS coi '.
|
|
|
367 |
' ON (coi.coi_ce_image = cim.ci_id_image AND coi.coi_ce_utilisateur = cim.ci_ce_utilisateur) '.
|
|
|
368 |
' LEFT JOIN cel_inventory AS ci '.
|
|
|
369 |
' ON (coi.coi_ce_observation = ci.ordre AND coi.coi_ce_utilisateur = ci.identifiant) '.
|
|
|
370 |
(($this->etreFluxAdmin()) ? '' : 'WHERE ci.transmission = 1 ').
|
710 |
delphine |
371 |
'ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby : 'ci_meta_date_ajout DESC').' '.
|
522 |
jpm |
372 |
"LIMIT $this->start, $this->limit ";
|
1269 |
jpm |
373 |
|
522 |
jpm |
374 |
$elements = $this->executerRequete($requete);
|
525 |
jpm |
375 |
|
522 |
jpm |
376 |
// Création du contenu
|
525 |
jpm |
377 |
if ($elements != false && count($elements) > 0) {
|
|
|
378 |
$contenu = $this->executerService($elements);
|
|
|
379 |
} else {
|
|
|
380 |
$this->messages[] = "Aucune image disponible.";
|
|
|
381 |
}
|
|
|
382 |
|
522 |
jpm |
383 |
return $contenu;
|
516 |
aurelien |
384 |
}
|
1269 |
jpm |
385 |
|
593 |
aurelien |
386 |
private function getServiceMultiCriteres() {
|
710 |
delphine |
387 |
$contenu = '';
|
1269 |
jpm |
388 |
if (isset($_GET['debut'])) $this->start = $_GET['debut'];
|
714 |
delphine |
389 |
if (isset($_GET['limite'])) $this->limite = $_GET['limite'];
|
1269 |
jpm |
390 |
|
593 |
aurelien |
391 |
// Construction de la requête
|
603 |
jpm |
392 |
$requete = 'SELECT * '.
|
1269 |
jpm |
393 |
'FROM cel_obs_images AS a '.
|
|
|
394 |
' INNER JOIN cel_inventory AS b '.
|
603 |
jpm |
395 |
' ON (a.coi_ce_observation = b.ordre AND a.coi_ce_utilisateur = b.identifiant) '.
|
1269 |
jpm |
396 |
' INNER JOIN cel_images AS c '.
|
|
|
397 |
' ON (a.coi_ce_image = c.ci_id_image AND a.coi_ce_utilisateur = c.ci_ce_utilisateur) '.
|
|
|
398 |
'WHERE b.identifiant = c.ci_ce_utilisateur '.
|
|
|
399 |
(($this->etreFluxAdmin()) ? '' : 'AND b.transmission = 1 ').
|
|
|
400 |
' AND ';
|
|
|
401 |
|
603 |
jpm |
402 |
if ($this->estUneRechercheGenerale()) {
|
593 |
aurelien |
403 |
$chaine_requete = $_GET['recherche'];
|
714 |
delphine |
404 |
$requete .= $this->creerSousRequeteRechercheGenerale($chaine_requete);
|
593 |
aurelien |
405 |
} else {
|
|
|
406 |
$criteres = $this->traiterCriteresMultiples($_GET) ;
|
714 |
delphine |
407 |
if (!empty($criteres)) {
|
|
|
408 |
$requete .= $this->creerSousRequeteRechercheParCriteres($criteres);
|
1269 |
jpm |
409 |
}
|
593 |
aurelien |
410 |
}
|
750 |
delphine |
411 |
$requete = str_replace(' AND ) ',' ', $requete);
|
603 |
jpm |
412 |
$requete = rtrim($requete, 'AND ');
|
1269 |
jpm |
413 |
$requete .= ' ORDER BY '.(isset($this->orderby) && (!is_null($this->orderby)) ? $this->orderby :
|
710 |
delphine |
414 |
'c.ci_meta_date_ajout DESC').' '."LIMIT $this->start,$this->limit ";
|
593 |
aurelien |
415 |
$elements = $this->executerRequete($requete);
|
|
|
416 |
|
|
|
417 |
// Création du contenu
|
|
|
418 |
if ($elements != false && count($elements) > 0) {
|
|
|
419 |
$contenu = $this->executerService($elements);
|
|
|
420 |
} else {
|
750 |
delphine |
421 |
$this->messages[] = "Aucune image disponible.";
|
593 |
aurelien |
422 |
}
|
1269 |
jpm |
423 |
|
593 |
aurelien |
424 |
return $contenu;
|
|
|
425 |
}
|
1269 |
jpm |
426 |
|
593 |
aurelien |
427 |
private function creerSousRequeteRechercheParCriteres($criteres) {
|
|
|
428 |
$requete = '';
|
603 |
jpm |
429 |
foreach ($criteres as $pair) {
|
|
|
430 |
$nom_valeur = explode("=",$pair);
|
1269 |
jpm |
431 |
if (count($nom_valeur) != 0) {
|
710 |
delphine |
432 |
switch ($nom_valeur[0]) {
|
|
|
433 |
case "ci_limite" : $this->limite = $this->bdd->quote($nom_valeur[1]); break;
|
|
|
434 |
case "c.ci_numero_page" : $this->limite*$this->bdd->quote($nom_valeur[1]); break;
|
|
|
435 |
case "c.ci_meta_comment" : $mots_comment_liste = explode(" " , $nom_valeur[1]);
|
|
|
436 |
foreach($mots_comment_liste as $mot_comment) {
|
|
|
437 |
$mot_comment = trim($mot_comment) ;
|
|
|
438 |
$requete .= $nom_valeur[0].' LIKE '.$this->bdd->quote('%'.$mot_comment.'%').' AND ';
|
|
|
439 |
}
|
|
|
440 |
break;
|
1269 |
jpm |
441 |
case "c.ci_meta_date" :
|
710 |
delphine |
442 |
$nom_valeur[1] = str_replace('/', '-', $nom_valeur[1]);
|
|
|
443 |
if (preg_match('/(^[0-9]{2})-([0-9]{2})-([0-9]{4}$)/', $nom_valeur[1], $matches)) {
|
|
|
444 |
$nom_valeur[1] = $matches[3].'-'.$matches[2].'-'.$matches[1];
|
|
|
445 |
}
|
|
|
446 |
$requete .= $nom_valeur[0].'='.$this->bdd->quote($nom_valeur[1]).' AND '; break;
|
1269 |
jpm |
447 |
case "b.nom_ret" :
|
|
|
448 |
if ($nom_valeur[1] == "indetermine") $nom_valeur[1] = 'null';
|
710 |
delphine |
449 |
$requete .= ' ('.$nom_valeur[0].' LIKE "%'.$nom_valeur[1].'%" OR b.nom_sel LIKE "%'.
|
|
|
450 |
$nom_valeur[1].'%") AND '; break;
|
1269 |
jpm |
451 |
case "tag" : $requete .= $this->creerSousRequeteMotsCles($nom_valeur[1]); break;
|
|
|
452 |
case "projet" : $requete .= $this->creerSousRequeteProjet($nom_valeur[1]); break;
|
710 |
delphine |
453 |
default : $requete .= $nom_valeur[0].' = "'.$nom_valeur[1].'" AND '; break;
|
603 |
jpm |
454 |
}
|
593 |
aurelien |
455 |
}
|
|
|
456 |
}
|
603 |
jpm |
457 |
$requete = rtrim($requete,' AND ');
|
593 |
aurelien |
458 |
return $requete;
|
|
|
459 |
}
|
1269 |
jpm |
460 |
|
714 |
delphine |
461 |
private function creerSousRequeteMotsCles($mot_cle) {
|
741 |
delphine |
462 |
if (preg_match('/.*OU.*/', $mot_cle)) {
|
714 |
delphine |
463 |
$requete = $this->creerSousRequeteMotsClesOu($mot_cle);
|
|
|
464 |
} else if (preg_match('/.*ET.*/', $mot_cle)) {
|
|
|
465 |
$requete = $this->creerSousRequeteMotsClesEt($mot_cle);
|
1269 |
jpm |
466 |
} else {
|
714 |
delphine |
467 |
// Construction de la requête
|
1269 |
jpm |
468 |
$utilisateur = isset($_GET['utilisateur']) ? $this->bdd->quote($_GET['utilisateur']) : null;
|
|
|
469 |
$prerequete = 'SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire '.
|
|
|
470 |
'FROM cel_mots_cles_images '.
|
|
|
471 |
'WHERE cmc_id_mot_cle_general = '.$this->bdd->quote($this->encoderMotCle($mot_cle)).' '.
|
|
|
472 |
(isset($utilisateur) ? "AND cmc_id_proprietaire = $utilisateur " : '');
|
716 |
delphine |
473 |
$elements = $this->executerRequete($prerequete);
|
1269 |
jpm |
474 |
|
714 |
delphine |
475 |
if ($elements != false && count($elements) > 0) {
|
749 |
delphine |
476 |
$requete = ' ( ';
|
714 |
delphine |
477 |
foreach ($elements as $occurence) {
|
1269 |
jpm |
478 |
$requete .= '(ci_meta_mots_cles LIKE "%'.$occurence['cmc_id_mot_cle_utilisateur'].'%" '.
|
|
|
479 |
'AND ci_ce_utilisateur = '.$this->bdd->quote($occurence['cmc_id_proprietaire']).' ) OR ';
|
714 |
delphine |
480 |
}
|
750 |
delphine |
481 |
} else {
|
|
|
482 |
$requete = ' (ci_meta_mots_cles like "inexistant" OR';
|
|
|
483 |
}
|
714 |
delphine |
484 |
}
|
718 |
delphine |
485 |
$requete = rtrim($requete,' OR ').' ) AND ';
|
714 |
delphine |
486 |
return $requete;
|
|
|
487 |
}
|
1269 |
jpm |
488 |
|
714 |
delphine |
489 |
private function creerSousRequeteMotsClesOu($mot_cle) {
|
741 |
delphine |
490 |
$tab_mots_cles = explode('OU', $mot_cle);
|
714 |
delphine |
491 |
$where = '';
|
|
|
492 |
foreach ($tab_mots_cles as $mot) {
|
741 |
delphine |
493 |
$where .= 'cmc_id_mot_cle_general = '.$this->bdd->quote($this->encoderMotCle(trim($mot))).' OR ';
|
714 |
delphine |
494 |
}
|
|
|
495 |
$where = rtrim($where,' OR ');
|
1269 |
jpm |
496 |
|
714 |
delphine |
497 |
// Construction de la requête
|
1269 |
jpm |
498 |
$prerequete = "SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_images WHERE $where ";
|
714 |
delphine |
499 |
$elements = $this->executerRequete($prerequete);//print_r($elements);
|
|
|
500 |
if ($elements != false && count($elements) > 0) {
|
749 |
delphine |
501 |
$requete = ' ( ';
|
714 |
delphine |
502 |
foreach ($elements as $occurence) {
|
|
|
503 |
$requete .= '(ci_meta_mots_cles LIKE "%'.$occurence['cmc_id_mot_cle_utilisateur'].'%" AND ci_ce_utilisateur = '.
|
|
|
504 |
$this->bdd->quote($occurence['cmc_id_proprietaire']).' ) OR ';
|
|
|
505 |
}
|
750 |
delphine |
506 |
} else {
|
|
|
507 |
$requete = ' (ci_meta_mots_cles like "inexistant" OR';
|
714 |
delphine |
508 |
}
|
|
|
509 |
return $requete;
|
|
|
510 |
}
|
1269 |
jpm |
511 |
|
714 |
delphine |
512 |
private function creerSousRequeteMotsClesEt($mot_cle) {
|
|
|
513 |
$where = '';
|
|
|
514 |
$champs = 'a.cmc_id_proprietaire , ';
|
|
|
515 |
$table = '';
|
|
|
516 |
$i = "a"; $j = "a";
|
1269 |
jpm |
517 |
|
|
|
518 |
$tab_mots_cles = explode("ET", $mot_cle);
|
714 |
delphine |
519 |
foreach ($tab_mots_cles as $mot) {
|
|
|
520 |
$champs .= "$i.cmc_id_mot_cle_utilisateur as $i , ";
|
|
|
521 |
$table .= "cel_mots_cles_images $i , ";
|
741 |
delphine |
522 |
$where .= "$i.cmc_id_mot_cle_general = ".$this->bdd->quote($this->encoderMotCle(trim($mot))).' AND ';
|
714 |
delphine |
523 |
if ($i !== "a") {
|
|
|
524 |
$where .= " $i.cmc_id_proprietaire = ".$j.".cmc_id_proprietaire AND ";
|
|
|
525 |
$j++;
|
|
|
526 |
}
|
|
|
527 |
$i++;
|
|
|
528 |
}
|
1269 |
jpm |
529 |
$where = rtrim($where,' AND ');
|
|
|
530 |
$champs = rtrim($champs,' , ');
|
|
|
531 |
$table = rtrim($table,' , ');
|
|
|
532 |
|
714 |
delphine |
533 |
// Construction de la requête
|
1269 |
jpm |
534 |
$prerequete = "SELECT $champs FROM $table WHERE $where ";
|
|
|
535 |
$elements = $this->executerRequete($prerequete);
|
714 |
delphine |
536 |
if ($elements != false && count($elements) > 0) {
|
749 |
delphine |
537 |
$requete = ' ( ';
|
714 |
delphine |
538 |
foreach ($elements as $occurence) {
|
741 |
delphine |
539 |
$requete .= ' (';
|
714 |
delphine |
540 |
for ($j = 'a'; $j < $i; $j++) {
|
1269 |
jpm |
541 |
$requete .= 'ci_meta_mots_cles LIKE "%'.$occurence[$j].'%" AND ';
|
714 |
delphine |
542 |
}
|
716 |
delphine |
543 |
$requete .= ' ci_ce_utilisateur = '.$this->bdd->quote($occurence['cmc_id_proprietaire']).' ) OR ';
|
714 |
delphine |
544 |
}
|
750 |
delphine |
545 |
} else {
|
1269 |
jpm |
546 |
$requete = ' (ci_meta_mots_cles LIKE "inexistant" OR';
|
714 |
delphine |
547 |
}
|
|
|
548 |
return $requete;
|
1269 |
jpm |
549 |
}
|
|
|
550 |
|
750 |
delphine |
551 |
private function creerSousRequeteProjet($mot_cle) {
|
|
|
552 |
$requete = 'mots_cles like "inexistant" OR';
|
|
|
553 |
if (preg_match('/.*OU.*/', $mot_cle)) {
|
|
|
554 |
$requete = $this->creerSousRequeteProjetOu($mot_cle);
|
|
|
555 |
} else if (preg_match('/.*ET.*/', $mot_cle)) {
|
|
|
556 |
$requete = $this->creerSousRequeteProjetEt($mot_cle);
|
|
|
557 |
} else {
|
|
|
558 |
// Construction de la requête
|
|
|
559 |
$prerequete = 'SELECT * '.
|
|
|
560 |
'FROM cel_mots_cles_obs '.
|
1269 |
jpm |
561 |
'WHERE cmc_id_mot_cle_general = '.$this->bdd->quote($this->encoderMotCle($mot_cle));
|
750 |
delphine |
562 |
$elements = $this->executerRequete($prerequete);
|
|
|
563 |
if ($elements != false && count($elements) > 0) {
|
|
|
564 |
$requete = '';
|
|
|
565 |
foreach ($elements as $occurence) {
|
|
|
566 |
$requete .= '(mots_cles LIKE "%'.$occurence['cmc_id_mot_cle_utilisateur'].'%" AND identifiant = '.
|
1269 |
jpm |
567 |
$this->bdd->quote($occurence['cmc_id_proprietaire']).' ) OR ';
|
750 |
delphine |
568 |
}
|
|
|
569 |
}
|
|
|
570 |
}
|
|
|
571 |
$requete = rtrim($requete,' OR ').' AND ';
|
|
|
572 |
return $requete;
|
|
|
573 |
}
|
1269 |
jpm |
574 |
|
|
|
575 |
private function creerSousRequeteProjetOu($mot_cle) {
|
|
|
576 |
$requete = 'mots_cles like "inexistant" OR';
|
750 |
delphine |
577 |
$tab_mots_cles = explode('OU', $mot_cle);
|
|
|
578 |
$where = '';
|
|
|
579 |
foreach ($tab_mots_cles as $mot) {
|
|
|
580 |
$where .= 'cmc_id_mot_cle_general = '.$this->bdd->quote($this->encoderMotCle(trim($mot))).' OR ';
|
|
|
581 |
}
|
|
|
582 |
$where = rtrim($where,' OR ');
|
1269 |
jpm |
583 |
|
750 |
delphine |
584 |
// Construction de la requête
|
1269 |
jpm |
585 |
$prerequete = "SELECT cmc_id_mot_cle_utilisateur, cmc_id_proprietaire FROM cel_mots_cles_obs WHERE $where ";
|
750 |
delphine |
586 |
$elements = $this->executerRequete($prerequete);
|
|
|
587 |
if ($elements != false && count($elements) > 0) {
|
|
|
588 |
$requete = '';
|
|
|
589 |
foreach ($elements as $occurence) {
|
|
|
590 |
$requete .= '(mots_cles LIKE "%'.$occurence['cmc_id_mot_cle_utilisateur'].'%" AND identifiant = '.
|
|
|
591 |
$this->bdd->quote($occurence['cmc_id_proprietaire']).' ) OR ';
|
|
|
592 |
}
|
|
|
593 |
}
|
|
|
594 |
return $requete;
|
|
|
595 |
}
|
1269 |
jpm |
596 |
|
750 |
delphine |
597 |
private function creerSousRequeteProjetEt($mot_cle) {
|
|
|
598 |
$requete = 'mots_cles like "inexistant" OR';
|
|
|
599 |
$where = '';
|
|
|
600 |
$champs = 'a.cmc_id_proprietaire , ';
|
|
|
601 |
$table = '';
|
|
|
602 |
$i = "a"; $j = "a";
|
1269 |
jpm |
603 |
|
|
|
604 |
$tab_mots_cles = explode("ET", $mot_cle);
|
750 |
delphine |
605 |
foreach ($tab_mots_cles as $mot) {
|
|
|
606 |
$champs .= "$i.cmc_id_mot_cle_utilisateur as $i , ";
|
|
|
607 |
$table .= "cel_mots_cles_obs $i , ";
|
|
|
608 |
$where .= "$i.cmc_id_mot_cle_general = ".$this->bdd->quote($this->encoderMotCle(trim($mot))).' AND ';
|
|
|
609 |
if ($i !== "a") {
|
|
|
610 |
$where .= " $i.cmc_id_proprietaire = ".$j.".cmc_id_proprietaire AND ";
|
|
|
611 |
$j++;
|
|
|
612 |
}
|
|
|
613 |
$i++;
|
|
|
614 |
}
|
1269 |
jpm |
615 |
$where = rtrim($where, ' AND ');
|
|
|
616 |
$champs = rtrim($champs, ' , ');
|
|
|
617 |
$table = rtrim($table, ' , ');
|
|
|
618 |
|
750 |
delphine |
619 |
// Construction de la requête
|
1269 |
jpm |
620 |
$prerequete = "SELECT $champs FROM $table WHERE $where ";
|
750 |
delphine |
621 |
$elements = $this->executerRequete($prerequete);//print_r($elements);
|
|
|
622 |
if ($elements != false && count($elements) > 0) {
|
|
|
623 |
$requete = '';
|
|
|
624 |
foreach ($elements as $occurence) {
|
|
|
625 |
$requete = ' (';
|
|
|
626 |
for ($j = 'a'; $j < $i; $j++) {
|
|
|
627 |
$requete .= 'mots_cles like "%'.$occurence[$j].'%" AND ';
|
|
|
628 |
}
|
|
|
629 |
$requete .= ' identifiant = '.$this->bdd->quote($occurence['cmc_id_proprietaire']).' ) OR ';
|
|
|
630 |
}
|
|
|
631 |
}
|
|
|
632 |
return $requete;
|
|
|
633 |
}
|
1269 |
jpm |
634 |
|
593 |
aurelien |
635 |
private function creerSousRequeteRechercheGenerale($chaine_requete) {
|
603 |
jpm |
636 |
$requete = '';
|
1269 |
jpm |
637 |
if (trim($chaine_requete) != '') {
|
603 |
jpm |
638 |
$chaine_requete = strtolower($chaine_requete);
|
|
|
639 |
$chaine_requete = str_replace(' ', '_', $chaine_requete);
|
|
|
640 |
$requete = ' ('.
|
|
|
641 |
'b.nom_ret LIKE "'.$chaine_requete.'%"'.
|
|
|
642 |
' OR '.
|
|
|
643 |
'b.nom_sel LIKE "'.$chaine_requete.'%"'.
|
|
|
644 |
' OR '.
|
|
|
645 |
'b.location LIKE "'.$chaine_requete.'%" '.
|
|
|
646 |
' OR '.
|
|
|
647 |
'b.id_location LIKE "'.$chaine_requete.'%" '.
|
|
|
648 |
' OR '.
|
|
|
649 |
'c.ci_ce_utilisateur LIKE "'.$chaine_requete.'%" '.
|
|
|
650 |
') ';
|
593 |
aurelien |
651 |
}
|
|
|
652 |
return $requete;
|
|
|
653 |
}
|
1269 |
jpm |
654 |
|
593 |
aurelien |
655 |
private function estUneRechercheGenerale() {
|
|
|
656 |
return isset($_GET['recherche']);
|
|
|
657 |
}
|
1269 |
jpm |
658 |
|
593 |
aurelien |
659 |
private function traiterCriteresMultiples($tableau_criteres) {
|
|
|
660 |
$tableau_criteres_pour_bdd = array();
|
1269 |
jpm |
661 |
|
|
|
662 |
foreach ($tableau_criteres as $nom_critere => $valeur_critere) {
|
603 |
jpm |
663 |
if (isset($this->criteres[$nom_critere])) {
|
593 |
aurelien |
664 |
$tableau_criteres_pour_bdd[] = $this->criteres[$nom_critere].'='.$valeur_critere;
|
|
|
665 |
}
|
|
|
666 |
}
|
|
|
667 |
return $tableau_criteres_pour_bdd;
|
|
|
668 |
}
|
|
|
669 |
|
523 |
jpm |
670 |
private function creerDescriptionComplet($donnees, $item) {
|
1336 |
jpm |
671 |
$auteur = $this->getIntituleAuteur($donnees['ci_ce_utilisateur']);
|
1269 |
jpm |
672 |
$auteur_mail = $donnees['ci_ce_utilisateur'];
|
|
|
673 |
|
525 |
jpm |
674 |
$id_img = $donnees['ci_id_image'];
|
528 |
jpm |
675 |
$nom_fichier = $donnees['ci_nom_original'];
|
628 |
jpm |
676 |
$url_img = $this->getUrlImage($donnees['ci_id_image'], 'CS');
|
630 |
jpm |
677 |
$url_img_normale = $this->getUrlImage($donnees['ci_id_image'], 'XL');
|
528 |
jpm |
678 |
$mots_cles_image = $this->decoderMotsClesImg($donnees['identifiant'], $donnees['ci_meta_mots_cles']);
|
|
|
679 |
$note = ($donnees['ci_note_image'] +1).'/5';
|
|
|
680 |
$commentaire_img = $donnees['ci_meta_comment'];
|
1269 |
jpm |
681 |
|
525 |
jpm |
682 |
$id_obs = $donnees['id'];
|
528 |
jpm |
683 |
$famille = $donnees['famille'];
|
|
|
684 |
$nom_saisi = $donnees['nom_sel'];
|
|
|
685 |
$nom_retenu = $donnees['nom_ret'];
|
525 |
jpm |
686 |
$mots_cles_obs = $this->decoderMotsClesObs($donnees['identifiant'], $donnees['mots_cles']);
|
528 |
jpm |
687 |
$lieu = $donnees['location'].' ('.$donnees['id_location'].') > '.$donnees['lieudit'].' > '.$donnees['station'];
|
|
|
688 |
$milieu = $donnees['milieu'];
|
525 |
jpm |
689 |
$coordonnees = ($this->etreNull($donnees['coord_x']) && $this->etreNull($donnees['coord_y'])) ? '' : $donnees['coord_x'].'/'.$donnees['coord_y'];
|
528 |
jpm |
690 |
$commentaire_obs = $donnees['commentaire'];
|
525 |
jpm |
691 |
$date_observation = $this->formaterDate($donnees['date_observation'], '%A %d %B %Y');
|
|
|
692 |
$date_transmission = $this->formaterDate($donnees['date_transmission']);
|
|
|
693 |
$date_modification = $this->formaterDate($donnees['date_modification']);
|
|
|
694 |
$date_creation = $this->formaterDate($donnees['date_creation']);
|
|
|
695 |
$transmission = $donnees['transmission'] == 1 ? "oui ($date_transmission)" : 'non';
|
1269 |
jpm |
696 |
|
525 |
jpm |
697 |
$description = '<style>.champ{color:grey} .gauche{float:left;padding:0 20px 0 0;} ul{list-style-type:none;padding:0;}</style>'.
|
603 |
jpm |
698 |
'<h2>'.(!$this->etreNull($id_obs) ? "Image #$id_img liée à l'observation #$id_obs" : "Image #$id_img non liée à une observation.").'</h2>'.
|
630 |
jpm |
699 |
'<a href="'.$url_img_normale.'"><img class="gauche" src="'.$url_img.'" alt="'.$nom_fichier.'" /></a>'.
|
525 |
jpm |
700 |
'<div class="gauche">'.
|
|
|
701 |
'<h3>'.'Image'.'</h3>'.
|
|
|
702 |
'<ul>'.
|
630 |
jpm |
703 |
'<li>'.'<span class="champ">URL :</span> <a href="'.$url_img_normale.'" onclick="javascript:window.open(this.href);return false;">'.$url_img_normale.'</a></li>'.
|
525 |
jpm |
704 |
'<li>'.'<span class="champ">Importée le :</span> '.$item['date_maj_simple'].'</li>'.
|
|
|
705 |
'<li>'.'<span class="champ">Par :</span> '.
|
1269 |
jpm |
706 |
(($this->etreFluxAdmin()) ? '<a href="mailto:'.$auteur_mail.'">'.$auteur.'</a>' : $auteur).
|
525 |
jpm |
707 |
'</li>'.
|
528 |
jpm |
708 |
'<li>'.'<span class="champ">Nom du fichier :</span> '.$nom_fichier.'</li>'.
|
|
|
709 |
'<li>'.'<span class="champ">Note qualité :</span> '.$note.'</li>'.
|
|
|
710 |
'<li>'.'<span class="champ">Commentaires :</span> '.$commentaire_img.'</li>'.
|
525 |
jpm |
711 |
'<li>'.'<span class="champ">Mots-clés :</span> '.implode(', ', $mots_cles_image).'</li>'.
|
|
|
712 |
'</ul>'.
|
603 |
jpm |
713 |
'</div>';
|
525 |
jpm |
714 |
// TODO : ajouter le champ commentaire EXIF.
|
603 |
jpm |
715 |
if (! $this->etreNull($id_obs)) {
|
1269 |
jpm |
716 |
$description .=
|
603 |
jpm |
717 |
'<div class="gauche">'.
|
|
|
718 |
'<h3>'.'Observation'.'</h3>'.
|
|
|
719 |
'<ul>'.
|
|
|
720 |
'<li>'.'<span class="champ">Famille :</span> '.$famille.'</li>'.
|
|
|
721 |
'<li>'.'<span class="champ">Nom saisi :</span> '.$nom_saisi.'</li>'.
|
|
|
722 |
'<li>'.'<span class="champ">Nom retenu :</span> '.$nom_retenu.'</li>'.
|
|
|
723 |
'<li>'.'<span class="champ">Observée le :</span> '.$date_observation.'</li>'.
|
|
|
724 |
'<li>'.'<span class="champ">Lieu :</span> '.$lieu.'</li>'.
|
|
|
725 |
'<li>'.'<span class="champ">Milieu :</span> '.$milieu.'</li>'.
|
|
|
726 |
(($this->etreFluxAdmin()) ? '<li><span class="champ">Coordonnées (Lat/Long) :</span> '.$coordonnees.'</li>' : '').
|
|
|
727 |
'<li>'.'<span class="champ">Commentaire :</span> '.$commentaire_obs.'</li>'.
|
|
|
728 |
'<li>'.'<span class="champ">Mots-clés :</span> '.implode(', ', $mots_cles_obs).'</li>'.
|
|
|
729 |
(($this->etreFluxAdmin()) ? '<li><span class="champ">Transmis (= public) :</span> '.$transmission.'</li>' : '').
|
|
|
730 |
'<li><span class="champ">Modifiée le :</span> '.$date_modification.'</li>'.
|
|
|
731 |
'<li><span class="champ">Créée le :</span> '.$date_creation.'</li>'.
|
|
|
732 |
'</ul>'.
|
|
|
733 |
'</div>';
|
|
|
734 |
}
|
522 |
jpm |
735 |
$description = $this->nettoyerTexte($description);
|
|
|
736 |
return $description;
|
416 |
aurelien |
737 |
}
|
1269 |
jpm |
738 |
|
525 |
jpm |
739 |
private function getServiceParMotsCles() {
|
742 |
delphine |
740 |
$infos=array();
|
|
|
741 |
$infos[0]['num_nom_sel'] = '';
|
|
|
742 |
$infos[0]['ci_meta_date_ajout'] = '2011-06-28';
|
|
|
743 |
$donnees = $this->construireDonneesCommunesAuFlux($infos);
|
|
|
744 |
$donnees['items'][0]['guid'] = 0;
|
|
|
745 |
$donnees['items'][0]['description'] = 'Ce flux est devenu obsolète. Veuillez utiliser le flux '.
|
|
|
746 |
'<b>http://www.tela-botanica.org/eflore/cel2/jrest/CelSyndicationImage/multicriteres/atom?tag=';
|
|
|
747 |
if (isset($this->parametres[0])) {
|
|
|
748 |
$donnees['items'][0]['description'] .= $this->parametres[0].'</b>';
|
525 |
jpm |
749 |
} else {
|
1269 |
jpm |
750 |
$donnees['items'][0]['description'] .= '</b>';
|
525 |
jpm |
751 |
}
|
742 |
delphine |
752 |
$donnees['items'][0]['titre'] = '';
|
|
|
753 |
$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
|
525 |
jpm |
754 |
return $contenu;
|
|
|
755 |
}
|
1269 |
jpm |
756 |
|
525 |
jpm |
757 |
private function getServiceParCommune() {
|
742 |
delphine |
758 |
$infos=array();
|
|
|
759 |
$infos[0]['num_nom_sel'] = '';
|
|
|
760 |
$infos[0]['ci_meta_date_ajout'] = '2011-06-28';
|
|
|
761 |
$donnees = $this->construireDonneesCommunesAuFlux($infos);
|
|
|
762 |
$donnees['items'][0]['guid'] = 0;
|
|
|
763 |
$donnees['items'][0]['description'] = 'Ce flux est devenu obsolète. Veuillez utiliser le flux '.
|
|
|
764 |
'<b>http://www.tela-botanica.org/eflore/cel2/jrest/CelSyndicationImage/multicriteres/atom?commune=';
|
|
|
765 |
if (isset($this->parametres[0])) {
|
|
|
766 |
$donnees['items'][0]['description'] .= $this->parametres[0].'</b>';
|
525 |
jpm |
767 |
} else {
|
1269 |
jpm |
768 |
$donnees['items'][0]['description'] .= '</b>';
|
525 |
jpm |
769 |
}
|
742 |
delphine |
770 |
$donnees['items'][0]['titre'] = '';
|
|
|
771 |
$contenu = Cel::traiterSquelettePhp($this->squelette, $donnees);
|
525 |
jpm |
772 |
return $contenu;
|
|
|
773 |
}
|
1336 |
jpm |
774 |
|
|
|
775 |
private function getIntituleAuteur($courriel) {
|
|
|
776 |
$courriel = strtolower($courriel);
|
|
|
777 |
$intitule = $this->auteurs[$courriel];
|
|
|
778 |
return $intitule;
|
|
|
779 |
}
|
1269 |
jpm |
780 |
}
|