Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

Rev 1156 Rev 1165
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
	private $referentiel = 'bdtfx';
22
	private $referentiel = 'bdtfx';
23
	private $donnees = array();
23
	private $donnees = array();
24
 
24
 
25
	public function __construct(Conteneur $conteneur) {
25
	public function __construct(Conteneur $conteneur) {
26
		$this->conteneur = $conteneur;
26
		$this->conteneur = $conteneur;
27
		$this->nomCourant = $this->conteneur->getNomCourant();
27
		$this->nomCourant = $this->conteneur->getNomCourant();
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
28
		$this->referentiel = $this->conteneur->getParametre('referentiel');
29
		$this->images = $this->conteneur->getApiImages();
29
		$this->images = $this->conteneur->getApiImages();
30
		$this->appUrls = $this->conteneur->getAppUrls();
30
		$this->appUrls = $this->conteneur->getAppUrls();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
31
		$this->meta = $this->conteneur->getApiMetaDonnees();
32
	}
32
	}
33
 
33
 
34
	public function obtenirDonnees() {
34
	public function obtenirDonnees() {
35
		$this->donnees['nt'] = $this->nomCourant->getNt();
35
		$this->donnees['nt'] = $this->nomCourant->getNt();
36
		$this->donnees['nnr'] = $this->nomCourant->getNnr();
36
		$this->donnees['nnr'] = $this->nomCourant->getNnr();
37
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
37
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
38
		$infosNomRetenu = $this->nomCourant->getNomRetenu()->getInfos();
38
		$infosNomRetenu = $this->nomCourant->getNomRetenu()->getInfos();
39
		$this->donnees['nomComplet'] = $infosNomRetenu['nom_complet'];
39
		$this->donnees['nomComplet'] = $infosNomRetenu['nom_complet'];
40
		$this->getPhotos();
40
		$this->getPhotos();
41
		$this->getDessin();
41
		$this->getDessin();
42
		//$this->getPhotosOrganes();
42
		//$this->getPhotosOrganes();
43
		$this->getPhotosCaracteresIdentification();
43
		$this->getPhotosCaracteresIdentification();
44
		$pso = $this->getPhotosSixOrganes();
44
		$pso = $this->getPhotosSixOrganes();
45
		// reconstruction de getPhotosOrganes à partir des données de getPhotosSixOrganes
45
		// reconstruction de getPhotosOrganes à partir des données de getPhotosSixOrganes
46
		$this->donnees['organes'] = array();
46
		$this->donnees['organes'] = array();
47
		foreach ($pso as $organe => $images) {
47
		foreach ($pso as $organe => $images) {
48
			$clefs = array_keys($images);
48
			$clefs = array_keys($images);
49
			$image = $images[$clefs[0]];
49
			$image = $images[$clefs[0]];
50
			// changement de format - en dur, cracra !
50
			// changement de format - en dur, cracra !
51
			$image['binaire.href'] = str_replace('CRX2S', 'CRS', $image['binaire.href']);
51
			$image['binaire.href'] = str_replace('CRX2S', 'CRS', $image['binaire.href']);
52
			$this->donnees['organes'][$organe] = $image;
52
			$this->donnees['organes'][$organe] = $image;
53
		}
53
		}
54
		// --
54
		// --
55
		$this->setCheminSquelette('modules/fiche/squelettes/'); // @FIXME le chemin devrait déjà être défini correctement !?
55
		$this->setCheminSquelette('modules/fiche/squelettes/'); // @FIXME le chemin devrait déjà être défini correctement !?
56
		$this->donnees['illustrationsOrganes'] = $this->getVue('fiche_illustrations_organes',
56
		$params = array('organes' => $pso, 'nnr' => $this->donnees['nnr'], 'nomComplet' => $this->donnees['nomComplet']);
57
				array('organes' => $pso, 'nnr' => $this->donnees['nnr'], 'nomComplet' => $this->donnees['nomComplet']));
57
		$this->donnees['illustrationsOrganes'] = $this->getVue('fiche_illustrations_organes',$params);
-
 
58
		
58
		// chemins
59
		// chemins
59
		$this->donnees['base_url_widget'] = Config::get('base_url_widget');
60
		$this->donnees['base_url_widget'] = Config::get('base_url_widget');
60
		$this->donnees['base_url_del'] = Config::get('base_url_del');
61
		$this->donnees['base_url_del'] = Config::get('base_url_del');
61
		return $this->donnees;
62
		return $this->donnees;
62
	}
63
	}
