Subversion Repositories Applications.referentiel

Rev

Rev 194 | Rev 212 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 194 Rev 199
1
<?php
1
<?php
2
// Encodage : UTF-8
2
// Encodage : UTF-8
3
// +-------------------------------------------------------------------------------------------------------------------+
3
// +-------------------------------------------------------------------------------------------------------------------+
4
/**
4
/**
5
* Tests de référentiels de nomenclature et taxonomie
5
* Tests de référentiels de nomenclature et taxonomie
6
*
6
*
7
* Description : classe permettant de tester les référentiels selon le manuel technique
7
* Description : classe permettant de tester les référentiels selon le manuel technique
8
* Utilisation : php script.php tests -p bdnff -a tout
8
* Utilisation : php script.php tests -p bdnff -a tout
9
*
9
*
10
//Auteur original :
10
//Auteur original :
11
* @author       Jean-Pascal MILCENT <jpm@tela-botanica.org>
11
* @author       Jean-Pascal MILCENT <jpm@tela-botanica.org>
12
* @copyright	Tela-Botanica 1999-2010
12
* @copyright	Tela-Botanica 1999-2010
13
* @link			http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel
13
* @link			http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel
14
* @licence		GPL v3 & CeCILL v2
14
* @licence		GPL v3 & CeCILL v2
15
* @version		$Id$
15
* @version		$Id$
16
*/
16
*/
17
// +-------------------------------------------------------------------------------------------------------------------+
17
// +-------------------------------------------------------------------------------------------------------------------+
18
// TODO : supprimer l'utilisation du paramêtres 'p' et chercher les infos depuis la bdd
18
// TODO : supprimer l'utilisation du paramêtres 'p' et chercher les infos depuis la bdd
19
class Tests extends ScriptCommande {
19
class Tests extends ScriptCommande {
20
	
20
	
21
	const SCRIPT_NOM = 'tests';
21
	const SCRIPT_NOM = 'tests';
22
	
22
	
23
	private $projet = null;
23
	private $projet = null;
24
	private $traitement = null;
24
	private $traitement = null;
25
	
25
	
26
	private $manuel = null;
26
	private $manuel = null;
27
	private $tests = null;
27
	private $tests = null;
28
	private $colonnes = null;
28
	private $colonnes = null;
29
	private $analyses = null;
29
	private $analyses = null;
30
	private $noms = null;
30
	private $noms = null;
31
	
31
	
32
	private $resultatDao = null;
32
	private $resultatDao = null;
33
	private $traitementDao = null;
33
	private $traitementDao = null;
34
	private $tableStructureDao = null;
34
	private $tableStructureDao = null;
35
	private $referentielDao = null;
35
	private $referentielDao = null;
36
	
36
	
37
	public function executer() {
37
	public function executer() {
38
		$this->manuel = parse_ini_file(Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS.'referentiel_v4.2.ini');
38
		$this->manuel = parse_ini_file(Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS.'referentiel_v4.2.ini');
39
		$this->definirConstantes();
39
		$this->definirConstantes();
40
		$this->tests = parse_ini_file($this->getModuleChemin().DS.'configurations'.DS.'tests.ini', true);
40
		$this->tests = parse_ini_file($this->getModuleChemin().DS.'configurations'.DS.'tests.ini', true);
41
		
41
		
42
		$this->resultatDao = new ResultatDao();
42
		$this->resultatDao = new ResultatDao();
43
		$this->traitementDao = new TraitementDao();
43
		$this->traitementDao = new TraitementDao();
44
		Debug::printr('Dans le script test');
44
		Debug::printr('Dans le script test');
45
		// Récupération du dernier traitement demandé
45
		// Récupération du dernier traitement demandé
46
		$this->traitement = $this->traitementDao->getDernierTraitement('tout', self::SCRIPT_NOM);
46
		$this->traitement = $this->traitementDao->getDernierTraitement('tout', self::SCRIPT_NOM);
47
		if (isset($this->traitement)) {
47
		if (isset($this->traitement)) {
48
			$this->projet = $this->traitement['referentiel_code']; // Récupération du nom de projet
48
			$this->projet = $this->traitement['referentiel_code']; // Récupération du nom de projet
49
			Debug::printr($this->traitement);
49
			Debug::printr($this->traitement);
50
			// Écriture de la date de début du traitement
50
			// Écriture de la date de début du traitement
51
			Debug::printr('Debute:'.$this->traitementDao->debuterTraitement($this->traitement['id_traitement']));
51
			Debug::printr('Debute:'.$this->traitementDao->debuterTraitement($this->traitement['id_traitement']));
52
			
52
			
53
			// Nettoyage des traitements obsolètes
53
			// Nettoyage des traitements obsolètes
54
			$traitements_obsoletes = $this->traitementDao->getTraitementsObsoletes($this->projet, self::SCRIPT_NOM);
54
			$traitements_obsoletes = $this->traitementDao->getTraitementsObsoletes($this->projet, self::SCRIPT_NOM);
55
			if (isset($traitements_obsoletes)) {
55
			if (isset($traitements_obsoletes)) {
56
				Debug::printr('Supp. obsoletes:'.$this->traitementDao->supprimer($traitements_obsoletes));
56
				Debug::printr('Supp. obsoletes:'.$this->traitementDao->supprimer($traitements_obsoletes));
57
			}
57
			}
58
			
58
			
59
			$this->tableStructureDao = new TableStructureDao();
59
			$this->tableStructureDao = new TableStructureDao();
60
			$this->referentielDao = new ReferentielDao();
60
			$this->referentielDao = new ReferentielDao();
61
			
61
			
62
			// Lancement du test demandé
62
			// Lancement du test demandé
63
			$cmd = $this->getParam('a');
63
			$cmd = $this->getParam('a');
64
	    	switch ($cmd) {
64
	    	switch ($cmd) {
65
				case 'tout' :
65
				case 'tout' :
66
					Debug::printr('Départ lancement test:');
66
					Debug::printr('Départ lancement test:');
67
					$this->recupererDonnees();
67
					$this->recupererDonnees();
68
					$this->lancerTestsAuto();
68
					$this->lancerTestsAuto();
69
					break;
69
					break;
70
				case 'test11' :
70
				case 'test11' :
71
					$this->recupererDonnees();
71
					$this->recupererDonnees();
72
					Debug::printr('Départ lancement test 11 :');
72
					Debug::printr('Départ lancement test 11 :');
73
					$this->testerClassificationRang();
73
					$this->testerExitenceTaxonSuperieurTransmis();
74
					break;
74
					break;
75
				default :
75
				default :
76
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
76
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
77
			}
77
			}
78
			// Écriture de la date de fin du traitement
78
			// Écriture de la date de fin du traitement
79
			Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
79
			Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
80
		} else {
80
		} else {
81
			Debug::printr("Aucun dernier traitement trouvé pour le script '".self::SCRIPT_NOM."' !");
81
			Debug::printr("Aucun dernier traitement trouvé pour le script '".self::SCRIPT_NOM."' !");
82
		}
82
		}
83
    }
83
    }
84
    
84
    
85
    /**
85
    /**
86
     * Cette méthode définie des constantes qui peuvent ensuite être utilisée dans les fichier ini.
86
     * Cette méthode définie des constantes qui peuvent ensuite être utilisée dans les fichier ini.
87
     * Surtout utile pour le fichier tests.ini
87
     * Surtout utile pour le fichier tests.ini
88
     */
88
     */
89
    private function definirConstantes() {
89
    private function definirConstantes() {
90
    	define('RANG_GENRE', $this->manuel['rang_genre']);
90
    	define('RANG_GENRE', $this->manuel['rang_genre']);
91
    	define('RANG_SP', $this->manuel['rang_sp']);
91
    	define('RANG_SP', $this->manuel['rang_sp']);
92
    	date_default_timezone_set('Europe/Berlin');
92
    	date_default_timezone_set('Europe/Berlin');
93
    	define('ANNEE_EN_COURS', date('Y'));
93
    	define('ANNEE_EN_COURS', date('Y'));
94
    	define('ANNEE_MINIMUM', 1753);
94
    	define('ANNEE_MINIMUM', 1753);
95
    }
95
    }
96
    
96
    
97
    public function recupererDonnees() {
97
    public function recupererDonnees() {
98
		// Récupération des données à tester
98
		// Récupération des données à tester
99
		$this->colonnes = $this->tableStructureDao->getColonnes($this->projet);
99
		$this->colonnes = $this->tableStructureDao->getColonnes($this->projet);
100
		$this->analyses = $this->tableStructureDao->getAnalyse($this->projet);
100
		$this->analyses = $this->tableStructureDao->getAnalyse($this->projet);
101
		$this->noms = $this->referentielDao->getTout($this->projet);
101
		$this->noms = $this->referentielDao->getTout($this->projet);
102
		Debug::printr('Nbre noms :'.count($this->noms));
102
		Debug::printr('Nbre noms :'.count($this->noms));
103
    }
103
    }
104
    
104
    
105
    public function lancerTestsAuto() {
105
    public function lancerTestsAuto() {
106
		$resultats = array();
106
		$resultats = array();
107
 
107
 
108
		// Lancement des tests unitaires
108
		// Lancement des tests unitaires
109
		Debug::printr('Lancement des tests unitaires');
109
		Debug::printr('Lancement des tests unitaires');
110
		$tests_numeros = array_keys($this->tests);
110
		$tests_numeros = array_keys($this->tests);
111
		Debug::printr($tests_numeros);
111
		Debug::printr($tests_numeros);
112
    	foreach ($tests_numeros as &$numero) {
112
    	foreach ($tests_numeros as &$numero) {
113
			$info = $this->getInfosTest($numero);
113
			$info = $this->getInfosTest($numero);
114
    		
114
    		
115
    		if ($numero < 5) {
115
    		if ($numero < 5) {
116
    			// Tests spéciaux vérifiant la structure de la table
116
    			// Tests spéciaux vérifiant la structure de la table
117
    			$resultats[] = $this->lancerTestUnitaire($info);
117
    			$resultats[] = $this->lancerTestUnitaire($info);
118
    		} else if ($numero >= 5 && $this->verifierResultats($resultats)) {		
118
    		} else if ($numero >= 5 && $this->verifierResultats($resultats)) {		
119
				// Si la structure est bonne nous lançons les autres tests
119
				// Si la structure est bonne nous lançons les autres tests
120
				$this->lancerTestUnitaire($info);
120
				$this->lancerTestUnitaire($info);
121
    		}
121
    		}
122
		}
122
		}
123
    }
123
    }
124
	
124
	
125
    private function getInfosTest($numero) {
125
    private function getInfosTest($numero) {
126
		$info = $this->tests[$numero];
126
		$info = $this->tests[$numero];
127
		$info['methode'] = 'tester'.implode('', explode(' ', ucwords($info['abr'])));
127
		$info['methode'] = 'tester'.implode('', explode(' ', ucwords($info['abr'])));
128
		$info['numero'] = $numero;
128
		$info['numero'] = $numero;
129
		$info['nom'] = '#'.$numero.' - '.$info['nom'];
129
		$info['nom'] = '#'.$numero.' - '.$info['nom'];
130
		$info['resultat'] = false;
130
		$info['resultat'] = false;
131
		return $info;
131
		return $info;
132
	}
132
	}
133
    
133
    
134
    public function lancerTestUnitaire($info) {
134
    public function lancerTestUnitaire($info) {
135
		Debug::printr($info['numero'].'::'.$info['methode']);
135
		Debug::printr($info['numero'].'::'.$info['methode']);
136
    	$methodeDeTest = $info['methode'];
136
    	$methodeDeTest = $info['methode'];
137
    	$erreurs = $this->$methodeDeTest();
137
    	$erreurs = $this->$methodeDeTest();
138
    	
138
    	
139
    	// Analyse des résultats
139
    	// Analyse des résultats
140
    	if (isset($erreurs['special'])) {
140
    	if (isset($erreurs['special'])) {
141
    		$info = $erreurs;
141
    		$info = $erreurs;
142
    	} else {
142
    	} else {
143
    		if (count($erreurs) > 0) {
143
    		if (count($erreurs) > 0) {
144
				$info['message']['entete'] = explode(',', $info['entete']);
144
				$info['message']['entete'] = explode(',', $info['entete']);
145
				if (isset($info['title'])) {
145
				if (isset($info['title'])) {
146
					$info['message']['title'] = explode(';', $info['title']);
146
					$info['message']['title'] = explode(';', $info['title']);
147
				}
147
				}
148
				$info['message']['lignes'] = $erreurs;
148
				$info['message']['lignes'] = $erreurs;
149
				unset($erreurs);
149
				unset($erreurs);
150
			} else {
150
			} else {
151
				$info['resultat'] = true;
151
				$info['resultat'] = true;
152
			}
152
			}
153
    	}
153
    	}
154
    	
154
    	
155
		$this->traiterResultatTest($info);
155
		$this->traiterResultatTest($info);
156
		
156
		
157
		if ($info['numero'] < 5) {
157
		if ($info['numero'] < 5) {
158
			return ($info['resultat'] ? '1' : '0');
158
			return ($info['resultat'] ? '1' : '0');
159
		}
159
		}
160
    }
160
    }
161
	
161
	
162
	private function verifierResultats(&$resultats) {
162
	private function verifierResultats(&$resultats) {
163
		$ok = true;
163
		$ok = true;
164
		foreach ($resultats as $resultat) {
164
		foreach ($resultats as $resultat) {
165
			if ($resultat == '0') {
165
			if ($resultat == '0') {
166
				$ok = false;
166
				$ok = false;
167
				break;
167
				break;
168
			}
168
			}
169
		}
169
		}
170
		return $ok;
170
		return $ok;
171
	}
171
	}
172
	
172
	
173
	private function traiterResultatTest($info) {
173
	private function traiterResultatTest($info) {
174
		if (isset($info['message'])) {
174
		if (isset($info['message'])) {
175
			if (is_array($info['message'])) {
175
			if (is_array($info['message'])) {
176
				$erreurs_nbre = count($info['message']['lignes']);
176
				$erreurs_nbre = count($info['message']['lignes']);
177
				$erreurs_max = 1000;
177
				$erreurs_max = 1000;
178
				if ($erreurs_nbre > $erreurs_max) {
178
				if ($erreurs_nbre > $erreurs_max) {
179
					$info['message']['lignes'] = array_slice($info['message']['lignes'], 0, $erreurs_max);
179
					$info['message']['lignes'] = array_slice($info['message']['lignes'], 0, $erreurs_max);
180
					$info['erreur'] = "$erreurs_nbre erreurs ont été détectées seules les $erreurs_max premières sont affichées";
180
					$info['erreur'] = "$erreurs_nbre erreurs ont été détectées seules les $erreurs_max premières sont affichées";
181
				}
181
				}
182
				$info['message'] = $this->getVue('tests/squelettes/message_table', $info);
182
				$info['message'] = $this->getVue('tests/squelettes/message_table', $info);
183
			} else {
183
			} else {
184
				$info['message'] = $this->getVue('tests/squelettes/message_p', $info);
184
				$info['message'] = $this->getVue('tests/squelettes/message_p', $info);
185
			}
185
			}
186
		}
186
		}
187
		Debug::printr($this->resultatDao->ajouter($this->traitement['id_traitement'], $info));
187
		Debug::printr($this->resultatDao->ajouter($this->traitement['id_traitement'], $info));
188
		$info = null;
188
		$info = null;
189
	}
189
	}
190
	
190
	
191
	//+--------------------------------------------------------------------------------------------------------------+//
191
	//+--------------------------------------------------------------------------------------------------------------+//
192
	// TESTS
192
	// TESTS
193
	
193
	
194
	/**
194
	/**
195
	 * Test #01
195
	 * Test #01
196
	 */
196
	 */
197
	private function testerNombreDeChamps() {
197
	private function testerNombreDeChamps() {
198
		$info = $this->getInfosTest(1);
198
		$info = $this->getInfosTest(1);
199
		$info['special'] = true;
199
		$info['special'] = true;
200
		
200
		
201
		$nbre_colonnes = count($this->colonnes);
201
		$nbre_colonnes = count($this->colonnes);
202
		$info['message'] = $nbre_colonnes;
202
		$info['message'] = $nbre_colonnes;
203
		if ($nbre_colonnes >= 35) {
203
		if ($nbre_colonnes >= 35) {
204
			$info['resultat'] = true;
204
			$info['resultat'] = true;
205
		}
205
		}
206
		
206
		
207
		return $info;
207
		return $info;
208
	}
208
	}
209
	
209
	
210
	/**
210
	/**
211
	 * Test #02
211
	 * Test #02
212
	 */
212
	 */
213
	private function testerNomDesChamps() {
213
	private function testerNomDesChamps() {
214
		$info = $this->getInfosTest(2);
214
		$info = $this->getInfosTest(2);
215
		$info['special'] = true;
215
		$info['special'] = true;
216
		
216
		
217
		$champs_attendus = explode(',', $this->manuel['champs']);
217
		$champs_attendus = explode(',', $this->manuel['champs']);
218
		$champs_presents = array();
218
		$champs_presents = array();
219
		foreach ($this->colonnes as &$colonne) {
219
		foreach ($this->colonnes as &$colonne) {
220
			$champs_presents[$colonne['Field']] = $colonne;
220
			$champs_presents[$colonne['Field']] = $colonne;
221
		}
221
		}
222
		
222
		
223
		$ok = true;
223
		$ok = true;
224
		$champs_manquant = array(); 
224
		$champs_manquant = array(); 
225
		foreach ($champs_attendus as &$champ_attendu) {
225
		foreach ($champs_attendus as &$champ_attendu) {
226
			if (!isset($champs_presents[$champ_attendu])) {
226
			if (!isset($champs_presents[$champ_attendu])) {
227
				$champs_manquant[] = $champ_attendu; 
227
				$champs_manquant[] = $champ_attendu; 
228
				$ok = false;
228
				$ok = false;
229
			}
229
			}
230
		}
230
		}
231
		
231
		
232
		$info['resultat'] = $ok;
232
		$info['resultat'] = $ok;
233
		if (!$ok) {
233
		if (!$ok) {
234
			$info['message'] = sprintf($info['message'], implode(', ', $champs_manquant));
234
			$info['message'] = sprintf($info['message'], implode(', ', $champs_manquant));
235
		}
235
		}
236
		
236
		
237
		return $info;
237
		return $info;
238
	}
238
	}
239
	
239
	
240
	/**
240
	/**
241
	 * Test #03
241
	 * Test #03
242
	 */
242
	 */
243
	private function testerTypeDesChamps() {
243
	private function testerTypeDesChamps() {
244
		$champs_attendus = explode(',', $this->manuel['champs_type']);
244
		$champs_attendus = explode(',', $this->manuel['champs_type']);
245
		$champs_presents = array();
245
		$champs_presents = array();
246
		foreach ($this->colonnes as &$colonne) {
246
		foreach ($this->colonnes as &$colonne) {
247
			$champs_presents[$colonne['Field']] = $colonne['Type'];
247
			$champs_presents[$colonne['Field']] = $colonne['Type'];
248
		}
248
		}
249
		
249
		
250
		// Recercherche des erreurs
250
		// Recercherche des erreurs
251
		$champs_erreur = array(); 
251
		$champs_erreur = array(); 
252
		foreach ($champs_attendus as &$champ_attendu) {
252
		foreach ($champs_attendus as &$champ_attendu) {
253
			list($champ_attendu_nom, $champ_attendu_type_taille) = explode('=', trim($champ_attendu));
253
			list($champ_attendu_nom, $champ_attendu_type_taille) = explode('=', trim($champ_attendu));
254
			list($champ_attendu_type, $champ_attendu_taille) = explode('|', trim($champ_attendu_type_taille));
254
			list($champ_attendu_type, $champ_attendu_taille) = explode('|', trim($champ_attendu_type_taille));
255
			
255
			
256
			if (isset($champs_presents[$champ_attendu_nom])) {
256
			if (isset($champs_presents[$champ_attendu_nom])) {
257
				$champs_present_type = $champs_presents[$champ_attendu_nom];
257
				$champs_present_type = $champs_presents[$champ_attendu_nom];
258
				
258
				
259
				if (($champ_attendu_type == 'VARCHAR' && strstr($champs_present_type, 'varchar') === false)
259
				if (($champ_attendu_type == 'VARCHAR' && strstr($champs_present_type, 'varchar') === false)
260
					|| ($champ_attendu_type == 'TEXT' && strstr($champs_present_type, 'text') === false)
260
					|| ($champ_attendu_type == 'TEXT' && strstr($champs_present_type, 'text') === false)
261
					|| ($champ_attendu_type == 'INT' && strstr($champs_present_type, 'int') === false) 
261
					|| ($champ_attendu_type == 'INT' && strstr($champs_present_type, 'int') === false) 
262
					|| ($champ_attendu_type == 'BOOL' && preg_match('/(?:bool|boolean|tinyint\(1\))/i', $champs_present_type) === false)) {
262
					|| ($champ_attendu_type == 'BOOL' && preg_match('/(?:bool|boolean|tinyint\(1\))/i', $champs_present_type) === false)) {
263
					$champs_erreur[] = array($champ_attendu, $champ_attendu_type, $champs_present_type);
263
					$champs_erreur[] = array($champ_attendu, $champ_attendu_type, $champs_present_type);
264
				}
264
				}
265
			}
265
			}
266
		}
266
		}
267
		return $champs_erreur;
267
		return $champs_erreur;
268
	}
268
	}
269
	
269
	
270
	/**
270
	/**
271
	 * Test #04
271
	 * Test #04
272
	 */
272
	 */
273
	private function testerNumNomClePrimaire() {
273
	private function testerNumNomClePrimaire() {
274
		$info = $this->getInfosTest(4);
274
		$info = $this->getInfosTest(4);
275
		$info['special'] = true;
275
		$info['special'] = true;
276
		
276
		
277
		foreach ($this->colonnes as &$colonne) {
277
		foreach ($this->colonnes as &$colonne) {
278
			if ($colonne['Field'] == 'num_nom' && $colonne['Key'] == 'PRI') {
278
			if ($colonne['Field'] == 'num_nom' && $colonne['Key'] == 'PRI') {
279
				$info['resultat'] = true;
279
				$info['resultat'] = true;
280
				break;
280
				break;
281
			}
281
			}
282
		}
282
		}
283
		return $info;
283
		return $info;
284
	}
284
	}
285
	
285
	
286
	
286
	
287
	/**
287
	/**
288
	 * Test #05
288
	 * Test #05
289
	 */
289
	 */
290
	private function testerTailleDesChamps() {
290
	private function testerTailleDesChamps() {
291
		$tailles_champs_maxi = array();
291
		$tailles_champs_maxi = array();
292
		foreach ($this->colonnes as &$colonne) {
292
		foreach ($this->colonnes as &$colonne) {
293
			if (preg_match('/^varchar\(([0-9]+)\)$/', $colonne['Type'], $match)) {
293
			if (preg_match('/^varchar\(([0-9]+)\)$/', $colonne['Type'], $match)) {
294
				$tailles_champs_maxi[$colonne['Field']] = $match[1];
294
				$tailles_champs_maxi[$colonne['Field']] = $match[1];
295
			}
295
			}
296
		}
296
		}
297
		
297
		
298
		$tailles_trouvees = array();
298
		$tailles_trouvees = array();
299
		foreach ($this->analyses as &$analyse) {
299
		foreach ($this->analyses as &$analyse) {
300
			if (preg_match('/\.([^.]+)$/', $analyse['Field_name'], $match)) {
300
			if (preg_match('/\.([^.]+)$/', $analyse['Field_name'], $match)) {
301
				$tailles_trouvees[$match[1]] = $analyse['Max_length'];
301
				$tailles_trouvees[$match[1]] = $analyse['Max_length'];
302
			}
302
			}
303
		}
303
		}
304
		
304
		
305
		$champs_erreur = array();
305
		$champs_erreur = array();
306
		$champs_attendus = explode(',', $this->manuel['champs']);
306
		$champs_attendus = explode(',', $this->manuel['champs']);
307
		foreach ($champs_attendus as &$champ_attendu) {
307
		foreach ($champs_attendus as &$champ_attendu) {
308
			if (isset($tailles_champs_maxi[$champ_attendu]) && isset($tailles_trouvees[$champ_attendu])) {
308
			if (isset($tailles_champs_maxi[$champ_attendu]) && isset($tailles_trouvees[$champ_attendu])) {
309
				if ($tailles_champs_maxi[$champ_attendu] == $tailles_trouvees[$champ_attendu]) {
309
				if ($tailles_champs_maxi[$champ_attendu] == $tailles_trouvees[$champ_attendu]) {
310
					$champs_erreur[] = array($champ_attendu, $tailles_champs_maxi[$champ_attendu], $tailles_trouvees[$champ_attendu]);
310
					$champs_erreur[] = array($champ_attendu, $tailles_champs_maxi[$champ_attendu], $tailles_trouvees[$champ_attendu]);
311
				}
311
				}
312
			}
312
			}
313
		}
313
		}
314
		return $champs_erreur;
314
		return $champs_erreur;
315
	}
315
	}
316
		
316
		
317
	/**
317
	/**
318
	 * Test #06
318
	 * Test #06
319
	 */
319
	 */
320
	private function testerNumNomSuperieurAZero() {
320
	private function testerNumNomSuperieurAZero() {
321
		$noms_erreur = array();
321
		$noms_erreur = array();
322
		foreach ($this->noms as &$nom) {
322
		foreach ($this->noms as &$nom) {
323
			if ($nom['num_nom'] <= 0) {
323
			if ($nom['num_nom'] <= 0) {
324
				$noms_erreur[] = array($nom['num_nom']);
324
				$noms_erreur[] = array($nom['num_nom']);
325
			}
325
			}
326
		}
326
		}
327
		return $noms_erreur;
327
		return $noms_erreur;
328
	}
328
	}
329
	
329
	
330
	/**
330
	/**
331
	 * Test #07
331
	 * Test #07
332
	 */
332
	 */
333
	private function testerNumNomRetenuSuperieurAZero() {
333
	private function testerNumNomRetenuSuperieurAZero() {
334
		$noms_erreur = array();
334
		$noms_erreur = array();
335
		foreach ($this->noms as &$nom) {
335
		foreach ($this->noms as &$nom) {
336
			if ($nom['num_nom_retenu'] != '' && $nom['num_nom_retenu'] <= 0) {
336
			if ($nom['num_nom_retenu'] != '' && $nom['num_nom_retenu'] <= 0) {
337
				$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu']);
337
				$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu']);
338
			}
338
			}
339
		}
339
		}
340
		return $noms_erreur;
340
		return $noms_erreur;
341
	}
341
	}
342
	
342
	
343
	/**
343
	/**
344
	 * Test #08
344
	 * Test #08
345
	 */
345
	 */
-
 
346
	private function testerExistenceNumNomRetenu() {
-
 
347
		$noms_erreur = array();
-
 
348
		foreach ($this->noms as &$nom) {
-
 
349
			if ($nom['num_nom_retenu'] != '' && $nom['num_nom_retenu'] != $nom['num_nom']) {
-
 
350
				if ($nom['num_nom_retenu'] != 0 && !isset($this->noms[$nom['num_nom_retenu']])) {
-
 
351
					$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu'], $nom['exclure_taxref']);
-
 
352
				} 
-
 
353
			}
-
 
354
		}
-
 
355
		return $noms_erreur;
-
 
356
	}
-
 
357
	
-
 
358
	/**
-
 
359
	 * Test #09
-
 
360
	 */
-
 
361
	private function testerTransmissionNumNomRetenu() {
-
 
362
		$noms_erreur = array();
-
 
363
		foreach ($this->noms as &$nom) {
-
 
364
			if ($nom['num_nom_retenu'] != $nom['num_nom'] && $nom['exclure_taxref'] == 0) {
-
 
365
				if ($nom['num_nom_retenu'] != 0 && isset($this->noms[$nom['num_nom_retenu']])) {
-
 
366
					if ($this->noms[$nom['num_nom_retenu']]['exclure_taxref'] != 0) {
-
 
367
						$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu'], $this->noms[$nom['num_nom_retenu']]['exclure_taxref']);
-
 
368
					}
-
 
369
				} 
-
 
370
			}
-
 
371
		}
-
 
372
		return $noms_erreur;
-
 
373
	}
-
 
374
	
-
 
375
	/**
-
 
376
	 * Test #10
-
 
377
	 */
-
 
378
	private function testerSynonymeNumNomRetenu() {
-
 
379
		$noms_erreur = array();
-
 
380
		foreach ($this->noms as &$nom) {
-
 
381
			if ($nom['num_nom_retenu'] != $nom['num_nom']) {
-
 
382
				if ($nom['num_nom_retenu'] != 0 && isset($this->noms[$nom['num_nom_retenu']])) {
-
 
383
					if ($this->noms[$nom['num_nom_retenu']]['num_nom'] != $this->noms[$nom['num_nom_retenu']]['num_nom_retenu']) {
-
 
384
						$noms_erreur[] = array($nom['num_nom'], $nom['num_nom_retenu'], $this->noms[$nom['num_nom_retenu']]['num_nom_retenu']);
-
 
385
					}
-
 
386
				} 
-
 
387
			}
-
 
388
		}
-
 
389
		return $noms_erreur;
-
 
390
	}
-
 
391
	
-
 
392
	
-
 
393
	/**
-
 
394
	 * Test #11
-
 
395
	 */
346
	private function testerNumTaxSupEgalZeroUnique() {
396
	private function testerNumTaxSupEgalZeroUnique() {
347
		$noms_erreur = array();
397
		$noms_erreur = array();
348
		foreach ($this->noms as &$nom) {
398
		foreach ($this->noms as &$nom) {
349
			if (preg_match('/^0$/', $nom['num_tax_sup'])) {
399
			if (preg_match('/^0$/', $nom['num_tax_sup'])) {
350
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']);
400
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup']);
351
			}
401
			}
352
		}
402
		}
353
		// Ce test est spécial car le nombre de noms en erreurs doit être supérieur à 1 et non à 0 pour être KO.
403
		// Ce test est spécial car le nombre de noms en erreurs doit être supérieur à 1 et non à 0 pour être KO.
354
		if (count($noms_erreur) == 1) {
404
		if (count($noms_erreur) == 1) {
355
			$noms_erreur = array();
405
			$noms_erreur = array();
356
		}
406
		}
357
		return $noms_erreur;
407
		return $noms_erreur;
358
	}
408
	}
359
	
409
	
360
	/**
410
	/**
361
	 * Test #09
411
	 * Test #12
362
	 */
412
	 */
363
	private function testerTaxSupPourTaxon() {
413
	private function testerTaxSupPourTaxon() {
364
		$noms_erreur = array();
414
		$noms_erreur = array();
365
		foreach ($this->noms as &$nom) {
415
		foreach ($this->noms as &$nom) {
366
			if ($nom['num_nom_retenu'] != $nom['num_nom'] && $nom['num_tax_sup'] != '') {
416
			if ($nom['num_nom_retenu'] != $nom['num_nom'] && $nom['num_tax_sup'] != '') {
367
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup'], $nom['exclure_taxref']); 
417
				$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup'], $nom['exclure_taxref']); 
368
			}
418
			}
369
		}
419
		}
370
		return $noms_erreur;
420
		return $noms_erreur;
371
	}
421
	}
372
	
422
	
373
	/**
423
	/**
374
	 * Test #10
424
	 * Test #13
375
	 */
425
	 */
376
	private function testerExitenceTaxonSuperieur() {
426
	private function testerExistenceTaxonSuperieur() {
377
		$noms_erreur = array();
427
		$noms_erreur = array();
378
		foreach ($this->noms as &$nom) {
428
		foreach ($this->noms as &$nom) {
379
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
429
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
380
				if ($nom['num_tax_sup'] != 0 && !isset($this->noms[$nom['num_tax_sup']])) {
430
				if ($nom['num_tax_sup'] != 0 && !isset($this->noms[$nom['num_tax_sup']])) {
381
					$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup'], $nom['exclure_taxref']);
431
					$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup'], $nom['exclure_taxref']);
382
				} 
432
				} 
383
			}
433
			}
384
		}
434
		}
385
		return $noms_erreur;
435
		return $noms_erreur;
386
	}
436
	}
