Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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