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