602 |
mathilde |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class BaseflorVerif extends VerificateurDonnees {
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
private $type_bio = array();
|
|
|
7 |
private $ss_type_bio = array();
|
|
|
8 |
private $signes_seuls = array();// basés sur valeurs trouvées (--> pas de légende !)
|
|
|
9 |
private $signes_nn_seuls = array();// basés sur valeurs trouvées (--> pas de légende !)
|
|
|
10 |
private $intervalles = array();
|
|
|
11 |
private $motifs = array();
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
//obligatoire
|
|
|
15 |
public function definirTraitementsColonnes() {
|
|
|
16 |
$this->initialiserParametresVerif() ;
|
|
|
17 |
if (( $this->colonne_num > 0 && $this->colonne_num < 15 )
|
|
|
18 |
|| $this->colonne_num == 16
|
|
|
19 |
|| ($this->colonne_num > 18 && $this->colonne_num < 23)
|
|
|
20 |
|| $this->colonne_num > 39) {
|
|
|
21 |
$this->verifierColonne();
|
|
|
22 |
} elseif ($this->colonne_num == 15) {
|
|
|
23 |
$this->verifierTypeBio();
|
|
|
24 |
} elseif ($this->colonne_num >= 23 && $this->colonne_num <= 32) {
|
|
|
25 |
$this->verifierIntervalles($this->colonne_valeur);
|
|
|
26 |
} elseif ($this->colonne_num >= 33 && $this->colonne_num < 41) {
|
|
|
27 |
$this->verifierValeursIndic();
|
|
|
28 |
}
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
|
33 |
private function initialiserParametresVerif() {
|
|
|
34 |
$this->type_bio = $this->getParametreTableau('Parametres.typesBio');
|
|
|
35 |
$this->ss_type_bio = $this->getParametreTableau('Parametres.sousTypesBio');
|
|
|
36 |
$this->signes_seuls = $this->getParametreTableau('Parametres.signesSeuls');
|
|
|
37 |
$this->signes_nn_seuls = $this->getParametreTableau('Parametres.signesNonSeuls');
|
|
|
38 |
$this->intervalles = $this->inverserTableau($this->getParametreTableau('Parametres.intervalles'));
|
|
|
39 |
$this->motifs = $this->inverserTableau($this->getParametreTableau('Parametres.motifs'));
|
|
|
40 |
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
//++---------------------------------traitements des colonnes baseflor------------------------------------++
|
|
|
44 |
|
|
|
45 |
|
|
|
46 |
private function verifierColonne(){
|
|
|
47 |
$motif = $this->motifs[$this->colonne_num];
|
|
|
48 |
if (preg_match($motif, $this->colonne_valeur) == 0 && $this->verifierSiVide() == false){
|
|
|
49 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
50 |
}
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
private function verifierSiVide(){
|
|
|
54 |
$vide = ($this->colonne_valeur == '') ? true : false;
|
|
|
55 |
return $vide;
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
private function verifierTypeBio(){
|
|
|
59 |
if (preg_match("/(.+)\((.+)\)$/", $this->colonne_valeur, $retour) == 1) {
|
|
|
60 |
$this->verifierTypeEtSsType($retour[1]);
|
|
|
61 |
$this->verifierTypeEtSsType($retour[2]);
|
|
|
62 |
} else {
|
|
|
63 |
$this->verifierTypeEtSsType($this->colonne_valeur);
|
|
|
64 |
}
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
private function verifierTypeEtSsType($chaine_a_verif){
|
|
|
68 |
if (preg_match("/^([a-zA-Zé]+)\-(.+)$|^([a-zA-Zé]+[^\-])$/", $chaine_a_verif, $retour) == 1) {
|
|
|
69 |
$type = (isset($retour[3])) ? $retour[3] : $retour[1];
|
|
|
70 |
$this->verifierType($type);
|
|
|
71 |
|
|
|
72 |
$sousType = $retour[2];
|
|
|
73 |
$this->verifierSousType($sousType);
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
|
|
|
77 |
private function verifierType($type) {
|
|
|
78 |
if (in_array($type, $this->type_bio) == false) {
|
|
|
79 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
80 |
}
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
private function verifierSousType($sousType) {
|
|
|
84 |
if ($sousType != ''){
|
|
|
85 |
$ss_type = explode('-', $sousType);
|
|
|
86 |
foreach ($ss_type as $sst) {
|
|
|
87 |
if (in_array($sst, $this->ss_type_bio) == false) {
|
|
|
88 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
89 |
}
|
|
|
90 |
}
|
|
|
91 |
}
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
private function verifierIntervalles($valeur){
|
|
|
95 |
if ($valeur != '') {
|
|
|
96 |
list($min, $max) = explode('-', $this->intervalles[$this->colonne_num]);
|
|
|
97 |
if ($valeur < $min || $valeur > $max){
|
|
|
98 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
99 |
}
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
private function verifierValeursIndic(){
|
|
|
104 |
if (preg_match("/^([^0-9])*([0-9]+)([^0-9])*$/", $this->colonne_valeur, $retour) == 1){
|
|
|
105 |
$this->verifierIntervalles($retour[2]);
|
|
|
106 |
if (isset($retour[3]) && in_array($retour[3], $this->signes_nn_seuls) == false){
|
|
|
107 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
108 |
}
|
|
|
109 |
if ($retour[1] != '-' && $retour[1] != ''){
|
|
|
110 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
111 |
}
|
|
|
112 |
} elseif (in_array( $this->colonne_valeur, $this->signes_seuls) == false && $this->verifierSiVide() == false) {
|
|
|
113 |
$this->erreurs_ligne[$this->colonne_num] = $this->colonne_valeur;
|
|
|
114 |
}
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
/*--------------------------------------------OUtils-------------------------------------------*/
|
|
|
118 |
|
|
|
119 |
private function getParametreTableau($cle) {
|
|
|
120 |
$tableau = array();
|
|
|
121 |
$parametre = Config::get($cle);
|
|
|
122 |
if (empty($parametre) === false) {
|
|
|
123 |
$tableauPartiel = explode(',', $parametre);
|
|
|
124 |
$tableauPartiel = array_map('trim', $tableauPartiel);
|
|
|
125 |
foreach ($tableauPartiel as $champ) {
|
|
|
126 |
if (strpos($champ, '=') !== false && strlen($champ) >= 3) {
|
|
|
127 |
list($cle, $val) = explode('=', $champ);
|
|
|
128 |
$tableau[trim($cle)] = trim($val);
|
|
|
129 |
} else {
|
|
|
130 |
$tableau[] = trim($champ);
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
}
|
|
|
134 |
return $tableau;
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
private function inverserTableau($tableau) {
|
|
|
138 |
$inverse = array();
|
|
|
139 |
foreach ($tableau as $cle => $valeurs) {
|
|
|
140 |
$valeurs = explode(';', $valeurs);
|
|
|
141 |
foreach ($valeurs as $valeur) {
|
|
|
142 |
$inverse[$valeur] = $cle;
|
|
|
143 |
}
|
|
|
144 |
}
|
|
|
145 |
return $inverse;
|
|
|
146 |
}
|
|
|
147 |
}
|
|
|
148 |
|
|
|
149 |
?>
|