Line 31... |
Line 31... |
31 |
private $correspondance_colonnes = array("CD_NOM" => "", "CD_SUP" => "", "CD_REF" => "",
|
31 |
private $correspondance_colonnes = array("CD_NOM" => "", "CD_SUP" => "", "CD_REF" => "",
|
32 |
"RANG" => "rang", "LB_NOM" => "nom_sci", "LB_AUTEUR" => array("auteur","annee"),
|
32 |
"RANG" => "rang", "LB_NOM" => "nom_sci", "LB_AUTEUR" => array("auteur","annee"),
|
33 |
"FR" => "presence",
|
33 |
"FR" => "presence",
|
34 |
"FR-FRA" => "presence_Ga", "FR-COR" => "presence_Co", "REU" => "presence",
|
34 |
"FR-FRA" => "presence_Ga", "FR-COR" => "presence_Co", "REU" => "presence",
|
35 |
"GUA" => "presence_Guadeloupe", "SMSB" => array("presence_Saint_Martin", "presence_Saint_Barthelemy"),
|
35 |
"GUA" => "presence_Guadeloupe", "SMSB" => array("presence_Saint_Martin", "presence_Saint_Barthelemy"),
|
36 |
"MAR" => "presence_Martinique",
|
36 |
"SM" => "presence_Saint_Martin", "SB" => "presence_Saint_Barthelemy", "MAR" => "presence_Martinique",
|
37 |
"GF" => "presence", "MAY" => "presence_Mayotte", "TAAF" => "presence_Taaf",
|
37 |
"GF" => "presence", "MAY" => "presence_Mayotte", "TAAF" => "presence_Taaf",
|
38 |
"SPM" => "presence_Guadeloupe", "PF" => "presence_Polynesie", "NC" => "presence_Nouvelle_Caledonie",
|
38 |
"SPM" => "presence_Guadeloupe", "PF" => "presence_Polynesie", "NC" => "presence_Nouvelle_Caledonie",
|
39 |
"BIBLIO" => "biblio_origine", "BDNGM" => "num_nom" );
|
39 |
"BIBLIO" => "biblio_origine", "BDNGM" => "num_nom", "NUM_NOM" => "num_nom", "NOM_VERN" => "nom_francais");
|
Line 40... |
Line 40... |
40 |
|
40 |
|
41 |
private $sans_correspondance = array(
|
41 |
private $sans_correspondance = array(
|
42 |
"FG_VALIDITE", "habitat", "WF", "CLI", "EPA",
|
42 |
"FG_VALIDITE", "habitat", "WF", "CLI", "EPA",
|
43 |
"EU", "WLD", "ORACLE",
|
43 |
"EU", "WLD", "ORACLE",
|
Line 92... |
Line 92... |
92 |
$this->creerTableTaxref();
|
92 |
$this->creerTableTaxref();
|
93 |
$this->ajouterColonneCDNOM();
|
93 |
$this->ajouterColonneCDNOM();
|
94 |
Debug::printr("Fin de la création de la table.");
|
94 |
Debug::printr("Fin de la création de la table.");
|
95 |
$this->ajouterDonneesTaxRef($donnees);
|
95 |
$this->ajouterDonneesTaxRef($donnees);
|
96 |
Debug::printr("Fin de l'insertion des données.");
|
96 |
Debug::printr("Fin de l'insertion des données.");
|
- |
|
97 |
$this->decouperNomSciTaxRef();
|
97 |
$this->creerTableComparaison();
|
98 |
$this->creerTableComparaison();
|
98 |
Debug::printr("Fin de la création de la table comparaison.");
|
99 |
Debug::printr("Fin de la création de la table comparaison.");
|
99 |
Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
|
100 |
Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
|
100 |
} else {
|
101 |
} else {
|
101 |
Debug::printr("Fichier introuvable".$fichier);
|
102 |
Debug::printr("Fichier introuvable".$fichier);
|
Line 104... |
Line 105... |
104 |
} else {
|
105 |
} else {
|
105 |
Debug::printr("Pas de traitement");
|
106 |
Debug::printr("Pas de traitement");
|
106 |
}
|
107 |
}
|
107 |
}
|
108 |
}
|
Line -... |
Line 109... |
- |
|
109 |
|
- |
|
110 |
|
108 |
|
111 |
// +-------------------------------------------------------------------------------------------------------------------+
|
109 |
private function creerTableTaxref() {
|
112 |
private function creerTableTaxref() {
|
110 |
$requete = "DROP TABLE IF EXISTS {$this->referentiel}_taxref; ".
|
113 |
$requete = "DROP TABLE IF EXISTS {$this->referentiel}_taxref; ".
|
111 |
"CREATE TABLE {$this->referentiel}_taxref AS SELECT * FROM {$this->referentiel};".
|
114 |
"CREATE TABLE {$this->referentiel}_taxref AS SELECT * FROM {$this->referentiel};".
|
112 |
"ALTER TABLE {$this->referentiel}_taxref ADD PRIMARY KEY (num_nom);";
|
115 |
"ALTER TABLE {$this->referentiel}_taxref ADD PRIMARY KEY (num_nom);";
|
113 |
$resultat = $this->executerRequeter($requete);
|
116 |
$resultat = $this->executerRequeter($requete);
|
- |
|
117 |
}
|
114 |
}
|
118 |
|
115 |
private function ajouterColonneCDNOM() {
|
119 |
private function ajouterColonneCDNOM() {
|
116 |
$requete = "ALTER TABLE {$this->referentiel}_taxref ADD ".
|
120 |
$requete = "ALTER TABLE {$this->referentiel}_taxref ADD ".
|
117 |
"`num_taxref` INT( 15 ) NULL DEFAULT NULL COMMENT 'numéro correspondant dans la base taxref.';";
|
121 |
"`CD_NOM` INT( 15 ) NULL DEFAULT NULL COMMENT 'numéro correspondant dans la base taxref.';";
|
118 |
$resultat = $this->executerRequeter($requete);
|
122 |
$resultat = $this->executerRequeter($requete);
|
- |
|
123 |
}
|
119 |
}
|
124 |
|
120 |
private function ajouterDonneesTaxRef($liste_noms) {
|
125 |
private function ajouterDonneesTaxRef($liste_noms) {
|
121 |
$i = 0; $j = 0; $requete = "";
|
126 |
$i = 0; $j = 0; $requete = "";
|
122 |
foreach ($liste_noms as $nom) { $i++;
|
127 |
foreach ($liste_noms as $nom) { $i++;
|
123 |
$requete .= "UPDATE {$this->referentiel}_taxref SET ".implode(' , ', $nom).
|
128 |
$requete .= "UPDATE {$this->referentiel}_taxref SET ".implode(' , ', $nom).
|
Line 129... |
Line 134... |
129 |
}
|
134 |
}
|
130 |
$i = 0; $requete = "";
|
135 |
$i = 0; $requete = "";
|
131 |
}
|
136 |
}
|
132 |
}
|
137 |
}
|
133 |
}
|
138 |
}
|
- |
|
139 |
|
134 |
private function creerTableComparaison() {
|
140 |
private function creerTableComparaison() {
|
135 |
foreach ($this->noms_colonnes as $colonne) {
|
141 |
foreach ($this->noms_colonnes as $colonne) {
|
136 |
if (isset($this->correspondance_colonnes[$colonne]) && $this->correspondance_colonnes[$colonne] != "") {
|
142 |
if (isset($this->correspondance_colonnes[$colonne]) && $this->correspondance_colonnes[$colonne] != "") {
|
137 |
$nom_champ = $this->correspondance_colonnes[$colonne];
|
143 |
$nom_champ = $this->correspondance_colonnes[$colonne];
|
138 |
if (is_array($nom_champ)) {
|
144 |
if (is_array($nom_champ)) {
|
Line 146... |
Line 152... |
146 |
$champs_tax[] = "b.{$nom_champ} AS {$nom_champ}";
|
152 |
$champs_tax[] = "b.{$nom_champ} AS {$nom_champ}";
|
147 |
$concat[] = "IF(t.{$nom_champ} != b.{$nom_champ}, '{$nom_champ}, ', '')";
|
153 |
$concat[] = "IF(t.{$nom_champ} != b.{$nom_champ}, '{$nom_champ}, ', '')";
|
148 |
}
|
154 |
}
|
149 |
}
|
155 |
}
|
150 |
}
|
156 |
}
|
- |
|
157 |
date_default_timezone_set('Europe/London');
|
151 |
$requete = "CREATE TABLE {$this->referentiel}_comparaison_".date("Y_m_d_H_i_s")." AS".
|
158 |
$requete = "CREATE TABLE {$this->referentiel}_comparaison_".date("Y_m_d_H_i_s")." AS".
|
152 |
" SELECT CONCAT(".implode(', ', $concat).") AS difference, ".implode(', ', $champs_tax).
|
159 |
" SELECT CONCAT(".implode(', ', $concat).") AS difference, ".implode(', ', $champs_tax).
|
153 |
" FROM {$this->referentiel} b, {$this->referentiel}_taxref t".
|
160 |
" FROM {$this->referentiel} b, {$this->referentiel}_taxref t".
|
154 |
" WHERE b.num_nom = t.num_nom AND (b.nom_sci != t.nom_sci or b.auteur != t.auteur or b.annee != t.annee);";
|
161 |
" WHERE b.num_nom = t.num_nom AND (b.nom_sci != t.nom_sci or b.auteur != t.auteur or b.annee != t.annee);";
|
155 |
echo $requete;
|
162 |
//echo $requete;
|
156 |
$resultat = $this->executerRequeter($requete);
|
163 |
$resultat = $this->executerRequeter($requete);
|
157 |
}
|
164 |
}
|
Line -... |
Line 165... |
- |
|
165 |
|
158 |
|
166 |
// +-------------------------------------------------------------------------------------------------------------------+
|
159 |
private function traiterFichierTaxref($fichier) {
|
167 |
private function traiterFichierTaxref($fichier) {
|
160 |
$donnees = array();
|
168 |
$donnees = array();
|
161 |
if (($pointeur = fopen($fichier, "r")) !== FALSE) {
|
169 |
if (($pointeur = fopen($fichier, "r")) !== FALSE) {
|
- |
|
170 |
$this->noms_colonnes = fgetcsv($pointeur, 1000, chr(9));
|
162 |
$this->noms_colonnes = fgetcsv($pointeur, 1000, chr(9));
|
171 |
$num_nom = 0;
|
163 |
while (($ligne = fgetcsv($pointeur, 1000, chr(9))) !== FALSE) {
|
172 |
while (($ligne = fgetcsv($pointeur, 1000, chr(9))) !== FALSE) {
|
164 |
$nombreChamps = count($ligne);
|
173 |
$nombreChamps = count($ligne);
|
165 |
$taxref[$ligne[0]] = $ligne;
|
174 |
$taxref[$ligne[0]] = $ligne;
|
166 |
for ($c=0; $c < $nombreChamps; $c++) {
|
175 |
for ($c=0; $c < $nombreChamps; $c++) {
|
167 |
if (isset($this->correspondance_colonnes[$this->noms_colonnes[$c]])) {
|
176 |
if (isset($this->correspondance_colonnes[$this->noms_colonnes[$c]])) {
|
168 |
if (is_array($this->correspondance_colonnes[$this->noms_colonnes[$c]])) {
|
177 |
if (is_array($this->correspondance_colonnes[$this->noms_colonnes[$c]])) {
|
169 |
if ($this->noms_colonnes[$c] == 'LB_AUTEUR') {//echo $ligne[$c];
|
- |
|
170 |
$valeur = explode(',', $ligne[$c]);
|
178 |
if ($this->noms_colonnes[$c] == 'LB_AUTEUR') {
|
171 |
if (count($valeur) > 1) {//print_r($matches);
|
179 |
if (preg_match('/(.*), +([0-9]{4})/', utf8_encode($ligne[$c]), $matches) == 1) {
|
172 |
$nom['auteur'] = 'auteur="'.$valeur[0].'"';
|
180 |
$nom['auteur'] = 'auteur="'.$matches[1].'"';
|
173 |
$nom['annee'] = 'annee="'.trim($valeur[1]).'"';
|
181 |
$nom['annee'] = 'annee="'.trim($matches[2]).'"';
|
174 |
} else {
|
182 |
} else {
|
175 |
$nom['auteur'] = 'auteur="'.$ligne[$c].'"';
|
183 |
$nom['auteur'] = 'auteur="'.utf8_encode($ligne[$c]).'"';
|
176 |
$nom['annee'] = 'annee=""';
|
184 |
$nom['annee'] = 'annee=""';
|
177 |
}
|
185 |
}
|
178 |
} else {
|
186 |
} else {
|
179 |
foreach ($this->correspondance_colonnes[$this->noms_colonnes[$c]] as $a=>$nom_colonne) {
|
187 |
foreach ($this->correspondance_colonnes[$this->noms_colonnes[$c]] as $a=>$nom_colonne) {
|
Line 182... |
Line 190... |
182 |
}
|
190 |
}
|
183 |
} elseif ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "") {
|
191 |
} elseif ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "") {
|
184 |
$nom[$this->noms_colonnes[$c]] = $ligne[$c];
|
192 |
$nom[$this->noms_colonnes[$c]] = $ligne[$c];
|
185 |
} else {
|
193 |
} else {
|
186 |
if ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "rang") {
|
194 |
if ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "rang") {
|
- |
|
195 |
$rang = $this->rangs_bdnt_taxref[$ligne[$c]];
|
- |
|
196 |
// à remettre si on décide de prendre les rangs taxref
|
187 |
$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
197 |
//$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
188 |
$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.$this->rangs_bdnt_taxref[$ligne[$c]].'"';
|
198 |
//$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.$this->rangs_bdnt_taxref[$ligne[$c]].'"';
|
189 |
} elseif ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "num_nom") {
|
199 |
} elseif ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "num_nom") {
|
190 |
$num_nom = $ligne[$c];
|
200 |
$num_nom = $ligne[$c];
|
191 |
$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
201 |
$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
192 |
$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.$ligne[$c].'"';
|
202 |
$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.$ligne[$c].'"';
|
- |
|
203 |
} elseif ($this->correspondance_colonnes[$this->noms_colonnes[$c]] == "nom_sci") {
|
- |
|
204 |
$nom_sci = $ligne[$c];
|
- |
|
205 |
$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
- |
|
206 |
$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.trim($ligne[$c]).'"';
|
193 |
} else {
|
207 |
} else {
|
194 |
$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
208 |
$nom[$this->correspondance_colonnes[$this->noms_colonnes[$c]]] =
|
195 |
$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.$ligne[$c].'"';;
|
209 |
$this->correspondance_colonnes[$this->noms_colonnes[$c]].'="'.trim($ligne[$c]).'"';
|
196 |
}
|
210 |
}
|
197 |
}
|
211 |
}
|
198 |
}
|
212 |
}
|
199 |
}
|
213 |
}
|
200 |
$nom['exclure_taxref'] = 'exclure_taxref="0"';
|
214 |
$nom['exclure_taxref'] = 'exclure_taxref="0"';
|
Line 213... |
Line 227... |
213 |
if (isset($correspondance[$infos['CD_SUP']])) {
|
227 |
if (isset($correspondance[$infos['CD_SUP']])) {
|
214 |
$donnees[$num_nom]['num_tax_sup'] = "num_tax_sup=".$correspondance[$infos['CD_SUP']];
|
228 |
$donnees[$num_nom]['num_tax_sup'] = "num_tax_sup=".$correspondance[$infos['CD_SUP']];
|
215 |
$i++;
|
229 |
$i++;
|
216 |
} elseif ($infos['CD_SUP'] != '') {
|
230 |
} elseif ($infos['CD_SUP'] != '') {
|
217 |
$donnees[$num_nom]['num_tax_sup'] = "num_tax_sup=''";
|
231 |
$donnees[$num_nom]['num_tax_sup'] = "num_tax_sup=''";
|
218 |
$sup[$infos['CD_NOM']] = $taxref[$infos['CD_NOM']];
|
232 |
//$sup[$infos['CD_NOM']] = $taxref[$infos['CD_NOM']];
|
- |
|
233 |
$sup[$infos['CD_SUP']] = $infos['CD_SUP'];
|
219 |
}
|
234 |
}
|
220 |
unset($donnees[$num_nom]['CD_SUP']);
|
235 |
unset($donnees[$num_nom]['CD_SUP']);
|
221 |
if (isset($correspondance[$infos['CD_REF']])) {
|
236 |
if (isset($correspondance[$infos['CD_REF']])) {
|
222 |
$donnees[$num_nom]['num_nom_retenu'] = "num_nom_retenu=".$correspondance[$infos['CD_REF']];
|
237 |
$donnees[$num_nom]['num_nom_retenu'] = "num_nom_retenu=".$correspondance[$infos['CD_REF']];
|
223 |
$j++;
|
238 |
$j++;
|
224 |
} elseif ($infos['CD_REF'] != '') {$k++;
|
239 |
} elseif ($infos['CD_REF'] != '') {$k++;
|
225 |
$donnees[$num_nom]['num_nom_retenu'] = "num_nom_retenu=''";
|
240 |
$donnees[$num_nom]['num_nom_retenu'] = "num_nom_retenu=''";
|
226 |
$ref[$infos['CD_NOM']] = $taxref[$infos['CD_NOM']];
|
241 |
//$ref[$infos['CD_NOM']] = $taxref[$infos['CD_NOM']];
|
- |
|
242 |
$ref[$infos['CD_REF']] = $infos['CD_REF'];
|
227 |
} else {
|
243 |
} else {
|
228 |
Debug::printr($infos['CD_NOM']."n'a pas de valeur pour CD_REF");
|
244 |
Debug::printr($infos['CD_NOM']."n'a pas de valeur pour CD_REF");
|
229 |
}
|
245 |
}
|
230 |
unset($donnees[$num_nom]['CD_REF']);
|
246 |
unset($donnees[$num_nom]['CD_REF']);
|
231 |
$donnees[$num_nom]['CD_NOM'] = 'num_taxref='.$donnees[$num_nom]['CD_NOM'];
|
247 |
$donnees[$num_nom]['CD_NOM'] = 'CD_NOM='.$donnees[$num_nom]['CD_NOM'];
|
232 |
}
|
- |
|
- |
|
248 |
}//echo "les taxons supérieurs manquants :".implode(" ,", $sup)." \nles retenus ".implode(" ,", $ref);
|
233 |
//$this->ecrireFichierCsv($ref, './retenu_absent.csv');
|
249 |
//$this->ecrireFichierCsv($ref, './retenu_absent.csv');
|
- |
|
250 |
//$this->ajouterTaxonAbsent($abs);
|
234 |
//$this->ecrireFichierCsv($sup, './superieur_absent.csv');
|
251 |
//$this->ecrireFichierCsv($sup, './superieur_absent.csv');
|
235 |
echo "$j correspondance pour nom retenu $i correspondance pour nom sup $k non pas de correspondance retenu";
|
252 |
echo "$j correspondance pour nom retenu $i correspondance pour nom sup $k non pas de correspondance retenu";
|
236 |
return $donnees;
|
253 |
return $donnees;
|
237 |
}
|
254 |
}
|
Line -... |
Line 255... |
- |
|
255 |
|
- |
|
256 |
// rechercher dans reftax les numéros absent dans la base
|
- |
|
257 |
// modifier les tableaux ref et sup pour modifier $donnees (ajout + modif)
|
- |
|
258 |
private function ajouterTaxonAbsent($abs) {
|
- |
|
259 |
$requete = "SELECT ".implode(",", $this->noms_colonnes)." FROM taxref_v5 where CD_NOM IN (".implode(",", $abs).")";
|
- |
|
260 |
echo $requete;
|
- |
|
261 |
}
|
- |
|
262 |
|
- |
|
263 |
private function creerCorrespondanceRangBdntTaxref() {
|
- |
|
264 |
$rangs = explode(',', $this->manuel['rangs_bdnt_taxref']);
|
- |
|
265 |
foreach ($rangs as $rang) {
|
- |
|
266 |
list($id_bdnt, $code_taxref) = explode(':', trim($rang));
|
- |
|
267 |
$this->rangs_bdnt_taxref[$code_taxref] = $id_bdnt;
|
- |
|
268 |
}
|
- |
|
269 |
}
|
- |
|
270 |
|
- |
|
271 |
// +-------------------------------------------------------------------------------------------------------------------+
|
- |
|
272 |
private function decouperNomSciTaxRef() {
|
- |
|
273 |
$requete = "SELECT num_nom, nom_sci, rang, type_epithete FROM {$this->referentiel}_taxref WHERE CD_NOM != ''";
|
- |
|
274 |
$resultats = $this->executerRequeter($requete);
|
- |
|
275 |
foreach ($resultats as $nom) {
|
- |
|
276 |
extract($nom);
|
- |
|
277 |
$nomen =array('nom_supra_generique' => 'nom_supra_generique=""', 'genre' => 'genre=""',
|
- |
|
278 |
'epithete_infra_generique' => 'epithete_infra_generique=""', 'epithete_sp' => 'epithete_sp=""',
|
- |
|
279 |
'type_epithete' => 'type_epithete=""', 'epithete_infra_sp' => 'epithete_infra_sp=""',
|
- |
|
280 |
'cultivar_groupe' => 'cultivar_groupe=""', 'cultivar' => 'cultivar=""', 'nom_commercial' => 'nom_commercial=""');
|
- |
|
281 |
$parties_noms = explode(' ', $nom_sci);
|
- |
|
282 |
if ($rang < 220) {
|
- |
|
283 |
$nomen['nom_supra_generique'] = 'nom_supra_generique="'.$nom_sci.'"';
|
- |
|
284 |
} elseif ($rang == 220) {
|
- |
|
285 |
$nomen['genre'] = 'genre="'.trim($nom_sci).'"';
|
- |
|
286 |
} elseif ($rang < 290) {
|
- |
|
287 |
$nomen['genre'] = 'genre="'.$parties_noms[0].'"';
|
- |
|
288 |
$nomen['epithete_infra_generique'] = 'epithete_infra_generique="'.$parties_noms[1].'"';
|
- |
|
289 |
} else {
|
- |
|
290 |
$nomen = array_merge($nomen, $this->decouperEspece($parties_noms));
|
- |
|
291 |
$hybride = $this->etreHybride($parties_noms);
|
- |
|
292 |
if (isset($parties_noms[2]) && ($hybride === false || $hybride > 2)) {
|
- |
|
293 |
$nomen = array_merge($nomen, $this->decouperSousEspece($parties_noms));
|
- |
|
294 |
}
|
- |
|
295 |
}
|
- |
|
296 |
$update = "UPDATE {$this->referentiel}_taxref SET ".implode(' , ', $nomen)." WHERE num_nom = ".$num_nom;
|
- |
|
297 |
$resultat = $this->executerRequeter($update);
|
- |
|
298 |
}
|
- |
|
299 |
return $nomen;
|
- |
|
300 |
}
|
- |
|
301 |
|
- |
|
302 |
private function decouperSousEspece($parties_noms) {
|
- |
|
303 |
if ($this->etreTypeSousEpithete($parties_noms[2]) == true) {
|
- |
|
304 |
$nomen['type_epithete'] = 'type_epithete="'.$parties_noms[2].'"';
|
- |
|
305 |
$nomen['epithete_infra_sp'] = 'epithete_infra_sp="'.$parties_noms[3].'"';
|
- |
|
306 |
} elseif (strpos($parties_noms[2], '(') === 0) {
|
- |
|
307 |
$nomen['cultivar_groupe'] = 'cultivar_groupe="'.trim($parties_noms[2], "(").'"';
|
- |
|
308 |
} elseif (strpos($parties_noms[2], "'") === 0) {
|
- |
|
309 |
$nomen['cultivar'] = 'cultivar="'.trim($parties_noms[2], "'").'"';
|
- |
|
310 |
} elseif (ctype_upper($parties_noms[2]) === true) {
|
- |
|
311 |
$nomen['nom_commercial'] = 'nom_commercial="'.$parties_noms[2].'"';
|
- |
|
312 |
} else {
|
- |
|
313 |
$nomen['epithete_infra_sp'] = 'epithete_infra_sp="'.$parties_noms[2].'"';
|
- |
|
314 |
}
|
- |
|
315 |
return $nomen;
|
- |
|
316 |
}
|
- |
|
317 |
|
- |
|
318 |
private function etreTypeSousEpithete($chaine) {
|
- |
|
319 |
$type = false;
|
- |
|
320 |
$types_epithete = array('subsp.', 'infra-sp.', 'var.', 'subvar.', 'f.', 'subf.', 'f. sp.', 'race', 'proles');
|
- |
|
321 |
if (in_array(utf8_encode($chaine), $types_epithete)) {
|
- |
|
322 |
$type = true;
|
- |
|
323 |
}
|
- |
|
324 |
return $type;
|
- |
|
325 |
}
|
- |
|
326 |
|
- |
|
327 |
private function decouperEspece($parties_noms) {
|
- |
|
328 |
$nomen['genre'] = 'genre="'.$parties_noms[0].'"';
|
- |
|
329 |
$nomen['epithete_sp'] = 'epithete_sp="'.$parties_noms[1].'"';
|
- |
|
330 |
$hybride = $this->etreHybride($parties_noms);
|
- |
|
331 |
$chimere = array_search('+', $parties_noms);
|
- |
|
332 |
if ($hybride != false || $hybride===0) {
|
- |
|
333 |
$nomen = $this->decouperEspeceHybride($hybride, $parties_noms);
|
- |
|
334 |
}
|
- |
|
335 |
return $nomen;
|
- |
|
336 |
}
|
- |
|
337 |
|
- |
|
338 |
private function etreHybride($parties_noms) {
|
- |
|
339 |
$hybride = array_search('x', $parties_noms);
|
- |
|
340 |
return $hybride;
|
- |
|
341 |
}
|
- |
|
342 |
|
- |
|
343 |
private function decouperEspeceHybride($hybride, $parties_noms) {
|
- |
|
344 |
if ($hybride == 0) {
|
- |
|
345 |
$nomen['genre'] = 'genre="'.$parties_noms[0].' '.$parties_noms[1].'"';
|
- |
|
346 |
$nomen['epithete_sp'] = 'epithete_sp="'.$parties_noms[2].'"';
|
- |
|
347 |
} elseif ($hybride == 1 && count($parties_noms) == 4) {
|
- |
|
348 |
$nomen['genre'] = 'genre="'.$parties_noms[0].' '.$parties_noms[1].' '.$parties_noms[2].'"';
|
- |
|
349 |
$nomen['epithete_sp'] = 'epithete_sp="'.$parties_noms[3].'"';
|
- |
|
350 |
} elseif ($hybride == 1 && count($parties_noms) == 3) {
|
- |
|
351 |
$nomen['genre'] = 'genre="'.$parties_noms[0].'"';
|
- |
|
352 |
$nomen['epithete_sp'] = 'epithete_sp="'.$parties_noms[1].' '.$parties_noms[2].'"';
|
- |
|
353 |
} elseif ($hybride == 2) {
|
- |
|
354 |
$nomen['genre'] = 'genre="'.$parties_noms[0].'"';
|
- |
|
355 |
$nomen['epithete_sp'] = 'epithete_sp="'.$parties_noms[1].' '.$parties_noms[2].' '.$parties_noms[3].'"';
|
- |
|
356 |
}
|
- |
|
357 |
return $nomen;
|
- |
|
358 |
}
|
- |
|
359 |
|
238 |
|
360 |
// +-------------------------------------------------------------------------------------------------------------------+
|
239 |
private function ecrireFichierCsv(&$contenu, $fichier) {
|
361 |
private function ecrireFichierCsv(&$contenu, $fichier) {
|
240 |
$retour = true;
|
362 |
$retour = true;
|
241 |
$fichier = fopen($fichier, "w");
|
363 |
$fichier = fopen($fichier, "w");
|
242 |
fputcsv($fichier, $this->noms_colonnes, chr('9'));
|
364 |
fputcsv($fichier, $this->noms_colonnes, chr('9'));
|
Line 249... |
Line 371... |
249 |
}
|
371 |
}
|
250 |
$contenu = null;
|
372 |
$contenu = null;
|
251 |
return $retour;
|
373 |
return $retour;
|
252 |
}
|
374 |
}
|
Line 253... |
Line -... |
253 |
|
- |
|
254 |
private function creerCorrespondanceRangBdntTaxref() {
|
- |
|
255 |
$rangs = explode(',', $this->manuel['rangs_bdnt_taxref']);
|
- |
|
256 |
foreach ($rangs as $rang) {
|
- |
|
257 |
list($id_bdnt, $code_taxref) = explode(':', trim($rang));
|
- |
|
258 |
$this->rangs_bdnt_taxref[$code_taxref] = $id_bdnt;
|
- |
|
259 |
}
|
- |
|
Line 260... |
Line 375... |
260 |
}
|
375 |
|
261 |
|
376 |
|
262 |
private function connecterPDO() {
|
377 |
private function connecterPDO() {
|
263 |
Config::charger('./configurations/bdd.ini');
|
378 |
Config::charger('./configurations/bdd.ini');
|
264 |
try {
|
379 |
try {
|
- |
|
380 |
$dsn = Config::get('bdd_type').':dbname='.Config::get('bdd_nom').';host='.
|
265 |
$dsn = Config::get('bdd_type').':dbname='.Config::get('bdd_nom').';host='.
|
381 |
Config::get('bdd_hote');
|
266 |
Config::get('bdd_hote');
|
382 |
//$dsn = "mysql:dbname=referentiels;host=localhost";
|
267 |
$this->bdd = new PDO($dsn, Config::get('bdd_utilisateur'), Config::get('bdd_mot_de_passe'));
|
383 |
$this->bdd = new PDO($dsn, Config::get('bdd_utilisateur'), Config::get('bdd_mot_de_passe'));
|
268 |
} catch (PDOException $e) {
|
384 |
} catch (PDOException $e) {
|
269 |
print_r($e);
|
385 |
print_r($e);
|
Line 281... |
Line 397... |
281 |
$infos = $this->bdd->query($requete);
|
397 |
$infos = $this->bdd->query($requete);
|
282 |
if ($infos === false) {
|
398 |
if ($infos === false) {
|
283 |
echo $requete;
|
399 |
echo $requete;
|
284 |
}
|
400 |
}
|
285 |
} catch (PDOException $e) {
|
401 |
} catch (PDOException $e) {
|
286 |
//print_r($this->bdd->errorInfo());
|
- |
|
287 |
echo sprintf($e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode()); //echo $requete;
|
402 |
echo sprintf($e->getFile(), $e->getLine(), $e->getMessage(), $e->getCode(), $requete);
|
288 |
}
|
403 |
}
|
289 |
return $infos;
|
404 |
return $infos;
|
290 |
}
|
405 |
}
|
291 |
}
|
406 |
}
|
292 |
?>
|
407 |
?>
|
293 |
|
408 |
|