Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 621 | Rev 633 | 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();
515 jpm 33
		$donnees['nt'] = $this->nomCourant->getNt();
34
		$donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
291 jpm 35
		$donnees['cel'] = $this->getCel();
339 aurelien 36
		$donnees['photoflora'] = $this->getPhotoFlora();
621 mathilde 37
		$donnees['coste'] = $this->getCoste();
272 delphine 38
		return $donnees;
238 delphine 39
	}
291 jpm 40
 
41
	public function getBloc() {
631 mathilde 42
		$donnees = array();
43
		$donnees = $this->getPhoto('cel');
44
		if (empty($donnees)) {
45
			$infos_image = $this->getCoste();
46
			if (empty($infos_image) == false ){
47
				$donnees['imageUrl'] =  array_shift($infos_image['images']);
48
			}
49
		}
50
		if (empty($donnees)) {
51
			$donnees = $this->getPhoto('photoflora');
52
		}
53
		return $donnees;
54
	}
55
 
56
 
57
	public function getPhoto($source) {
58
		$donnees = array();
59
		$this->images->setProjet($source);
448 delphine 60
		$nnr = $this->nomCourant->getNnr();
61
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
631 mathilde 62
		if ($infos_image['resultats']) {
63
			$image = array_shift($infos_image['resultats']);
64
			$donnees['imageUrl'] =  $image['binaire.href'];
470 aurelien 65
		}
291 jpm 66
		return $donnees;
67
	}
478 jpm 68
 
621 mathilde 69
	public function getCoste() {
70
		$coste = array();
71
		$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
72
		$this->images->setProjet('coste');
73
		$this->images->setNnTaxon($tax);
74
		$costeImg = $this->images->getInfosImagesTaxons();
75
			foreach ($costeImg as $infos) {
76
				$coste['images'][] = $infos['binaire.href'];
77
			}
78
		return $coste;
79
	}
80
 
339 aurelien 81
	public function getPhotoFlora() {
82
		$photoflora = array();
83
		$this->images->setProjet('photoflora');
448 delphine 84
		$nnr = $this->nomCourant->getNnr();
515 jpm 85
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
86
		foreach ($images as $idImg => $img) {
87
			$infosImg = array();
88
			$infosImg['src'] = $img['binaire.href'];
89
			$infosImg['nomSci'] = $img['determination.nom_sci'];
553 jpm 90
			$infosImg['station'] = $img['station.libelle'];
515 jpm 91
			$infosImg['date'] = $this->formaterDateImg($img['date']);
553 jpm 92
			$infosImg['auteur'] = $img['auteur.libelle'];
515 jpm 93
 
94
			//$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
95
			//$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
96
			$photoflora['images'][$idImg] = $infosImg;
97
		}
478 jpm 98
 
339 aurelien 99
		$this->meta->setProjet('photoflora');
100
		$meta = $this->meta->getMetaDonnees();
101
		$titreMeta = $meta[0]['titre'];
102
		$photoflora['meta']['titre'] = $titreMeta;
103
		$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
478 jpm 104
 
339 aurelien 105
		return $photoflora;
106
	}
291 jpm 107
 
108
	public function getCel() {
109
		$cel = array();
110
		$this->images->setProjet('cel');
448 delphine 111
		$nnr = $this->nomCourant->getNnr();
112
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
497 jpm 113
 
114
		foreach ($images as $idImg => $img) {
115
			$infosImg = array();
116
			$infosImg['src'] = $img['binaire.href'];
117
			$infosImg['nomSci'] = $img['determination.nom_sci'];
118
			$infosImg['commune'] = $img['station.commune'];
119
			$infosImg['date'] = $this->formaterDateImg($img['date']);
120
			$infosImg['auteur'] = $img['auteur.libelle'];
121
 
122
			$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
123
			$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
124
			$cel['images'][$idImg] = $infosImg;
478 jpm 125
		}
126
 
320 aurelien 127
		$this->meta->setProjet('cel');
128
		$meta = $this->meta->getMetaDonnees();
129
		$titreMeta = $meta[0]['titre'];
130
		$cel['meta']['titre'] = $titreMeta;
291 jpm 131
		$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
478 jpm 132
 
291 jpm 133
		return $cel;
134
	}
497 jpm 135
 
136
	private function formaterDateImg($date) {
137
		$dateFmt = $date;
515 jpm 138
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
497 jpm 139
			$dateFmt = 'inconnue';
140
		} else {
515 jpm 141
			$dateFmt = strftime('%e %B %Y', strtotime($date));
497 jpm 142
		}
143
		return $dateFmt;
144
	}
145
 
146
	private function formaterNomSci($nom) {
147
		$nomFmt = $nom;
148
		if (is_null($nom) || $nom == '') {
149
			$nomFmt = 'inconnu';
150
		}
151
		return $nomFmt;
152
	}
238 delphine 153
}
154
?>