Line 201... |
Line 201... |
201 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
201 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
202 |
$widget['squelette'] = 'contact';
|
202 |
$widget['squelette'] = 'contact';
|
Line 203... |
Line 203... |
203 |
|
203 |
|
204 |
return $widget;
|
204 |
return $widget;
|
205 |
}
|
- |
|
206 |
|
205 |
}
|
207 |
|
206 |
|
208 |
private function executerPhoto() {
|
207 |
private function executerPhoto() {
|
Line 209... |
Line 208... |
209 |
$widget = null;
|
208 |
$widget = null;
|
210 |
|
209 |
|
Line 211... |
Line 210... |
211 |
$this->parametres['start'] = $this->parametres['start'] ?? self::START_DEFAUT;
|
210 |
$this->parametres['start'] = $this->parametres['start'] ?? self::START_DEFAUT;
|
212 |
$this->parametres['limit'] = $this->parametres['limit'] ?? self::LIMIT_DEFAUT;
|
211 |
$this->parametres['limit'] = $this->parametres['limit'] ?? self::LIMIT_DEFAUT;
|
213 |
|
212 |
|
214 |
extract($this->parametres);
|
213 |
extract($this->parametres);
|
215 |
|
214 |
|
216 |
$hasTriedValueInConfig = false;
|
215 |
$hasTriedValueInConfig = false;
|
217 |
while (!isset($vignette) || !preg_match('/^[0-9]+,[0-9]+$/', $vignette)) {
|
216 |
while (!isset($vignette) || !preg_match('/^[0-9]+,[0-9]+$/', $vignette)) {
|
- |
|
217 |
$vignette = (!$hasTriedValueInConfig) ? $this->config['photo']['vignette'] : self::VIGNETTE_DEFAULT;
|
218 |
$vignette = (!$hasTriedValueInConfig) ? $this->config['photo']['vignette'] : self::VIGNETTE_DEFAULT;
|
218 |
$hasTriedValueInConfig = true;
|
219 |
$hasTriedValueInConfig = true;
|
219 |
}
|
Line 220... |
Line 220... |
220 |
}
|
220 |
|
221 |
$id = '-'.(isset($id) ? $id : '1');
|
221 |
$id = '-'.(isset($id) ? $id : '1');
|
222 |
$titre = isset($titre) ? htmlentities(rawurldecode($titre)) : '';
|
222 |
$titre = isset($titre) ? htmlentities(rawurldecode($titre)) : '';
|
223 |
|
- |
|
224 |
$icone_rss = (isset($_GET['rss']) && $_GET['rss'] != 1) ? false : true;
|
- |
|
225 |
$utilise_fancybox = (isset($_GET['mode_zoom']) && $_GET['mode_zoom'] != 'fancybox') ? false : true;
|
- |
|
226 |
|
223 |
|
227 |
list($colonne, $ligne) = explode(',', $vignette);
|
- |
|
228 |
$extra = (isset($extra) && $extra == 0) ? false : (!$this->config['photo']['extraActif'] ? false : ($colonne == 1 || $ligne == 1 ? false : true));
|
- |
|
229 |
|
- |
|
230 |
$champ_recherche = $champ_recherche ? $this->obtenirBooleen($champ_recherche) : ($this->config['photo']['champRecherche'] ? $this->obtenirBooleen($this->config['photo']['champRecherche']) : false) ;
|
- |
|
231 |
$max_photo = $colonne * $ligne;
|
- |
|
232 |
if ( $extra && 2 == $colonne ) {
|
- |
|
233 |
$max_photo = $max_photo - 1;
|
- |
|
234 |
} elseif ( $extra && 2 < $colonne ) {
|
- |
|
235 |
$max_photo = $max_photo - 3;
|
- |
|
236 |
}
|
- |
|
237 |
$limit = $limit < $max_photo ? $limit : $max_photo;
|
- |
|
238 |
$this->parametres['limit'] = $limit;
|
- |
|
239 |
$parametresTraites = $this->traiterParametres();
|
224 |
$icone_rss = (isset($_GET['rss']) && $_GET['rss'] != 1) ? false : true;
|
240 |
$this->flux_rss_url .= $parametresTraites;
|
- |
|
241 |
$url = $this->service_images_url.(!empty($parametresTraites) ? $parametresTraites.'&' : '?');
|
- |
|
242 |
$json = $this->getDao()->consulter($url);
|
225 |
$utilise_fancybox = (isset($_GET['mode_zoom']) && $_GET['mode_zoom'] != 'fancybox') ? false : true;
|
243 |
|
- |
|
244 |
if (empty($json) || !strpos($json,'images') ) {
|
226 |
|
245 |
$this->messages[] = "L'URI suivante est invalide : $this->service_images_url.\n".
|
227 |
$champ_recherche = $champ_recherche ? $this->obtenirBooleen($champ_recherche) : ($this->config['photo']['champRecherche'] ? $this->obtenirBooleen($this->config['photo']['champRecherche']) : false) ;
|
246 |
"Veuillez vérifier les paramêtres indiqués et la présence d'images associées.";
|
228 |
|
247 |
|
- |
|
248 |
} else {
|
- |
|
249 |
$tableau = json_decode($json, true);
|
229 |
// Si la config champ_recherche est désactivé -> affichage mode e-flore
|
250 |
|
- |
|
251 |
if (empty($tableau['total']) || empty($tableau['images'])) {
|
- |
|
252 |
$this->messages[] = 'Aucune photo ne correspond à vos critères';
|
230 |
if (!$champ_recherche) {
|
253 |
} else {
|
- |
|
254 |
|
- |
|
255 |
$parametres_photo_suivante = $parametres_photo_precedente = $this->parametres;
|
231 |
$vignette ='5,2';
|
256 |
$parametres_photo_suivante['start'] = $start + $limit;
|
232 |
|
257 |
$parametres_photo_precedente['start'] = 0 < $start - $limit ? $start - $limit : 0;
|
233 |
$tags = [
|
258 |
|
- |
|
259 |
$widget['donnees']['total'] = $tableau['total'];
|
234 |
'fleur',
|
260 |
$widget['donnees']['id'] = $id;
|
- |
|
261 |
$widget['donnees']['titre'] = $titre;
|
- |
|
262 |
$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
|
- |
|
263 |
$widget['donnees']['url_widget'] = $this->url_widget;
|
- |
|
264 |
$widget['donnees']['url_widget_photos_suivantes'] = $this->url_widget.'?'.http_build_query($parametres_photo_suivante);
|
235 |
'feuille',
|
- |
|
236 |
'fruit',
|
265 |
$widget['donnees']['url_widget_photos_precedente'] = $this->url_widget.'?'.http_build_query($parametres_photo_precedente);
|
237 |
'ecorce',
|
266 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
238 |
'port',
|
267 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
239 |
'rameau',
|
268 |
$widget['donnees']['colonne'] = $colonne;
|
240 |
];
|
269 |
$widget['donnees']['ligne'] = $ligne;
|
- |
|
270 |
$widget['donnees']['extra_actif'] = $extra;
|
- |
|
271 |
$widget['donnees']['icone_rss'] = $icone_rss;
|
- |
|
272 |
$widget['donnees']['champ_recherche'] = $champ_recherche;
|
- |
|
273 |
$widget['donnees']['start'] = $start;
|
- |
|
274 |
$widget['donnees']['limit'] = $limit;
|
- |
|
275 |
$widget['donnees']['utilise_fancybox'] = $utilise_fancybox;
|
- |
|
276 |
$widget['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
|
- |
|
277 |
$widget['donnees']['filtres'] = $this->parametres;
|
- |
|
278 |
|
- |
|
279 |
$num = 0;
|
- |
|
280 |
$galerie_id = md5(http_build_query($_GET));
|
- |
|
281 |
$widget['donnees']['galerie_id'] = $galerie_id;
|
- |
|
282 |
|
- |
|
283 |
session_start();
|
- |
|
284 |
$_SESSION[$galerie_id]['max_photo'] = $max_photo;
|
- |
|
285 |
$_SESSION[$galerie_id]['start'] = $start;
|
- |
|
286 |
|
- |
|
287 |
foreach ($tableau['images'] as $key => $image) {
|
- |
|
288 |
if ($key == $max_photo) {
|
- |
|
289 |
break;
|
- |
|
290 |
}
|
- |
|
291 |
$auteurTruncatedEmail = $this->tronquerCourriel($image['utilisateur']['mail_utilisateur']);
|
- |
|
292 |
$auteur = trim($image['utilisateur']['nom_utilisateur']) ? $image['utilisateur']['nom_utilisateur'] : $auteurTruncatedEmail;
|
- |
|
293 |
|
- |
|
294 |
$item = $image;
|
- |
|
295 |
// Formatage date
|
- |
|
296 |
$item['date_photo'] = $image['date_photo'] ?? $image['obs']['date_obs'];
|
- |
|
297 |
$item['date_redige'] = strftime('%A %d %B %Y', strtotime($item['date_photo']));
|
- |
|
298 |
$item['date'] = date_format(date_create($item['date_photo']),"d/m/Y");
|
- |
|
299 |
$item['lien'] = sprintf($this->eflore_url_tpl, $image['obs']['nom_referentiel'], $image['obs']['nom_sel_nn']);
|
- |
|
300 |
$image['url_photo'] = preg_replace('/,/', "", $image['url_photo']);
|
- |
|
301 |
$item['url_tpl'] = preg_replace('/(O|XS|[SML]|X(?:[23]|)L|CR(?:|X2)S|C(?:|X)S)$/', '%s.jpg',$image['url_photo']);
|
- |
|
302 |
// Formatage titre
|
- |
|
303 |
|
- |
|
304 |
$item['titre'] = $image['obs']['nom_sel'].' [nn'.$image['obs']['nom_sel_nn'].'] par '.$auteur.' le '
|
- |
|
305 |
.date_format(date_create($image['obs']['date_obs']),"d/m/Y").' - '.$image['obs']['localisation'];
|
- |
|
306 |
|
- |
|
307 |
$item['id_photo_formate'] = sprintf('%09d', $image['id_photo']);
|
- |
|
308 |
$item['urlProfil'] = sprintf($this->config['photo']['tbProfilUrlTpl'], $image['utilisateur']['id_utilisateur'] );
|
- |
|
309 |
// Ajout aux items et si première photo à extra
|
- |
|
310 |
if ($key == 0) {
|
- |
|
311 |
$widget['donnees']['extra'] = $item;
|
- |
|
312 |
|
- |
|
313 |
}
|
- |
|
314 |
|
- |
|
315 |
$widget['donnees']['items'][$num++] = $item;
|
- |
|
316 |
$url_galerie_popup = sprintf($item['url_tpl'],'O');
|
- |
|
317 |
$image_size = getimagesize($url_galerie_popup);
|
- |
|
318 |
$item['width'] = $image_size[0];
|
- |
|
319 |
$item['height'] = $image_size[1];
|
- |
|
320 |
|
- |
|
321 |
// Récupération des votes pictoflora
|
- |
|
322 |
$item['votes'] = $this->getVotes($item);
|
- |
|
323 |
|
- |
|
324 |
$_SESSION[$galerie_id]['infos_images'][$url_galerie_popup] = $item;
|
241 |
foreach ($tags as $tag) {
|
- |
|
242 |
$widget = $this->getImages($vignette, $extra, $limit, $id, $titre, $icone_rss, $utilise_fancybox,
|
- |
|
243 |
true, $tag, $widget,$champ_recherche);
|
- |
|
244 |
$widget['donnees']['champ_recherche'] = $champ_recherche;
|
- |
|
245 |
}
|
325 |
}
|
246 |
$widget['donnees']['tagToDisplay'] = 'fleur';
|
326 |
|
247 |
} else {
|
327 |
$widget['squelette'] = 'photo';
|
248 |
$widget = $this->getImages($vignette, $extra, $limit, $id, $titre, $icone_rss, $utilise_fancybox,false, 'non_eflore', $widget,$champ_recherche);
|
328 |
}
|
249 |
$widget['donnees']['champ_recherche'] = $champ_recherche;
|
Line 329... |
Line 250... |
329 |
}
|
250 |
}
|
330 |
|
251 |
|
Line 472... |
Line 393... |
472 |
|
393 |
|
473 |
fclose($flux);
|
394 |
fclose($flux);
|
474 |
}
|
395 |
}
|
475 |
return $contenu;
|
396 |
return $contenu;
|
- |
|
397 |
}
|
- |
|
398 |
|
- |
|
399 |
public function formaterDate($item, $image){
|
- |
|
400 |
$item['date_photo'] = $image['date_photo'] ?? $image['obs']['date_obs'];
|
- |
|
401 |
$item['date_redige'] = strftime('%A %d %B %Y', strtotime($item['date_photo']));
|
- |
|
402 |
$item['date'] = date_format(date_create($item['date_photo']),"d/m/Y");
|
- |
|
403 |
$item['lien'] = sprintf($this->eflore_url_tpl, $image['obs']['nom_referentiel'], $image['obs']['nom_sel_nn']);
|
- |
|
404 |
$image['url_photo'] = preg_replace('/,/', "", $image['url_photo']);
|
- |
|
405 |
$item['url_tpl'] = preg_replace('/(O|XS|[SML]|X(?:[23]|)L|CR(?:|X2)S|C(?:|X)S)$/', '%s.jpg',$image['url_photo']);
|
- |
|
406 |
|
- |
|
407 |
return $item;
|
- |
|
408 |
}
|
- |
|
409 |
|
- |
|
410 |
public function formaterTitre($item, $image, $auteur){
|
- |
|
411 |
$item['titre'] = $image['obs']['nom_sel'].' [nn'.$image['obs']['nom_sel_nn'].'] par '.$auteur.' le '
|
- |
|
412 |
.date_format(date_create($image['obs']['date_obs']),"d/m/Y").' - '.$image['obs']['localisation'];
|
- |
|
413 |
|
- |
|
414 |
$item['id_photo_formate'] = sprintf('%09d', $image['id_photo']);
|
- |
|
415 |
$item['urlProfil'] = sprintf($this->config['photo']['tbProfilUrlTpl'], $image['utilisateur']['id_utilisateur'] );
|
- |
|
416 |
return $item;
|
- |
|
417 |
}
|
- |
|
418 |
|
- |
|
419 |
private function getImages($vignette, $extra, $limit, $id, $titre, $icone_rss, $utilise_fancybox, $fromEflore,
|
- |
|
420 |
$tag, $widget, $champ_recherche){
|
- |
|
421 |
if ($fromEflore){
|
- |
|
422 |
$this->parametres['tag'] = $tag;
|
- |
|
423 |
}
|
- |
|
424 |
list($colonne, $ligne) = explode(',', $vignette);
|
- |
|
425 |
$extra = (isset($extra) && $extra == 0) ? false : (!$this->config['photo']['extraActif'] ? false : ($colonne == 1 || $ligne == 1 ? false : true));
|
- |
|
426 |
|
- |
|
427 |
$max_photo = $colonne * $ligne;
|
- |
|
428 |
if ( $extra && 2 == $colonne ) {
|
- |
|
429 |
$max_photo = $max_photo - 1;
|
- |
|
430 |
} elseif ( $extra && 2 < $colonne ) {
|
- |
|
431 |
$max_photo = $max_photo - 3;
|
- |
|
432 |
}
|
- |
|
433 |
|
- |
|
434 |
$limit = $limit < $max_photo ? $limit : $max_photo;
|
- |
|
435 |
$this->parametres['limit'] = $limit;
|
- |
|
436 |
$parametresTraites = $this->traiterParametres();
|
- |
|
437 |
$this->flux_rss_url .= $parametresTraites;
|
- |
|
438 |
$url = $this->service_images_url.(!empty($parametresTraites) ? $parametresTraites.'&' : '?');
|
- |
|
439 |
$json = $this->getDao()->consulter($url);
|
- |
|
440 |
if ($fromEflore) {
|
- |
|
441 |
unset($this->parametres['tag']);
|
- |
|
442 |
}
|
- |
|
443 |
if (empty($json) || !strpos($json,'images') ) {
|
- |
|
444 |
$this->messages[] = "L'URI suivante est invalide : $this->service_images_url.\n".
|
- |
|
445 |
"Veuillez vérifier les paramêtres indiqués et la présence d'images associées.";
|
- |
|
446 |
|
- |
|
447 |
} else {
|
- |
|
448 |
$tableau = json_decode($json, true);
|
- |
|
449 |
|
- |
|
450 |
if (empty($tableau['total']) || empty($tableau['images'])) {
|
- |
|
451 |
$this->messages[] = 'Aucune photo ne correspond à vos critères';
|
- |
|
452 |
} else {
|
- |
|
453 |
|
- |
|
454 |
$parametres_photo_suivante = $parametres_photo_precedente = $this->parametres;
|
- |
|
455 |
$parametres_photo_suivante['start'] = $start + $limit;
|
- |
|
456 |
$parametres_photo_precedente['start'] = 0 < $start - $limit ? $start - $limit : 0;
|
- |
|
457 |
|
- |
|
458 |
$widget['donnees']['total'] = $tableau['total'];
|
- |
|
459 |
$widget['donnees']['id'] = $id;
|
- |
|
460 |
$widget['donnees']['titre'] = $titre;
|
- |
|
461 |
$widget['donnees']['flux_rss_url'] = $this->flux_rss_url;
|
- |
|
462 |
$widget['donnees']['url_widget'] = $this->url_widget;
|
- |
|
463 |
$widget['donnees']['url_widget_photos_suivantes'] = $this->url_widget.'?'.http_build_query($parametres_photo_suivante);
|
- |
|
464 |
$widget['donnees']['url_widget_photos_precedente'] = $this->url_widget.'?'.http_build_query($parametres_photo_precedente);
|
- |
|
465 |
$widget['donnees']['url_css'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/css/');
|
- |
|
466 |
$widget['donnees']['url_js'] = sprintf($this->config['chemins']['baseURLAbsoluDyn'], 'modules/photo/squelettes/js/');
|
- |
|
467 |
$widget['donnees']['colonne'] = $colonne;
|
- |
|
468 |
$widget['donnees']['ligne'] = $ligne;
|
- |
|
469 |
$widget['donnees']['extra_actif'] = $extra;
|
- |
|
470 |
$widget['donnees']['icone_rss'] = $icone_rss;
|
- |
|
471 |
$widget['donnees']['champ_recherche'] = $champ_recherche;
|
- |
|
472 |
$widget['donnees']['start'] = $start;
|
- |
|
473 |
$widget['donnees']['limit'] = $limit;
|
- |
|
474 |
$widget['donnees']['utilise_fancybox'] = $utilise_fancybox;
|
- |
|
475 |
$widget['donnees']['prod'] = ($this->config['parametres']['modeServeur'] === 'prod');
|
- |
|
476 |
$widget['donnees']['filtres'] = $this->parametres;
|
- |
|
477 |
|
- |
|
478 |
$num = 0;
|
- |
|
479 |
$galerie_id = md5(http_build_query($_GET));
|
- |
|
480 |
$widget['donnees']['galerie_id'] = $galerie_id;
|
- |
|
481 |
|
- |
|
482 |
session_start();
|
- |
|
483 |
$_SESSION[$galerie_id]['max_photo'] = $max_photo;
|
- |
|
484 |
$_SESSION[$galerie_id]['start'] = $start;
|
- |
|
485 |
|
- |
|
486 |
foreach ($tableau['images'] as $key => $image) {
|
- |
|
487 |
if ($key == $max_photo) {
|
- |
|
488 |
break;
|
- |
|
489 |
}
|
- |
|
490 |
$auteurTruncatedEmail = $this->tronquerCourriel($image['utilisateur']['mail_utilisateur']);
|
- |
|
491 |
$auteur = trim($image['utilisateur']['nom_utilisateur']) ? $image['utilisateur']['nom_utilisateur'] : $auteurTruncatedEmail;
|
- |
|
492 |
|
- |
|
493 |
$item = $image;
|
- |
|
494 |
|
- |
|
495 |
$item = $this->formaterDate($item, $image);
|
- |
|
496 |
|
- |
|
497 |
$item = $this->formaterTitre($item, $image, $auteur);
|
- |
|
498 |
|
- |
|
499 |
$item['tag_eflore'] = $tag;
|
- |
|
500 |
|
- |
|
501 |
// Ajout aux items et si première photo à extra
|
- |
|
502 |
if ($key == 0) {
|
- |
|
503 |
$widget['donnees']['extra'] = $item;
|
- |
|
504 |
}
|
- |
|
505 |
|
- |
|
506 |
$widget['donnees']['items'][$tag][$num++] = $item;
|
- |
|
507 |
$url_galerie_popup = sprintf($item['url_tpl'],'O');
|
- |
|
508 |
$image_size = getimagesize($url_galerie_popup);
|
- |
|
509 |
$item['width'] = $image_size[0];
|
- |
|
510 |
$item['height'] = $image_size[1];
|
- |
|
511 |
|
- |
|
512 |
// Récupération des votes pictoflora
|
- |
|
513 |
$item['votes'] = $this->getVotes($item);
|
- |
|
514 |
|
- |
|
515 |
$_SESSION[$galerie_id]['infos_images'][$url_galerie_popup] = $item;
|
- |
|
516 |
}
|
- |
|
517 |
|
- |
|
518 |
$widget['squelette'] = 'photo';
|
- |
|
519 |
}
|
- |
|
520 |
}
|
- |
|
521 |
|
- |
|
522 |
return $widget;
|
476 |
}
|
523 |
}
|
477 |
}
|
524 |
}
|