916 |
aurelien |
1 |
<?php
|
|
|
2 |
// declare(encoding='UTF-8');
|
|
|
3 |
/**
|
|
|
4 |
* Affiche un pop-up avec une galerie d'illustrations.
|
|
|
5 |
*
|
|
|
6 |
* @category php 5.2
|
|
|
7 |
* @package eFlore-consultation
|
|
|
8 |
* @author Aurélien PERONNET <aurelien@tela-botanica.org>
|
|
|
9 |
* @copyright Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org)
|
|
|
10 |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
|
|
|
11 |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
|
|
|
12 |
* @version $Id$
|
|
|
13 |
*/
|
|
|
14 |
|
|
|
15 |
class PopupGalerie extends aControleur {
|
|
|
16 |
private $conteneur = null;
|
|
|
17 |
private $urlImage = null;
|
|
|
18 |
private $images = null;
|
|
|
19 |
private $appUrls = null;
|
922 |
aurelien |
20 |
private $titre = '';
|
1066 |
aurelien |
21 |
private $formats_possibles = array("O","CRX2S","CRS","CXS","CS","XS","S","M","L","XL","X2L","X3L");
|
922 |
aurelien |
22 |
private $format_agrandi = 'L';
|
916 |
aurelien |
23 |
|
|
|
24 |
public function initialiser() {
|
|
|
25 |
$this->capturerParametres();
|
|
|
26 |
$this->conteneur = new Conteneur();
|
|
|
27 |
$this->images = $this->conteneur->getApiImages();
|
|
|
28 |
$this->appUrls = $this->conteneur->getAppUrls();
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
private function capturerParametres() {
|
|
|
32 |
if (isset($_GET['num_nom'])) {
|
|
|
33 |
$this->num_nom = $_GET['num_nom'];
|
|
|
34 |
}
|
|
|
35 |
if (isset($_GET['url_image'])) {
|
|
|
36 |
$this->urlImage = urldecode($_GET['url_image']);
|
|
|
37 |
}
|
|
|
38 |
if (isset($_GET['format'])) {
|
|
|
39 |
$this->format = $_GET['format'];
|
|
|
40 |
}
|
922 |
aurelien |
41 |
if (isset($_GET['titre'])) {
|
|
|
42 |
$this->titre = $_GET['titre'];
|
|
|
43 |
}
|
916 |
aurelien |
44 |
}
|
|
|
45 |
|
|
|
46 |
public function executerActionParDefaut() {
|
|
|
47 |
$this->executerFiche();
|
|
|
48 |
}
|
|
|
49 |
|
|
|
50 |
public function executerFiche(){
|
|
|
51 |
$infos = array();
|
|
|
52 |
$this->images->setProjet('cel');
|
|
|
53 |
$urls = $this->images->getUrlsImagesParIdsNoms(array($this->num_nom));
|
947 |
aurelien |
54 |
$urls = $urls[Registre::get('parametres.referentiel').'.'.$this->num_nom];
|
922 |
aurelien |
55 |
$ids = array();
|
|
|
56 |
foreach($urls as $index => $url) {
|
1066 |
aurelien |
57 |
$urls[$index] = str_replace($this->formats_possibles, $this->format_agrandi, $url);
|
922 |
aurelien |
58 |
$ids[$index] = $this->extraireIdDeUrl($url);
|
|
|
59 |
}
|
|
|
60 |
$infos['urls'] = $urls;
|
|
|
61 |
$infos['ids'] = $ids;
|
916 |
aurelien |
62 |
$infos['num_nom'] = $this->num_nom;
|
947 |
aurelien |
63 |
$infos['referentiel'] = Registre::get('parametres.referentiel');
|
1066 |
aurelien |
64 |
$infos['url_image'] = str_replace($this->formats_possibles, $this->format_agrandi, $this->urlImage);
|
922 |
aurelien |
65 |
$infos['titre'] = $this->titre;
|
|
|
66 |
$infos['url_meta'] = Config::get('imagesPopupTpl');
|
|
|
67 |
$infos['url_contact'] = $this->appUrls->obtenirUrlPopUpContact("{id_auteur}", "{id_img}");
|
916 |
aurelien |
68 |
|
922 |
aurelien |
69 |
$this->setSortie(self::META_TITRE,$this->titre, true);
|
916 |
aurelien |
70 |
$this->setSortie(self::RENDU_CORPS, $this->getVue('popup_galerie_illustrations', $infos));
|
|
|
71 |
}
|
|
|
72 |
|
922 |
aurelien |
73 |
private function extraireIdDeUrl($url) {
|
|
|
74 |
$matches = array();
|
1066 |
aurelien |
75 |
$formats = implode("|", $this->formats_possibles);
|
|
|
76 |
preg_match('#cel-img:([0-9]*)('.$formats.')#', $url, $matches);
|
922 |
aurelien |
77 |
return ltrim($matches[1],'0');
|
|
|
78 |
}
|
|
|
79 |
|
916 |
aurelien |
80 |
private function formaterDateImg($date) {
|
|
|
81 |
$dateFmt = $date;
|
|
|
82 |
if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
|
|
|
83 |
$dateFmt = 'inconnue';
|
|
|
84 |
} else {
|
|
|
85 |
$dateFmt = strftime('%e %B %Y', strtotime($date));
|
|
|
86 |
}
|
|
|
87 |
return $dateFmt;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
}
|
|
|
91 |
?>
|