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