Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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