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