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 Floraison extends aControleur {
|
|
|
16 |
|
|
|
17 |
private $conteneur = null;
|
|
|
18 |
private $nomCourant = null;
|
|
|
19 |
private $textes = null;
|
|
|
20 |
private $meta = null;
|
|
|
21 |
private $wikini = null;
|
|
|
22 |
private $informations = null;
|
|
|
23 |
private $mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août',
|
|
|
24 |
'septembre', 'octobre', 'novembre', 'décembre');
|
|
|
25 |
private $CosteFormate;
|
|
|
26 |
private $CosteTexte;
|
|
|
27 |
|
|
|
28 |
private $referentiel = 'bdtfx';
|
|
|
29 |
private $donnees = array();
|
|
|
30 |
|
|
|
31 |
public function __construct(Conteneur $conteneur) {
|
|
|
32 |
$this->conteneur = $conteneur;
|
|
|
33 |
$this->nomCourant = $this->conteneur->getNomCourant();
|
|
|
34 |
$this->referentiel = $this->conteneur->getParametre('referentiel');
|
|
|
35 |
$this->textes = $this->conteneur->getApiTextes();
|
|
|
36 |
$this->wikini = $this->conteneur->getApiWikini();
|
|
|
37 |
$this->meta = $this->conteneur->getApiMetaDonnees();
|
|
|
38 |
$this->informations = $this->conteneur->getApiInformations();
|
|
|
39 |
$this->appUrls = $this->conteneur->getAppUrls();
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public function getDonnees() {
|
1357 |
mathias |
43 |
if ($this->referentiel == 'bdtfx') {
|
|
|
44 |
$this->getCoste();
|
|
|
45 |
}
|
990 |
isa |
46 |
if (isset($this->CosteFormate['floraison'])) {
|
|
|
47 |
$this->donnees['floraison'] = $this->getIndiceMois($this->CosteFormate['floraison']);
|
|
|
48 |
} else {
|
|
|
49 |
$this->getFloraisonBaseflor();
|
|
|
50 |
}
|
|
|
51 |
if (isset($this->CosteFormate['fructification'])) {
|
|
|
52 |
$this->donnees['fructification'] = $this->getIndiceMois($this->CosteFormate['fructification']);
|
|
|
53 |
} else {
|
|
|
54 |
$this->donnees['fructification'] = -1;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
return $this->donnees;
|
|
|
58 |
}
|
|
|
59 |
|
|
|
60 |
private function getCoste() {
|
|
|
61 |
$coste = array();
|
|
|
62 |
$this->textes->setProjet('coste');
|
|
|
63 |
$this->textes->setId('bdtfx.nn:'.$this->nomCourant->getNnr());
|
|
|
64 |
$texte = $this->textes->getTexte();
|
1092 |
raphael |
65 |
$texte = array_pop($texte['resultats']);
|
990 |
isa |
66 |
if ($texte) {
|
|
|
67 |
$coste['titre'] = $texte['titre'];
|
1092 |
raphael |
68 |
// TODO: réintroduire les modif' effectuées sur modules/fiche/formateurs/Description.php
|
|
|
69 |
// -les joies du code copié/collé-
|
990 |
isa |
70 |
$coste['description'] = $this->mettreEnFormeCoste($texte['texte']);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
$this->donnees['coste'] = $coste;
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
private function getIndiceMois($elt) {
|
|
|
77 |
$mois = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août',
|
|
|
78 |
'septembre', 'octobre', 'novembre', 'décembre');
|
|
|
79 |
$indice_mois = -1;
|
|
|
80 |
$elt = $this->nettoyerTexte($elt);
|
|
|
81 |
$arr = preg_split('/-/', $elt, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
82 |
if (isset($arr[1])) {
|
|
|
83 |
$mois1 = $this->getIndiceMois($arr[0]);
|
|
|
84 |
$mois2 = $this->getIndiceMois($arr[1]);
|
|
|
85 |
$indice_mois = $mois1.'-'.$mois2;
|
|
|
86 |
} else {
|
|
|
87 |
for ($i = 0; $i < count($mois); $i++) {
|
|
|
88 |
if ($elt == $mois[$i]) {
|
|
|
89 |
$indice_mois = $i;
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
return $indice_mois;
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
private function nettoyerTexte($texte) {
|
|
|
98 |
$texte = trim($texte);
|
|
|
99 |
|
|
|
100 |
$a_effacer = array('.', ' ', 'de');
|
|
|
101 |
$texte = str_replace($a_effacer, '', $texte);
|
|
|
102 |
|
|
|
103 |
$texte = strtolower($texte);
|
|
|
104 |
return $texte;
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
private function getFloraisonBaseflor() {
|
|
|
108 |
$baseflor = array();
|
|
|
109 |
$this->informations->setProjet('baseflor');
|
|
|
110 |
$this->informations->setBdnt($this->conteneur->getParametre('referentiel'));
|
|
|
111 |
$this->informations->setNum_nom($this->conteneur->getParametre('num_nom'));
|
|
|
112 |
$informations = $this->informations->getInformationsDescription();
|
|
|
113 |
|
|
|
114 |
if ($informations){
|
|
|
115 |
$baseflor['chorologie'] = isset($informations['chorologie']) ? $informations['chorologie'] : '';
|
|
|
116 |
$baseflor['inflorescence'] = isset($informations['inflorescence']) ? $informations['inflorescence'] : '';
|
|
|
117 |
$baseflor['sexualite'] = isset($informations['sexualite']) ? $informations['sexualite'] : '';
|
|
|
118 |
$baseflor['ordre_maturation'] = isset($informations['ordre_maturation']) ? $informations['ordre_maturation'] : '';
|
|
|
119 |
$baseflor['pollinisation'] = isset($informations['pollinisation']) ? $informations['pollinisation'] : '';
|
|
|
120 |
$baseflor['dissemination'] = isset($informations['dissemination']) ? $informations['dissemination'] : '';
|
|
|
121 |
$baseflor['fruit'] = isset($informations['fruit']) ? $informations['fruit'] : '';
|
|
|
122 |
$baseflor['couleur_fleur'] = isset($informations['couleur_fleur']) ? $informations['couleur_fleur'] : '';
|
|
|
123 |
$baseflor['macule'] = isset($informations['macule']) ? $informations['macule'] : '';
|
|
|
124 |
$baseflor['type_bio'] = isset($informations['type_bio']) ? $informations['type_bio'] : '';
|
|
|
125 |
$baseflor['form_vegetale'] = isset($informations['form_vegetale']) ? $informations['form_vegetale'] : '';
|
|
|
126 |
$baseflor['floraison'] = isset($informations['floraison']) ? $informations['floraison'] : '';
|
|
|
127 |
}
|
|
|
128 |
$this->donnees['baseflor'] = $baseflor;
|
|
|
129 |
$this->donnees['floraison'] = $baseflor['floraison'];
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
public function mettreEnFormeCoste($texte){
|
|
|
134 |
$this->CosteFormate = array();
|
|
|
135 |
$this->CosteTexte = $texte;
|
|
|
136 |
//decouper elements remarquables avant le texte
|
|
|
137 |
$this->separerNomScientifique_a_NomCommun();
|
|
|
138 |
$this->CosteTexte = preg_replace('/\//','',$this->CosteTexte);
|
|
|
139 |
//decouper elements remarquables après le texte
|
|
|
140 |
$this->separerEcologie_a_Usages();
|
|
|
141 |
//le morceau qui reste est le gros de la description
|
|
|
142 |
$this->CosteTexte = str_replace(';','<br /> -','- '.$this->CosteTexte);
|
|
|
143 |
$this->CosteTexte = str_replace('–','',$this->CosteTexte);
|
|
|
144 |
$this->CosteFormate['texte'] = htmlspecialchars_decode(htmlentities($this->CosteTexte, ENT_NOQUOTES, 'UTF-8'), ENT_NOQUOTES);
|
|
|
145 |
return $this->CosteFormate;
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
public function separerNomScientifique_a_NomCommun(){
|
|
|
149 |
if ( preg_match('/\*\*(.+)\*\*([^–]*)–/', $this->CosteTexte, $retour)){
|
|
|
150 |
/* !! attention on enlève un tiret cadratin – pas un trait d'union - !! */
|
|
|
151 |
$a_enlever = array('/–/','/\./' );
|
|
|
152 |
$this->CosteFormate['nom_scientifique'] = preg_replace($a_enlever,'',$retour[1]);
|
|
|
153 |
if(preg_match('/\((.+)\)/',$retour[2],$synonymes)){
|
|
|
154 |
$this->CosteFormate['synonymes'] = $synonymes[1];
|
|
|
155 |
} else {
|
|
|
156 |
$this->CosteFormate['nom_scientifique'] .= $retour[2];
|
|
|
157 |
}
|
|
|
158 |
$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
|
|
|
159 |
}
|
|
|
160 |
/* !! attention il y a un espace avant les // du début !! */
|
|
|
161 |
if ( preg_match('/^ \/\/([^\/\/]+)\/\//', $this->CosteTexte, $retour)){
|
|
|
162 |
$a_enlever = array('/–/','/\./' );
|
|
|
163 |
$this->CosteFormate['nom_commun'] = preg_replace($a_enlever,'',$retour[1]);
|
|
|
164 |
$this->CosteTexte = str_replace($retour[0],'',$this->CosteTexte);
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
public function separerEcologie_a_Usages(){
|
|
|
169 |
if ( preg_match('/\.[ ]*([A-ZÉÀÈ].+)$/',$this->CosteTexte, $retour)){
|
|
|
170 |
$this->CosteFormate['ecologie'] = $retour[1];
|
|
|
171 |
$this->CosteTexte = str_replace($retour[0],'.',$this->CosteTexte);
|
|
|
172 |
if (isset($this->CosteFormate['ecologie']) && preg_match('/–(.+)/', $this->CosteFormate['ecologie'] , $retour)){
|
|
|
173 |
$this->CosteFormate['repartition'] = $retour[1];
|
|
|
174 |
$this->CosteFormate['ecologie'] = str_replace($retour[0],'',$this->CosteFormate['ecologie']);
|
|
|
175 |
}
|
|
|
176 |
if (isset($this->CosteFormate['repartition']) && preg_match('/=(.+)$/', $this->CosteFormate['repartition'], $retour)){
|
|
|
177 |
$this->CosteFormate['floraison'] = $retour[1];
|
|
|
178 |
$this->CosteFormate['repartition'] = str_replace($retour[0],'',$this->CosteFormate['repartition']);
|
|
|
179 |
}
|
|
|
180 |
if (isset($this->CosteFormate['floraison']) && preg_match('/–(.+)$|\n(.+)$/',$this->CosteFormate['floraison'], $retour)){
|
|
|
181 |
$this->CosteFormate['usages'] = isset($retour[1]) ? $retour[1] : $retour[2];
|
|
|
182 |
$this->CosteFormate['floraison'] = str_replace($retour[0],'.',$this->CosteFormate['floraison']);
|
|
|
183 |
}
|
|
|
184 |
if (isset($this->CosteFormate['floraison']) && preg_match('/([Ff]l\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
|
|
|
185 |
$this->CosteFormate['floraison'] = $retour[2];
|
|
|
186 |
$this->CosteFormate['floraison'] = str_replace($retour[1],'',$this->CosteFormate['floraison']);
|
|
|
187 |
}
|
|
|
188 |
if (isset($this->CosteFormate['floraison']) && preg_match('/([Ff]r\.) (.+)/',$this->CosteFormate['floraison'], $retour)){
|
|
|
189 |
$this->CosteFormate['fructification'] = $retour[2];
|
|
|
190 |
$this->CosteFormate['floraison'] = str_replace($retour[0],'',$this->CosteFormate['floraison']);
|
|
|
191 |
$this->CosteFormate['floraison'] = str_replace(',','',$this->CosteFormate['floraison']);
|
|
|
192 |
$this->CosteFormate['fructification'] = str_replace($retour[1],'',$this->CosteFormate['fructification']);
|
|
|
193 |
$this->CosteFormate['fructification'] = str_replace('.','',$this->CosteFormate['fructification']);
|
|
|
194 |
}
|
|
|
195 |
}
|
|
|
196 |
}
|
|
|
197 |
}
|
|
|
198 |
?>
|