63
	
64
	
64
	public function obtenirDonneesExport() {
65
	public function obtenirDonneesExport() {
65
		$this->donnees['nt'] = $this->nomCourant->getNt();
66
		$this->donnees['nt'] = $this->nomCourant->getNt();
66
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
67
		$this->donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
67
		$this->donnees['cel'] = $this->getCelExport();
68
		$this->donnees['cel'] = $this->getCelExport();
68
		$this->donnees['coste'] = $this->getCoste();
69
		$this->donnees['coste'] = $this->getCoste();
69
		return $this->donnees;
70
		return $this->donnees;
70
	}
71
	}
71
 
72
 
72
	public function getBloc() {
73
	public function getBloc() {
73
		$this->donnees = $this->images->getInfosMeilleureImageParPrioriteTags($nnr = $this->nomCourant->getNnr(), array(
74
		$this->donnees = $this->images->getInfosMeilleureImageParPrioriteTags($nnr = $this->nomCourant->getNnr(), array(
74
				'fleur', 'feuille', 'fruit', 'ecorce', 'port', 'rameau'));
75
				'fleur', 'feuille', 'fruit', 'ecorce', 'port', 'rameau'));
75
		if (empty($this->donnees)) {
76
		if (empty($this->donnees)) {
76
			$this->donnees = $this->getPhoto('cel');
77
			$this->donnees = $this->getPhoto('cel');
77
			if (empty($this->donnees)) {
78
			if (empty($this->donnees)) {
78
				$infos_image = $this->getDessin();
79
				$infos_image = $this->getDessin();
79
				if (empty($infos_image) == false ) {
80
				if (empty($infos_image) == false ) {
80
					$this->donnees['imageUrl'] =  array_shift($infos_image['images']);
81
					$this->donnees['imageUrl'] =  array_shift($infos_image['images']);
81
				}
82
				}
82
			}
83
			}
83
		} else {
84
		} else {
84
			// extraction de l'url
85
			// extraction de l'url
85
			$this->donnees = array('imageUrl' => $this->donnees['binaire.href']);
86
			$this->donnees = array('imageUrl' => $this->donnees['binaire.href']);
86
		}
87
		}
87
		if (empty($this->donnees)) {
88
		if (empty($this->donnees)) {
88
			$this->donnees = $this->getPhoto('photoflora');
89
			$this->donnees = $this->getPhoto('photoflora');
89
		}
90
		}
90
		return $this->donnees;
91
		return $this->donnees;
91
	}
92
	}
92
	
93
	
93
	
94
	
94
	public function getPhoto($source) {
95
	public function getPhoto($source) {
95
		$donnees = array();
96
		$donnees = array();
96
		$this->images->setProjet($source);
97
		$this->images->setProjet($source);
97
		$nnr = $this->nomCourant->getNnr();
98
		$nnr = $this->nomCourant->getNnr();
98
		$infos_image = $this->images->setApi(Eflore::API_EFLORE)->getInfosPremiereImageParIdsNoms(array($nnr));
99
		$infos_image = $this->images->setApi(Eflore::API_EFLORE)->getInfosPremiereImageParIdsNoms(array($nnr));
99
		if ($infos_image != array()) {
100
		if ($infos_image != array()) {
100
			$image = array_shift($infos_image);
101
			$image = array_shift($infos_image);
101
			$donnees['imageUrl'] =  $image['binaire.href'];
102
			$donnees['imageUrl'] =  $image['binaire.href'];
102
		}
103
		}
103
		return $donnees;
104
		return $donnees;
104
	}
105
	}
