Rev 1066 | Rev 1136 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
<?php
// declare(encoding='UTF-8');
/**
* Affiche un pop-up avec une galerie d'illustrations.
*
* @category php 5.2
* @package eFlore-consultation
* @author Aurélien PERONNET <aurelien@tela-botanica.org>
* @copyright Copyright (c) 2012, Tela Botanica (accueil@tela-botanica.org)
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
* @version $Id$
*/
class PopupGalerie extends aControleur {
private $conteneur = null;
private $urlImage = null;
private $images = null;
private $appUrls = null;
private $titre = '';
private $formats_possibles = array("O","CRX2S","CRS","CXS","CS","XS","S","M","L","XL","X2L","X3L");
private $format_agrandi = 'L';
public function initialiser() {
$this->capturerParametres();
$this->conteneur = new Conteneur();
$this->images = $this->conteneur->getApiImages();
$this->appUrls = $this->conteneur->getAppUrls();
}
private function capturerParametres() {
if (isset($_GET['num_nom'])) {
$this->num_nom = $_GET['num_nom'];
}
if (isset($_GET['url_image'])) {
$this->urlImage = urldecode($_GET['url_image']);
}
if (isset($_GET['format'])) {
$this->format = $_GET['format'];
}
if (isset($_GET['titre'])) {
$this->titre = $_GET['titre'];
}
}
public function executerActionParDefaut() {
$this->executerFiche();
}
public function executerFiche(){
$infos = array();
$this->images->setProjet('cel');
$urls = $this->images->setApi(Eflore::API_EFLORE)->getUrlsImagesParIdsNoms(array($this->num_nom));
$urls = $urls[Registre::get('parametres.referentiel').'.'.$this->num_nom];
$ids = array();
foreach($urls as $index => $url) {
$urls[$index] = str_replace($this->formats_possibles, $this->format_agrandi, $url);
$ids[$index] = $this->extraireIdDeUrl($url);
}
$infos['urls'] = $urls;
$infos['ids'] = $ids;
$infos['num_nom'] = $this->num_nom;
$infos['referentiel'] = Registre::get('parametres.referentiel');
$infos['url_image'] = str_replace($this->formats_possibles, $this->format_agrandi, $this->urlImage);
$infos['titre'] = $this->titre;
$infos['url_meta'] = Config::get('imagesPopupTpl');
$infos['url_contact'] = $this->appUrls->obtenirUrlPopUpContact("{id_auteur}", "{id_img}");
$this->setSortie(self::META_TITRE,$this->titre, true);
$this->setSortie(self::RENDU_CORPS, $this->getVue('popup_galerie_illustrations', $infos));
}
private function extraireIdDeUrl($url) {
$matches = array();
$formats = implode("|", $this->formats_possibles);
preg_match('#cel-img:([0-9]*)('.$formats.')#', $url, $matches);
return ltrim($matches[1],'0');
}
private function formaterDateImg($date) {
$dateFmt = $date;
if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
$dateFmt = 'inconnue';
} else {
$dateFmt = strftime('%e %B %Y', strtotime($date));
}
return $dateFmt;
}
}
?>