Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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