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