105
 
106
 
106
	public function getCoste() {
107
	public function getCoste() {
107
		$coste = array();
108
		$coste = array();
108
		$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
109
		$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
109
		$this->images->setProjet('coste');
110
		$this->images->setProjet('coste');
110
		$this->images->setNnTaxon($tax);
111
		$this->images->setNnTaxon($tax);
111
		$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
112
		$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
112
		foreach ($costeImg as $infos) {
113
		foreach ($costeImg as $infos) {
113
			$coste['images'][] = $infos['binaire.href'];
114
			$coste['images'][] = $infos['binaire.href'];
114
		}
115
		}
115
		$this->meta->setProjet('coste');
116
		$this->meta->setProjet('coste');
116
		$meta = $this->meta->getMetaDonnees();
117
		$meta = $this->meta->getMetaDonnees();
117
		$coste['meta'] = $meta[0];
118
		$coste['meta'] = $meta[0];
118
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
119
		$coste['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('coste');
119
		return $coste;
120
		return $coste;
120
	}
121
	}
121
 
122
 
122
	public function getDessin() {
123
	public function getDessin() {
123
		$projet = Config::get($this->referentiel.'.baseDessins');
124
		$projet = Config::get($this->referentiel.'.baseDessins');
124
		if ($projet != "") {
125
		if ($projet != "") {
125
			$dessin = array();
126
			$dessin = array();
126
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
127
			$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
127
			$this->images->setProjet($projet);
128
			$this->images->setProjet($projet);
128
			$this->images->setNnTaxon($tax);
129
			$this->images->setNnTaxon($tax);
129
			$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
130
			$costeImg = $this->images->setApi(Eflore::API_EFLORE)->getInfosImagesTaxons();
130
				foreach ($costeImg as $infos) {
131
				foreach ($costeImg as $infos) {
131
					$dessin['images'][] = $infos['binaire.href'];
132
					$dessin['images'][] = $infos['binaire.href'];
132
				}
133
				}
133
			$this->meta->setProjet('coste');
134
			$this->meta->setProjet('coste');
134
			$meta = $this->meta->getMetaDonnees();
135
			$meta = $this->meta->getMetaDonnees();
135
			$dessin['meta'] = $meta[0];
136
			$dessin['meta'] = $meta[0];
136
			$dessin['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
137
			$dessin['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
137
			$this->donnees['coste'] = $dessin;
138
			$this->donnees['coste'] = $dessin;
138
		}
139
		}
139
	}
140
	}
140
	
141
	
141
	public function getPhotos() {
142
	public function getPhotos() {
142
		$projets[] = Config::get($this->referentiel.'.baseImages');
143
		$projets[] = Config::get($this->referentiel.'.baseImages');
143
		$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
144
		$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
144
		foreach ($projets as $projet) {
145
		foreach ($projets as $projet) {
145
			if ($projet != "") {
146
			if ($projet != "") {
146
				if ($projet == "cel") {
147
				if ($projet == "cel") {
147
					$this->images->setApi(Eflore::API_EFLORE); // prêt à passer à API_DEL
148
					$this->images->setApi(Eflore::API_EFLORE); // prêt à passer à API_DEL
148
				} else {
149
				} else {
149
					$this->images->setApi(Eflore::API_EFLORE);
150
					$this->images->setApi(Eflore::API_EFLORE);
150
				}
151
				}
151
				$images = $this->initialiserPhotos($projet);
152
				$images = $this->initialiserPhotos($projet);
152
				$this->formaterListePhotos($projet, $images);
153
				$this->formaterListePhotos($projet, $images);
153
				$this->formaterMetaPhotos($projet);
154
				$this->formaterMetaPhotos($projet);
154
			}
155
			}
155
		}
156
		}
156
	}
157
	}
157
	
158
	
158
	public function getPhotosSixOrganes() {
159
	public function getPhotosSixOrganes() {
159
		$organes = array(
160
		$organes = $this->getOrganes();
160
				'fleur' => array(),
-
 
161
				'feuille' => array(),
-
 
162
				'fruit' => array(),
-
 
163
				'ecorce' => array(),
-
 
164
				'port' => array(),
-
 
165
				'rameau' => array());
-
 
166
		$nnr = $this->nomCourant->getNnr();
161
		$nnr = $this->nomCourant->getNnr();
167
		$infosOrganes = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CAPITALISATION, 6, 'CRX2S');
162
		$infosOrganes = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CAPITALISATION, 6, 'CRX2S');
168
		$vide = true;
163
		$vide = true;
169
		foreach ($infosOrganes as $tag => $organe) {
164
		foreach ($infosOrganes as $tag => $organe) {
170
			$organes[$tag] = $organe;
165
			$organes[$tag] = $organe;
171
			$nbImages = count($organe);
166
			$nbImages = count($organe);
172
			if ($nbImages != 0) {
167
			if ($nbImages != 0) {
173
				$vide = false;
168
				$vide = false;
174
				for ($i = 6; $i > $nbImages; $i--) {
169
				for ($i = 6; $i > $nbImages; $i--) {
175
					$organes[$tag][] = null;
170
					$organes[$tag][] = null;
176
				}
171
				}
177
			}
172
			}
178
		}
173
		}
179
		if ($vide) {
174
		if ($vide) {
180
			$organes = array();
175
			$organes = array();
181
		}
176
		}
182
		return $organes;
177
		return $organes;
183
	}
178
	}
184
	
179
	
185
	public function getPhotosOrganes() {
180
	public function getPhotosOrganes() {
186
		$organes = array(
181
		$organes = $this->getOrganes();
187
				'fleur' => array(),
-
 
188
				'feuille' => array(),
-
 
189
				'fruit' => array(),
-
 
190
				'ecorce' => array(),
-
 
191
				'port' => array(),
-
 
192
				'rameau' => array());
-
 
193
		$nnr = $this->nomCourant->getNnr();
182
		$nnr = $this->nomCourant->getNnr();
194
		$infosOrganes = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CAPITALISATION, 1);
183
		$infosOrganes = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CAPITALISATION, 1);
195
		$vide = true;
184
		$vide = true;
196
		foreach ($infosOrganes as $tag => $organe) {
185
		foreach ($infosOrganes as $tag => $organe) {
197
			$nbImages = count($organe);
186
			$nbImages = count($organe);
198
			// une image par organe seulement
187
			// une image par organe seulement
199
			$organes[$tag] = array_pop($organe);
188
			$organes[$tag] = array_pop($organe);
200
			if ($nbImages != 0) {
189
			if ($nbImages != 0) {
201
				$vide = false;
190
				$vide = false;
202
			}
191
			}
203
		}
192
		}
204
		if ($vide) {
193
		if ($vide) {
205
			$organes = array();
194
			$organes = array();
206
		}
195
		}
207
		$this->donnees['organes'] = $organes;
196
		$this->donnees['organes'] = $organes;
208
	}
