Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 497 | Rev 553 | 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();
272 delphine 37
		return $donnees;
238 delphine 38
	}
291 jpm 39
 
40
	public function getBloc() {
41
		$this->images->setProjet('cel');
448 delphine 42
		$nnr = $this->nomCourant->getNnr();
43
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
478 jpm 44
		if (!$infos_image || $infos_image['entete']['total'] == 0) {
470 aurelien 45
			$this->images->setProjet('photoflora');
46
			$nnr = $this->nomCourant->getNnr();
47
			$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
48
		}
478 jpm 49
 
470 aurelien 50
		$image = array_shift($infos_image['resultats']);
51
		$donnees['imageUrl'] = $image['binaire.href'];
291 jpm 52
		return $donnees;
53
	}
478 jpm 54
 
339 aurelien 55
	public function getPhotoFlora() {
56
		$photoflora = array();
57
		$this->images->setProjet('photoflora');
448 delphine 58
		$nnr = $this->nomCourant->getNnr();
515 jpm 59
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
60
		foreach ($images as $idImg => $img) {
61
			$infosImg = array();
62
			$infosImg['src'] = $img['binaire.href'];
63
			$infosImg['nomSci'] = $img['determination.nom_sci'];
64
			$infosImg['station'] = $img['station'];
65
			$infosImg['date'] = $this->formaterDateImg($img['date']);
66
			$infosImg['auteur'] = $img['auteur'];
67
 
68
			//$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
69
			//$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
70
			$photoflora['images'][$idImg] = $infosImg;
71
		}
478 jpm 72
 
339 aurelien 73
		$this->meta->setProjet('photoflora');
74
		$meta = $this->meta->getMetaDonnees();
75
		$titreMeta = $meta[0]['titre'];
76
		$photoflora['meta']['titre'] = $titreMeta;
77
		$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
478 jpm 78
 
339 aurelien 79
		return $photoflora;
80
	}
291 jpm 81
 
82
	public function getCel() {
83
		$cel = array();
84
		$this->images->setProjet('cel');
448 delphine 85
		$nnr = $this->nomCourant->getNnr();
86
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
497 jpm 87
 
88
		foreach ($images as $idImg => $img) {
89
			$infosImg = array();
90
			$infosImg['src'] = $img['binaire.href'];
91
			$infosImg['nomSci'] = $img['determination.nom_sci'];
92
			$infosImg['commune'] = $img['station.commune'];
93
			$infosImg['date'] = $this->formaterDateImg($img['date']);
94
			$infosImg['auteur'] = $img['auteur.libelle'];
95
 
96
			$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
97
			$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
98
			$cel['images'][$idImg] = $infosImg;
478 jpm 99
		}
100
 
320 aurelien 101
		$this->meta->setProjet('cel');
102
		$meta = $this->meta->getMetaDonnees();
103
		$titreMeta = $meta[0]['titre'];
104
		$cel['meta']['titre'] = $titreMeta;
291 jpm 105
		$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
478 jpm 106
 
291 jpm 107
		return $cel;
108
	}
497 jpm 109
 
110
	private function formaterDateImg($date) {
111
		$dateFmt = $date;
515 jpm 112
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
497 jpm 113
			$dateFmt = 'inconnue';
114
		} else {
515 jpm 115
			$dateFmt = strftime('%e %B %Y', strtotime($date));
497 jpm 116
		}
117
		return $dateFmt;
118
	}
119
 
120
	private function formaterNomSci($nom) {
121
		$nomFmt = $nom;
122
		if (is_null($nom) || $nom == '') {
123
			$nomFmt = 'inconnu';
124
		}
125
		return $nomFmt;
126
	}
238 delphine 127
}
128
?>