387
	
437
	
388
	/**
438
	/**
389
	 * Test #11
439
	 * Test #14
-
 
440
	 */
-
 
441
	private function testerTransmissionTaxonSuperieur() {
-
 
442
		$noms_erreur = array();
-
 
443
		foreach ($this->noms as &$nom) {
-
 
444
			if ($nom['num_nom_retenu'] == $nom['num_nom'] && $nom['exclure_taxref'] == 0) {
-
 
445
				if ($nom['num_tax_sup'] != 0 && isset($this->noms[$nom['num_tax_sup']])) {
-
 
446
					if ($this->noms[$nom['num_tax_sup']]['exclure_taxref'] != 0) {
-
 
447
						$noms_erreur[] = array($nom['num_nom'], $nom['num_tax_sup'], $this->noms[$nom['num_tax_sup']]['exclure_taxref']);
-
 
448
					}
-
 
449
				} 
-
 
450
			}
-
 
451
		}
-
 
452
		return $noms_erreur;
-
 
453
	}
-
 
454
	
-
 
455
	
-
 
456
	/**
-
 
457
	 * Test #15
390
	 */
458
	 */
391
	private function testerClassificationRang() {
459
	private function testerClassificationRang() {
392
		$noms_erreur = array();
460
		$noms_erreur = array();
393
		foreach ($this->noms as &$nom) {
461
		foreach ($this->noms as &$nom) {
394
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
462
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
395
				if (isset($this->noms[$nom['num_tax_sup']])) {
463
				if (isset($this->noms[$nom['num_tax_sup']])) {
396
					$nom_sup = $this->noms[$nom['num_tax_sup']];
464
					$nom_sup = $this->noms[$nom['num_tax_sup']];
397
					if ($nom_sup['rang'] >= $nom['rang']) {
465
					if ($nom_sup['rang'] >= $nom['rang']) {
398
						// Prise en compte de l'exception des clades
466
						// Prise en compte de l'exception des clades
399
						if (! ($nom_sup['rang'] == 70 && $nom['rang'] == 70)) {
467
						if (! ($nom_sup['rang'] == 70 && $nom['rang'] == 70)) {
400
							$noms_erreur[] = array($nom['num_nom'], $nom['rang'], $nom_sup['num_nom'], $nom_sup['rang'], $nom['exclure_taxref']);
468
							$noms_erreur[] = array($nom['num_nom'], $nom['rang'], $nom_sup['num_nom'], $nom_sup['rang'], $nom['exclure_taxref']);
401
						}
469
						}
402
					}
470
					}
403
				}
471
				}
404
			}
472
			}
405
		}
473
		}
