990 |
isa |
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 {
|
|
|
16 |
|
|
|
17 |
private $conteneur = null;
|
|
|
18 |
private $nomCourant = null;
|
|
|
19 |
private $images = null;
|
|
|
20 |
private $appUrls = null;
|
|
|
21 |
private $meta = null;
|
|
|
22 |
private $referentiel = 'bdtfx';
|
|
|
23 |
private $donnees = array();
|
|
|
24 |
|
|
|
25 |
public function __construct(Conteneur $conteneur) {
|
|
|
26 |
$this->conteneur = $conteneur;
|
|
|
27 |
$this->nomCourant = $this->conteneur->getNomCourant();
|
|
|
28 |
$this->referentiel = $this->conteneur->getParametre('referentiel');
|
|
|
29 |
$this->images = $this->conteneur->getApiImages();
|
|
|
30 |
$this->appUrls = $this->conteneur->getAppUrls();
|
|
|
31 |
$this->meta = $this->conteneur->getApiMetaDonnees();
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
public function getDonnees() {
|
|
|
35 |
$this->donnees = array();
|
|
|
36 |
$this->getPhotos();
|
|
|
37 |
$dessin = $this->addDessin();
|
|
|
38 |
if (!empty($dessin)) {
|
|
|
39 |
array_push($this->donnees, $dessin);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
return $this->donnees;
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
public function getPhotos() {
|
1036 |
isa |
46 |
$url_picto = $this->obtenirUrlPicto();
|
|
|
47 |
$obj = json_decode(file_get_contents($url_picto), true);
|
|
|
48 |
|
|
|
49 |
$arr = $obj['resultats'];
|
|
|
50 |
//echo '<pre>'.print_r($obj, true).'</pre>';
|
|
|
51 |
foreach($arr as $index) {
|
|
|
52 |
$this->formaterListePhotos($index);
|
990 |
isa |
53 |
}
|
|
|
54 |
}
|
1036 |
isa |
55 |
|
990 |
isa |
56 |
|
1036 |
isa |
57 |
public function obtenirUrlPicto() {
|
1103 |
isa |
58 |
//TODO : passer les valeurs dans le fichier de config
|
1036 |
isa |
59 |
$url_picto = "http://www.tela-botanica.org/eflore/del/services/0.1/images?navigation.depart=0"
|
|
|
60 |
."&navigation.limite=4&masque.nn=".$this->nomCourant->getNnr()
|
1103 |
isa |
61 |
."&tri=votes&ordre=desc&protocole=3&format=CRS";
|
1036 |
isa |
62 |
|
|
|
63 |
return ($url_picto);
|
990 |
isa |
64 |
}
|
|
|
65 |
|
1036 |
isa |
66 |
private function formaterListePhotos($images) {
|
|
|
67 |
$infosImg['src'] = $images['binaire.href'];
|
|
|
68 |
|
|
|
69 |
$obs = $images['observation'];
|
|
|
70 |
if ($obs['auteur.nom'] != '') {
|
|
|
71 |
$infosImg['legende']['titre'] = $obs['auteur.nom'];
|
|
|
72 |
if ($obs['auteur.prenom'] != '') {
|
|
|
73 |
$infosImg['legende']['titre'] .= ' '.$obs['auteur.prenom'];
|
|
|
74 |
}
|
|
|
75 |
} else {
|
|
|
76 |
$infosImg['legende']['titre'] = "Anonyme";
|
|
|
77 |
}
|
990 |
isa |
78 |
|
1036 |
isa |
79 |
if ($obs['date_observation'] != '') {
|
|
|
80 |
$infosImg['legende']['titre'] .= ", le ".$this->formaterDateImg($obs['date_observation']);
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
if ($obs['zone_geo'] != '') {
|
|
|
84 |
$infosImg['legende']['texte'] = $obs['zone_geo'];
|
|
|
85 |
if ($obs['lieudit'] != '') {
|
|
|
86 |
$infosImg['legende']['texte'] .= ' ('.$obs['lieudit'].')';
|
990 |
isa |
87 |
}
|
1036 |
isa |
88 |
} else {
|
|
|
89 |
$infosImg['legende']['texte'] = " ";
|
990 |
isa |
90 |
}
|
1036 |
isa |
91 |
|
|
|
92 |
array_push($this->donnees, $infosImg);
|
990 |
isa |
93 |
}
|
|
|
94 |
|
|
|
95 |
private function formaterDateImg($date) {
|
|
|
96 |
$dateFmt = $date;
|
|
|
97 |
if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
|
|
|
98 |
$dateFmt = 'inconnue';
|
|
|
99 |
} else {
|
|
|
100 |
$dateFmt = strftime('%e %B %Y', strtotime($date));
|
|
|
101 |
}
|
|
|
102 |
return $dateFmt;
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
public function addDessin() {
|
|
|
106 |
$img = array();
|
|
|
107 |
$projet = Config::get($this->referentiel.'.baseDessins');
|
|
|
108 |
if ($projet != "") {
|
|
|
109 |
$dessin = array();
|
|
|
110 |
$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
|
|
|
111 |
$this->images->setProjet($projet);
|
|
|
112 |
$this->images->setNnTaxon($tax);
|
|
|
113 |
$costeImg = $this->images->getInfosImagesTaxons();
|
|
|
114 |
|
|
|
115 |
if (count($costeImg) != 0) {
|
|
|
116 |
$img['src'] = $costeImg[key($costeImg)]['binaire.href'];
|
|
|
117 |
$img['legende']['titre'] = "Illustration de Coste";
|
|
|
118 |
$img['legende']['texte'] = " ";
|
|
|
119 |
}
|
|
|
120 |
}
|
|
|
121 |
|
|
|
122 |
return $img;
|
|
|
123 |
}
|
|
|
124 |
}
|
|
|
125 |
?>
|