197
	}
209
	
198
	
210
	public function getPhotosCaracteresIdentification() {
199
	public function getPhotosCaracteresIdentification() {
211
		$caracteres = array();
200
		$caracteres = array();
212
		$nnr = $this->nomCourant->getNnr();
201
		$nnr = $this->nomCourant->getNnr();
213
		$infosCaracteres = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($organes), Eflore::PROTOCOLE_CARACTERES, 3);
202
		$infosCaracteres = $this->images->getInfosMeilleuresImagesParTag($nnr, array_keys($this->getOrganes()), Eflore::PROTOCOLE_CARACTERES, 3);
214
		if (! empty($infosCaracteres) && ! empty($infosCaracteres[''])) { // le tag est vide, ici
203
		if (! empty($infosCaracteres) && ! empty($infosCaracteres[''])) { // le tag est vide, ici
215
			$caracteres = $infosCaracteres[''];
204
			$caracteres = $infosCaracteres;
216
		}
205
		}
217
		$this->donnees['caracteres'] = $caracteres;
206
		$this->donnees['caracteres'] = $caracteres;
218
	}
207
	}
-
 
208
	
-
 
209
	private function getOrganes() {
-
 
210
		return array(
-
 
211
				'fleur' => array(),
-
 
212
				'feuille' => array(),
-
 
213
				'fruit' => array(),
-
 
214
				'ecorce' => array(),
-
 
215
				'port' => array(),
-
 
216
				'rameau' => array());
-
 
217
	}