406
		return $noms_erreur;
474
		return $noms_erreur;
407
	}
475
	}
408
	
476
	
409
	/**
477
	/**
410
	 * Test #12
478
	 * Test #16
411
	 */
479
	 */
412
	private function testerClassification() {
480
	private function testerClassification() {
413
		$noms_erreur = array();
481
		$noms_erreur = array();
414
		$this->noms_ok = array();
482
		$this->noms_ok = array();
415
		foreach ($this->noms as &$nom) {
483
		foreach ($this->noms as &$nom) {
416
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
484
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
417
				if (isset($this->noms_ok[$nom['num_tax_sup']])) {
485
				if (isset($this->noms_ok[$nom['num_tax_sup']])) {
418
					$this->noms_ok[$nom['num_nom']] = true;
486
					$this->noms_ok[$nom['num_nom']] = true;
419
				} else {
487
				} else {
420
					$this->detection_boucle_infini = array();
488
					$this->detection_boucle_infini = array();
421
					$classif_ok = $this->remonterClassif($nom);
489
					$classif_ok = $this->remonterClassif($nom);
422
					unset($this->detection_boucle_infini); 
490
					unset($this->detection_boucle_infini); 
423
					
491
					
424
					if ($classif_ok === true) {
492
					if ($classif_ok === true) {
425
						$this->noms_ok[$nom['num_nom']] = $classif_ok;
493
						$this->noms_ok[$nom['num_nom']] = $classif_ok;
426
					} else {
494
					} else {
427
						$noms_erreur[] = array($nom['num_nom'], $classif_ok, $nom['exclure_taxref']);
495
						$noms_erreur[] = array($nom['num_nom'], $classif_ok, $nom['exclure_taxref']);
428
					}
496
					}
429
				}
497
				}
430
			}
498
			}
431
		}
499
		}
432
		unset($this->noms_ok);
500
		unset($this->noms_ok);
433
		return $noms_erreur;
501
		return $noms_erreur;
434
	}
502
	}
435
	
503
	
436
	private function remonterClassif(&$nom) {
504
	private function remonterClassif(&$nom) {
437
		$this->detection_boucle_infini[$nom['num_nom']] = true;
505
		$this->detection_boucle_infini[$nom['num_nom']] = true;
438
		if (preg_match('/^[0-9]*$/', $nom['num_tax_sup'])) {
506
		if (preg_match('/^[0-9]*$/', $nom['num_tax_sup'])) {
439
			if (isset($this->noms_ok[$nom['num_tax_sup']])) {
507
			if (isset($this->noms_ok[$nom['num_tax_sup']])) {
440
				$this->noms_ok[$nom['num_nom']] = true;
508
				$this->noms_ok[$nom['num_nom']] = true;
441
				return true;
509
				return true;
442
			} else if (!isset($this->noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] == '0') {
510
			} else if (!isset($this->noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] == '0') {
443
				$this->noms_ok[$nom['num_nom']] = true;
511
				$this->noms_ok[$nom['num_nom']] = true;
444
				return true;
512
				return true;
445
			} else if (!isset($this->noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] != '0') {
513
			} else if (!isset($this->noms[$nom['num_tax_sup']]) && $nom['num_tax_sup'] != '0') {
446
				return 'Hiérarchie avec le taxon #'.$nom['num_nom'].' ayant un taxon superieur #'.$nom['num_tax_sup'].' inexistant';
514
				return 'Hiérarchie avec le taxon #'.$nom['num_nom'].' ayant un taxon superieur #'.$nom['num_tax_sup'].' inexistant';
447
			} else if (isset($this->detection_boucle_infini[$nom['num_tax_sup']])) {
515
			} else if (isset($this->detection_boucle_infini[$nom['num_tax_sup']])) {
448
				return 'Boucle infinie pour le taxon #'.$nom['num_tax_sup'];
516
				return 'Boucle infinie pour le taxon #'.$nom['num_tax_sup'];
449
			} else {
517
			} else {
450
				$retour = $this->remonterClassif($this->noms[$nom['num_tax_sup']]);
518
				$retour = $this->remonterClassif($this->noms[$nom['num_tax_sup']]);
451
				if ($retour === true) {
519
				if ($retour === true) {
452
					$this->noms_ok[$nom['num_tax_sup']] = true;
520
					$this->noms_ok[$nom['num_tax_sup']] = true;
453
				}
521
				}
454
				return $retour;
522
				return $retour;
455
			}
523
			}
456
		} else {
524
		} else {
457
			return 'Valeur num_tax_sup incorrecte : '.$nom['num_tax_sup'];
525
			return 'Valeur num_tax_sup incorrecte : '.$nom['num_tax_sup'];
458
		}
526
		}
459
	}
527
	}
460
	
528
	
461
	/**
529
	/**
462
	 * Test #13
530
	 * Test #17
463
	 */
531
	 */
464
	private function testerRang() {
532
	private function testerRang() {
465
		$rangs = array_flip(explode(',', $this->manuel['rangs']));
533
		$rangs = array_flip(explode(',', $this->manuel['rangs']));
466
		
534
		
467
		// Réalisation du test
535
		// Réalisation du test
468
		$noms_erreur = array();
536
		$noms_erreur = array();
469
		foreach ($this->noms as &$nom) {
537
		foreach ($this->noms as &$nom) {
470
			if (!isset($rangs[$nom['rang']])) {
538
			if (!isset($rangs[$nom['rang']])) {
471
				$noms_erreur[] = array($nom['num_nom'], $nom['rang'], $nom['exclure_taxref']);
539
				$noms_erreur[] = array($nom['num_nom'], $nom['rang'], $nom['exclure_taxref']);
472
			}
540
			}
473
		}
541
		}
474
		return $noms_erreur;
542
		return $noms_erreur;
475
	}
543
	}
476
	
544
	
477
	/**
545
	/**
478
	 * Test #14
546
	 * Test #18
479
	 */
547
	 */
480
	private function testerNomCompletSupraGenerique() {
548
	private function testerNomCompletSupraGenerique() {
481
		$noms_erreur = array();
549
		$noms_erreur = array();
482
		foreach ($this->noms as &$nom) {
550
		foreach ($this->noms as &$nom) {
483
			if ($nom['rang'] < $this->manuel['rang_genre']) {
551
			if ($nom['rang'] < $this->manuel['rang_genre']) {
484
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
552
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
485
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['nom_supra_generique']);
553
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['nom_supra_generique']);
486
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
554
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
487
				if ($nom['nom_sci'] != $nom_sci_ideal) {
555
				if ($nom['nom_sci'] != $nom_sci_ideal) {
488
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
556
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
489
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
557
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
490
				}
558
				}
491
			}
559
			}
492
		}
560
		}
493
		return $noms_erreur;
561
		return $noms_erreur;
494
	}
562
	}
495
	
563
	
496
	/**
564
	/**
497
	 * Test #15
565
	 * Test #19
498
	 */
566
	 */
499
	private function testerNomCompletGenre() {
567
	private function testerNomCompletGenre() {
500
		$noms_erreur = array();
568
		$noms_erreur = array();
501
		foreach ($this->noms as &$nom) {
569
		foreach ($this->noms as &$nom) {
502
			if ($nom['rang'] == $this->manuel['rang_genre']) {
570
			if ($nom['rang'] == $this->manuel['rang_genre']) {
503
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
571
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
504
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
572
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
505
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
573
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
506
				if ($nom['nom_sci'] != $nom_sci_ideal) {
574
				if ($nom['nom_sci'] != $nom_sci_ideal) {
507
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
575
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
508
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
576
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
509
				}
577
				}
510
			}
578
			}
511
		}
579
		}
512
		return $noms_erreur;
580
		return $noms_erreur;
513
	}
581
	}
514
	
582
	
515
	/**
583
	/**
516
	 * Test #16
584
	 * Test #20
517
	 */
585
	 */
518
	private function testerNomCompletInfraGenre() {
586
	private function testerNomCompletInfraGenre() {
519
		$noms_erreur = array();
587
		$noms_erreur = array();
520
		foreach ($this->noms as &$nom) {
588
		foreach ($this->noms as &$nom) {
521
			if ($nom['rang'] > $this->manuel['rang_genre'] && $nom['rang'] < $this->manuel['rang_sp']) {
589
			if ($nom['rang'] > $this->manuel['rang_genre'] && $nom['rang'] < $this->manuel['rang_sp']) {
522
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
590
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
523
				$nom_sci_ideal = '';
591
				$nom_sci_ideal = '';
524
				if ($nom['type_epithete'] == 'agg.') {
592
				if ($nom['type_epithete'] == 'agg.') {
525
					$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
593
					$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
526
					$nom_sci_ideal .= ' '.$this->formaterStyleNomGenre($nom['epithete_infra_generique']);
594
					$nom_sci_ideal .= ' '.$this->formaterStyleNomGenre($nom['epithete_infra_generique']);
527
					$nom_sci_ideal .= ' '.$nom['type_epithete'];
595
					$nom_sci_ideal .= ' '.$nom['type_epithete'];
528
				} else {
596
				} else {
529
					$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
597
					$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
530
					$nom_sci_ideal .= ' '.$nom['type_epithete'];
598
					$nom_sci_ideal .= ' '.$nom['type_epithete'];
531
					$nom_sci_ideal .= ' '.$this->formaterStyleNomGenre($nom['epithete_infra_generique']);
599
					$nom_sci_ideal .= ' '.$this->formaterStyleNomGenre($nom['epithete_infra_generique']);
532
				}
600
				}
533
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
601
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
534
				if ($nom['nom_sci'] != $nom_sci_ideal) {
602
				if ($nom['nom_sci'] != $nom_sci_ideal) {
535
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
603
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
536
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
604
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
537
				}
605
				}
538
			}
606
			}
539
		}
607
		}
540
		return $noms_erreur;
608
		return $noms_erreur;
541
	}
609
	}
542
	
610
	
543
	/**
611
	/**
544
	 * Test #17
612
	 * Test #21
545
	 */
613
	 */
546
	private function testerNomCompletEspece() {
614
	private function testerNomCompletEspece() {
547
		$noms_erreur = array();
615
		$noms_erreur = array();
548
		foreach ($this->noms as &$nom) {
616
		foreach ($this->noms as &$nom) {
549
			if ($nom['rang'] == $this->manuel['rang_sp']) {
617
			if ($nom['rang'] == $this->manuel['rang_sp']) {
550
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
618
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
551
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
619
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
552
				$nom_sci_ideal .= (preg_match('/^(.+)\s+([x+])\s+(.+)$/i', $nom['epithete_sp'], $match) != '' ? 
620
				$nom_sci_ideal .= (preg_match('/^(.+)\s+([x+])\s+(.+)$/i', $nom['epithete_sp'], $match) != '' ? 
553
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[1])))).' '.utf8_encode(strtolower(utf8_decode($match[2]))).
621
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[1])))).' '.utf8_encode(strtolower(utf8_decode($match[2]))).
554
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[3])))) : 
622
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[3])))) : 
555
					' '.utf8_encode(strtolower(utf8_decode($nom['epithete_sp']))));
623
					' '.utf8_encode(strtolower(utf8_decode($nom['epithete_sp']))));
556
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
624
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
557
				$nom_sci_ideal = trim($nom_sci_ideal);
625
				$nom_sci_ideal = trim($nom_sci_ideal);
558
				if ($nom['nom_sci'] != $nom_sci_ideal) {
626
				if ($nom['nom_sci'] != $nom_sci_ideal) {
559
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
627
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
560
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
628
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
561
				}
629
				}
562
			}
630
			}
563
		}
631
		}
564
		return $noms_erreur;
632
		return $noms_erreur;
565
	}
633
	}
566
	
634
	
567
	/**
635
	/**
568
	 * Test #18
636
	 * Test #22
569
	 */
637
	 */
570
	private function testerNomCompletInfraSpecifique() {
638
	private function testerNomCompletInfraSpecifique() {
571
		$noms_erreur = array();
639
		$noms_erreur = array();
572
		foreach ($this->noms as &$nom) {
640
		foreach ($this->noms as &$nom) {
573
			if ($nom['rang'] > $this->manuel['rang_sp']) {
641
			if ($nom['rang'] > $this->manuel['rang_sp']) {
574
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
642
				$suffixe_plte_cultivee = $this->construireSuffixeNomPltCultivee($nom);
575
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
643
				$nom_sci_ideal = $this->formaterStyleNomGenre($nom['genre']);
576
				$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['epithete_sp'])));
644
				$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['epithete_sp'])));
577
				$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['type_epithete'])));
645
				$nom_sci_ideal .= ' '.utf8_encode(strtolower(utf8_decode($nom['type_epithete'])));
578
				$nom_sci_ideal .= (preg_match('/^(.+)\s+([x+])\s+(.+)$/i', $nom['epithete_infra_sp'], $match) != '' ? 
646
				$nom_sci_ideal .= (preg_match('/^(.+)\s+([x+])\s+(.+)$/i', $nom['epithete_infra_sp'], $match) != '' ? 
579
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[1])))).' '.utf8_encode(strtolower(utf8_decode($match[2]))).
647
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[1])))).' '.utf8_encode(strtolower(utf8_decode($match[2]))).
580
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[3])))) : 
648
					' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[3])))) : 
