Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 631 | Rev 697 | 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
			}
633 mathilde 78
		$this->meta->setProjet('coste');
79
		$meta = $this->meta->getMetaDonnees();
80
		$coste['meta']['titre']= $meta[0]['titre'];
81
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
621 mathilde 82
		return $coste;
83
	}
84
 
339 aurelien 85
	public function getPhotoFlora() {
86
		$photoflora = array();
87
		$this->images->setProjet('photoflora');
448 delphine 88
		$nnr = $this->nomCourant->getNnr();
515 jpm 89
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
90
		foreach ($images as $idImg => $img) {
91
			$infosImg = array();
92
			$infosImg['src'] = $img['binaire.href'];
93
			$infosImg['nomSci'] = $img['determination.nom_sci'];
553 jpm 94
			$infosImg['station'] = $img['station.libelle'];
515 jpm 95
			$infosImg['date'] = $this->formaterDateImg($img['date']);
553 jpm 96
			$infosImg['auteur'] = $img['auteur.libelle'];
515 jpm 97
 
98
			//$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
99
			//$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
100
			$photoflora['images'][$idImg] = $infosImg;
101
		}
478 jpm 102
 
339 aurelien 103
		$this->meta->setProjet('photoflora');
104
		$meta = $this->meta->getMetaDonnees();
105
		$titreMeta = $meta[0]['titre'];
106
		$photoflora['meta']['titre'] = $titreMeta;
107
		$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
478 jpm 108
 
339 aurelien 109
		return $photoflora;
110
	}
291 jpm 111
 
112
	public function getCel() {
113
		$cel = array();
114
		$this->images->setProjet('cel');
448 delphine 115
		$nnr = $this->nomCourant->getNnr();
116
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
497 jpm 117
 
118
		foreach ($images as $idImg => $img) {
119
			$infosImg = array();
120
			$infosImg['src'] = $img['binaire.href'];
121
			$infosImg['nomSci'] = $img['determination.nom_sci'];
122
			$infosImg['commune'] = $img['station.commune'];
123
			$infosImg['date'] = $this->formaterDateImg($img['date']);
124
			$infosImg['auteur'] = $img['auteur.libelle'];
125
 
126
			$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
127
			$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
128
			$cel['images'][$idImg] = $infosImg;
478 jpm 129
		}
130
 
320 aurelien 131
		$this->meta->setProjet('cel');
132
		$meta = $this->meta->getMetaDonnees();
133
		$titreMeta = $meta[0]['titre'];
134
		$cel['meta']['titre'] = $titreMeta;
291 jpm 135
		$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
478 jpm 136
 
291 jpm 137
		return $cel;
138
	}
497 jpm 139
 
140
	private function formaterDateImg($date) {
141
		$dateFmt = $date;
515 jpm 142
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
497 jpm 143
			$dateFmt = 'inconnue';
144
		} else {
515 jpm 145
			$dateFmt = strftime('%e %B %Y', strtotime($date));
497 jpm 146
		}
147
		return $dateFmt;
148
	}
149
 
150
	private function formaterNomSci($nom) {
151
		$nomFmt = $nom;
152
		if (is_null($nom) || $nom == '') {
153
			$nomFmt = 'inconnu';
154
		}
155
		return $nomFmt;
156
	}
238 delphine 157
}
158
?>