Subversion Repositories eFlore/Applications.eflore-consultation

Rev

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

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