581
					' '.utf8_encode(strtolower(utf8_decode($nom['epithete_infra_sp']))));
649
					' '.utf8_encode(strtolower(utf8_decode($nom['epithete_infra_sp']))));
582
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
650
				$nom_sci_ideal .= ($suffixe_plte_cultivee != '' ? ' '.$suffixe_plte_cultivee : '');
583
				$nom_sci_ideal = trim($nom_sci_ideal);
651
				$nom_sci_ideal = trim($nom_sci_ideal);
584
				if ($nom['nom_sci'] != $nom_sci_ideal) {
652
				if ($nom['nom_sci'] != $nom_sci_ideal) {
585
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
653
					$nom_sci_traite = $this->repererEspace($nom['nom_sci']);
586
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
654
					$noms_erreur[] = array($nom['num_nom'], $nom_sci_traite, $nom_sci_ideal, $nom['exclure_taxref']);
587
				}
655
				}
588
			}
656
			}
589
		}
657
		}
590
		return $noms_erreur;
658
		return $noms_erreur;
591
	}
659
	}
592
	
660
	
593
	/**
661
	/**
594
	 * Test #19
662
	 * Test #23
595
	 */
663
	 */
596
	private function testerNomSupraGeneriqueEspaces() {
664
	private function testerNomSupraGeneriqueEspaces() {
597
		$noms_erreur = array();
665
		$noms_erreur = array();
598
		foreach ($this->noms as &$nom) {
666
		foreach ($this->noms as &$nom) {
599
			if ($nom['nom_supra_generique'] != '') {
667
			if ($nom['nom_supra_generique'] != '') {
600
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s+$)/', $nom['nom_supra_generique'])) {
668
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s+$)/', $nom['nom_supra_generique'])) {
601
					$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
669
					$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
602
					$noms_erreur[] = array($nom['num_nom'], $nom_supra_generique_traite, $nom['exclure_taxref']);
670
					$noms_erreur[] = array($nom['num_nom'], $nom_supra_generique_traite, $nom['exclure_taxref']);
603
				}
671
				}
604
			}
672
			}
605
		}
673
		}
606
		return $noms_erreur;
674
		return $noms_erreur;
607
	}
675
	}
608
	
676
	
609
	/**
677
	/**
610
	 * Test #20
678
	 * Test #24
611
	 */
679
	 */
612
	private function testerNomSupraGeneriqueSyntaxe() {
680
	private function testerNomSupraGeneriqueSyntaxe() {
613
		$noms_erreur = array();
681
		$noms_erreur = array();
614
		foreach ($this->noms as &$nom) {
682
		foreach ($this->noms as &$nom) {
615
			if ($nom['nom_supra_generique'] != '') {
683
			if ($nom['nom_supra_generique'] != '') {
616
				if (!preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ][-a-zäëḧïöẗüẅẍÿ]+$/', $nom['nom_supra_generique'])) {
684
				if (!preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ][-a-zäëḧïöẗüẅẍÿ]+$/', $nom['nom_supra_generique'])) {
617
					$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
685
					$nom_supra_generique_traite = $this->repererEspace($nom['nom_supra_generique']);
618
					$noms_erreur[] = array($nom['num_nom'], $nom_supra_generique_traite, $nom['exclure_taxref']);
686
					$noms_erreur[] = array($nom['num_nom'], $nom_supra_generique_traite, $nom['exclure_taxref']);
619
				}
687
				}
620
			}
688
			}
621
		}
689
		}
622
		return $noms_erreur;
690
		return $noms_erreur;
623
	}
691
	}
624
	
692
	
625
	/**
693
	/**
626
	 * Test #21
694
	 * Test #25
627
	 */
695
	 */
628
	private function testerNomSupraGeneriqueRang() {
696
	private function testerNomSupraGeneriqueRang() {
629
		$noms_erreur = array();
697
		$noms_erreur = array();
630
		foreach ($this->noms as &$nom) {
698
		foreach ($this->noms as &$nom) {
631
			if ($nom['nom_supra_generique'] != '') {
699
			if ($nom['nom_supra_generique'] != '') {
632
				if ($nom['rang'] >= $this->manuel['rang_genre']) {
700
				if ($nom['rang'] >= $this->manuel['rang_genre']) {
633
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
701
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
634
				}
702
				}
635
			}
703
			}
636
		}
704
		}
637
		return $noms_erreur;
705
		return $noms_erreur;
638
	}
706
	}
639
	
707
	
640
	/**
708
	/**
641
	 * Test #22
709
	 * Test #26
642
	 */
710
	 */
643
	private function testerGenreEspaces() {
711
	private function testerGenreEspaces() {
644
		$noms_erreur = array();
712
		$noms_erreur = array();
645
		foreach ($this->noms as &$nom) {
713
		foreach ($this->noms as &$nom) {
646
			if ($nom['genre'] != '') {
714
			if ($nom['genre'] != '') {
647
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['genre'])) {
715
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['genre'])) {
648
					$nom_traite = $this->repererEspace($nom['genre']);
716
					$nom_traite = $this->repererEspace($nom['genre']);
649
					$noms_erreur[] = array($nom['num_nom'], $nom_traite, $nom['exclure_taxref']);
717
					$noms_erreur[] = array($nom['num_nom'], $nom_traite, $nom['exclure_taxref']);
650
				}
718
				}
651
			}
719
			}
652
		}
720
		}
653
		return $noms_erreur;
721
		return $noms_erreur;
654
	}
722
	}
655
	
723
	
656
	/**
724
	/**
657
	 * Test #23
725
	 * Test #27
658
	 */
726
	 */
659
	private function testerGenreSyntaxe() {
727
	private function testerGenreSyntaxe() {
660
		$noms_erreur = array();
728
		$noms_erreur = array();
661
		foreach ($this->noms as &$nom) {
729
		foreach ($this->noms as &$nom) {
662
			if ($nom['genre'] != '') {
730
			if ($nom['genre'] != '') {
663
				$mots = explode(' ', $nom['genre']);
731
				$mots = explode(' ', $nom['genre']);
664
				foreach ($mots as $mot) {
732
				foreach ($mots as $mot) {
665
					if (!(preg_match('/^[+x]$/', $mot) || $this->verifierEpitheteGenre($mot))) {
733
					if (!(preg_match('/^[+x]$/', $mot) || $this->verifierEpitheteGenre($mot))) {
666
						$nom_traite = $this->repererEspace($nom['genre']);
734
						$nom_traite = $this->repererEspace($nom['genre']);
667
						$noms_erreur[] = array($nom['num_nom'], $nom_traite, $nom['exclure_taxref']);
735
						$noms_erreur[] = array($nom['num_nom'], $nom_traite, $nom['exclure_taxref']);
668
						break;
736
						break;
669
					}
737
					}
670
				}
738
				}
671
			}
739
			}
672
		}
740
		}
673
		return $noms_erreur;
741
		return $noms_erreur;
674
	}
742
	}
675
	
743
	
676
	/**
744
	/**
677
	 * Test #24
745
	 * Test #28
678
	 */
746
	 */
679
	private function testerGenreRang() {
747
	private function testerGenreRang() {
680
		$noms_erreur = array();
748
		$noms_erreur = array();
681
		foreach ($this->noms as &$nom) {
749
		foreach ($this->noms as &$nom) {
682
			if ($nom['genre'] != '') {
750
			if ($nom['genre'] != '') {
683
				if ($nom['rang'] < $this->manuel['rang_genre']) {
751
				if ($nom['rang'] < $this->manuel['rang_genre']) {
684
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
752
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
685
				}
753
				}
686
			}
754
			}
687
		}
755
		}
688
		return $noms_erreur;
756
		return $noms_erreur;
689
	}
757
	}
690
		
758
		
691
	/**
759
	/**
692
	 * Test #25
760
	 * Test #29
693
	 */
761
	 */
694
	private function testerEpitheteInfraGeneriqueSyntaxe() {
762
	private function testerEpitheteInfraGeneriqueSyntaxe() {
695
		$noms_erreur = array();
763
		$noms_erreur = array();
696
		foreach ($this->noms as &$nom) {
764
		foreach ($this->noms as &$nom) {
697
			if ($nom['epithete_infra_generique'] != '') {
765
			if ($nom['epithete_infra_generique'] != '') {
698
				if (!preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ][-a-zäëḧïöẗüẅẍÿ]+/', $nom['epithete_infra_generique'])) {
766
				if (!preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ][-a-zäëḧïöẗüẅẍÿ]+/', $nom['epithete_infra_generique'])) {
699
					$epithete_traite = $this->repererEspace($nom['epithete_infra_generique']);
767
					$epithete_traite = $this->repererEspace($nom['epithete_infra_generique']);
700
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
768
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
701
				}
769
				}
702
			}
770
			}
703
		}
771
		}
704
		return $noms_erreur;
772
		return $noms_erreur;
705
	}
773
	}
706
	
774
	
707
	/**
775
	/**
708
	 * Test #26
776
	 * Test #30
709
	 */
777
	 */
710
	private function testerEpitheteInfraGeneriqueRang() {
778
	private function testerEpitheteInfraGeneriqueRang() {
711
		$noms_erreur = array();
779
		$noms_erreur = array();
712
		foreach ($this->noms as &$nom) {
780
		foreach ($this->noms as &$nom) {
713
			if ($nom['epithete_infra_generique'] != '') {
781
			if ($nom['epithete_infra_generique'] != '') {
714
				if ($nom['rang'] <= $this->manuel['rang_genre'] || $nom['rang'] >= $this->manuel['rang_sp']) {
782
				if ($nom['rang'] <= $this->manuel['rang_genre'] || $nom['rang'] >= $this->manuel['rang_sp']) {
715
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
783
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
716
				}
784
				}
717
			}
785
			}
718
		}
786
		}
719
		return $noms_erreur;
787
		return $noms_erreur;
720
	}
788
	}
721
	
789
	
722
	/**
790
	/**
723
	 * Test #27
791
	 * Test #31
724
	 */
792
	 */
725
	private function testerEpitheteInfraGeneriqueEspaces() {
793
	private function testerEpitheteInfraGeneriqueEspaces() {
726
		$noms_erreur = array();
794
		$noms_erreur = array();
727
		foreach ($this->noms as &$nom) {
795
		foreach ($this->noms as &$nom) {
728
			if ($nom['epithete_infra_generique'] != '') {
796
			if ($nom['epithete_infra_generique'] != '') {
729
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_infra_generique'])) {
797
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_infra_generique'])) {
730
					$epithete_traite = $this->repererEspace($nom['epithete_infra_generique']);
798
					$epithete_traite = $this->repererEspace($nom['epithete_infra_generique']);
731
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
799
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
732
				}
800
				}
733
			}
801
			}
734
		}
802
		}
735
		return $noms_erreur;
803
		return $noms_erreur;
736
	}
804
	}
737
	
805
	
738
	/**
806
	/**
739
	 * Test #28
807
	 * Test #32
740
	 */
808
	 */
741
	private function testerEpitheteSpEspaces() {
809
	private function testerEpitheteSpEspaces() {
742
		$noms_erreur = array();
810
		$noms_erreur = array();
743
		foreach ($this->noms as &$nom) {
811
		foreach ($this->noms as &$nom) {
744
			if ($nom['epithete_sp'] != '') {
812
			if ($nom['epithete_sp'] != '') {
745
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_sp'])) {
813
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_sp'])) {
746
					$epithete_traite = $this->repererEspace($nom['epithete_sp']);
814
					$epithete_traite = $this->repererEspace($nom['epithete_sp']);
747
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
815
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
748
				}
816
				}
749
			}
817
			}
750
		}
818
		}
751
		return $noms_erreur;
819
		return $noms_erreur;
752
	}
820
	}
753
	
821
	
754
	/**
822
	/**
755
	 * Test #29
823
	 * Test #33
756
	 */
824
	 */
757
	private function testerEpitheteSpSyntaxe() {
825
	private function testerEpitheteSpSyntaxe() {
758
		$noms_erreur = array();
826
		$noms_erreur = array();
759
		foreach ($this->noms as &$nom) {
827
		foreach ($this->noms as &$nom) {
760
			if ($nom['epithete_sp'] != '') {
828
			if ($nom['epithete_sp'] != '') {
761
				$mots = explode(' ', $nom['epithete_sp']);
829
				$mots = explode(' ', $nom['epithete_sp']);
762
				foreach ($mots as $mot) {
830
				foreach ($mots as $mot) {
763
					if (!(preg_match('/^[+x]$/', $mot) || $this->verifierEpitheteSp($mot))) {
831
					if (!(preg_match('/^[+x]$/', $mot) || $this->verifierEpitheteSp($mot))) {
764
						$epithete_traite = $this->repererEspace($nom['epithete_sp']);
832
						$epithete_traite = $this->repererEspace($nom['epithete_sp']);
765
						$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
833
						$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
766
						break;
834
						break;
767
					}
835
					}
768
				}
836
				}
769
			}
837
			}
770
		}
838
		}
771
		return $noms_erreur;
839
		return $noms_erreur;
772
	}
840
	}
773
	
841
	
774
	/**
842
	/**
775
	 * Test #30
843
	 * Test #34
776
	 */
844
	 */
777
	private function testerEpitheteSpRang() {
845
	private function testerEpitheteSpRang() {
778
		$noms_erreur = array();
846
		$noms_erreur = array();
779
		foreach ($this->noms as &$nom) {
847
		foreach ($this->noms as &$nom) {
780
			if ($nom['epithete_sp'] != '') {
848
			if ($nom['epithete_sp'] != '') {
781
				if ($nom['rang'] < $this->manuel['rang_sp']) {
849
				if ($nom['rang'] < $this->manuel['rang_sp']) {
782
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
850
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
783
				}
851
				}
784
			}
852
			}
785
		}
853
		}
786
		return $noms_erreur;
854
		return $noms_erreur;
787
	}
855
	}
788
	
856
	
789
	/**
857
	/**
790
	 * Test #31
858
	 * Test #35
791
	 */
859
	 */
792
	private function testerTypeEpitheteEspaces() {
860
	private function testerTypeEpitheteEspaces() {
793
		$noms_erreur = array();
861
		$noms_erreur = array();
794
		foreach ($this->noms as &$nom) {
862
		foreach ($this->noms as &$nom) {
795
			if ($nom['type_epithete'] != '') {
863
			if ($nom['type_epithete'] != '') {
796
				if (preg_match('/\s+/', $nom['type_epithete'])) {
864
				if (preg_match('/\s+/', $nom['type_epithete'])) {
797
					$valeur_traitee = $this->repererEspace($nom['epithete_sp']);
865
					$valeur_traitee = $this->repererEspace($nom['epithete_sp']);
798
					$noms_erreur[] = array($nom['num_nom'], $valeur_traitee, $nom['exclure_taxref']);
866
					$noms_erreur[] = array($nom['num_nom'], $valeur_traitee, $nom['exclure_taxref']);
799
				}
867
				}
800
			}
868
			}
801
		}
869
		}
802
		return $noms_erreur;
870
		return $noms_erreur;
803
	}
871
	}
804
	
872
	
805
	/**
873
	/**
806
	 * Test #32
874
	 * Test #36
807
	 */
875
	 */
808
	private function testerTypeEpitheteSyntaxe() {
876
	private function testerTypeEpitheteSyntaxe() {
809
		$noms_erreur = array();
877
		$noms_erreur = array();
810
		foreach ($this->noms as &$nom) {
878
		foreach ($this->noms as &$nom) {
811
			if ($nom['type_epithete'] != '') {
879
			if ($nom['type_epithete'] != '') {
812
				if (!$this->verifierTypeEpithete($nom['type_epithete'])) {
880
				if (!$this->verifierTypeEpithete($nom['type_epithete'])) {
813
					$noms_erreur[] = array($nom['num_nom'],  $nom['type_epithete'], $nom['exclure_taxref']);
881
					$noms_erreur[] = array($nom['num_nom'],  $nom['type_epithete'], $nom['exclure_taxref']);
814
				}
882
				}
815
			}
883
			}
816
		}
884
		}
817
		return $noms_erreur;
885
		return $noms_erreur;
818
	}
886
	}
