370 |
mathilde |
1 |
<?php
|
|
|
2 |
/** Exemple lancement:
|
|
|
3 |
* /opt/lampp/bin/php -d memory_limit=3500M ~/web/eflore-projets/scripts/cli.php baseflor -a chargerTous
|
|
|
4 |
*/
|
|
|
5 |
class Baseflor extends EfloreScript {
|
433 |
jpm |
6 |
|
370 |
mathilde |
7 |
private $table = null;
|
433 |
jpm |
8 |
private $fichierDonnees = '';
|
|
|
9 |
private $log = '';
|
|
|
10 |
private $nb_erreurs;
|
370 |
mathilde |
11 |
private $erreurs_ligne;
|
|
|
12 |
private $ligne_num;
|
|
|
13 |
private $colonne_valeur;
|
|
|
14 |
private $colonne_num;
|
433 |
jpm |
15 |
private $type_bio = array();
|
|
|
16 |
private $ss_type_bio = array();
|
|
|
17 |
private $signes_seuls = array();// basés sur valeurs trouvées (--> pas de légende !)
|
|
|
18 |
private $signes_nn_seuls = array();// basés sur valeurs trouvées (--> pas de légende !)
|
|
|
19 |
private $intervalles = array();
|
|
|
20 |
private $motifs = array();
|
370 |
mathilde |
21 |
|
|
|
22 |
public function executer() {
|
|
|
23 |
try {
|
|
|
24 |
$this->initialiserProjet('baseflor');
|
|
|
25 |
$cmd = $this->getParametre('a');
|
433 |
jpm |
26 |
switch ($cmd) {
|
|
|
27 |
case 'chargerStructureSql' :
|
|
|
28 |
$this->chargerStructureSql();
|
370 |
mathilde |
29 |
break;
|
433 |
jpm |
30 |
case 'chargerMetadonnees':
|
|
|
31 |
$this->chargerMetadonnees();
|
370 |
mathilde |
32 |
break;
|
433 |
jpm |
33 |
case 'chargerOntologies' :
|
|
|
34 |
$this->chargerOntologies();
|
|
|
35 |
break;
|
|
|
36 |
case 'verifierDonnees' :
|
591 |
mathilde |
37 |
$this->verifFichier();
|
433 |
jpm |
38 |
break;
|
|
|
39 |
case 'chargerDonnees' :
|
|
|
40 |
$this->chargerDonnees();
|
|
|
41 |
break;
|
370 |
mathilde |
42 |
case 'genererChamps' :
|
433 |
jpm |
43 |
$this->genererChamps();
|
370 |
mathilde |
44 |
break;
|
522 |
mathilde |
45 |
case 'chargerTous':
|
433 |
jpm |
46 |
$this->chargerStructureSql();
|
416 |
mathilde |
47 |
$this->chargerMetadonnees();
|
433 |
jpm |
48 |
$this->chargerOntologies();
|
|
|
49 |
$this->chargerDonnees();
|
456 |
mathilde |
50 |
$this->genererChamps();
|
522 |
mathilde |
51 |
$this->insererDonneesBaseflorRangSupEcolo();
|
|
|
52 |
$this->insererDonneesIndex();
|
416 |
mathilde |
53 |
break;
|
439 |
mathilde |
54 |
case 'insererDonneesRangSup' :
|
|
|
55 |
$this->insererDonneesBaseflorRangSupEcolo();
|
|
|
56 |
break;
|
433 |
jpm |
57 |
case 'supprimerTous' :
|
|
|
58 |
$this->supprimerTous();
|
|
|
59 |
break;
|
439 |
mathilde |
60 |
case 'voirRangSup' :
|
|
|
61 |
$this->voirRangSup();
|
|
|
62 |
break;
|
|
|
63 |
case 'voirRangSupEcologie' :
|
|
|
64 |
$this->voirRangSupEcologie();
|
|
|
65 |
break;
|
522 |
mathilde |
66 |
case 'insererDonneesIndex' :
|
|
|
67 |
$this->insererDonneesIndex();
|
|
|
68 |
break;
|
370 |
mathilde |
69 |
default :
|
|
|
70 |
throw new Exception("Erreur : la commande '$cmd' n'existe pas!");
|
|
|
71 |
}
|
|
|
72 |
} catch (Exception $e) {
|
|
|
73 |
$this->traiterErreur($e->getMessage());
|
|
|
74 |
}
|
433 |
jpm |
75 |
}
|
370 |
mathilde |
76 |
|
522 |
mathilde |
77 |
|
439 |
mathilde |
78 |
//-- traitement de la table baseflorRangSupInsertion --//
|
|
|
79 |
|
|
|
80 |
private function getClasseBaseflorRangSupInsertion() {
|
|
|
81 |
$conteneur = new Conteneur();
|
|
|
82 |
require_once dirname(__FILE__)."/BaseflorRangSupInsertion.php";
|
522 |
mathilde |
83 |
$rangSupInsert = new BaseflorRangSupInsertion($conteneur, $this->getBdd());
|
439 |
mathilde |
84 |
return $rangSupInsert;
|
|
|
85 |
}
|
522 |
mathilde |
86 |
|
439 |
mathilde |
87 |
private function insererDonneesBaseflorRangSupEcolo(){
|
|
|
88 |
$rangSupInsert = $this->getClasseBaseflorRangSupInsertion();
|
|
|
89 |
$rangSupInsert->insererDonnees();
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
private function voirRangSup(){
|
|
|
93 |
$rangSupInsert = $this->getClasseBaseflorRangSupInsertion();
|
|
|
94 |
$rangSupInsert->testAscendantsDeBaseflor();
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
private function voirRangSupEcologie(){
|
|
|
98 |
$rangSupInsert = $this->getClasseBaseflorRangSupInsertion();
|
|
|
99 |
$rangSupInsert->testEcologieAscendantsDeBaseflor();
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
|
522 |
mathilde |
103 |
//-- traitement de la table baseflorIndex --//
|
|
|
104 |
|
|
|
105 |
private function getClasseBaseflorIndex() {
|
|
|
106 |
$conteneur = new Conteneur();
|
|
|
107 |
require_once dirname(__FILE__)."/BaseflorIndex.php";
|
|
|
108 |
$Index = new BaseflorIndex($conteneur, $this->getBdd());
|
|
|
109 |
return $Index;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
private function insererDonneesIndex(){
|
|
|
113 |
$Index= $this->getClasseBaseflorIndex();
|
|
|
114 |
$Index->insererDonnees();
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
|
439 |
mathilde |
118 |
//-- traitement de la table generer champs --//
|
522 |
mathilde |
119 |
|
433 |
jpm |
120 |
private function genererChamps(){
|
|
|
121 |
$this->initialiserGenerationChamps();
|
|
|
122 |
$this->ajouterChamps();
|
|
|
123 |
$this->analyserChampsExistant();
|
|
|
124 |
}
|
370 |
mathilde |
125 |
|
433 |
jpm |
126 |
private function initialiserGenerationChamps() {
|
|
|
127 |
$this->table = Config::get('tables.donnees');
|
|
|
128 |
}
|
370 |
mathilde |
129 |
|
433 |
jpm |
130 |
private function ajouterChamps() {
|
|
|
131 |
$this->preparerTablePrChpsBDNT();
|
|
|
132 |
$this->preparerTablePrChpsNumTaxon();
|
|
|
133 |
$this->preparerTablePrChpsNumNomen();
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
private function preparerTablePrChpsBDNT() {
|
|
|
137 |
$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'BDNT' ";
|
|
|
138 |
$resultat = $this->getBdd()->recuperer($requete);
|
|
|
139 |
if ($resultat === false) {
|
|
|
140 |
$requete = "ALTER TABLE {$this->table} ".
|
|
|
141 |
'ADD BDNT VARCHAR( 6 ) '.
|
|
|
142 |
'CHARACTER SET utf8 COLLATE utf8_general_ci '.
|
|
|
143 |
'NOT NULL AFTER catminat_code ';
|
|
|
144 |
$this->getBdd()->requeter($requete);
|
|
|
145 |
}
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
private function preparerTablePrChpsNumTaxon() {
|
|
|
149 |
$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'num_taxon' ";
|
|
|
150 |
$resultat = $this->getBdd()->recuperer($requete);
|
|
|
151 |
if ($resultat === false) {
|
|
|
152 |
$requete = "ALTER TABLE {$this->table} ".
|
|
|
153 |
'ADD num_taxon INT( 10 ) NOT NULL '.
|
|
|
154 |
'AFTER catminat_code';
|
|
|
155 |
$this->getBdd()->requeter($requete);
|
|
|
156 |
}
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
private function preparerTablePrChpsNumNomen() {
|
|
|
160 |
$requete = "SHOW COLUMNS FROM {$this->table} LIKE 'num_nomen' ";
|
|
|
161 |
$resultat = $this->getBdd()->recuperer($requete);
|
|
|
162 |
if ($resultat === false) {
|
|
|
163 |
$requete = "ALTER TABLE {$this->table} ".
|
|
|
164 |
'ADD num_nomen INT( 10 ) NOT NULL '.
|
|
|
165 |
'AFTER catminat_code';
|
|
|
166 |
$this->getBdd()->requeter($requete);
|
|
|
167 |
}
|
|
|
168 |
}
|
370 |
mathilde |
169 |
|
433 |
jpm |
170 |
private function analyserChampsExistant() {
|
|
|
171 |
$resultats = $this->recupererTuplesNumsOriginels();
|
|
|
172 |
foreach ($resultats as $chps) {
|
|
|
173 |
$cle = $chps['cle'];
|
|
|
174 |
$nno = $chps['num_nomen_originel'];
|
|
|
175 |
$nto = $chps['num_taxon_originel'];
|
370 |
mathilde |
176 |
|
433 |
jpm |
177 |
$valeurs = array();
|
|
|
178 |
$valeurs["BDNT"] = $this->genererChpsBDNT($nno, $nto);
|
|
|
179 |
$valeurs["num_taxon"] = $this->genererChpsNumTaxon($nto);
|
|
|
180 |
$valeurs["num_nomen"] = $this->genererChpsNumNomen($nno);
|
370 |
mathilde |
181 |
|
433 |
jpm |
182 |
$this->remplirChamps($cle, $valeurs);
|
370 |
mathilde |
183 |
|
433 |
jpm |
184 |
$this->afficherAvancement("Insertion des valeurs dans la base en cours");
|
|
|
185 |
}
|
|
|
186 |
echo "\n";
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
private function recupererTuplesNumsOriginels(){
|
|
|
190 |
$requete = "SELECT cle, num_taxon_originel, num_nomen_originel FROM {$this->table} ";
|
|
|
191 |
$resultat = $this->getBdd()->recupererTous($requete);
|
|
|
192 |
return $resultat;
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
private function genererChpsBDNT($nno, $nto) {
|
|
|
196 |
$bdnt = '';
|
|
|
197 |
if (preg_match("/^([AB])[0-9]+$/", $nno, $retour) || preg_match("/^([AB])[0-9]+$/", $nto, $retour)){
|
|
|
198 |
if ($retour[1]=='A') {
|
|
|
199 |
$bdnt = "BDAFX";
|
|
|
200 |
} else {
|
|
|
201 |
$bdnt = "BDBFX";
|
|
|
202 |
}
|
|
|
203 |
} elseif (($nno == 'nc') && ($nto == 'nc')) {
|
|
|
204 |
$bdnt = "nc";
|
|
|
205 |
} else {
|
|
|
206 |
$bdnt = "BDTFX";
|
|
|
207 |
}
|
|
|
208 |
return $bdnt;
|
|
|
209 |
}
|
|
|
210 |
|
|
|
211 |
private function genererChpsNumTaxon($nto){
|
|
|
212 |
$num_taxon = '';
|
|
|
213 |
if (preg_match("/^[AB]([0-9]+)$/", $nto, $retour)) {
|
|
|
214 |
$num_taxon = intval($retour[1]);
|
|
|
215 |
} elseif($nto == 'nc') {
|
|
|
216 |
$num_taxon = 0;
|
|
|
217 |
} else {
|
|
|
218 |
$num_taxon = intval($nto);
|
|
|
219 |
}
|
|
|
220 |
return $num_taxon;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
private function genererChpsNumNomen($nno) {
|
|
|
224 |
$num_nomen = '';
|
|
|
225 |
if (preg_match("/^[AB]([0-9]+)$/", $nno, $retour)) {
|
|
|
226 |
$num_nomen = intval($retour[1]);
|
|
|
227 |
} elseif ($nno == 'nc') {
|
|
|
228 |
$num_nomen = 0;
|
|
|
229 |
} else {
|
|
|
230 |
$num_nomen = intval($nno);
|
|
|
231 |
}
|
|
|
232 |
return $num_nomen;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
private function remplirChamps($cle, $valeurs) {
|
|
|
236 |
foreach ($valeurs as $nomChamp => $valeurChamp) {
|
|
|
237 |
$valeurChamp = $this->getBdd()->proteger($valeurChamp);
|
|
|
238 |
$requete = "UPDATE {$this->table} SET $nomChamp = $valeurChamp WHERE cle = $cle ";
|
|
|
239 |
$resultat = $this->getBdd()->requeter($requete);
|
|
|
240 |
if ($resultat === false) {
|
|
|
241 |
throw new Exception("Erreur d'insertion pour le tuple clé = $cle");
|
|
|
242 |
}
|
|
|
243 |
}
|
|
|
244 |
}
|
|
|
245 |
|
|
|
246 |
//+------------------------------------------------------------------------------------------------------+
|
|
|
247 |
// chargements, suppression, exécution
|
|
|
248 |
|
|
|
249 |
protected function chargerMetadonnees() {
|
|
|
250 |
$contenuSql = $this->recupererContenu(Config::get('chemins.metadonnees'));
|
|
|
251 |
$this->executerScripSql($contenuSql);
|
|
|
252 |
}
|
|
|
253 |
|
|
|
254 |
private function chargerOntologies() {
|
|
|
255 |
$chemin = Config::get('chemins.ontologies');
|
|
|
256 |
$table = Config::get('tables.ontologies');
|
|
|
257 |
$requete = "LOAD DATA INFILE '$chemin' ".
|
|
|
258 |
"REPLACE INTO TABLE $table ".
|
|
|
259 |
'CHARACTER SET utf8 '.
|
|
|
260 |
'FIELDS '.
|
|
|
261 |
" TERMINATED BY '\t' ".
|
|
|
262 |
" ENCLOSED BY '' ".
|
|
|
263 |
" ESCAPED BY '\\\' "
|
|
|
264 |
;
|
|
|
265 |
$this->getBdd()->requeter($requete);
|
|
|
266 |
}
|
|
|
267 |
|
|
|
268 |
protected function chargerStructureSql() {
|
|
|
269 |
$contenuSql = $this->recupererContenu(Config::get('chemins.structureSql'));
|
|
|
270 |
$this->executerScripSql($contenuSql);
|
|
|
271 |
}
|
|
|
272 |
|
|
|
273 |
protected function executerScripSql($sql) {
|
|
|
274 |
$requetes = Outils::extraireRequetes($sql);
|
|
|
275 |
foreach ($requetes as $requete) {
|
|
|
276 |
$this->getBdd()->requeter($requete);
|
|
|
277 |
}
|
|
|
278 |
}
|
|
|
279 |
|
591 |
mathilde |
280 |
private function chargerDonnees() {
|
433 |
jpm |
281 |
$this->verifFichier();
|
|
|
282 |
if ($this->nb_erreurs > 0) {
|
|
|
283 |
$e = "Je ne peux pas charger les données car le fichier comporte des erreurs.".
|
|
|
284 |
"Voir le fichier baseflor_verif.txt\n";
|
|
|
285 |
throw new Exception($e);
|
|
|
286 |
}
|
|
|
287 |
|
|
|
288 |
$table = Config::get('tables.donnees');
|
|
|
289 |
$requete = "LOAD DATA INFILE '".Config::get('chemins.donnees')."' ".
|
|
|
290 |
"REPLACE INTO TABLE $table ".
|
|
|
291 |
'CHARACTER SET utf8 '.
|
|
|
292 |
'FIELDS '.
|
|
|
293 |
" TERMINATED BY '\t' ".
|
|
|
294 |
" ENCLOSED BY '' ".
|
|
|
295 |
" ESCAPED BY '\\\'";
|
|
|
296 |
$this->getBdd()->requeter($requete);
|
|
|
297 |
}
|
|
|
298 |
|
|
|
299 |
private function supprimerTous() {
|
522 |
mathilde |
300 |
$requete = "DROP TABLE IF EXISTS baseflor_meta, baseflor_ontologies, baseflor_v2012_03_19,".
|
|
|
301 |
" baseflor_rang_sup_ecologie_v2012_03_19, baseflor_index_v2012_03_19 ";
|
433 |
jpm |
302 |
$this->getBdd()->requeter($requete);
|
|
|
303 |
}
|
|
|
304 |
|
|
|
305 |
//+------------------------------------------------------------------------------------------------------+
|
|
|
306 |
// vérifications de données
|
|
|
307 |
|
|
|
308 |
//verifie la cohérence des valeurs des colonnes
|
|
|
309 |
private function verifFichier(){
|
|
|
310 |
$this->initialiserParametresVerif();
|
|
|
311 |
$lignes = file($this->fichierDonnees, FILE_IGNORE_NEW_LINES);
|
|
|
312 |
if ($lignes != false) {
|
|
|
313 |
$this->ajouterAuLog("!!! REGARDEZ LES COLONNES DANS NUMERO_COLONNES_IMPORTANT.TXT.");
|
|
|
314 |
foreach ($lignes as $this->ligne_num => $ligne) {
|
|
|
315 |
$this->verifierErreursLigne($ligne);
|
|
|
316 |
$this->afficherAvancement("Vérification des lignes");
|
|
|
317 |
}
|
|
|
318 |
echo "\n";
|
|
|
319 |
} else {
|
|
|
320 |
$this->traiterErreur("Le fichier {$this->fichierDonnees} ne peut pas être ouvert.");
|
|
|
321 |
}
|
|
|
322 |
|
|
|
323 |
if ($this->nb_erreurs == 0) {
|
|
|
324 |
$this->ajouterAuLog("Il n'y a pas d'erreurs.");
|
|
|
325 |
}
|
|
|
326 |
$this->traiterInfo($this->nb_erreurs." erreurs");
|
|
|
327 |
|
|
|
328 |
$this->ecrireFichierLog();
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
//vérifie par colonnes les erreurs d'une ligne
|
|
|
332 |
private function verifierErreursLigne($ligne){
|
|
|
333 |
$this->erreurs_ligne = array();
|
|
|
334 |
$colonnes = explode("\t", $ligne);
|
|
|
335 |
if (isset($colonnes)) {
|
|
|
336 |
foreach ($colonnes as $this->colonne_num => $this->colonne_valeur) {
|
|
|
337 |
if (( $this->colonne_num > 0 && $this->colonne_num < 15 )
|
|
|
338 |
|| $this->colonne_num == 16
|
|
|
339 |
|| ($this->colonne_num > 18 && $this->colonne_num < 23)
|
|
|
340 |
|| $this->colonne_num > 39) {
|
|
|
341 |
$this->verifierColonne();
|
|
|
342 |
} elseif ($this->colonne_num == 15) {
|
|
|
343 |
$this->verifierTypeBio();
|
|
|
344 |
} elseif ($this->colonne_num >= 23 && $this->colonne_num <= 32) {
|
|
|
345 |
$this->verifierIntervalles($this->colonne_valeur);
|
|
|
346 |
} elseif ($this->colonne_num >= 33 && $this->colonne_num < 41) {
|
|
|
347 |
$this->verifierValeursIndic();
|
|
|
348 |
}
|
|
|
349 |
}
|
|
|
350 |
} else {
|
|
|
351 |
$message = "Ligne {$this->ligne_num} : pas de tabulation";
|
|
|
352 |
$this->ajouterAuLog($message);
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
$this->controlerErreursLigne();
|
|
|
356 |
}
|
|
|
357 |
|
|
|
358 |
private function verifierColonne(){
|
|
|
359 |
$motif = $this->motifs[$this->colonne_num];
|
|
|
360 |
if (preg_match($motif, $this->colonne_valeur) == 0 && $this->verifierSiVide() == false){
|
|
|
361 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
362 |
}
|
|
|
363 |
}
|
|
|
364 |
|
|
|
365 |
private function verifierSiVide(){
|
|
|
366 |
$vide = ($this->colonne_valeur == '') ? true : false;
|
|
|
367 |
return $vide;
|
|
|
368 |
}
|
|
|
369 |
|
|
|
370 |
private function verifierTypeBio(){
|
|
|
371 |
if (preg_match("/(.+)\((.+)\)$/", $this->colonne_valeur, $retour) == 1) {
|
|
|
372 |
$this->verifierTypeEtSsType($retour[1]);
|
|
|
373 |
$this->verifierTypeEtSsType($retour[2]);
|
|
|
374 |
} else {
|
|
|
375 |
$this->verifierTypeEtSsType($this->colonne_valeur);
|
|
|
376 |
}
|
|
|
377 |
}
|
|
|
378 |
|
|
|
379 |
private function verifierTypeEtSsType($chaine_a_verif){
|
|
|
380 |
if (preg_match("/^([a-zA-Zé]+)\-(.+)$|^([a-zA-Zé]+[^\-])$/", $chaine_a_verif, $retour) == 1) {
|
|
|
381 |
$type = (isset($retour[3])) ? $retour[3] : $retour[1];
|
|
|
382 |
$this->verifierType($type);
|
|
|
383 |
|
|
|
384 |
$sousType = $retour[2];
|
|
|
385 |
$this->verifierSousType($sousType);
|
|
|
386 |
}
|
|
|
387 |
}
|
|
|
388 |
|
|
|
389 |
private function verifierType($type) {
|
|
|
390 |
if (in_array($type, $this->type_bio) == false) {
|
|
|
391 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
392 |
}
|
|
|
393 |
}
|
|
|
394 |
|
|
|
395 |
private function verifierSousType($sousType) {
|
|
|
396 |
if ($sousType != ''){
|
|
|
397 |
$ss_type = explode('-', $sousType);
|
|
|
398 |
foreach ($ss_type as $sst) {
|
|
|
399 |
if (in_array($sst, $this->ss_type_bio) == false) {
|
|
|
400 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
401 |
}
|
|
|
402 |
}
|
|
|
403 |
}
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
private function verifierIntervalles($valeur){
|
|
|
407 |
if ($valeur != '') {
|
|
|
408 |
list($min, $max) = explode('-', $this->intervalles[$this->colonne_num]);
|
|
|
409 |
if ($valeur < $min || $valeur > $max){
|
|
|
410 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
411 |
}
|
|
|
412 |
}
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
private function verifierValeursIndic(){
|
|
|
416 |
if (preg_match("/^([^0-9])*([0-9]+)([^0-9])*$/", $this->colonne_valeur, $retour) == 1){
|
|
|
417 |
$this->verifierIntervalles($retour[2]);
|
|
|
418 |
if (isset($retour[3]) && in_array($retour[3], $this->signes_nn_seuls) == false){
|
|
|
419 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
420 |
}
|
|
|
421 |
if ($retour[1] != '-' && $retour[1] != ''){
|
|
|
422 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
423 |
}
|
|
|
424 |
} elseif (in_array( $this->colonne_valeur, $this->signes_seuls) == false && $this->verifierSiVide() == false) {
|
|
|
425 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
426 |
}
|
|
|
427 |
}
|
|
|
428 |
|
|
|
429 |
private function controlerErreursLigne() {
|
|
|
430 |
$nbreErreursLigne = count($this->erreurs_ligne);
|
|
|
431 |
$this->nb_erreurs += $nbreErreursLigne;
|
|
|
432 |
if ($nbreErreursLigne != 0) {
|
|
|
433 |
$this->ajouterAuLog("Erreurs sur la ligne {$this->ligne_num}");
|
|
|
434 |
$ligneLog = '';
|
|
|
435 |
foreach ($this->erreurs_ligne as $cle => $v){
|
|
|
436 |
$ligneLog .= "colonne $cle : $v - ";
|
|
|
437 |
}
|
|
|
438 |
$this->ajouterAuLog($ligneLog);
|
|
|
439 |
}
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
//+------------------------------------------------------------------------------------------------------+
|
|
|
443 |
// Chargement Paramètres
|
|
|
444 |
|
|
|
445 |
private function initialiserParametresVerif() {
|
|
|
446 |
$this->nb_erreurs = 0;
|
|
|
447 |
$this->fichierDonnees = Config::get('chemins.donnees');
|
|
|
448 |
$this->type_bio = $this->getParametreTableau('Parametres.typesBio');
|
|
|
449 |
$this->ss_type_bio = $this->getParametreTableau('Parametres.sousTypesBio');
|
|
|
450 |
$this->signes_seuls = $this->getParametreTableau('Parametres.signesSeuls');
|
|
|
451 |
$this->signes_nn_seuls = $this->getParametreTableau('Parametres.signesNonSeuls');
|
|
|
452 |
$this->intervalles = $this->inverserTableau($this->getParametreTableau('Parametres.intervalles'));
|
|
|
453 |
$this->motifs = $this->inverserTableau($this->getParametreTableau('Parametres.motifs'));
|
439 |
mathilde |
454 |
|
433 |
jpm |
455 |
}
|
|
|
456 |
|
|
|
457 |
private function getParametreTableau($cle) {
|
|
|
458 |
$tableau = array();
|
|
|
459 |
$parametre = Config::get($cle);
|
|
|
460 |
if (empty($parametre) === false) {
|
|
|
461 |
$tableauPartiel = explode(',', $parametre);
|
|
|
462 |
$tableauPartiel = array_map('trim', $tableauPartiel);
|
|
|
463 |
foreach ($tableauPartiel as $champ) {
|
|
|
464 |
if (strpos($champ, '=') !== false && strlen($champ) >= 3) {
|
|
|
465 |
list($cle, $val) = explode('=', $champ);
|
|
|
466 |
$tableau[trim($cle)] = trim($val);
|
|
|
467 |
} else {
|
|
|
468 |
$tableau[] = trim($champ);
|
|
|
469 |
}
|
|
|
470 |
}
|
|
|
471 |
}
|
|
|
472 |
return $tableau;
|
|
|
473 |
}
|
|
|
474 |
|
|
|
475 |
private function inverserTableau($tableau) {
|
|
|
476 |
$inverse = array();
|
|
|
477 |
foreach ($tableau as $cle => $valeurs) {
|
|
|
478 |
$valeurs = explode(';', $valeurs);
|
|
|
479 |
foreach ($valeurs as $valeur) {
|
|
|
480 |
$inverse[$valeur] = $cle;
|
|
|
481 |
}
|
|
|
482 |
}
|
|
|
483 |
return $inverse;
|
|
|
484 |
}
|
|
|
485 |
|
|
|
486 |
//+------------------------------------------------------------------------------------------------------+
|
|
|
487 |
// Gestion du Log
|
|
|
488 |
|
|
|
489 |
private function ajouterAuLog($txt) {
|
|
|
490 |
$this->log .= "$txt\n";
|
|
|
491 |
}
|
|
|
492 |
|
|
|
493 |
private function ecrireFichierLog() {
|
|
|
494 |
$fichierLog = dirname(__FILE__).'/log/verification.log';
|
|
|
495 |
file_put_contents($fichierLog, $this->log);
|
|
|
496 |
}
|
370 |
mathilde |
497 |
}
|
|
|
498 |
?>
|