Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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