819
	
887
	
820
	/**
888
	/**
821
	 * Test #33
889
	 * Test #37
822
	 */
890
	 */
823
	private function testerTypeEpitheteHybridite() {
891
	private function testerTypeEpitheteHybridite() {
824
		$noms_erreur = array();
892
		$noms_erreur = array();
825
		foreach ($this->noms as &$nom) {
893
		foreach ($this->noms as &$nom) {
826
			if ($nom['type_epithete'] != '') {
894
			if ($nom['type_epithete'] != '') {
827
				if (preg_match('/^(?:n-|notho-)/', $nom['type_epithete'])) {
895
				if (preg_match('/^(?:n-|notho-)/', $nom['type_epithete'])) {
828
					$noms_erreur[] = array($nom['num_nom'], $nom['type_epithete'], $nom['exclure_taxref']);
896
					$noms_erreur[] = array($nom['num_nom'], $nom['type_epithete'], $nom['exclure_taxref']);
829
				}
897
				}
830
			}
898
			}
831
		}
899
		}
832
		return $noms_erreur;
900
		return $noms_erreur;
833
	}
901
	}
834
	
902
	
835
	/**
903
	/**
836
	 * Test #34
904
	 * Test #38
837
	 */
905
	 */
838
	private function testerEpitheteInfraSpEspaces() {
906
	private function testerEpitheteInfraSpEspaces() {
839
		$noms_erreur = array();
907
		$noms_erreur = array();
840
		foreach ($this->noms as &$nom) {
908
		foreach ($this->noms as &$nom) {
841
			if ($nom['epithete_infra_sp'] != '') {
909
			if ($nom['epithete_infra_sp'] != '') {
842
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_infra_sp'])) {
910
				if (preg_match('/(?:^\s+(?!:\s+)|(?!:\s+)\s{2,}(?!:\s+)|(?!:\s+)\s+$)/', $nom['epithete_infra_sp'])) {
843
					$epithete_traite = $this->repererEspace($nom['epithete_infra_sp']);
911
					$epithete_traite = $this->repererEspace($nom['epithete_infra_sp']);
844
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
912
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
845
				}
913
				}
846
			}
914
			}
847
		}
915
		}
848
		return $noms_erreur;
916
		return $noms_erreur;
849
	}
917
	}
850
	
918
	
851
	/**
919
	/**
852
	 * Test #35
920
	 * Test #39
853
	 */
921
	 */
854
	private function testerEpitheteInfraSpSyntaxe() {
922
	private function testerEpitheteInfraSpSyntaxe() {
855
		$noms_erreur = array();
923
		$noms_erreur = array();
856
		foreach ($this->noms as &$nom) {
924
		foreach ($this->noms as &$nom) {
857
			if ($nom['epithete_infra_sp'] != '') {
925
			if ($nom['epithete_infra_sp'] != '') {
858
				$mots = explode(' ', $nom['epithete_infra_sp']);
926
				$mots = explode(' ', $nom['epithete_infra_sp']);
859
				foreach ($mots as $mot) {
927
				foreach ($mots as $mot) {
860
					if (!(preg_match('/^[+x]$/', $mot) || $this->verifierTypeEpithete($mot)|| $this->verifierEpitheteSp($mot))) {
928
					if (!(preg_match('/^[+x]$/', $mot) || $this->verifierTypeEpithete($mot)|| $this->verifierEpitheteSp($mot))) {
861
						$epithete_traite = $this->repererEspace($nom['epithete_infra_sp']);
929
						$epithete_traite = $this->repererEspace($nom['epithete_infra_sp']);
862
						$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
930
						$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
863
						break;
931
						break;
864
					}
932
					}
865
				}
933
				}
866
			}
934
			}
867
		}
935
		}
868
		return $noms_erreur;
936
		return $noms_erreur;
869
	}
937
	}
870
	
938
	
871
	/**
939
	/**
872
	 * Test #36
940
	 * Test #40
873
	 */
941
	 */
874
	private function testerEpitheteInfraSpRang() {
942
	private function testerEpitheteInfraSpRang() {
875
		$noms_erreur = array();
943
		$noms_erreur = array();
876
		foreach ($this->noms as &$nom) {
944
		foreach ($this->noms as &$nom) {
877
			if ($nom['epithete_infra_sp'] != '') {
945
			if ($nom['epithete_infra_sp'] != '') {
878
				if ($nom['rang'] < $this->manuel['rang_sp']) {
946
				if ($nom['rang'] < $this->manuel['rang_sp']) {
879
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
947
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
880
				}
948
				}
881
			}
949
			}
882
		}
950
		}
883
		return $noms_erreur;
951
		return $noms_erreur;
884
	}
952
	}
885
	
953
	
886
	/**
954
	/**
887
	 * Test #37
955
	 * Test #41
888
	 */
956
	 */
889
	private function testerGroupeCultivarSyntaxe() {
957
	private function testerGroupeCultivarSyntaxe() {
890
		$noms_erreur = array();
958
		$noms_erreur = array();
891
		foreach ($this->noms as &$nom) {
959
		foreach ($this->noms as &$nom) {
892
			if ($nom['cultivar_groupe'] != '') {
960
			if ($nom['cultivar_groupe'] != '') {
893
				if (!$this->verifierEpitheteGroupeCultivar($nom['cultivar_groupe'])) {
961
				if (!$this->verifierEpitheteGroupeCultivar($nom['cultivar_groupe'])) {
894
					$epithete_traite = $this->repererEspace($nom['cultivar_groupe']);
962
					$epithete_traite = $this->repererEspace($nom['cultivar_groupe']);
895
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
963
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
896
				}
964
				}
897
			}
965
			}
898
		}
966
		}
899
		return $noms_erreur;
967
		return $noms_erreur;
900
	}
968
	}
901
	
969
	
902
	/**
970
	/**
903
	 * Test #38
971
	 * Test #42
904
	 */
972
	 */
905
	private function testerGroupeCultivarRang() {
973
	private function testerGroupeCultivarRang() {
906
		$noms_erreur = array();
974
		$noms_erreur = array();
907
		foreach ($this->noms as &$nom) {
975
		foreach ($this->noms as &$nom) {
908
			if ($nom['cultivar_groupe'] != '') {
976
			if ($nom['cultivar_groupe'] != '') {
909
				if ($nom['rang'] < $this->manuel['rang_genre']) {
977
				if ($nom['rang'] < $this->manuel['rang_genre']) {
910
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
978
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
911
				}
979
				}
912
			}
980
			}
913
		}
981
		}
914
		return $noms_erreur;
982
		return $noms_erreur;
915
	}
983
	}
916
	
984
	
917
	/**
985
	/**
918
	 * Test #39
986
	 * Test #43
919
	 */
987
	 */
920
	private function testerCultivarSyntaxe() {
988
	private function testerCultivarSyntaxe() {
921
		$noms_erreur = array();
989
		$noms_erreur = array();
922
		foreach ($this->noms as &$nom) {
990
		foreach ($this->noms as &$nom) {
923
			if ($nom['cultivar'] != '') {
991
			if ($nom['cultivar'] != '') {
924
				if (!$this->verifierEpitheteCultivar($nom['cultivar'])) {
992
				if (!$this->verifierEpitheteCultivar($nom['cultivar'])) {
925
					$epithete_traite = $this->repererEspace($nom['cultivar']);
993
					$epithete_traite = $this->repererEspace($nom['cultivar']);
926
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
994
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
927
				}
995
				}
928
			}
996
			}
929
		}
997
		}
930
		return $noms_erreur;
998
		return $noms_erreur;
931
	}
999
	}
932
	
1000
	
933
	/**
1001
	/**
934
	 * Test #40
1002
	 * Test #44
935
	 */
1003
	 */
936
	private function testerCultivarRang() {
1004
	private function testerCultivarRang() {
937
		$noms_erreur = array();
1005
		$noms_erreur = array();
938
		foreach ($this->noms as &$nom) {
1006
		foreach ($this->noms as &$nom) {
939
			if ($nom['cultivar'] != '') {
1007
			if ($nom['cultivar'] != '') {
940
				if ($nom['rang'] < $this->manuel['rang_genre']) {
1008
				if ($nom['rang'] < $this->manuel['rang_genre']) {
941
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
1009
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['rang'], $nom['exclure_taxref']);
942
				}
1010
				}
943
			}
1011
			}
944
		}
1012
		}
945
		return $noms_erreur;
1013
		return $noms_erreur;
946
	}
1014
	}
947
	
1015
	
948
	/**
1016
	/**
949
	 * Test #41
1017
	 * Test #45
950
	 */
1018
	 */
951
	private function testerNomCommercialSyntaxe() {
1019
	private function testerNomCommercialSyntaxe() {
952
		$noms_erreur = array();
1020
		$noms_erreur = array();
953
		foreach ($this->noms as &$nom) {
1021
		foreach ($this->noms as &$nom) {
954
			if ($nom['nom_commercial'] != '') {
1022
			if ($nom['nom_commercial'] != '') {
955
				if (!$this->verifierNomCommercial($nom['nom_commercial'])) {
1023
				if (!$this->verifierNomCommercial($nom['nom_commercial'])) {
956
					$epithete_traite = $this->repererEspace($nom['nom_commercial']);
1024
					$epithete_traite = $this->repererEspace($nom['nom_commercial']);
957
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
1025
					$noms_erreur[] = array($nom['num_nom'], $epithete_traite, $nom['exclure_taxref']);
958
				}
1026
				}
959
			}
1027
			}
960
		}
1028
		}
961
		return $noms_erreur;
1029
		return $noms_erreur;
962
	}
1030
	}
963
	
1031
	
964
	/**
1032
	/**
965
	 * Test #42
1033
	 * Test #46
966
	 */
1034
	 */
967
	private function testerNomCommercialPresenceCultivar() {
1035
	private function testerNomCommercialPresenceCultivar() {
968
		$noms_erreur = array();
1036
		$noms_erreur = array();
969
		foreach ($this->noms as &$nom) {
1037
		foreach ($this->noms as &$nom) {
970
			if ((isset($nom['nom_commercial']) && $nom['nom_commercial'] != '') && ($nom['cultivar'] == '' && $nom['cultivar_groupe'] == '')) {
1038
			if ((isset($nom['nom_commercial']) && $nom['nom_commercial'] != '') && ($nom['cultivar'] == '' && $nom['cultivar_groupe'] == '')) {
971
				$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['exclure_taxref']);
1039
				$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['exclure_taxref']);
972
			}
1040
			}
973
		}
1041
		}
974
		return $noms_erreur;
1042
		return $noms_erreur;
975
	}
1043
	}
976
	
1044
	
977
	/**
1045
	/**
978
	 * Test #43
1046
	 * Test #47
979
	 */
1047
	 */
980
	private function testerAuteurSyntaxe() {
1048
	private function testerAuteurSyntaxe() {
981
		$noms_erreur = array();
1049
		$noms_erreur = array();
982
		foreach ($this->noms as &$nom) {
1050
		foreach ($this->noms as &$nom) {
983
			if ($nom['auteur'] != '') {
1051
			if ($nom['auteur'] != '') {
984
				if (!$this->verifierAuteur($nom['auteur'])) {
1052
				if (!$this->verifierAuteur($nom['auteur'])) {
985
					$intitule_traite = $this->repererEspace($nom['auteur']);
1053
					$intitule_traite = $this->repererEspace($nom['auteur']);
986
					$noms_erreur[] = array($nom['num_nom'], $intitule_traite, $nom['exclure_taxref']);
1054
					$noms_erreur[] = array($nom['num_nom'], $intitule_traite, $nom['exclure_taxref']);
987
				}
1055
				}
988
			}
1056
			}
989
		}
1057
		}
990
		return $noms_erreur;
1058
		return $noms_erreur;
991
	}
1059
	}
992
	
1060
	
993
	/**
1061
	/**
994
	 * Test #44
1062
	 * Test #48
995
	 */
1063
	 */
996
	private function testerAnneeSyntaxe() {
1064
	private function testerAnneeSyntaxe() {
997
		$noms_erreur = array();
1065
		$noms_erreur = array();
998
		foreach ($this->noms as &$nom) {
1066
		foreach ($this->noms as &$nom) {
999
			if ($nom['annee'] != '') {
1067
			if ($nom['annee'] != '') {
1000
				if (!$this->verifierAnnee($nom['annee'])) {
1068
				if (!$this->verifierAnnee($nom['annee'])) {
1001
					$noms_erreur[] = array($nom['num_nom'], $nom['annee'], $nom['exclure_taxref']);
1069
					$noms_erreur[] = array($nom['num_nom'], $nom['annee'], $nom['exclure_taxref']);
1002
				}
1070
				}
1003
			}
1071
			}
1004
		}
1072
		}
1005
		return $noms_erreur;
1073
		return $noms_erreur;
1006
	}
1074
	}
1007
	
1075
	
1008
	/**
1076
	/**
1009
	 * Test #45
1077
	 * Test #49
1010
	 */
1078
	 */
1011
	private function testerBiblioOrigineSyntaxe() {
1079
	private function testerBiblioOrigineSyntaxe() {
1012
		$noms_erreur = array();
1080
		$noms_erreur = array();
1013
		foreach ($this->noms as &$nom) {
1081
		foreach ($this->noms as &$nom) {
1014
			if ($nom['biblio_origine'] != '') {
1082
			if ($nom['biblio_origine'] != '') {
1015
				if (!$this->verifierBiblioOrigine($nom['biblio_origine'])) {
1083
				if (!$this->verifierBiblioOrigine($nom['biblio_origine'])) {
1016
					$biblio_traite = $this->repererEspace($nom['biblio_origine']);
1084
					$biblio_traite = $this->repererEspace($nom['biblio_origine']);
1017
					$noms_erreur[] = array($nom['num_nom'], $biblio_traite, $nom['exclure_taxref']);
1085
					$noms_erreur[] = array($nom['num_nom'], $biblio_traite, $nom['exclure_taxref']);
1018
				}
1086
				}
1019
			}
1087
			}
1020
		}
1088
		}
1021
		return $noms_erreur;
1089
		return $noms_erreur;
1022
	}
1090
	}
1023
	
1091
	
1024
	/**
1092
	/**
1025
	 * Test #46
1093
	 * Test #50
1026
	 */
1094
	 */
1027
	private function testerHomonymieSyntaxe() {
1095
	private function testerHomonymieSyntaxe() {
1028
		$noms_erreur = array();
1096
		$noms_erreur = array();
1029
		foreach ($this->noms as &$nom) {
1097
		foreach ($this->noms as &$nom) {
1030
			if ($nom['homonyme'] != '') {
1098
			if ($nom['homonyme'] != '') {
1031
				if (!$this->verifierBooleen($nom['homonyme'])) {
1099
				if (!$this->verifierBooleen($nom['homonyme'])) {
1032
					$noms_erreur[] = array($nom['num_nom'], $nom['homonyme'], $nom['exclure_taxref']);
1100
					$noms_erreur[] = array($nom['num_nom'], $nom['homonyme'], $nom['exclure_taxref']);
1033
				}
1101
				}
1034
			}
1102
			}
1035
		}
1103
		}
1036
		return $noms_erreur;
1104
		return $noms_erreur;
1037
	}
1105
	}
1038
	
1106
	
1039
	/**
1107
	/**
1040
	 * Test #47
1108
	 * Test #51
1041
	 */
1109
	 */
