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;
|
291 |
jpm |
22 |
|
|
|
23 |
public function __construct(Conteneur $conteneur) {
|
|
|
24 |
$this->conteneur = $conteneur;
|
294 |
delphine |
25 |
$this->nomCourant = $this->conteneur->getNomCourant();
|
291 |
jpm |
26 |
$this->images = $this->conteneur->getApiImages();
|
|
|
27 |
$this->appUrls = $this->conteneur->getAppUrls();
|
320 |
aurelien |
28 |
$this->meta = $this->conteneur->getApiMetaDonnees();
|
238 |
delphine |
29 |
}
|
291 |
jpm |
30 |
|
|
|
31 |
public function obtenirDonnees() {
|
|
|
32 |
$donnees = array();
|
515 |
jpm |
33 |
$donnees['nt'] = $this->nomCourant->getNt();
|
|
|
34 |
$donnees['nomSciRetenu'] = $this->nomCourant->getNomRetenu()->get('nom_sci_html');
|
291 |
jpm |
35 |
$donnees['cel'] = $this->getCel();
|
339 |
aurelien |
36 |
$donnees['photoflora'] = $this->getPhotoFlora();
|
621 |
mathilde |
37 |
$donnees['coste'] = $this->getCoste();
|
272 |
delphine |
38 |
return $donnees;
|
238 |
delphine |
39 |
}
|
291 |
jpm |
40 |
|
|
|
41 |
public function getBloc() {
|
|
|
42 |
$this->images->setProjet('cel');
|
448 |
delphine |
43 |
$nnr = $this->nomCourant->getNnr();
|
|
|
44 |
$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
|
478 |
jpm |
45 |
if (!$infos_image || $infos_image['entete']['total'] == 0) {
|
470 |
aurelien |
46 |
$this->images->setProjet('photoflora');
|
|
|
47 |
$nnr = $this->nomCourant->getNnr();
|
|
|
48 |
$infos_image = $this->images->getUrlPremiereImageParIdsNoms(array($nnr));
|
|
|
49 |
}
|
478 |
jpm |
50 |
|
470 |
aurelien |
51 |
$image = array_shift($infos_image['resultats']);
|
|
|
52 |
$donnees['imageUrl'] = $image['binaire.href'];
|
291 |
jpm |
53 |
return $donnees;
|
|
|
54 |
}
|
478 |
jpm |
55 |
|
621 |
mathilde |
56 |
public function getCoste() {
|
|
|
57 |
$coste = array();
|
|
|
58 |
$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
|
|
|
59 |
$this->images->setProjet('coste');
|
|
|
60 |
$this->images->setNnTaxon($tax);
|
|
|
61 |
$costeImg = $this->images->getInfosImagesTaxons();
|
|
|
62 |
foreach ($costeImg as $infos) {
|
|
|
63 |
$coste['images'][] = $infos['binaire.href'];
|
|
|
64 |
}
|
|
|
65 |
return $coste;
|
|
|
66 |
}
|
|
|
67 |
|
339 |
aurelien |
68 |
public function getPhotoFlora() {
|
|
|
69 |
$photoflora = array();
|
|
|
70 |
$this->images->setProjet('photoflora');
|
448 |
delphine |
71 |
$nnr = $this->nomCourant->getNnr();
|
515 |
jpm |
72 |
$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
|
|
|
73 |
foreach ($images as $idImg => $img) {
|
|
|
74 |
$infosImg = array();
|
|
|
75 |
$infosImg['src'] = $img['binaire.href'];
|
|
|
76 |
$infosImg['nomSci'] = $img['determination.nom_sci'];
|
553 |
jpm |
77 |
$infosImg['station'] = $img['station.libelle'];
|
515 |
jpm |
78 |
$infosImg['date'] = $this->formaterDateImg($img['date']);
|
553 |
jpm |
79 |
$infosImg['auteur'] = $img['auteur.libelle'];
|
515 |
jpm |
80 |
|
|
|
81 |
//$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
|
|
|
82 |
//$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
|
|
|
83 |
$photoflora['images'][$idImg] = $infosImg;
|
|
|
84 |
}
|
478 |
jpm |
85 |
|
339 |
aurelien |
86 |
$this->meta->setProjet('photoflora');
|
|
|
87 |
$meta = $this->meta->getMetaDonnees();
|
|
|
88 |
$titreMeta = $meta[0]['titre'];
|
|
|
89 |
$photoflora['meta']['titre'] = $titreMeta;
|
|
|
90 |
$photoflora['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('photoflora');
|
478 |
jpm |
91 |
|
339 |
aurelien |
92 |
return $photoflora;
|
|
|
93 |
}
|
291 |
jpm |
94 |
|
|
|
95 |
public function getCel() {
|
|
|
96 |
$cel = array();
|
|
|
97 |
$this->images->setProjet('cel');
|
448 |
delphine |
98 |
$nnr = $this->nomCourant->getNnr();
|
|
|
99 |
$images = $this->images->getInfosImagesParIdsNoms(array($nnr));
|
497 |
jpm |
100 |
|
|
|
101 |
foreach ($images as $idImg => $img) {
|
|
|
102 |
$infosImg = array();
|
|
|
103 |
$infosImg['src'] = $img['binaire.href'];
|
|
|
104 |
$infosImg['nomSci'] = $img['determination.nom_sci'];
|
|
|
105 |
$infosImg['commune'] = $img['station.commune'];
|
|
|
106 |
$infosImg['date'] = $this->formaterDateImg($img['date']);
|
|
|
107 |
$infosImg['auteur'] = $img['auteur.libelle'];
|
|
|
108 |
|
|
|
109 |
$infosImg['urlDetailImg'] = $this->appUrls->obtenirUrlPopUpIllustrations($idImg);
|
|
|
110 |
$infosImg['urlContact'] = $this->appUrls->obtenirUrlPopUpContact($img['auteur.id'], $idImg);
|
|
|
111 |
$cel['images'][$idImg] = $infosImg;
|
478 |
jpm |
112 |
}
|
|
|
113 |
|
320 |
aurelien |
114 |
$this->meta->setProjet('cel');
|
|
|
115 |
$meta = $this->meta->getMetaDonnees();
|
|
|
116 |
$titreMeta = $meta[0]['titre'];
|
|
|
117 |
$cel['meta']['titre'] = $titreMeta;
|
291 |
jpm |
118 |
$cel['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees('cel');
|
478 |
jpm |
119 |
|
291 |
jpm |
120 |
return $cel;
|
|
|
121 |
}
|
497 |
jpm |
122 |
|
|
|
123 |
private function formaterDateImg($date) {
|
|
|
124 |
$dateFmt = $date;
|
515 |
jpm |
125 |
if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
|
497 |
jpm |
126 |
$dateFmt = 'inconnue';
|
|
|
127 |
} else {
|
515 |
jpm |
128 |
$dateFmt = strftime('%e %B %Y', strtotime($date));
|
497 |
jpm |
129 |
}
|
|
|
130 |
return $dateFmt;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
private function formaterNomSci($nom) {
|
|
|
134 |
$nomFmt = $nom;
|
|
|
135 |
if (is_null($nom) || $nom == '') {
|
|
|
136 |
$nomFmt = 'inconnu';
|
|
|
137 |
}
|
|
|
138 |
return $nomFmt;
|
|
|
139 |
}
|
238 |
delphine |
140 |
}
|
|
|
141 |
?>
|