Subversion Repositories eFlore/Applications.eflore-consultation

Rev

Rev 633 | Rev 801 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 633 Rev 697
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Classe mère du module Liste.
4
 * Classe mère du module Liste.
5
 *
5
 *
6
 * @category	PHP 5.2
6
 * @category	PHP 5.2
7
 * @package		eflore-consultation
7
 * @package		eflore-consultation
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
8
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
9
 * @author		Delphine CAUQUIL <delphine@tela-botanica.org>
10
 * @copyright	2011 Tela-Botanica
10
 * @copyright	2011 Tela-Botanica
11
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL-v3
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
12
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL-v2
13
 * @version		$Id$
13
 * @version		$Id$
14
 */
14
 */
15
class Illustrations extends aControleur {
15
class Illustrations extends aControleur {
16
 
16
 
17
	private $conteneur = null;
17
	private $conteneur = null;
18
	private $nomCourant = null;
18
	private $nomCourant = null;
19
	private $images = null;
19
	private $images = null;
20
	private $appUrls = null;
20
	private $appUrls = null;
21
	private $meta = null;
21
	private $meta = null;
22
 
22
 
23
	public function __construct(Conteneur $conteneur) {
23
	public function __construct(Conteneur $conteneur) {
24
		$this->conteneur = $conteneur;
24
		$this->conteneur = $conteneur;
25
		$this->nomCourant = $this->conteneur->getNomCourant();
25
		$this->nomCourant = $this->conteneur->getNomCourant();
26
		$this->images = $this->conteneur->getApiImages();
26
		$this->images = $this->conteneur->getApiImages();
27
		$this->appUrls = $this->conteneur->getAppUrls();
27
		$this->appUrls = $this->conteneur->getAppUrls();
28
		$this->meta = $this->conteneur->getApiMetaDonnees();
28
		$this->meta = $this->conteneur->getApiMetaDonnees();
29
	}
29
	}
30
 
30
 
31
	public function obtenirDonnees() {
31
	public function obtenirDonnees() {
32
		$donnees = array();
32
		$donnees = array();
33
		$donnees['nt'] = $this->nomCourant->getNt();
33
		$donnees['nt'] = $this->nomCourant->getNt();
34
		$donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
34
		$donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
35
		$donnees['cel'] = $this->getCel();
35
		$donnees['cel'] = $this->getCel();
36
		$donnees['photoflora'] = $this->getPhotoFlora();
36
		$donnees['photoflora'] = $this->getPhotoFlora();
37
		$donnees['coste'] = $this->getCoste();
37
		$donnees['coste'] = $this->getCoste();
38
		return $donnees;
38
		return $donnees;
39
	}
39
	}
-
 
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
	}
40
 
49
 
41
	public function getBloc() {
50
	public function getBloc() {
42
		$donnees = array();
51
		$donnees = array();
43
		$donnees = $this->getPhoto('cel');
52
		$donnees = $this->getPhoto('cel');
44
		if (empty($donnees)) {
53
		if (empty($donnees)) {
45
			$infos_image = $this->getCoste();
54
			$infos_image = $this->getCoste();
46
			if (empty($infos_image) == false ){
55
			if (empty($infos_image) == false ){
47
				$donnees['imageUrl'] =  array_shift($infos_image['images']);
56
				$donnees['imageUrl'] =  array_shift($infos_image['images']);
48
			}
57
			}
49
		}
58
		}
50
		if (empty($donnees)) {
59
		if (empty($donnees)) {
51
			$donnees = $this->getPhoto('photoflora');
60
			$donnees = $this->getPhoto('photoflora');
52
		}
61
		}
53
		return $donnees;
62
		return $donnees;
54
	}
63
	}
55
	
64
	
56
	
65
	
57
	public function getPhoto($source) {
66
	public function getPhoto($source) {
58
		$donnees = array();
67
		$donnees = array();
59
		$this->images->setProjet($source);
68
		$this->images->setProjet($source);
60
		$nnr = $this->nomCourant->getNnr();
69
		$nnr = $this->nomCourant->getNnr();
61
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
70
		$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
62
		if ($infos_image['resultats']) {
71
		if ($infos_image['resultats']) {
63
			$image = array_shift($infos_image['resultats']);
72
			$image = array_shift($infos_image['resultats']);
64
			$donnees['imageUrl'] =  $image['binaire.href'];
73
			$donnees['imageUrl'] =  $image['binaire.href'];
65
		}
74
		}
66
		return $donnees;
75
		return $donnees;
67
	}
76
	}
68
 
77
 
69
	public function getCoste() {
78
	public function getCoste() {
70
		$coste = array();
79
		$coste = array();
71
		$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
80
		$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
72
		$this->images->setProjet('coste');
81
		$this->images->setProjet('coste');
73
		$this->images->setNnTaxon($tax);
82
		$this->images->setNnTaxon($tax);
74
		$costeImg = $this->images->getInfosImagesTaxons();
83
		$costeImg = $this->images->getInfosImagesTaxons();
75
			foreach ($costeImg as $infos) {
84
			foreach ($costeImg as $infos) {
76
				$coste['images'][] = $infos['binaire.href'];
85
				$coste['images'][] = $infos['binaire.href'];
77
			}
86
			}
78
		$this->meta->setProjet('coste');
87
		$this->meta->setProjet('coste');
79
		$meta = $this->meta->getMetaDonnees();
88
		$meta = $this->meta->getMetaDonnees();
80
		$coste['meta']['titre']= $meta[0]['titre'];
89
		$coste['meta']['titre']= $meta[0]['titre'];
81
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
90
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
82
		return $coste;
91
		return $coste;
83
	}
92
	}
84
	
93
	
85
	public function getPhotoFlora() {
94
	public function getPhotoFlora() {
86
		$photoflora = array();
95
		$photoflora = array();
87
		$this->images->setProjet('photoflora');
96
		$this->images->setProjet('photoflora');
88
		$nnr = $this->nomCourant->getNnr();
97
		$nnr = $this->nomCourant->getNnr();
89
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
98
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
90
		foreach ($images as $idImg => $img) {
99
		foreach ($images as $idImg => $img) {
91
			$infosImg = array();
100
			$infosImg = array();
92
			$infosImg['src'] = $img['binaire.href'];
101
			$infosImg['src'] = $img['binaire.href'];
93
			$infosImg['nomSci'] = $img['determination.nom_sci'];
102
			$infosImg['nomSci'] = $img['determination.nom_sci'];
94
			$infosImg['station'] = $img['station.libelle'];
103
			$infosImg['station'] = $img['station.libelle'];
95
			$infosImg['date'] = $this->formaterDateImg($img['date']);
104
			$infosImg['date'] = $this->formaterDateImg($img['date']);
96
			$infosImg['auteur'] = $img['auteur.libelle'];
105
			$infosImg['auteur'] = $img['auteur.libelle'];
97
 
106
 
98
			//$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
107
			//$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
99
			//$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
108
			//$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
100
			$photoflora['images'][$idImg] = $infosImg;
109
			$photoflora['images'][$idImg] = $infosImg;
101
		}
110
		}
102
 
111
 
103
		$this->meta->setProjet('photoflora');
112
		$this->meta->setProjet('photoflora');
104
		$meta = $this->meta->getMetaDonnees();
113
		$meta = $this->meta->getMetaDonnees();
105
		$titreMeta = $meta[0]['titre'];
114
		$titreMeta = $meta[0]['titre'];
106
		$photoflora['meta']['titre'] = $titreMeta;
115
		$photoflora['meta']['titre'] = $titreMeta;
107
		$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
116
		$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
108
 
117
 
109
		return $photoflora;
118
		return $photoflora;
110
	}
119
	}
-
 
120
	
-
 
121
 
-
 
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
	}