1042
	private function testerHomonymieExistence() {
1110
	private function testerHomonymieExistence() {
1043
		$noms_homonymie = $this->classerNomsParNomComplet();
1111
		$noms_homonymie = $this->classerNomsParNomComplet();
1044
		
1112
		
1045
		$noms_erreur = array();
1113
		$noms_erreur = array();
1046
		foreach ($this->noms as &$nom) {
1114
		foreach ($this->noms as &$nom) {
1047
			if ($nom['homonyme'] != '0' && $nom['homonyme'] != '') {
1115
			if ($nom['homonyme'] != '0' && $nom['homonyme'] != '') {
1048
				if ($noms_homonymie[$nom['nom_sci']] <= 1) {
1116
				if ($noms_homonymie[$nom['nom_sci']] <= 1) {
1049
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['exclure_taxref']);
1117
					$noms_erreur[] = array($nom['num_nom'], $nom['nom_sci'], $nom['exclure_taxref']);
1050
				}
1118
				}
1051
			}
1119
			}
1052
		}
1120
		}
1053
		$noms_homonymie = null;
1121
		$noms_homonymie = null;
1054
		return $noms_erreur;
1122
		return $noms_erreur;
1055
	}
1123
	}
1056
	
1124
	
1057
	/**
1125
	/**
1058
	 * Test #48
1126
	 * Test #52
1059
	 */
1127
	 */
1060
	private function testerBasionymeSyntaxe() {
1128
	private function testerBasionymeSyntaxe() {
1061
		$noms_erreur = array();
1129
		$noms_erreur = array();
1062
		foreach ($this->noms as &$nom) {
1130
		foreach ($this->noms as &$nom) {
1063
			if ($nom['basionyme'] != '') {
1131
			if ($nom['basionyme'] != '') {
1064
				if (!$this->verifierNombre($nom['basionyme'])) {
1132
				if (!$this->verifierNombre($nom['basionyme'])) {
1065
					$noms_erreur[] = array($nom['num_nom'], $nom['basionyme'], $nom['exclure_taxref']);
1133
					$noms_erreur[] = array($nom['num_nom'], $nom['basionyme'], $nom['exclure_taxref']);
1066
				}
1134
				}
1067
			}
1135
			}
1068
		}
1136
		}
1069
		return $noms_erreur;
1137
		return $noms_erreur;
1070
	}
1138
	}
1071
 
1139
 
1072
	/**
1140
	/**
1073
	 * Test #49
1141
	 * Test #53
1074
	 */
1142
	 */
1075
	private function testerBasionymeExistence() {
1143
	private function testerBasionymeExistence() {
1076
		$noms_erreur = array();
1144
		$noms_erreur = array();
1077
		foreach ($this->noms as &$nom) {
1145
		foreach ($this->noms as &$nom) {
1078
			if ($nom['basionyme'] != '') {
1146
			if ($nom['basionyme'] != '') {
1079
				if (!isset($this->noms[$nom['basionyme']])) {
1147
				if (!isset($this->noms[$nom['basionyme']])) {
1080
					$noms_erreur[] = array($nom['num_nom'], $nom['basionyme'], $nom['exclure_taxref']);
1148
					$noms_erreur[] = array($nom['num_nom'], $nom['basionyme'], $nom['exclure_taxref']);
1081
				}
1149
				}
1082
			}
1150
			}
1083
		}
1151
		}
1084
		return $noms_erreur;
1152
		return $noms_erreur;
1085
	}
1153
	}
1086
	
1154
	
1087
	/**
1155
	/**
1088
	 * Test #50
1156
	 * Test #54
1089
	 */
1157
	 */
1090
	private function testerSynonymeProparteSyntaxe() {
1158
	private function testerSynonymeProparteSyntaxe() {
1091
		$noms_erreur = array();
1159
		$noms_erreur = array();
1092
		foreach ($this->noms as &$nom) {
1160
		foreach ($this->noms as &$nom) {
1093
			if ($nom['synonyme_proparte'] != '') {
1161
			if ($nom['synonyme_proparte'] != '') {
1094
				if (!$this->verifierNombreSuite($nom['synonyme_proparte'])) {
1162
				if (!$this->verifierNombreSuite($nom['synonyme_proparte'])) {
1095
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_proparte'], $nom['exclure_taxref']);
1163
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_proparte'], $nom['exclure_taxref']);
1096
				}
1164
				}
1097
			}
1165
			}
1098
		}
1166
		}
1099
		return $noms_erreur;
1167
		return $noms_erreur;
1100
	}
1168
	}
1101
	
1169
	
1102
	/**
1170
	/**
1103
	 * Test #51
1171
	 * Test #55
1104
	 */
1172
	 */
1105
	private function testerSynonymeProparteExistence() {
1173
	private function testerSynonymeProparteExistence() {
1106
		$noms_erreur = array();
1174
		$noms_erreur = array();
1107
		foreach ($this->noms as &$nom) {
1175
		foreach ($this->noms as &$nom) {
1108
			if ($nom['synonyme_proparte'] != '') {
1176
			if ($nom['synonyme_proparte'] != '') {
1109
				$num_nom_a_verifier = explode(',', $nom['synonyme_proparte']);
1177
				$num_nom_a_verifier = explode(',', $nom['synonyme_proparte']);
1110
				$num_nom_en_erreur = array();
1178
				$num_nom_en_erreur = array();
1111
				foreach ($num_nom_a_verifier as $num_nom) {
1179
				foreach ($num_nom_a_verifier as $num_nom) {
1112
					if (!isset($this->noms[$num_nom])) {
1180
					if (!isset($this->noms[$num_nom])) {
1113
						$num_nom_en_erreur[] = $num_nom;
1181
						$num_nom_en_erreur[] = $num_nom;
1114
					}
1182
					}
1115
				}
1183
				}
1116
				if (count($nbre_en_erreur) > 0) {
1184
				if (count($nbre_en_erreur) > 0) {
1117
					$noms_erreur[] = array($nom['num_nom'], implode(',', $num_nom_en_erreur), $nom['exclure_taxref']);
1185
					$noms_erreur[] = array($nom['num_nom'], implode(',', $num_nom_en_erreur), $nom['exclure_taxref']);
1118
				}
1186
				}
1119
			}
1187
			}
1120
		}
1188
		}
1121
		return $noms_erreur;
1189
		return $noms_erreur;
1122
	}
1190
	}
1123
	
1191
	
1124
	/**
1192
	/**
1125
	 * Test #52
1193
	 * Test #56
1126
	 */
1194
	 */
1127
	private function testerSynonymeDouteuxSyntaxe() {
1195
	private function testerSynonymeDouteuxSyntaxe() {
1128
		$noms_erreur = array();
1196
		$noms_erreur = array();
1129
		foreach ($this->noms as &$nom) {
1197
		foreach ($this->noms as &$nom) {
1130
			if ($nom['synonyme_douteux'] != '') {
1198
			if ($nom['synonyme_douteux'] != '') {
1131
				if (!$this->verifierBooleen($nom['synonyme_douteux'])) {
1199
				if (!$this->verifierBooleen($nom['synonyme_douteux'])) {
1132
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_douteux'], $nom['exclure_taxref']);
1200
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_douteux'], $nom['exclure_taxref']);
1133
				}
1201
				}
1134
			}
1202
			}
1135
		}
1203
		}
1136
		return $noms_erreur;		
1204
		return $noms_erreur;		
1137
	}
1205
	}
1138
	
1206
	
1139
	/**
1207
	/**
1140
	 * Test #53
1208
	 * Test #57
1141
	 */
1209
	 */
1142
	private function testerSynonymeDouteuxNumNomRetenu() {
1210
	private function testerSynonymeDouteuxNumNomRetenu() {
1143
		$noms_erreur = array();
1211
		$noms_erreur = array();
1144
		foreach ($this->noms as &$nom) {
1212
		foreach ($this->noms as &$nom) {
1145
			if ($nom['synonyme_douteux'] == 1 && !$this->verifierNombre($nom['num_nom_retenu'])) {
1213
			if ($nom['synonyme_douteux'] == 1 && !$this->verifierNombre($nom['num_nom_retenu'])) {
1146
				$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_douteux'], $nom['exclure_taxref']);
1214
				$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_douteux'], $nom['exclure_taxref']);
1147
			}
1215
			}
1148
		}
1216
		}
1149
		return $noms_erreur;
1217
		return $noms_erreur;
1150
	}
1218
	}
1151
	
1219
	
1152
	/**
1220
	/**
1153
	 * Test #54
1221
	 * Test #58
1154
	 */
1222
	 */
1155
	private function testerSynonymeMalAppliqueSyntaxe() {
1223
	private function testerSynonymeMalAppliqueSyntaxe() {
1156
		$noms_erreur = array();
1224
		$noms_erreur = array();
1157
		foreach ($this->noms as &$nom) {
1225
		foreach ($this->noms as &$nom) {
1158
			if ($nom['synonyme_mal_applique'] != '') {
1226
			if ($nom['synonyme_mal_applique'] != '') {
1159
				if (!$this->verifierBooleen($nom['synonyme_mal_applique'])) {
1227
				if (!$this->verifierBooleen($nom['synonyme_mal_applique'])) {
1160
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_mal_applique'], $nom['exclure_taxref']);
1228
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_mal_applique'], $nom['exclure_taxref']);
1161
				}
1229
				}
1162
			}
1230
			}
1163
		}
1231
		}
1164
		return $noms_erreur;
1232
		return $noms_erreur;
1165
	}
1233
	}
1166
	
1234
	
1167
	/**
1235
	/**
1168
	 * Test #55
1236
	 * Test #59
1169
	 */
1237
	 */
1170
	private function testerSynonymeOrthographiqueSyntaxe() {
1238
	private function testerSynonymeOrthographiqueSyntaxe() {
1171
		$noms_erreur = array();
1239
		$noms_erreur = array();
1172
		foreach ($this->noms as $nom) {
1240
		foreach ($this->noms as $nom) {
1173
			if ($nom['synonyme_orthographique'] != '') {
1241
			if ($nom['synonyme_orthographique'] != '') {
1174
				if (!$this->verifierNombre($nom['synonyme_orthographique'])) {
1242
				if (!$this->verifierNombre($nom['synonyme_orthographique'])) {
1175
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_orthographique'], $nom['exclure_taxref']);
1243
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_orthographique'], $nom['exclure_taxref']);
1176
				}
1244
				}
1177
			}
1245
			}
1178
		}
1246
		}
1179
		return $noms_erreur;
1247
		return $noms_erreur;
1180
	}
1248
	}
1181
	
1249
	
1182
	/**
1250
	/**
1183
	 * Test #56
1251
	 * Test #60
1184
	 */
1252
	 */
1185
	private function testerSynonymeOrthographiqueExistence() {
1253
	private function testerSynonymeOrthographiqueExistence() {
1186
		$noms_erreur = array();
1254
		$noms_erreur = array();
1187
		foreach ($this->noms as &$nom) {
1255
		foreach ($this->noms as &$nom) {
1188
			if ($nom['synonyme_orthographique'] != '') {
1256
			if ($nom['synonyme_orthographique'] != '') {
1189
				if (!isset($this->noms[$nom['synonyme_orthographique']])) {
1257
				if (!isset($this->noms[$nom['synonyme_orthographique']])) {
1190
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_orthographique'], $nom['exclure_taxref']);
1258
					$noms_erreur[] = array($nom['num_nom'], $nom['synonyme_orthographique'], $nom['exclure_taxref']);
1191
				}
1259
				}
1192
			}
1260
			}
1193
		}
1261
		}
1194
		return $noms_erreur;
1262
		return $noms_erreur;
1195
	}
1263
	}
1196
	
1264
	
1197
	/**
1265
	/**
1198
	 * Test #57
1266
	 * Test #61
1199
	 */
1267
	 */
1200
	private function testerHybrideParent01Syntaxe() {
1268
	private function testerHybrideParent01Syntaxe() {
1201
		$noms_erreur = array();
1269
		$noms_erreur = array();
1202
		foreach ($this->noms as &$nom) {
1270
		foreach ($this->noms as &$nom) {
1203
			if ($nom['hybride_parent_01'] != '') {
1271
			if ($nom['hybride_parent_01'] != '') {
1204
				if (!$this->verifierNombre($nom['hybride_parent_01'])) {
1272
				if (!$this->verifierNombre($nom['hybride_parent_01'])) {
1205
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_01']), $nom['exclure_taxref']);
1273
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_01']), $nom['exclure_taxref']);
1206
				}
1274
				}
1207
			}
1275
			}
1208
		}
1276
		}
1209
		return $noms_erreur;
1277
		return $noms_erreur;
1210
	}
1278
	}
1211
	
1279
	
1212
	/**
1280
	/**
1213
	 * Test #58
1281
	 * Test #62
1214
	 */
1282
	 */
1215
	private function testerHybrideParent01Existence() {
1283
	private function testerHybrideParent01Existence() {
1216
		$noms_erreur = array();
1284
		$noms_erreur = array();
1217
		foreach ($this->noms as &$nom) {
1285
		foreach ($this->noms as &$nom) {
1218
			if ($nom['hybride_parent_01'] != '' && $nom['hybride_parent_01'] != '0') {
1286
			if ($nom['hybride_parent_01'] != '' && $nom['hybride_parent_01'] != '0') {
1219
				if (!isset($this->noms[$nom['hybride_parent_01']])) {
1287
				if (!isset($this->noms[$nom['hybride_parent_01']])) {
1220
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_01']), $nom['exclure_taxref']);
1288
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_01']), $nom['exclure_taxref']);
1221
				}
1289
				}
1222
			}
1290
			}
1223
		}
1291
		}
1224
		return $noms_erreur;
1292
		return $noms_erreur;
1225
	}
1293
	}
1226
	
1294
	
1227
	/**
1295
	/**
1228
	 * Test #59
1296
	 * Test #63
1229
	 */
1297
	 */
1230
	private function testerHybrideParent02Syntaxe() {
1298
	private function testerHybrideParent02Syntaxe() {
1231
		$noms_erreur = array();
1299
		$noms_erreur = array();
1232
		foreach ($this->noms as &$nom) {
1300
		foreach ($this->noms as &$nom) {
1233
			if ($nom['hybride_parent_02'] != '') {
1301
			if ($nom['hybride_parent_02'] != '') {
1234
				if (!$this->verifierNombre($nom['hybride_parent_02'])) {
1302
				if (!$this->verifierNombre($nom['hybride_parent_02'])) {
1235
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_02']), $nom['exclure_taxref']);
1303
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_02']), $nom['exclure_taxref']);
1236
				}
1304
				}
1237
			}
1305
			}
1238
		}
1306
		}
1239
		return $noms_erreur;
1307
		return $noms_erreur;
1240
	}
1308
	}
1241
	
1309
	
1242
	/**
1310
	/**
1243
	 * Test #60
1311
	 * Test #64
1244
	 */
1312
	 */
1245
	private function testerHybrideParent02Existence() {
1313
	private function testerHybrideParent02Existence() {
1246
		$noms_erreur = array();
1314
		$noms_erreur = array();
1247
		foreach ($this->noms as &$nom) {
1315
		foreach ($this->noms as &$nom) {
1248
			if ($nom['hybride_parent_02'] != '') {
1316
			if ($nom['hybride_parent_02'] != '') {
1249
				if (!isset($this->noms[$nom['hybride_parent_02']]) && $nom['hybride_parent_02'] != '0') {
1317
				if (!isset($this->noms[$nom['hybride_parent_02']]) && $nom['hybride_parent_02'] != '0') {
1250
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_02']), $nom['exclure_taxref']);
1318
					$noms_erreur[] = array($nom['num_nom'], $this->repererEspace($nom['hybride_parent_02']), $nom['exclure_taxref']);
1251
				}
1319
				}
1252
			}
1320
			}
1253
		}
1321
		}
1254
		return $noms_erreur;
1322
		return $noms_erreur;
1255
	}
1323
	}
1256
	
1324
	
1257
	/**
1325
	/**
1258
	 * Test #61
1326
	 * Test #65
1259
	 */
1327
	 */
