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() {
|
|
|
46 |
$projets[] = Config::get($this->referentiel.'.baseImages');
|
|
|
47 |
$projets[] = Config::get($this->referentiel.'.baseImagesSupp');
|
|
|
48 |
foreach ($projets as $projet) {
|
|
|
49 |
if ($projet != "") {
|
|
|
50 |
$images = $this->initialiserPhotos($projet);
|
|
|
51 |
$this->formaterListePhotos($projet, $images);
|
|
|
52 |
}
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
private function initialiserPhotos($projet) {
|
|
|
57 |
$this->images->setProjet($projet);
|
|
|
58 |
$nnr = $this->nomCourant->getNnr();
|
|
|
59 |
return $this->images->getInfosImagesParIdsNoms(array($nnr));
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
private function formaterListePhotos($projet, $images) {
|
|
|
63 |
$max = Config::get('pictures.number.max');
|
|
|
64 |
foreach ($images as $idImg => $img) {
|
|
|
65 |
$infosImg['src'] = htmlentities($img['binaire.href']);
|
|
|
66 |
|
|
|
67 |
if ($img['auteur.libelle'] != '') {
|
|
|
68 |
$infosImg['legende']['titre'] = htmlentities($img['auteur.libelle']);
|
|
|
69 |
} else {
|
|
|
70 |
$infosImg['legende']['titre'] = "Anonyme";
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
if ($img['date'] != '') {
|
|
|
74 |
$infosImg['legende']['titre'] .= ", le ".htmlentities($this->formaterDateImg($img['date']));
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
if ($img['station.libelle'] != '') {
|
|
|
78 |
$infosImg['legende']['texte'] = htmlentities($img['station.libelle']);
|
|
|
79 |
} else {
|
|
|
80 |
$infosImg['legende']['texte'] = " ";
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
array_push($this->donnees, $infosImg);
|
|
|
84 |
if (--$max <= 0) {
|
|
|
85 |
return null;
|
|
|
86 |
}
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
private function formaterDateImg($date) {
|
|
|
91 |
$dateFmt = $date;
|
|
|
92 |
if ($date == '0000-00-00' || $date == '1970-01-01 01:01:01') {
|
|
|
93 |
$dateFmt = 'inconnue';
|
|
|
94 |
} else {
|
|
|
95 |
$dateFmt = strftime('%e %B %Y', strtotime($date));
|
|
|
96 |
}
|
|
|
97 |
return $dateFmt;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public function addDessin() {
|
|
|
101 |
$img = array();
|
|
|
102 |
$projet = Config::get($this->referentiel.'.baseDessins');
|
|
|
103 |
if ($projet != "") {
|
|
|
104 |
$dessin = array();
|
|
|
105 |
$tax = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
|
|
|
106 |
$this->images->setProjet($projet);
|
|
|
107 |
$this->images->setNnTaxon($tax);
|
|
|
108 |
$costeImg = $this->images->getInfosImagesTaxons();
|
|
|
109 |
|
|
|
110 |
if (count($costeImg) != 0) {
|
|
|
111 |
$img['src'] = $costeImg[key($costeImg)]['binaire.href'];
|
|
|
112 |
$img['legende']['titre'] = "Illustration de Coste";
|
|
|
113 |
$img['legende']['texte'] = " ";
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
return $img;
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
?>
|