Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
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 = '';
21
	private $format_miniature = 'CS';
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));
922 aurelien 54
		$urls = $urls['bdtfx.'.$this->num_nom];
55
		$ids = array();
56
		foreach($urls as $index => $url) {
57
			$urls[$index] = str_replace($this->format_miniature, $this->format_agrandi, $url);
58
			$ids[$index] = $this->extraireIdDeUrl($url);
59
		}
60
 
61
		$infos['urls'] = $urls;
62
		$infos['ids'] = $ids;
916 aurelien 63
		$infos['num_nom'] = $this->num_nom;
922 aurelien 64
		$infos['url_image'] = str_replace($this->format_miniature, $this->format_agrandi, $this->urlImage);
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();
75
		preg_match('#cel-img:([0-9]*)'.$this->format_miniature.'#', $url, $matches);
76
		return ltrim($matches[1],'0');
77
	}
78
 
916 aurelien 79
	private function formaterDateImg($date) {
80
		$dateFmt = $date;
81
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
82
			$dateFmt = 'inconnue';
83
		} else {
84
			$dateFmt = strftime('%e %B %Y', strtotime($date));
85
		}
86
		return $dateFmt;
87
	}
88
 
89
}
90
?>