1260
	private function testerPresenceSyntaxe() {
1328
	private function testerPresenceSyntaxe() {
1261
		$noms_erreur = array();
1329
		$noms_erreur = array();
1262
		foreach ($this->noms as &$nom) {
1330
		foreach ($this->noms as &$nom) {
1263
			if ($nom['presence'] != '') {
1331
			if ($nom['presence'] != '') {
1264
				if (!$this->verifierPresence($nom['presence'])) {
1332
				if (!$this->verifierPresence($nom['presence'])) {
1265
					$noms_erreur[] = array($nom['num_nom'], $nom['presence'], $nom['exclure_taxref']);
1333
					$noms_erreur[] = array($nom['num_nom'], $nom['presence'], $nom['exclure_taxref']);
1266
				}
1334
				}
1267
			}
1335
			}
1268
		}
1336
		}
1269
		return $noms_erreur;
1337
		return $noms_erreur;
1270
	}
1338
	}
1271
	
1339
	
1272
	/**
1340
	/**
1273
	 * Test #62
1341
	 * Test #66
1274
	 */
1342
	 */
1275
	private function testerStatutOrigineSyntaxe() {
1343
	private function testerStatutOrigineSyntaxe() {
1276
		$noms_erreur = array();
1344
		$noms_erreur = array();
1277
		foreach ($this->noms as &$nom) {
1345
		foreach ($this->noms as &$nom) {
1278
			if ($nom['statut_origine'] != '') {
1346
			if ($nom['statut_origine'] != '') {
1279
				if (!$this->verifierStatutOrigine($nom['statut_origine'])) {
1347
				if (!$this->verifierStatutOrigine($nom['statut_origine'])) {
1280
					$noms_erreur[] = array($nom['num_nom'], $nom['statut_origine'], $nom['exclure_taxref']);
1348
					$noms_erreur[] = array($nom['num_nom'], $nom['statut_origine'], $nom['exclure_taxref']);
1281
				}
1349
				}
1282
			}
1350
			}
1283
		}
1351
		}
1284
		return $noms_erreur;
1352
		return $noms_erreur;
1285
	}
1353
	}
1286
	
1354
	
1287
	/**
1355
	/**
1288
	 * Test #63
1356
	 * Test #67
1289
	 */
1357
	 */
1290
	private function testerStatutIntroductionSyntaxe() {
1358
	private function testerStatutIntroductionSyntaxe() {
1291
		$noms_erreur = array();
1359
		$noms_erreur = array();
1292
		foreach ($this->noms as &$nom) {
1360
		foreach ($this->noms as &$nom) {
1293
			if ($nom['statut_introduction'] != '') {
1361
			if ($nom['statut_introduction'] != '') {
1294
				if (!$this->verifierStatutIntroduction($nom['statut_introduction'])) {
1362
				if (!$this->verifierStatutIntroduction($nom['statut_introduction'])) {
1295
					$noms_erreur[] = array($nom['num_nom'], $nom['statut_introduction'], $nom['exclure_taxref']);
1363
					$noms_erreur[] = array($nom['num_nom'], $nom['statut_introduction'], $nom['exclure_taxref']);
1296
				}
1364
				}
1297
			}
1365
			}
1298
		}
1366
		}
1299
		return $noms_erreur;
1367
		return $noms_erreur;
1300
	}
1368
	}
1301
	
1369
	
1302
	/**
1370
	/**
1303
	 * Test #64
1371
	 * Test #68
1304
	 */
1372
	 */
1305
	private function testerStatutCultureSyntaxe() {
1373
	private function testerStatutCultureSyntaxe() {
1306
		$noms_erreur = array();
1374
		$noms_erreur = array();
1307
		foreach ($this->noms as &$nom) {
1375
		foreach ($this->noms as &$nom) {
1308
			if ($nom['statut_culture'] != '') {
1376
			if ($nom['statut_culture'] != '') {
1309
				if (!$this->verifierStatutCulture($nom['statut_culture'])) {
1377
				if (!$this->verifierStatutCulture($nom['statut_culture'])) {
1310
					$noms_erreur[] = array($nom['num_nom'], $nom['statut_culture'], $nom['exclure_taxref']);
1378
					$noms_erreur[] = array($nom['num_nom'], $nom['statut_culture'], $nom['exclure_taxref']);
1311
				}
1379
				}
1312
			}
1380
			}
1313
		}
1381
		}
1314
		return $noms_erreur;
1382
		return $noms_erreur;
1315
	}
1383
	}
1316
	
1384
	
1317
	/**
1385
	/**
1318
	 * Test #65
1386
	 * Test #69
1319
	 */
1387
	 */
1320
	private function testerExclureTaxRefSyntaxe() {
1388
	private function testerExclureTaxRefSyntaxe() {
1321
		$noms_erreur = array();
1389
		$noms_erreur = array();
1322
		foreach ($this->noms as &$nom) {
1390
		foreach ($this->noms as &$nom) {
1323
			if ($nom['exclure_taxref'] != '' && $nom['exclure_taxref'] != null) {
1391
			if ($nom['exclure_taxref'] != '' && $nom['exclure_taxref'] != null) {
1324
				if (!preg_match('/^(?:0|1|9)$/', $nom['exclure_taxref'])) {
1392
				if (!preg_match('/^(?:0|1|9)$/', $nom['exclure_taxref'])) {
1325
					$noms_erreur[] = array($nom['num_nom'], $nom['exclure_taxref']);
1393
					$noms_erreur[] = array($nom['num_nom'], $nom['exclure_taxref']);
1326
				}
1394
				}
1327
			}
1395
			}
1328
		}
1396
		}
1329
		return $noms_erreur;
1397
		return $noms_erreur;
1330
	}
1398
	}
1331
 
1399
 
1332
	
1400
	
1333
 
1401
 
1334
	//+--------------------------------------------------------------------------------------------------------------+//
1402
	//+--------------------------------------------------------------------------------------------------------------+//
1335
	// MÉTHODES COMMUNES aux TESTS
1403
	// MÉTHODES COMMUNES aux TESTS
1336
	
1404
	
1337
	private function verifierPresence(&$valeur) {
1405
	private function verifierPresence(&$valeur) {
1338
		$codes = $this->manuel['codes_presence'];
1406
		$codes = $this->manuel['codes_presence'];
1339
		$ok = $this->verifierStatuts($valeur, $codes);
1407
		$ok = $this->verifierStatuts($valeur, $codes);
1340
		return $ok;
1408
		return $ok;
1341
	}
1409
	}
1342
	
1410
	
1343
	private function verifierStatutOrigine(&$valeur) {
1411
	private function verifierStatutOrigine(&$valeur) {
1344
		$codes = $this->manuel['codes_statuts_origine'];
1412
		$codes = $this->manuel['codes_statuts_origine'];
1345
		$ok = $this->verifierStatuts($valeur, $codes);
1413
		$ok = $this->verifierStatuts($valeur, $codes);
1346
		return $ok;
1414
		return $ok;
1347
	}
1415
	}
1348
	
1416
	
1349
	private function verifierStatutIntroduction(&$valeur) {
1417
	private function verifierStatutIntroduction(&$valeur) {
1350
		$codes = $this->manuel['codes_statuts_introduction'];
1418
		$codes = $this->manuel['codes_statuts_introduction'];
1351
		$ok = $this->verifierStatuts($valeur, $codes);
1419
		$ok = $this->verifierStatuts($valeur, $codes);
1352
		return $ok;
1420
		return $ok;
1353
	}
1421
	}
1354
	
1422
	
1355
	private function verifierStatutCulture(&$valeur) {
1423
	private function verifierStatutCulture(&$valeur) {
1356
		$codes = $this->manuel['codes_statuts_culture'];
1424
		$codes = $this->manuel['codes_statuts_culture'];
1357
		$ok = $this->verifierStatuts($valeur, $codes);
1425
		$ok = $this->verifierStatuts($valeur, $codes);
1358
		return $ok;
1426
		return $ok;
1359
	}
1427
	}
1360
	
1428
	
1361
	private function verifierStatuts(&$valeur, &$codes) {
1429
	private function verifierStatuts(&$valeur, &$codes) {
1362
		$ok = true;
1430
		$ok = true;
1363
		if (!preg_match("/^(?:|-|[$codes](?:-[A-Z])?)$/", $valeur)) {
1431
		if (!preg_match("/^(?:|-|[$codes](?:-[A-Z])?)$/", $valeur)) {
1364
			$ok = false;
1432
			$ok = false;
1365
		}
1433
		}
1366
		return $ok;
1434
		return $ok;
1367
	}
1435
	}
1368
	
1436
	
1369
	private function verifierBooleen(&$valeur) {
1437
	private function verifierBooleen(&$valeur) {
1370
		$ok = true;
1438
		$ok = true;
1371
		if (!preg_match('/^1$/', $valeur)) {
1439
		if (!preg_match('/^1$/', $valeur)) {
1372
			$ok = false;
1440
			$ok = false;
1373
		}
1441
		}
1374
		return $ok;
1442
		return $ok;
1375
	}
1443
	}
1376
	
1444
	
1377
	private function verifierNombre(&$valeur) {
1445
	private function verifierNombre(&$valeur) {
1378
		$ok = true;
1446
		$ok = true;
1379
		if (!preg_match('/^[0-9]+$/', $valeur)) {
1447
		if (!preg_match('/^[0-9]+$/', $valeur)) {
1380
			$ok = false;
1448
			$ok = false;
1381
		}
1449
		}
1382
		return $ok;
1450
		return $ok;
1383
	}
1451
	}
1384
	
1452
	
1385
	private function verifierNombreSuite(&$valeur) {
1453
	private function verifierNombreSuite(&$valeur) {
1386
		$ok = true;
1454
		$ok = true;
1387
		if (!preg_match('/^(?:[0-9]+,)*[0-9]+$/', $valeur)) {
1455
		if (!preg_match('/^(?:[0-9]+,)*[0-9]+$/', $valeur)) {
1388
			$ok = false;
1456
			$ok = false;
1389
		}
1457
		}
1390
		return $ok;
1458
		return $ok;
1391
	}
1459
	}
1392
	
1460
	
1393
	private function verifierTypeEpithete(&$type) {
1461
	private function verifierTypeEpithete(&$type) {
1394
		$ok = false;
1462
		$ok = false;
1395
		$rejetes = $this->manuel['type_epithete_rejetes'];
1463
		$rejetes = $this->manuel['type_epithete_rejetes'];
1396
		if (preg_replace("/^(?:$rejetes)$/", '', $type) == '') {
1464
		if (preg_replace("/^(?:$rejetes)$/", '', $type) == '') {
1397
			$ok = false;
1465
			$ok = false;
1398
		} else if (preg_match('/^[a-z][-a-z]*[.]?$/', $type)) {
1466
		} else if (preg_match('/^[a-z][-a-z]*[.]?$/', $type)) {
1399
			$ok = true;
1467
			$ok = true;
1400
		}
1468
		}
1401
		return $ok;
1469
		return $ok;
1402
	}
1470
	}
1403
	
1471
	
1404
	private function verifierBiblioOrigine(&$intitule) {
1472
	private function verifierBiblioOrigine(&$intitule) {
1405
		$ok = true;
1473
		$ok = true;
1406
		if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $intitule)) {
1474
		if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $intitule)) {
1407
			$ok = false;// Contient des espaces en trop
1475
			$ok = false;// Contient des espaces en trop
1408
		} else if (!preg_match('/^(?:in [^;]+[;]|)[^,]+?(?:[,][^:]+|)(?:[:].+|)$/', $intitule)) {
1476
		} else if (!preg_match('/^(?:in [^;]+[;]|)[^,]+?(?:[,][^:]+|)(?:[:].+|)$/', $intitule)) {
1409
			$ok = false;
1477
			$ok = false;
1410
		} else if (preg_match('/(?:(?:^|[,:])\s*(?:[:,]|$))/', $intitule)) {
1478
		} else if (preg_match('/(?:(?:^|[,:])\s*(?:[:,]|$))/', $intitule)) {
1411
			$ok = false;// Contient une mauvaise suite de caractères
1479
			$ok = false;// Contient une mauvaise suite de caractères
1412
		}
1480
		}
1413
		return $ok;
1481
		return $ok;
1414
	}
1482
	}
1415
	
1483
	
1416
	private function verifierAnnee(&$annee) {
1484
	private function verifierAnnee(&$annee) {
1417
		$ok = true;
1485
		$ok = true;
1418
		if (!preg_match('/^[0-9]{4}$/', $annee)) {
1486
		if (!preg_match('/^[0-9]{4}$/', $annee)) {
1419
			$ok = false;
1487
			$ok = false;
1420
		} else if ($annee < ANNEE_MINIMUM) {
1488
		} else if ($annee < ANNEE_MINIMUM) {
1421
			$ok = false;
1489
			$ok = false;
1422
		} else if ($annee > ANNEE_EN_COURS) {
1490
		} else if ($annee > ANNEE_EN_COURS) {
1423
			$ok = false;
1491
			$ok = false;
1424
		}
1492
		}
1425
		return $ok;
1493
		return $ok;
1426
	}
1494
	}
1427
	
1495
	
1428
	private function verifierAuteur(&$intitule) {
1496
	private function verifierAuteur(&$intitule) {
1429
		$ok = true;
1497
		$ok = true;
1430
		$acceptes = $this->manuel['auteur_acceptes'];
1498
		$acceptes = $this->manuel['auteur_acceptes'];
1431
		if (!preg_match("/^(?:$acceptes)$/", $intitule)) {
1499
		if (!preg_match("/^(?:$acceptes)$/", $intitule)) {
1432
			if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $intitule)) {
1500
			if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $intitule)) {
1433
				$ok = false;// Contient des espaces en trop
1501
				$ok = false;// Contient des espaces en trop
1434
			} else {
1502
			} else {
1435
				$mots_rejetes = $this->manuel['auteur_mots_rejetes'];
1503
				$mots_rejetes = $this->manuel['auteur_mots_rejetes'];
1436
				$mots = explode(' ', $intitule);
1504
				$mots = explode(' ', $intitule);
1437
				foreach ($mots as $position => $mot) {
1505
				foreach ($mots as $position => $mot) {
1438
					if (preg_match("/^(?:$mots_rejetes)$/i", $mot)) {
1506
					if (preg_match("/^(?:$mots_rejetes)$/i", $mot)) {
1439
						$ok = false;// Mot rejeté
1507
						$ok = false;// Mot rejeté
1440
					} else if (preg_match("/^(?:(?:\p{L}|[.'\(\),-])+|[&])$/u", $mot)) {
1508
					} else if (preg_match("/^(?:(?:\p{L}|[.'\(\),-])+|[&])$/u", $mot)) {
1441
						continue;// Mot de l'intitulé auteur
1509
						continue;// Mot de l'intitulé auteur
1442
					} else {
1510
					} else {
1443
						$ok = false;
1511
						$ok = false;
1444
					}
1512
					}
1445
				}
1513
				}
1446
			}
1514
			}
1447
		}
1515
		}
1448
		return $ok;
1516
		return $ok;
1449
	}
1517
	}
1450
	
1518
	
1451
	private function verifierNomCommercial(&$epithete) {
1519
	private function verifierNomCommercial(&$epithete) {
1452
		$ok = false;
1520
		$ok = false;
1453
		if (preg_match("/^[[:upper:][:punct:][:digit:][:space:]]+$/", $epithete)) {
1521
		if (preg_match("/^[[:upper:][:punct:][:digit:][:space:]]+$/", $epithete)) {
1454
			$ok = true;
1522
			$ok = true;
1455
		}
1523
		}
1456
		return $ok;
1524
		return $ok;
1457
	}
1525
	}
1458
	
1526
	
