272 |
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 Ethnobotanique extends aControleur {
|
302 |
jpm |
16 |
|
|
|
17 |
private $conteneur = null;
|
|
|
18 |
private $nomCourant = null;
|
|
|
19 |
private $nomsVernaculaires = null;
|
408 |
aurelien |
20 |
private $wikini;
|
959 |
delphine |
21 |
private $referentiel = 'bdtfx';
|
|
|
22 |
private $donnees = array();
|
302 |
jpm |
23 |
|
|
|
24 |
public function __construct(Conteneur $conteneur) {
|
|
|
25 |
$this->conteneur = $conteneur;
|
|
|
26 |
$this->nomCourant = $this->conteneur->getNomCourant();
|
|
|
27 |
$this->nomsVernaculaires = $this->conteneur->getApiNomsVernaculaires();
|
959 |
delphine |
28 |
$this->referentiel = $this->conteneur->getParametre('referentiel');
|
408 |
aurelien |
29 |
$this->wikini = $this->conteneur->getApiWikini();
|
307 |
jpm |
30 |
$this->meta = $this->conteneur->getApiMetaDonnees();
|
|
|
31 |
$this->appUrls = $this->conteneur->getAppUrls();
|
284 |
aurelien |
32 |
}
|
302 |
jpm |
33 |
|
|
|
34 |
public function obtenirDonnees() {
|
964 |
delphine |
35 |
$this->getNomsVernaculaires('.referentielVerna');
|
|
|
36 |
$this->getNomsVernaculaires('.referentielVernaGrec');
|
959 |
delphine |
37 |
$this->getChorologie();
|
|
|
38 |
$this->donnees['wikini'] = $this->getWikini();
|
|
|
39 |
return $this->donnees;
|
306 |
jpm |
40 |
}
|
|
|
41 |
|
964 |
delphine |
42 |
private function getNomsVernaculaires($projet) {
|
|
|
43 |
$projet = Config::get($this->referentiel.$projet);
|
959 |
delphine |
44 |
if ($projet != "") {
|
|
|
45 |
$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
|
964 |
delphine |
46 |
$nomsVerna = $this->nomsVernaculaires->getRechercheComplete($projet, $nt);
|
959 |
delphine |
47 |
$this->donnees[$projet]['noms'] = $nomsVerna['resultat'];
|
|
|
48 |
$this->meta->setProjet($projet);
|
|
|
49 |
$meta = $this->meta->getMetaDonnees();
|
|
|
50 |
$titreMeta = $meta[0]['titre'];
|
|
|
51 |
$this->donnees[$projet]['meta']['titre'] = $titreMeta;
|
|
|
52 |
$this->donnees[$projet]['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($projet);
|
|
|
53 |
}
|
272 |
delphine |
54 |
}
|
321 |
aurelien |
55 |
|
329 |
aurelien |
56 |
public function getBloc() {
|
|
|
57 |
$nt = $this->nomCourant->getNomRetenu()->get('num_taxonomique');
|
964 |
delphine |
58 |
$projet = Config::get($this->referentiel.'.referentielVerna');
|
|
|
59 |
if ($projet != "") {
|
|
|
60 |
$nomsVerna = $this->nomsVernaculaires->getRechercheLimitee($projet, $nt);
|
|
|
61 |
$this->donnees['nomsVerna'] = (isset($nomsVerna['resultat']) && is_array($nomsVerna['resultat'])) ? array_slice($nomsVerna['resultat'], 0, 3) : array();
|
|
|
62 |
$this->donnees['autresNomsVerna'] = count($nomsVerna['resultat']) - 3;
|
|
|
63 |
}
|
959 |
delphine |
64 |
$this->donnees['wikini'] = $this->getWikini();
|
|
|
65 |
return $this->donnees;
|
329 |
aurelien |
66 |
}
|
|
|
67 |
|
321 |
aurelien |
68 |
private function getChorologie() {
|
448 |
delphine |
69 |
$infos_choro = $this->nomCourant->getNomRetenu()->getInfos();
|
959 |
delphine |
70 |
$this->donnees['chorologie'] = $this->traiterTableauChorologie($infos_choro);
|
|
|
71 |
$this->meta->setProjet($this->referentiel);
|
329 |
aurelien |
72 |
$meta = $this->meta->getMetaDonnees();
|
|
|
73 |
$titreMeta = $meta[0]['titre'];
|
959 |
delphine |
74 |
$this->donnees['chorologie']['meta']['titre'] = $titreMeta;
|
|
|
75 |
$this->donnees['chorologie']['meta']['url'] = $this->appUrls->obtenirUrlMetaDonnees($this->referentiel);
|
329 |
aurelien |
76 |
}
|
|
|
77 |
|
|
|
78 |
private function traiterTableauChorologie($infos_choro) {
|
321 |
aurelien |
79 |
$donnees_choro = array();
|
|
|
80 |
$colonnes = array();
|
|
|
81 |
foreach ($infos_choro as $param => $valeur) {
|
329 |
aurelien |
82 |
if(substr($param, 0, 8) == 'presence') {
|
|
|
83 |
$lieu = $this->obtenirLieuPourCodePresence($param);
|
1054 |
raphael |
84 |
if($lieu != '') {
|
321 |
aurelien |
85 |
$donnees_choro['Présence'][$lieu] = $valeur;
|
329 |
aurelien |
86 |
if(!in_array($lieu, $colonnes)) {
|
|
|
87 |
$colonnes[] = $lieu;
|
|
|
88 |
}
|
321 |
aurelien |
89 |
}
|
329 |
aurelien |
90 |
} else {
|
|
|
91 |
$donnees_choro = $this->traiterChampsStatuts($donnees_choro, $param, $valeur);
|
321 |
aurelien |
92 |
}
|
|
|
93 |
}
|
329 |
aurelien |
94 |
|
|
|
95 |
ksort($donnees_choro);
|
|
|
96 |
$donnees = array('colonnes' => $colonnes, 'donnees' => $donnees_choro);
|
321 |
aurelien |
97 |
|
|
|
98 |
return $donnees;
|
|
|
99 |
}
|
329 |
aurelien |
100 |
|
|
|
101 |
private function traiterChampsStatuts($tableau_donnees, $code, $valeur) {
|
455 |
delphine |
102 |
if ($code == 'statut_origine.libelle') {
|
329 |
aurelien |
103 |
$tableau_donnees['Statut d\'origine']['France'] = $valeur;
|
455 |
delphine |
104 |
} elseif ($code == 'statut_introduction.libelle') {
|
329 |
aurelien |
105 |
$tableau_donnees['Statut d\'introduction']['France'] = $valeur;
|
455 |
delphine |
106 |
} elseif ($code == 'statut_culture.libelle') {
|
329 |
aurelien |
107 |
$tableau_donnees['Statut de culture']['France'] = $valeur;
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
return $tableau_donnees;
|
306 |
jpm |
111 |
}
|
329 |
aurelien |
112 |
|
|
|
113 |
private function obtenirLieuPourCodePresence($code) {
|
|
|
114 |
$tableau_presence = explode('_', $code, 2);
|
|
|
115 |
$prefixe = (count($tableau_presence) == 2) ? $tableau_presence[0] : '';
|
|
|
116 |
$lieu = (count($tableau_presence) == 2) ? $tableau_presence[1] : '';
|
|
|
117 |
|
455 |
delphine |
118 |
if($code == 'presence.libelle') {
|
329 |
aurelien |
119 |
$lieu = 'France';
|
1054 |
raphael |
120 |
} elseif (($lieu != '') && strpos($lieu , '.') === false) {
|
329 |
aurelien |
121 |
$lieu = 'France ('.$this->getCorrespondanceLieu($lieu).')';
|
|
|
122 |
} else {
|
|
|
123 |
$lieu = '';
|
|
|
124 |
}
|
|
|
125 |
return $lieu;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
private function getCorrespondanceLieu($lieu) {
|
|
|
129 |
switch(strtolower($lieu)) {
|
|
|
130 |
case 'ga':
|
|
|
131 |
$lieu = 'Hors Corse';
|
|
|
132 |
break;
|
|
|
133 |
case 'co':
|
|
|
134 |
$lieu = 'Corse';
|
|
|
135 |
break;
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
return $lieu;
|
|
|
139 |
}
|
408 |
aurelien |
140 |
|
|
|
141 |
private function getWikini() {
|
|
|
142 |
$wikini = array();
|
|
|
143 |
$wikini['titre'] = 'Wikini';
|
|
|
144 |
$referentiel = $this->conteneur->getParametre('referentiel');
|
|
|
145 |
$num_tax = $this->nomCourant->getNomSelectionne()->get('num_taxonomique');
|
|
|
146 |
$page_wiki = $this->wikini->getPageWikiPourRefEtNumTax($referentiel, $num_tax);
|
419 |
aurelien |
147 |
$wikini['noms_communs'] = $this->wikini->getTexteFormate($page_wiki, 'noms communs');
|
|
|
148 |
$wikini['culture_et_arts'] = $this->wikini->getTexteFormate($page_wiki, 'culture et arts');
|
|
|
149 |
$wikini['usage'] = $this->wikini->getTexteFormate($page_wiki, 'usage');
|
408 |
aurelien |
150 |
return $wikini;
|
|
|
151 |
}
|
272 |
delphine |
152 |
}
|
|
|
153 |
?>
|