111
 
142
 
112
	public function getCel() {
143
	public function getCel() {
113
		$cel = array();
144
		$cel = array();
114
		$this->images->setProjet('cel');
145
		$this->images->setProjet('cel');
115
		$nnr = $this->nomCourant->getNnr();
146
		$nnr = $this->nomCourant->getNnr();
116
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
147
		$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
117
 
148
 
118
		foreach ($images as $idImg => $img) {
149
		foreach ($images as $idImg => $img) {
119
			$infosImg = array();
150
			$infosImg = array();
120
			$infosImg['src'] = $img['binaire.href'];
151
			$infosImg['src'] = $img['binaire.href'];
121
			$infosImg['nomSci'] = $img['determination.nom_sci'];
152
			$infosImg['nomSci'] = $img['determination.nom_sci'];
122
			$infosImg['commune'] = $img['station.commune'];
153
			$infosImg['commune'] = $img['station.commune'];
123
			$infosImg['date'] = $this->formaterDateImg($img['date']);
154
			$infosImg['date'] = $this->formaterDateImg($img['date']);
124
			$infosImg['auteur'] = $img['auteur.libelle'];
155
			$infosImg['auteur'] = $img['auteur.libelle'];
125
 
156
 
126
			$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
157
			$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
127
			$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
158
			$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
128
			$cel['images'][$idImg] = $infosImg;
159
			$cel['images'][$idImg] = $infosImg;
129
		}
160
		}
130
 
161
 
131
		$this->meta->setProjet('cel');
162
		$this->meta->setProjet('cel');
132
		$meta = $this->meta->getMetaDonnees();
163
		$meta = $this->meta->getMetaDonnees();
133
		$titreMeta = $meta[0]['titre'];
164
		$titreMeta = $meta[0]['titre'];
134
		$cel['meta']['titre'] = $titreMeta;
165
		$cel['meta']['titre'] = $titreMeta;
135
		$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
166
		$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
136
 
167
 
137
		return $cel;
168
		return $cel;
138
	}
169
	}
139
 
170
 
140
	private function formaterDateImg($date) {
171
	private function formaterDateImg($date) {
141
		$dateFmt = $date;
172
		$dateFmt = $date;
142
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
173
		if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
143
			$dateFmt = 'inconnue';
174
			$dateFmt = 'inconnue';
144
		} else {
175
		} else {
145
			$dateFmt = strftime('%e %B %Y', strtotime($date));
176
			$dateFmt = strftime('%e %B %Y', strtotime($date));
146
		}
177
		}
147
		return $dateFmt;
178
		return $dateFmt;
148
	}
179
	}
149
 
180
 
150
	private function formaterNomSci($nom) {
181
	private function formaterNomSci($nom) {
151
		$nomFmt = $nom;
182
		$nomFmt = $nom;
152
		if (is_null($nom) || $nom == '') {
183
		if (is_null($nom) || $nom == '') {
153
			$nomFmt = 'inconnu';
184
			$nomFmt = 'inconnu';
154
		}
185
		}
155
		return $nomFmt;
186
		return $nomFmt;
156
	}
187
	}
157
}
188
}
158
?>
189
?>