1459
	private function verifierEpitheteCultivar(&$epithete) {
1527
	private function verifierEpitheteCultivar(&$epithete) {
1460
		$ok = true;
1528
		$ok = true;
1461
		$acceptes = $this->manuel['cultivar_acceptes'];
1529
		$acceptes = $this->manuel['cultivar_acceptes'];
1462
		if (!preg_match("/^(?:$acceptes)$/", $epithete)) {
1530
		if (!preg_match("/^(?:$acceptes)$/", $epithete)) {
1463
			if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $epithete)) {
1531
			if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $epithete)) {
1464
				$ok = false;// Contient des espaces en trop
1532
				$ok = false;// Contient des espaces en trop
1465
			} else {
1533
			} else {
1466
				$mots_rejetes = $this->manuel['cultivar_mots_rejetes'];
1534
				$mots_rejetes = $this->manuel['cultivar_mots_rejetes'];
1467
				$mots_mineurs = $this->manuel['mots_mineurs'];
1535
				$mots_mineurs = $this->manuel['mots_mineurs'];
1468
				$mots = explode(' ', $epithete);
1536
				$mots = explode(' ', $epithete);
1469
				foreach ($mots as $position => $mot) {
1537
				foreach ($mots as $position => $mot) {
1470
					if (preg_match("/^(?:$mots_rejetes)$/i", $mot)) {
1538
					if (preg_match("/^(?:$mots_rejetes)$/i", $mot)) {
1471
						$ok = false;// Mot rejeté
1539
						$ok = false;// Mot rejeté
1472
					} else if ($position > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot)) {
1540
					} else if ($position > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot)) {
1473
						continue;// Mot mineur en minuscule qui n'est pas en 1ère position
1541
						continue;// Mot mineur en minuscule qui n'est pas en 1ère position
1474
					} else {
1542
					} else {
1475
						$mots_tiret = explode('-', $mot);
1543
						$mots_tiret = explode('-', $mot);
1476
						foreach ($mots_tiret as $position_tiret => $mot_tiret) {
1544
						foreach ($mots_tiret as $position_tiret => $mot_tiret) {
1477
							if ($position_tiret > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot_tiret)) {
1545
							if ($position_tiret > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot_tiret)) {
1478
								continue;// Mot-tiret mineur en minuscule qui n'est pas en 1ère position
1546
								continue;// Mot-tiret mineur en minuscule qui n'est pas en 1ère position
1479
							} else if (preg_match('/^[[:upper:]][[:lower:]]+$/', $mot_tiret)) {
1547
							} else if (preg_match('/^[[:upper:]][[:lower:]]+$/', $mot_tiret)) {
1480
								continue;//Mot (ou 'mot-tiret') avec lettre initiale majuscule
1548
								continue;//Mot (ou 'mot-tiret') avec lettre initiale majuscule
1481
							} else if ($position_tiret == count($mots_tiret) && preg_match('/^[:upper:][:lower:]+[:punct:]?$/', $mot_tiret)) {
1549
							} else if ($position_tiret == count($mots_tiret) && preg_match('/^[:upper:][:lower:]+[:punct:]?$/', $mot_tiret)) {
1482
								continue;//Dernier mot (ou 'mot-tiret') avec lettre initiale majuscule, suivi d'un éventuel signe de ponctuation
1550
								continue;//Dernier mot (ou 'mot-tiret') avec lettre initiale majuscule, suivi d'un éventuel signe de ponctuation
1483
							} else {
1551
							} else {
1484
								$ok = false;
1552
								$ok = false;
1485
							}
1553
							}
1486
						}
1554
						}
1487
					}
1555
					}
1488
				}
1556
				}
1489
			}
1557
			}
1490
		}
1558
		}
1491
		return $ok;
1559
		return $ok;
1492
	}
1560
	}
1493
	
1561
	
1494
	private function verifierEpitheteGroupeCultivar(&$epithete) {
1562
	private function verifierEpitheteGroupeCultivar(&$epithete) {
1495
		$ok = true;
1563
		$ok = true;
1496
		$acceptes = $this->manuel['cultivar_gp_acceptes'];
1564
		$acceptes = $this->manuel['cultivar_gp_acceptes'];
1497
		if (!preg_match("/^(?:$acceptes)$/", $epithete)) {
1565
		if (!preg_match("/^(?:$acceptes)$/", $epithete)) {
1498
			if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $epithete)) {
1566
			if (preg_match('/(?:^\s+|\s{2,}|\s+$)/', $epithete)) {
1499
				$ok = false;// Contient des espaces en trop
1567
				$ok = false;// Contient des espaces en trop
1500
			} else {
1568
			} else {
1501
				$mots_acceptes = $this->manuel['cultivar_gp_mots_acceptes'];
1569
				$mots_acceptes = $this->manuel['cultivar_gp_mots_acceptes'];
1502
				$mots_rejetes = $this->manuel['cultivar_gp_mots_rejetes'];
1570
				$mots_rejetes = $this->manuel['cultivar_gp_mots_rejetes'];
1503
				$mots_mineurs = $this->manuel['mots_mineurs'];
1571
				$mots_mineurs = $this->manuel['mots_mineurs'];
1504
				$mots = explode(' ', $epithete);
1572
				$mots = explode(' ', $epithete);
1505
				foreach ($mots as $position => $mot) {
1573
				foreach ($mots as $position => $mot) {
1506
					if (preg_match("/^(?:$mots_acceptes)$/i", $mot)) {
1574
					if (preg_match("/^(?:$mots_acceptes)$/i", $mot)) {
1507
						continue;// Mot accepté
1575
						continue;// Mot accepté
1508
					} else if (preg_match("/^(?:$mots_rejetes)$/i", $mot)) {
1576
					} else if (preg_match("/^(?:$mots_rejetes)$/i", $mot)) {
1509
						$ok = false;// Mot rejeté
1577
						$ok = false;// Mot rejeté
1510
					} else if ($position > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot)) {
1578
					} else if ($position > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot)) {
1511
						continue;// Mot mineur en minuscule qui n'est pas en 1ère position
1579
						continue;// Mot mineur en minuscule qui n'est pas en 1ère position
1512
					} else {
1580
					} else {
1513
						$mots_tiret = explode('-', $mot);
1581
						$mots_tiret = explode('-', $mot);
1514
						foreach ($mots_tiret as $position_tiret => $mot_tiret) {
1582
						foreach ($mots_tiret as $position_tiret => $mot_tiret) {
1515
							if ($position_tiret > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot_tiret)) {
1583
							if ($position_tiret > 0 && preg_match("/^(?:$mots_mineurs)$/", $mot_tiret)) {
1516
								continue;// Mot-tiret mineur en minuscule qui n'est pas en 1ère position dans le mot
1584
								continue;// Mot-tiret mineur en minuscule qui n'est pas en 1ère position dans le mot
1517
							} else if (preg_match('/^[[:upper:]][[:lower:]]+$/', $mot_tiret)) {
1585
							} else if (preg_match('/^[[:upper:]][[:lower:]]+$/', $mot_tiret)) {
1518
								continue;// Mot (ou 'mot-tiret') avec lettre initiale majuscule
1586
								continue;// Mot (ou 'mot-tiret') avec lettre initiale majuscule
1519
							} else if ($position_tiret == count($mots_tiret) && preg_match('/^[:upper:][:lower:]+[:punct:]?$/', $mot_tiret)) {
1587
							} else if ($position_tiret == count($mots_tiret) && preg_match('/^[:upper:][:lower:]+[:punct:]?$/', $mot_tiret)) {
1520
								continue;// Dernier mot (ou 'mot-tiret') avec lettre initiale majuscule, suivi d'un éventuel signe de ponctuation
1588
								continue;// Dernier mot (ou 'mot-tiret') avec lettre initiale majuscule, suivi d'un éventuel signe de ponctuation
1521
							} else {
1589
							} else {
1522
								$ok = false;
1590
								$ok = false;
1523
							}
1591
							}
1524
						}
1592
						}
1525
					}
1593
					}
1526
				}
1594
				}
1527
			}
1595
			}
1528
		}
1596
		}
1529
		return $ok;
1597
		return $ok;
1530
	}
1598
	}
1531
	
1599
	
1532
	private function verifierEpitheteSp(&$epithete) {
1600
	private function verifierEpitheteSp(&$epithete) {
1533
		$ok = false;
1601
		$ok = false;
1534
		if (preg_match('/^[a-zäëḧïöẗüẅẍÿ][-a-zäëḧïöẗüẅẍÿ]+$/', $epithete)) {
1602
		if (preg_match('/^[a-zäëḧïöẗüẅẍÿ][-a-zäëḧïöẗüẅẍÿ]+$/', $epithete)) {
1535
			$ok = true;
1603
			$ok = true;
1536
		} else if (preg_match('/^sp\.(?:[A-Z]|[1-9][0-9]*)$/', $epithete)) {
1604
		} else if (preg_match('/^sp\.(?:[A-Z]|[1-9][0-9]*)$/', $epithete)) {
1537
			$ok = true;
1605
			$ok = true;
1538
		}
1606
		}
1539
		return $ok;
1607
		return $ok;
1540
	}
1608
	}
1541
	
1609
	
1542
	private function verifierEpitheteGenre(&$epithete) {
1610
	private function verifierEpitheteGenre(&$epithete) {
1543
		$ok = false;
1611
		$ok = false;
1544
		if (preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ](?:[-a-zäëḧïöẗüẅẍÿ]+|[a-zäëḧïöẗüẅẍÿ]+-[A-ZÄËḦÏÖÜẄẌŸ][a-zäëḧïöẗüẅẍÿ]+)$/', $epithete)) {
1612
		if (preg_match('/^[A-ZÄËḦÏÖÜẄẌŸ](?:[-a-zäëḧïöẗüẅẍÿ]+|[a-zäëḧïöẗüẅẍÿ]+-[A-ZÄËḦÏÖÜẄẌŸ][a-zäëḧïöẗüẅẍÿ]+)$/', $epithete)) {
1545
			$ok = true;
1613
			$ok = true;
1546
		}
1614
		}
1547
		return $ok;
1615
		return $ok;
1548
	}
1616
	}
1549
	
1617
	
1550
	private function formaterStyleNomGenre(&$genre) {
1618
	private function formaterStyleNomGenre(&$genre) {
1551
		$genre_fmt = '';
1619
		$genre_fmt = '';
1552
		if (preg_match('/^\s*([x+])\s+(.+)$/i', $genre, $match)) {
1620
		if (preg_match('/^\s*([x+])\s+(.+)$/i', $genre, $match)) {
1553
			$genre_fmt = utf8_encode(strtolower(utf8_decode($match[1]))).' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[2]))));
1621
			$genre_fmt = utf8_encode(strtolower(utf8_decode($match[1]))).' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[2]))));
1554
		} elseif (preg_match('/^(.+)\s+([x+])\s+(.+)$/i', $genre, $match)) {
1622
		} elseif (preg_match('/^(.+)\s+([x+])\s+(.+)$/i', $genre, $match)) {
1555
			$genre_fmt = utf8_encode(ucfirst(strtolower(utf8_decode($match[1])))).' '.
1623
			$genre_fmt = utf8_encode(ucfirst(strtolower(utf8_decode($match[1])))).' '.
1556
				utf8_encode(strtolower(utf8_decode($match[2]))).' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[3]))));
1624
				utf8_encode(strtolower(utf8_decode($match[2]))).' '.utf8_encode(ucfirst(strtolower(utf8_decode($match[3]))));
1557
		} else {
1625
		} else {
1558
			$genre_fmt = utf8_encode(ucfirst(strtolower(utf8_decode($genre))));
1626
			$genre_fmt = utf8_encode(ucfirst(strtolower(utf8_decode($genre))));
1559
		}
1627
		}
1560
		return $genre_fmt;
1628
		return $genre_fmt;
1561
	}
1629
	}
1562
	
1630
	
1563
	private function repererEspace($nom_sci) {
1631
	private function repererEspace($nom_sci) {
1564
		$nom_sci = str_replace(' ', '<span class="espace">&nbsp;</span>', $nom_sci);
1632
		$nom_sci = str_replace(' ', '<span class="espace">&nbsp;</span>', $nom_sci);
1565
		return $nom_sci;
1633
		return $nom_sci;
1566
	}
1634
	}
1567
	
1635
	
1568
	private function construireSuffixeNomPltCultivee(&$nom) {
1636
	private function construireSuffixeNomPltCultivee(&$nom) {
1569
		$suffixe = array();
1637
		$suffixe = array();
1570
		$suffixe[] = $this->construireNomCultivarGroupe($nom);
1638
		$suffixe[] = $this->construireNomCultivarGroupe($nom);
1571
		$suffixe[] = $this->construireNomCommercial($nom);
1639
		$suffixe[] = $this->construireNomCommercial($nom);
1572
		$suffixe[] = $this->construireNomCultivar($nom);
1640
		$suffixe[] = $this->construireNomCultivar($nom);
1573
		$suffixe = array_filter($suffixe);
1641
		$suffixe = array_filter($suffixe);
1574
		return implode(' ', $suffixe);
1642
		return implode(' ', $suffixe);
1575
	}
1643
	}
1576
	
1644
	
1577
	private function construireNomCultivarGroupe(&$nom) {
1645
	private function construireNomCultivarGroupe(&$nom) {
1578
		$nom_groupe_cultivar = '';
1646
		$nom_groupe_cultivar = '';
1579
		if ($nom['cultivar_groupe'] != '') {
1647
		if ($nom['cultivar_groupe'] != '') {
1580
			if (preg_match('/ gx$/', $nom['cultivar_groupe'])) {
1648
			if (preg_match('/ gx$/', $nom['cultivar_groupe'])) {
1581
				$nom_groupe_cultivar =  '('.$nom['cultivar_groupe'].')';
1649
				$nom_groupe_cultivar =  '('.$nom['cultivar_groupe'].')';
1582
			} else {
1650
			} else {
1583
				$nom_groupe_cultivar =  '('.$nom['cultivar_groupe'].' Gp)';
1651
				$nom_groupe_cultivar =  '('.$nom['cultivar_groupe'].' Gp)';
1584
			}
1652
			}
1585
		}
1653
		}
1586
		return $nom_groupe_cultivar;
1654
		return $nom_groupe_cultivar;
1587
	}
1655
	}
1588
	
1656
	
1589
	private function construireNomCommercial(&$nom) {
1657
	private function construireNomCommercial(&$nom) {
1590
		$nom_commercial = '';
1658
		$nom_commercial = '';
1591
		if ($nom['nom_commercial'] != '') {
1659
		if ($nom['nom_commercial'] != '') {
1592
			$nom_commercial =  strtoupper($nom['nom_commercial']);
1660
			$nom_commercial =  strtoupper($nom['nom_commercial']);
1593
		}
1661
		}
1594
		return $nom_commercial;
1662
		return $nom_commercial;
1595
	}
1663
	}
1596
	
1664
	
1597
	private function construireNomCultivar(&$nom) {
1665
	private function construireNomCultivar(&$nom) {
1598
		$nom_cultivar = '';
1666
		$nom_cultivar = '';
1599
		if ($nom['cultivar'] != '') {
1667
		if ($nom['cultivar'] != '') {
1600
			$nom_cultivar =  "'".$nom['cultivar']."'";
1668
			$nom_cultivar =  "'".$nom['cultivar']."'";
1601
		}
1669
		}
1602
		return $nom_cultivar;
1670
		return $nom_cultivar;
1603
	}
1671
	}
1604
	
1672
	
1605
	private function classerNomsParNomComplet() {
1673
	private function classerNomsParNomComplet() {
1606
		$noms_classes = array();
1674
		$noms_classes = array();
1607
		foreach ($this->noms as &$nom) {
1675
		foreach ($this->noms as &$nom) {
1608
			if (!isset($noms_classes[$nom['nom_sci']])) {
1676
			if (!isset($noms_classes[$nom['nom_sci']])) {
1609
				$noms_classes[$nom['nom_sci']] = 1;
1677
				$noms_classes[$nom['nom_sci']] = 1;
1610
			} else {
1678
			} else {
1611
				$noms_classes[$nom['nom_sci']]++;
1679
				$noms_classes[$nom['nom_sci']]++;
1612
			}
1680
			}
1613
		}
1681
		}
1614
		return $noms_classes;
1682
		return $noms_classes;
1615
	}
1683
	}
1616
}
1684
}
1617
?>
1685
?>