Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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