Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 482 | Rev 515 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
238 delphine 1
<?php
2
// declare(encoding='UTF-8');
3
/**
4
 * Classe mère du module Liste.
5
 *
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
14
 */
15
class Illustrations extends aControleur {
291 jpm 16
 
17
	private $conteneur = null;
294 delphine 18
	private $nomCourant = null;
291 jpm 19
	private $images = null;
478 jpm 20
	private $appUrls = null;
21
	private $meta = null;
291 jpm 22
 
23
	public function __construct(Conteneur $conteneur) {
24
		$this->conteneur = $conteneur;
294 delphine 25
		$this->nomCourant = $this->conteneur->getNomCourant();
291 jpm 26
		$this->images = $this->conteneur->getApiImages();
27
		$this->appUrls = $this->conteneur->getAppUrls();
320 aurelien 28
		$this->meta = $this->conteneur->getApiMetaDonnees();
238 delphine 29
	}
291 jpm 30
 
31
	public function obtenirDonnees() {
32
		$donnees = array();
33
		$donnees['cel'] = $this->getCel();
339 aurelien 34
		$donnees['photoflora'] = $this->getPhotoFlora();
272 delphine 35
		return $donnees;
238 delphine 36
	}
291 jpm 37
 
38
	public function getBloc() {
39
		$this->images->setProjet('cel');
448 delphine 40
		$nnr = $this->nomCourant->getNnr();
41
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
478 jpm 42
		if (!$infos_image || $infos_image['entete']['total'] == 0) {
470 aurelien 43
			$this->images->setProjet('photoflora');
44
			$nnr = $this->nomCourant->getNnr();
45
			$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
46
		}
478 jpm 47
 
470 aurelien 48
		$image = array_shift($infos_image['resultats']);
49
		$donnees['imageUrl'] = $image['binaire.href'];
291 jpm 50
		return $donnees;
51
	}
478 jpm 52
 
339 aurelien 53
	public function getPhotoFlora() {
54
		$photoflora = array();
55
		$this->images->setProjet('photoflora');
448 delphine 56
		$nnr = $this->nomCourant->getNnr();
497 jpm 57
		$photoflora['images'] = $this->images->getInfosImagesParIdsNoms(array($nnr));
478 jpm 58
 
339 aurelien 59
		$this->meta->setProjet('photoflora');
60
		$meta = $this->meta->getMetaDonnees();
61
		$titreMeta = $meta[0]['titre'];
62
		$photoflora['meta']['titre'] = $titreMeta;
63
		$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
478 jpm 64
 
339 aurelien 65
		return $photoflora;
66
	}
291 jpm 67
 
68
	public function getCel() {
69
		$cel = array();
70
		$this->images->setProjet('cel');
448 delphine 71
		$nnr = $this->nomCourant->getNnr();
72
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
497 jpm 73
 
74
		foreach ($images as $idImg => $img) {
75
			$infosImg = array();
76
			$infosImg['src'] = $img['binaire.href'];
77
			$infosImg['nomSci'] = $img['determination.nom_sci'];
78
			$infosImg['commune'] = $img['station.commune'];
79
			$infosImg['date'] = $this->formaterDateImg($img['date']);
80
			$infosImg['auteur'] = $img['auteur.libelle'];
81
 
82
			$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
83
			$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
84
			$cel['images'][$idImg] = $infosImg;
478 jpm 85
		}
86
 
320 aurelien 87
		$this->meta->setProjet('cel');
88
		$meta = $this->meta->getMetaDonnees();
89
		$titreMeta = $meta[0]['titre'];
90
		$cel['meta']['titre'] = $titreMeta;
291 jpm 91
		$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
478 jpm 92
 
291 jpm 93
		return $cel;
94
	}
497 jpm 95
 
96
	private function formaterDateImg($date) {
97
		$dateFmt = $date;
98
		if ($date == '0000-00-00') {
99
			$dateFmt = 'inconnue';
100
		} else {
101
			$dateFmt = date('d/m/Y', strtotime($date));
102
		}
103
		return $dateFmt;
104
	}
105
 
106
	private function formaterNomSci($nom) {
107
		$nomFmt = $nom;
108
		if (is_null($nom) || $nom == '') {
109
			$nomFmt = 'inconnu';
110
		}
111
		return $nomFmt;
112
	}
238 delphine 113
}
114
?>