Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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