Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 1115 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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