219
 
218
 
220
	// XXX: webservice:
219
	// XXX: webservice:
221
	// /service:eflore:0.1/cel/images?masque.nn=XXX&referentiel=bdtfx&retour.format=CS&navigation.limite=801
220
	// /service:eflore:0.1/cel/images?masque.nn=XXX&referentiel=bdtfx&retour.format=CS&navigation.limite=801
222
	private function initialiserPhotos($projet) {
221
	private function initialiserPhotos($projet) {
223
		$this->images->setProjet($projet);
222
		$this->images->setProjet($projet);
224
		$nnr = $this->nomCourant->getNnr();
223
		$nnr = $this->nomCourant->getNnr();
225
		$ret = $this->images->getInfosImagesParIdsNoms(array($nnr));
224
		$ret = $this->images->getInfosImagesParIdsNoms(array($nnr));
226
		return $ret;
225
		return $ret;
227
	}
226
	}
228
	
227
	
229
	private function formaterListePhotos($projet, $images) {
228
	private function formaterListePhotos($projet, $images) {
230
		foreach ($images as $idImg => $img) {
229
		foreach ($images as $idImg => $img) {
231
			$infosImg = array();
230
			$infosImg = array();
232
			$infosImg['src'] = $img['binaire.href'];
231
			$infosImg['src'] = $img['binaire.href'];
233
			$infosImg['nomSci'] = $img['determination.nom_sci'];
232
			$infosImg['nomSci'] = $img['determination.nom_sci'];
234
			$infosImg['station'] = $img['station.libelle'];
233
			$infosImg['station'] = $img['station.libelle'];
235
			$infosImg['date'] = $this->formaterDateImg($img['date']);
234
			$infosImg['date'] = $this->formaterDateImg($img['date']);
236
			$infosImg['auteur'] = $img['auteur.libelle'];
235
			$infosImg['auteur'] = $img['auteur.libelle'];
237
			$infosImg['auteur.id'] = $img['auteur.id'];
236
			$infosImg['auteur.id'] = $img['auteur.id'];
238
			if ($projet == "cel") {
237
			if ($projet == "cel") {
239
				$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
238
				$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
240
				$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
239
				$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
241
				$infosImg['urlProfil'] = $this->appUrls->obtenirUrlProfilAnnuaire($img['auteur.id']);
240
				$infosImg['urlProfil'] = $this->appUrls->obtenirUrlProfilAnnuaire($img['auteur.id']);
242
				$infosImg['urlMauvaiseIdentification'] =  $this->appUrls->obtenirUrlMauvaiseIdentification($img['observation.id']);
241
				$infosImg['urlMauvaiseIdentification'] =  $this->appUrls->obtenirUrlMauvaiseIdentification($img['observation.id']);
243
			}
242
			}
244
			$this->donnees[$projet]['images'][$idImg] = $infosImg;
243
			$this->donnees[$projet]['images'][$idImg] = $infosImg;
245
		}
244
		}
246
	}
245
	}
247
	
246
	
248
	private function formaterMetaPhotos($projet) {
247
	private function formaterMetaPhotos($projet) {
249
		$this->meta->setProjet($projet);
248
		$this->meta->setProjet($projet);
250
		$meta = $this->meta->getMetaDonnees();
249
		$meta = $this->meta->getMetaDonnees();
251
		$titreMeta = $meta[0];
250
		$titreMeta = $meta[0];
252
		$this->donnees[$projet]['meta'] = $titreMeta;
251
		$this->donnees[$projet]['meta'] = $titreMeta;
253
		$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
252
		$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
254
	}
253
	}
255
	
254
	
256
	
255
	
257
	
256
	
258
	public function getCelExport() {
257
	public function getCelExport() {
259
		$cel = array();
258
		$cel = array();
260
		$this->images->setProjet('cel');
259
		$this->images->setProjet('cel');
261
		$nnr = $this->nomCourant->getNnr();
260
		$nnr = $this->nomCourant->getNnr();
262
		$img = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
261
		$img = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
263
		if($img) {
262
		if($img) {
264
			$img = array_values($img);
263
			$img = array_values($img);
265
			$cel['images']['src'] = $img[0]['binaire.href'];
264
			$cel['images']['src'] = $img[0]['binaire.href'];
266
			$cel['images']['nomSci'] = $img[0]['determination.nom_sci'];
265
			$cel['images']['nomSci'] = $img[0]['determination.nom_sci'];
267
			$cel['images']['station'] = $img[0]['station.libelle'];
266
			$cel['images']['station'] = $img[0]['station.libelle'];
268
			$cel['images']['date'] = $this->formaterDateImg($img[0]['date']);
267
			$cel['images']['date'] = $this->formaterDateImg($img[0]['date']);
269
			$cel['images']['auteur'] = $img[0]['auteur.libelle'];
268
			$cel['images']['auteur'] = $img[0]['auteur.libelle'];
270
			$this->meta->setProjet('cel');
269
			$this->meta->setProjet('cel');
271
			$meta = $this->meta->getMetaDonnees();
270
			$meta = $this->meta->getMetaDonnees();
272
			$cel['meta'] = $meta[0];
271
			$cel['meta'] = $meta[0];
273
			$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
272
			$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
274
		}
273
		}
275
		return $cel;
274
		return $cel;
276
	}
275
	}
277
 
276
 
278
	private function formaterDateImg($date) {
277
	private function formaterDateImg($date) {
279
		$dateFmt = $date;
278
		$dateFmt = $date;
280
		if ($date == '' || $date == null || $date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
279
		if ($date == '' || $date == null || $date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
281
			return 'inconnue';
280
			return 'inconnue';
282
		}
281
		}
283
		$time = strtotime($date);
282
		$time = strtotime($date);
284
		if(!$time) {
283
		if(!$time) {
285
			/* TODO: php -r "echo strtotime('1891-00-00 00:00:00');"
284
			/* TODO: php -r "echo strtotime('1891-00-00 00:00:00');"
286
			   TODO: fixer le template pour affiche "en l'année X", plutôt que "le X"
285
			   TODO: fixer le template pour affiche "en l'année X", plutôt que "le X"
287
			   si FALSE pour avant 1901: problème php
286
			   si FALSE pour avant 1901: problème php
288
			   On retourne alors simplement l'année.
287
			   On retourne alors simplement l'année.
289
			   si correction, ne pas oublier modules/popup_illustrations/PopupIllustrations.php */
288
			   si correction, ne pas oublier modules/popup_illustrations/PopupIllustrations.php */
290
			$dateFmt = explode('-', $date);
289
			$dateFmt = explode('-', $date);
291
			return $dateFmt[0];
290
			return $dateFmt[0];
292
		}
291
		}
293
		return strftime('%e %B %Y', strtotime($date));
292
		return strftime('%e %B %Y', strtotime($date));
294
	}
293
	}
295
 
294
 
296
	private function formaterNomSci($nom) {
295
	private function formaterNomSci($nom) {
297
		$nomFmt = $nom;
296
		$nomFmt = $nom;
298
		if (is_null($nom) || $nom == '') {
297
		if (is_null($nom) || $nom == '') {
299
			$nomFmt = 'inconnu';
298
			$nomFmt = 'inconnu';
300
		}
299
		}
301
		return $nomFmt;
300
		return $nomFmt;
302
	}
301
	}
303
}
302
}
304
?>
303
?>