Subversion Repositories eFlore/Projets.eflore-projets

Rev

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

Rev 459 Rev 470
1
<?php
1
<?php
2
// commande : /opt/lampp/bin/php cli.php description_sp -a tester -n /home/jennifer/Tela-botanica_projets/Coste/descriptions/html
2
// commande : /opt/lampp/bin/php cli.php description_sp -a tester -n /home/jennifer/Tela-botanica_projets/Coste/descriptions/html
3
class Description {
3
class Description {
4
 
4
 
5
	const DOSSIER_V0 = '../../../donnees/coste/0.00/';
5
	const DOSSIER_V0 = '../../../donnees/coste/0.00/';
6
	const DOSSIER_DSC_HTML = '../../../donnees/coste/descriptions/html/';
6
	const DOSSIER_DSC_HTML = '../../../donnees/coste/descriptions/html/';
7
	const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
7
	const DOSSIER_DSC_TXT = '../../../donnees/coste/descriptions/txt/';
8
	const DOSSIER_LOG = 'log/';
8
	const DOSSIER_LOG = 'log/';
9
 
9
 
10
	private $atueurs = array();
10
	private $auteurs = array();
11
	private $dossierBase = '';
11
	private $dossierBase = '';
12
	private $conteneur = null;
12
	private $conteneur = null;
13
	private $outils = null;
13
	private $outils = null;
14
	private $messages = null;
14
	private $messages = null;
15
	private $action = '';
15
	private $action = '';
16
	private $nomFichier = '';
16
	private $nomFichier = '';
17
	private $nomDossier = '';
17
	private $nomDossier = '';
18
	private $listeFichiers = array();
18
	private $listeFichiers = array();
19
	private $fichierNum = '';
19
	private $fichierNum = '';
20
	private $fichier = '';
20
	private $fichier = '';
21
	private $log = '';
21
	private $log = '';
22
	private $correspondance = array();
22
	private $correspondance = array();
23
	private $infosCorrespondanceBase = array(
23
	private $infosCorrespondanceBase = array(
24
		'nom_sci' => '',
24
		'nom_sci' => '',
25
		'auteur' => '',
25
		'auteur' => '',
26
		'nom_addendum' => '',
26
		'nom_addendum' => '',
27
		'annee' => '',
27
		'annee' => '',
28
		'biblio_origine' => '',
28
		'biblio_origine' => '',
29
		'rang' => 290,
29
		'rang' => 290,
30
		'nom_francais' => '',
30
		'nom_francais' => '',
31
		'nom_coste' => '',
31
		'nom_coste' => '',
32
		'auteur_coste' => '',
32
		'auteur_coste' => '',
33
		'biblio_coste' => '',
33
		'biblio_coste' => '',
34
		'num_nom_coste' => '',
34
		'num_nom_coste' => '',
35
		'num_nom_retenu_coste' => '',
35
		'num_nom_retenu_coste' => '',
36
		'num_tax_sup_coste' => '',
36
		'num_tax_sup_coste' => '',
37
		'tome' => '',
37
		'tome' => '',
38
		'page' => '',
38
		'page' => '',
39
		'synonymie_coste' => '',
39
		'synonymie_coste' => '',
40
		'bdnff_nn' => '',
40
		'bdnff_nn' => '',
41
		'bdnff_nt' => '');
41
		'bdnff_nt' => '');
42
 
42
 
43
	public function __construct(Conteneur $conteneur) {
43
	public function __construct(Conteneur $conteneur) {
44
		mb_internal_encoding('UTF-8');
44
		mb_internal_encoding('UTF-8');
45
		setlocale(LC_ALL, 'fr_FR.UTF-8');
45
		setlocale(LC_ALL, 'fr_FR.UTF-8');
46
		$this->conteneur = $conteneur;
46
		$this->conteneur = $conteneur;
47
		$this->outils = $conteneur->getOutils();
47
		$this->outils = $conteneur->getOutils();
48
		$this->messages = $conteneur->getMessages();
48
		$this->messages = $conteneur->getMessages();
49
		$this->dossierBase = dirname(__FILE__).'/';
49
		$this->dossierBase = dirname(__FILE__).'/';
50
	}
50
	}
51
 
51
 
52
	public function genererDescriptionTxt() {
52
	public function genererDescriptionTxt() {
53
		$this->chargerFichiers();
53
		$this->chargerFichiers();
54
 
54
 
55
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
55
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
56
			$this->messages->afficherAvancement("Création des descriptions au format txt");
56
			$this->messages->afficherAvancement("Création des descriptions au format txt");
57
			$this->genererFichier();
57
			$this->genererFichier();
58
		}
58
		}
59
		echo "\n";
59
		echo "\n";
60
	}
60
	}
61
 
61
 
62
	public function verifierDescriptionTxt() {
62
	public function verifierDescriptionTxt() {
63
		$this->chargerFichiers();
63
		$this->chargerFichiers();
64
 
64
 
65
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
65
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
66
			$this->messages->afficherAvancement("Analyse des descriptions");
66
			$this->messages->afficherAvancement("Analyse des descriptions");
67
			$this->verifierFichier();
67
			$this->verifierFichier();
68
		}
68
		}
69
		echo "\n";
69
		echo "\n";
70
		$this->ecrireLogs();
70
		$this->ecrireLogs();
71
	}
71
	}
72
 
72
 
73
	public function genererCorrespondance() {
73
	public function genererCorrespondance() {
74
		$this->chargerFichiers();
74
		$this->chargerFichiers();
75
 
75
 
76
		$this->ajouterLogSyno(implode("\t", array_keys($this->infosCorrespondanceBase)));
76
		$this->ajouterLogSyno(implode("\t", array_keys($this->infosCorrespondanceBase)));
77
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
77
		foreach ($this->listeFichiers as $this->fichierNum => $this->fichier) {
78
			$this->messages->afficherAvancement("Création du fichier de correspondance");
78
			$this->messages->afficherAvancement("Création du fichier de correspondance");
79
			$this->extraireInfosCorrespondance();
79
			$this->extraireInfosCorrespondance();
80
		}
80
		}
81
		echo "\n";
81
		echo "\n";
82
 
82
 
83
		$fichierTxt = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv';
83
		$fichierTxt = $this->dossierBase.self::DOSSIER_V0.'index_general_sp.tsv';
84
		$txtCorrespondance = $this->creerFichierCsvCorrespondance();
84
		$txtCorrespondance = $this->creerFichierCsvCorrespondance();
85
		file_put_contents($fichierTxt, $txtCorrespondance);
85
		file_put_contents($fichierTxt, $txtCorrespondance);
86
 
86
 
87
		ksort($this->auteurs);
87
		ksort($this->auteurs);
88
		foreach ($this->auteurs as $auteur => $nbre) {
88
		foreach ($this->auteurs as $auteur => $nbre) {
89
			$this->ajouterLogAuteur("$auteur\t$nbre");
89
			$this->ajouterLogAuteur("$auteur\t$nbre");
90
		}
90
		}
91
 
91
 
92
		$this->ecrireLogs();
92
		$this->ecrireLogs();
93
	}
93
	}
-
 
94
 
94
 
95
 
95
	private function chargerFichiers() {
96
	private function chargerFichiers() {
96
		$this->nomDossier = $this->dossierBase.self::DOSSIER_DSC_HTML;
97
		$this->nomDossier = $this->dossierBase.self::DOSSIER_DSC_HTML;
97
		if (file_exists($this->nomDossier) === true) {
98
		if (file_exists($this->nomDossier) === true) {
98
			if (is_dir($this->nomDossier)) {
99
			if (is_dir($this->nomDossier)) {
99
				if ($dossierOuvert = opendir($this->nomDossier)) {
100
				if ($dossierOuvert = opendir($this->nomDossier)) {
100
					while (($this->nomFichier = readdir($dossierOuvert)) !== false) {
101
					while (($this->nomFichier = readdir($dossierOuvert)) !== false) {
101
						if (! is_dir($this->nomFichier) && preg_match('/e([0-9]{4})\.htm/', $this->nomFichier, $match)) {
102
						if (! is_dir($this->nomFichier) && preg_match('/e([0-9]{4})\.htm/', $this->nomFichier, $match)) {
102
							$this->listeFichiers[$match[1]] = $this->nomDossier.'/'.$this->nomFichier;
103
							$this->listeFichiers[$match[1]] = $this->nomDossier.'/'.$this->nomFichier;
103
						}
104
						}
104
					}
105
					}
105
					closedir($dossierOuvert);
106
					closedir($dossierOuvert);
106
				} else {
107
				} else {
107
					$this->messages->traiterErreur("Le dossier {$this->nomDossier} n'a pas pu être ouvert.");
108
					$this->messages->traiterErreur("Le dossier {$this->nomDossier} n'a pas pu être ouvert.");
108
				}
109
				}
109
			} else {
110
			} else {
110
				$this->messages->traiterErreur("{$this->nomDossier} n'est pas un dossier.");
111
				$this->messages->traiterErreur("{$this->nomDossier} n'est pas un dossier.");
111
			}
112
			}
112
		} else {
113
		} else {
113
			$this->messages->traiterErreur("Le dossier {$this->nomDossier} est introuvable.");
114
			$this->messages->traiterErreur("Le dossier {$this->nomDossier} est introuvable.");
114
		}
115
		}
115
 
116
 
116
		asort($this->listeFichiers);
117
		asort($this->listeFichiers);
117
	}
118
	}
118
 
119
 
119
	private function verifierFichier() {
120
	private function verifierFichier() {
120
		$donnees = $this->analyserFichier();
121
		$donnees = $this->analyserFichier();
121
		$txt = $donnees['texte'];
122
		$txt = $donnees['texte'];
122
		$this->verifierOuvertureFermetureBalise($txt);
123
		$this->verifierOuvertureFermetureBalise($txt);
123
		$this->verifierAbscenceEgale($txt);
124
		$this->verifierAbscenceEgale($txt);
124
		$this->verifierNumero($txt);
125
		$this->verifierNumero($txt);
125
		// TODO : vérifier les noms vernauclaire qui sont abrégés
126
		// TODO : vérifier les noms vernauclaire qui sont abrégés
126
	}
127
	}
127
 
128
 
128
	private function verifierOuvertureFermetureBalise($txt) {
129
	private function verifierOuvertureFermetureBalise($txt) {
129
		$b_ouvert = substr_count($txt, '<B>');
130
		$b_ouvert = substr_count($txt, '<B>');
130
		$b_ferme = substr_count($txt, '</B>');
131
		$b_ferme = substr_count($txt, '</B>');
131
		if ($b_ouvert != $b_ferme) {
132
		if ($b_ouvert != $b_ferme) {
132
			$message = "{$this->fichierNum} contient $b_ouvert balises B ouvertes et $b_ferme fermées";
133
			$message = "{$this->fichierNum} contient $b_ouvert balises B ouvertes et $b_ferme fermées";
133
			$this->ajouterLogAnalyse($message);
134
			$this->ajouterLogAnalyse($message);
134
		}
135
		}
135
		$i_ouvert = substr_count($txt, '<I>');
136
		$i_ouvert = substr_count($txt, '<I>');
136
		$i_ferme = substr_count($txt, '</I>');
137
		$i_ferme = substr_count($txt, '</I>');
137
		if ($i_ouvert != $i_ferme) {
138
		if ($i_ouvert != $i_ferme) {
138
			$message = "{$this->fichierNum} contient $i_ouvert balises I ouvertes et $i_ferme fermées";
139
			$message = "{$this->fichierNum} contient $i_ouvert balises I ouvertes et $i_ferme fermées";
139
			$this->ajouterLogAnalyse($message);
140
			$this->ajouterLogAnalyse($message);
140
		}
141
		}
141
	}
142
	}
142
 
143
 
143
	private function verifierAbscenceEgale($txt) {
144
	private function verifierAbscenceEgale($txt) {
144
		if (strripos($txt, '=') === false) {
145
		if (strripos($txt, '=') === false) {
145
			$message = "{$this->fichierNum} ne contient pas le séparateur de phénologie (=)";
146
			$message = "{$this->fichierNum} ne contient pas le séparateur de phénologie (=)";
146
			$this->ajouterLogAnalyse($message);
147
			$this->ajouterLogAnalyse($message);
147
		}
148
		}
148
	}
149
	}
149
 
150
 
150
	private function verifierNumero($txt) {
151
	private function verifierNumero($txt) {
151
		if (preg_match('/^<B>[0-9]{1,4}. – /', $txt) == 0) {
152
		if (preg_match('/^<B>[0-9]{1,4}. – /', $txt) == 0) {
152
			$message = "{$this->fichierNum} ne contient pas un numéro bien formaté";
153
			$message = "{$this->fichierNum} ne contient pas un numéro bien formaté";
153
			$this->ajouterLogAnalyse($message);
154
			$this->ajouterLogAnalyse($message);
154
		}
155
		}
155
	}
156
	}
156
 
157
 
157
	private function extraireInfosCorrespondance() {
158
	private function extraireInfosCorrespondance() {
158
		$donnees = $this->analyserFichier();
159
		$donnees = $this->analyserFichier();
159
		$infos = $this->infosCorrespondanceBase;
160
		$infos = $this->infosCorrespondanceBase;
160
 
161
 
161
		$titre = $donnees['titre'];
162
		$titre = $donnees['titre'];
162
		if (preg_match('/^Coste ([0-9]+) - ((?:(?! - ).)+) - F[0-9]+, (?:(?! - ).)+ - (G[0-9]+), T([123])[.]p([0-9]+)$/', $titre, $match)) {
163
		if (preg_match('/^Coste ([0-9]+) - ((?:(?! - ).)+) - F[0-9]+, (?:(?! - ).)+ - (G[0-9]+), T([123])[.]p([0-9]+)$/', $titre, $match)) {
163
			$infos['num_nom_coste'] = $match[1];
164
			$infos['num_nom_coste'] = $match[1];
164
			$infos['num_nom_retenu_coste'] = $match[1];
165
			$infos['num_nom_retenu_coste'] = $match[1];
165
			$infos['nom_sci'] = $match[2];
166
			$infos['nom_sci'] = $match[2];
166
			$infos['num_tax_sup_coste'] = $match[3];
167
			$infos['num_tax_sup_coste'] = $match[3];
167
			$infos['tome'] = $match[4];
168
			$infos['tome'] = $match[4];
168
			$infos['page'] = $match[5];
169
			$infos['page'] = $match[5];
169
		} else {
170
		} else {
170
			$this->messages->traiterErreur("Le titre du fichier {$this->fichierNum} est mal formaté.");
171
			$this->messages->traiterErreur("Le titre du fichier {$this->fichierNum} est mal formaté.");
171
		}
172
		}
172
 
173
 
173
		$corres = $donnees['correspondance'];
174
		$corres = $donnees['correspondance'];
174
		if (preg_match('/^Bdnff ([0-9]+) - (?:(?! - ).)+ - (?:(?! - ).)+ - Tax=([0-9]+)$/', $corres, $match)) {
175
		if (preg_match('/^Bdnff ([0-9]+) - (?:(?! - ).)+ - (?:(?! - ).)+ - Tax=([0-9]+)$/', $corres, $match)) {
175
			$infos['bdnff_nn'] = $match[1];
176
			$infos['bdnff_nn'] = $match[1];
176
			$infos['bdnff_nt'] = $match[2];
177
			$infos['bdnff_nt'] = $match[2];
177
		} else {
178
		} else {
178
			$this->messages->traiterErreur("La correspondance du fichier {$this->fichierNum} est mal formatée.");
179
			$this->messages->traiterErreur("La correspondance du fichier {$this->fichierNum} est mal formatée.");
179
		}
180
		}
180
 
181
 
181
		$txt = $donnees['texte'];
182
		$txt = $donnees['texte'];
182
		$txt = $this->corrigerDescription($txt);
183
		$txt = $this->corrigerDescription($txt);
183
		if (preg_match('/^<B>[0-9]{1,4}[.] – ([^<]+)<\/B> ([^–]*)– (?:<I>([^<]+)<\/I>[.] – |<I>([^<]+)<\/I>( \([^)]+\))[.] – |[A-Z]|<I>(?:Sous-|Espèce|Turion|Souche|Plante|Feuille|Racine))/u', $txt, $match)) {
184
		if (preg_match('/^<B>[0-9]{1,4}[.] – ([^<]+)<\/B> ([^–]*)– (?:<I>([^<]+)<\/I>[.] – |<I>([^<]+)<\/I>( \([^)]+\))[.] – |[A-Z]|<I>(?:Sous-|Espèce|Turion|Souche|Plante|Feuille|Racine))/u', $txt, $match)) {
184
			$infos['nom_coste'] = trim($match[1]);
185
			$infos['nom_coste'] = trim($match[1]);
185
			$infos['rang'] = $this->obtenirRangNom($infos['nom_coste']);
186
			$infos['rang'] = $this->obtenirRangNom($infos['nom_coste']);
186
			$infos['auteur_coste'] = trim($match[2]);
187
			$infos['auteur_coste'] = trim($match[2]);
187
			$infos['nom_francais'] = isset($match[3]) ? $match[3] : '';
188
			$infos['nom_francais'] = isset($match[3]) ? $match[3] : '';
188
			$infos['nom_francais'] = isset($match[4]) && isset($match[5]) ? $match[4].$match[5] : $infos['nom_francais'];
189
			$infos['nom_francais'] = isset($match[4]) && isset($match[5]) ? $match[4].$match[5] : $infos['nom_francais'];
189
			if (strpos($infos['auteur_coste'], '(' ) !== false) {
190
			if (strpos($infos['auteur_coste'], '(' ) !== false) {
190
				if (preg_match('/^([^(]*)\(([^)]+)\)(?:[.]?| ; ((?:(?! – ).)+))$/', $infos['auteur_coste'], $match)) {
191
				if (preg_match('/^([^(]*)\(([^)]+)\)(?:[.]?| ; ((?:(?! – ).)+))$/', $infos['auteur_coste'], $match)) {
191
					$infos['auteur_coste'] = $this->traiterAuteur(trim($match[1]));
192
					$infos['auteur_coste'] = $this->traiterAuteur(trim($match[1]));
192
					$infos['auteur'] = $this->normaliserAuteur($infos['auteur_coste']);
193
					$infos['auteur'] = $this->normaliserAuteur($infos['auteur_coste']);
193
					$parentheseContenu = trim($match[2]);
194
					$parentheseContenu = trim($match[2]);
194
					if (preg_match('/^[0-9]+$/', $parentheseContenu)) {
195
					if (preg_match('/^[0-9]+$/', $parentheseContenu)) {
195
						$infos['annee'] = $parentheseContenu;
196
						$infos['annee'] = $parentheseContenu;
196
					} else {
197
					} else {
197
						$infos['synonymie_coste'] = $parentheseContenu;
198
						$infos['synonymie_coste'] = $parentheseContenu;
198
						$infos['biblio_coste'] = isset($match[3]) ? trim($match[3]) : '';
199
						$infos['biblio_coste'] = isset($match[3]) ? trim($match[3]) : '';
199
					}
200
					}
200
				} else {
201
				} else {
201
					$this->messages->traiterErreur("L'auteur du nom sciencitifique du fichier {$this->fichierNum} est mal formaté.");
202
					$this->messages->traiterErreur("L'auteur du nom sciencitifique du fichier {$this->fichierNum} est mal formaté.");
202
				}
203
				}
203
			}
204
			}
204
		} else {
205
		} else {
205
			$this->messages->traiterErreur("La texte du fichier {$this->fichierNum} est mal formaté.");
206
			$this->messages->traiterErreur("La texte du fichier {$this->fichierNum} est mal formaté.");
206
		}
207
		}
207
 
208
 
208
		$this->correspondance[] = $infos;
209
		$this->correspondance[] = $infos;
209
 
210
 
210
		if ($infos['synonymie_coste'] != '') {
211
		if ($infos['synonymie_coste'] != '') {
211
			$this->traiterSynonymie($infos);
212
			$this->traiterSynonymie($infos);
212
		}
213
		}
213
	}
214
	}
214
 
215
 
215
	private function normaliserAuteur($auteurCoste) {
216
	private function normaliserAuteur($auteurCoste) {
216
		$auteur = '';
217
		$auteur = '';
217
		if ($auteurCoste != '') {
218
		if ($auteurCoste != '') {
218
			$auteur = str_replace(' et ', ' & ', $auteurCoste);
219
			$auteur = str_replace(' et ', ' & ', $auteurCoste);
219
		}
220
		}
220
		return $auteur;
221
		return $auteur;
221
	}
222
	}
222
 
223
 
223
	private function traiterSynonymie($infos) {
224
	private function traiterSynonymie($infos) {
224
		$synoCoste = $infos['synonymie_coste'];
225
		$synoCoste = $infos['synonymie_coste'];
225
		$synoCoste = preg_replace('/^et /', '', $synoCoste);
226
		$synoCoste = preg_replace('/^et /', '', $synoCoste);
226
		$synoCoste = preg_replace('/^(([A-Z][.]|[A-Z]{3,}) [A-Z]{3,}(?:(?! et ).+)) et ([A-Z]{3,}) ((?![A-Z]{3,}).+)$/', '$1 ; $2 $3 $4', $synoCoste);
227
		$synoCoste = preg_replace('/^(([A-Z][.]|[A-Z]{3,}) [A-Z]{3,}(?:(?! et ).+)) et ([A-Z]{3,}) ((?![A-Z]{3,}).+)$/', '$1 ; $2 $3 $4', $synoCoste);
227
		$synoCoste = preg_replace('/ et ((?:[A-Z][.]|[A-Z]{3,}) [A-Z]{3,})/', ' ; $1', $synoCoste);
228
		$synoCoste = preg_replace('/ et ((?:[A-Z][.]|[A-Z]{3,}) [A-Z]{3,})/', ' ; $1', $synoCoste);
228
		$synoCoste = preg_replace('/, ((?:(?!non |part[.]|an |G[.] G[.]|part[.]|centr[.])[^,]+))/', ' ;$1', $synoCoste);
229
		$synoCoste = preg_replace('/, ((?:(?!non |part[.]|an |G[.] G[.]|part[.]|centr[.])[^,]+))/', ' ;$1', $synoCoste);
229
 
230
 
230
		$synonymes = explode(';', $synoCoste);
231
		$synonymes = explode(';', $synoCoste);
231
 
232
 
232
		foreach ($synonymes as $num => $syno) {
233
		foreach ($synonymes as $num => $syno) {
233
			$synoTraite = $this->traiterNomSyno($syno);
234
			$synoTraite = $this->traiterNomSyno($syno);
234
			$nomSci = $this->obtenirNomSci($synoTraite, $infos, $synonymes, $num);
235
			$nomSci = $this->obtenirNomSci($synoTraite, $infos, $synonymes, $num);
235
			$rang = $this->obtenirRangNom($nomSci);
236
			$rang = $this->obtenirRangNom($nomSci);
236
			$complementNom = $this->obtenirComplementNom($synoTraite);
237
			$complementNom = $this->obtenirComplementNom($synoTraite);
237
			$auteurCoste = $this->obtenirAuteur($complementNom);
238
			$auteurCoste = $this->obtenirAuteur($complementNom);
238
			$auteur = $this->normaliserAuteur($auteurCoste);
239
			$auteur = $this->normaliserAuteur($auteurCoste);
239
			$this->ajouterAuteur($auteur);
240
			$this->ajouterAuteur($auteur);
240
			$biblioCoste = $this->obtenirBiblio($complementNom);
241
			$biblioCoste = $this->obtenirBiblio($complementNom);
241
			$annee = $this->extraireAnnee($complementNom);
242
			$annee = $this->extraireAnnee($complementNom);
242
 
243
 
243
			$infosSyno = $this->infosCorrespondanceBase;
244
			$infosSyno = $this->infosCorrespondanceBase;
244
			$infosSyno['nom_sci'] = $nomSci;
245
			$infosSyno['nom_sci'] = $nomSci;
245
			$infosSyno['auteur'] = $auteur;
246
			$infosSyno['auteur'] = $auteur;
246
			$infosSyno['biblio_origine'] = $biblioCoste;
247
			$infosSyno['biblio_origine'] = $biblioCoste;
247
			$infosSyno['annee'] = $annee;
248
			$infosSyno['annee'] = $annee;
248
			$infosSyno['nom_addendum'] =  $this->obtenirNomAddendum($syno);
249
			$infosSyno['nom_addendum'] =  $this->obtenirNomAddendum($syno);
249
 
250
 
250
			$infosSyno['rang'] = $rang;
251
			$infosSyno['rang'] = $rang;
251
			$infosSyno['nom_coste'] = $synoTraite;
252
			$infosSyno['nom_coste'] = $synoTraite;
252
			$infosSyno['auteur_coste'] = $auteurCoste;
253
			$infosSyno['auteur_coste'] = $auteurCoste;
253
			$infosSyno['biblio_coste'] =  $biblioCoste;
254
			$infosSyno['biblio_coste'] =  $biblioCoste;
254
			$infosSyno['num_nom_coste'] = $infos['num_nom_coste'].'.'.($num + 1);
255
			$infosSyno['num_nom_coste'] = $infos['num_nom_coste'].'.'.($num + 1);
255
			$infosSyno['num_nom_retenu_coste'] = $infos['num_nom_coste'];
256
			$infosSyno['num_nom_retenu_coste'] = $infos['num_nom_coste'];
256
			$this->ajouterLogSyno(implode("\t", $infosSyno));
257
			$this->ajouterLogSyno(implode("\t", $infosSyno));
257
			$this->correspondance[] = $infosSyno;
258
			$this->correspondance[] = $infosSyno;
258
		}
259
		}
259
	}
260
	}
260
 
261
 
261
	private function traiterNomSyno($syno) {
262
	private function traiterNomSyno($syno) {
262
		$syno = $this->nettoyerEspacesNomSyno($syno);
263
		$syno = $this->nettoyerEspacesNomSyno($syno);
263
		$syno = preg_replace('/^(?:avec|(?:compr|incl)[.]) /', '', $syno);
264
		$syno = preg_replace('/^(?:avec|(?:compr|incl)[.]) /', '', $syno);
264
		return $syno;
265
		return $syno;
265
	}
266
	}
266
 
267
 
267
	private function nettoyerEspacesNomSyno($syno) {
268
	private function nettoyerEspacesNomSyno($syno) {
268
		$syno = trim($syno);
269
		$syno = trim($syno);
269
		$syno = trim($syno, ' ');
270
		$syno = trim($syno, ' ');
270
		return $syno;
271
		return $syno;
271
	}
272
	}
272
 
273
 
273
	private function obtenirComplementNom($syno) {
274
	private function obtenirComplementNom($syno) {
274
		$complementNom = '';
275
		$complementNom = '';
275
		if (preg_match('/^(?:[^ ]+ [^ ]+ (?:(?:var|V)[.] [^ ]+|STELATUM|MINUS)|[^ ]+ [^ ]+) (.+)$/', $syno, $match)) {
276
		if (preg_match('/^(?:[^ ]+ [^ ]+ (?:(?:var|V)[.] [^ ]+|STELATUM|MINUS)|[^ ]+ [^ ]+) (.+)$/', $syno, $match)) {
276
			$complementNom = $match[1];
277
			$complementNom = $match[1];
277
		}
278
		}
278
		return $complementNom;
279
		return $complementNom;
279
	}
280
	}
280
 
281
 
281
	private function obtenirBiblio($complementNom) {
282
	private function obtenirBiblio($complementNom) {
282
		$biblioCoste = '';
283
		$biblioCoste = '';
283
		if (preg_match("/ (p[.] [0-9]{1,}|in .+||Fl[.] fr[.]|(?: Sp[.])? ed[.] [1-2])$/", $complementNom, $match)) {
284
		if (preg_match("/ (p[.] [0-9]{1,}|in .+||Fl[.] fr[.]|(?: Sp[.])? ed[.] [1-2])$/", $complementNom, $match)) {
284
			$biblioCoste = $match[1];
285
			$biblioCoste = $match[1];
285
		}
286
		}
286
		return $biblioCoste;
287
		return $biblioCoste;
287
	}
288
	}
288
 
289
 
289
	private function extraireAnnee($complementNom) {
290
	private function extraireAnnee($complementNom) {
290
		$annee = '';
291
		$annee = '';
291
		if (preg_match('/(?:^| )([0-9]+)$/', $complementNom, $match)) {
292
		if (preg_match('/(?:^| )([0-9]+)$/', $complementNom, $match)) {
292
			$annee = $match[1];
293
			$annee = $match[1];
293
		}
294
		}
294
		return $annee;
295
		return $annee;
295
	}
296
	}
296
 
297
 
297
	private function obtenirAuteur($complementNom) {
298
	private function obtenirAuteur($complementNom) {
298
		$auteurCoste = '';
299
		$auteurCoste = '';
299
		if ($complementNom != '') {
300
		if ($complementNom != '') {
300
			if (preg_match("/^((?!(?:auct.+|(?:, )?(?:non|an) .+|p[.] p[.])$).+)$/", $complementNom, $match)) {
301
			if (preg_match("/^((?!(?:auct.+|(?:, )?(?:non|an) .+|p[.] p[.])$).+)$/", $complementNom, $match)) {
301
				$auteurCoste = $this->traiterAuteur($match[1]);
302
				$auteurCoste = $this->traiterAuteur($match[1]);
302
			} else {
303
			} else {
303
				$message = "Impossible de récupérer l'auteur pour le complément de nom ($complementNom).";
304
				$message = "Impossible de récupérer l'auteur pour le complément de nom ($complementNom).";
304
				$this->ajouterLogProbleme($message);
305
				$this->ajouterLogProbleme($message);
305
			}
306
			}
306
		}
307
		}
307
		return $auteurCoste;
308
		return $auteurCoste;
308
	}
309
	}
309
 
310
 
310
	private function traiterAuteur($auteurCoste) {
311
	private function traiterAuteur($auteurCoste) {
311
		$auteur = '';
312
		$auteur = '';
312
		if ($auteurCoste != '') {
313
		if ($auteurCoste != '') {
313
			$remplacementTxt = array(' p. p.', ' saltem part.', 'Fl. fr.');
314
			$remplacementTxt = array(' p. p.', ' saltem part.', 'Fl. fr.');
314
			$auteurCoste = str_replace($remplacementTxt, '', $auteurCoste);
315
			$auteurCoste = str_replace($remplacementTxt, '', $auteurCoste);
315
			$remplacementsRegExp = array(
316
			$remplacementsRegExp = array(
316
				' [0-9]{4}',
317
				' [0-9]{4}',
317
				'[^ ]+ et auct[.], .+',
318
				'[^ ]+ et auct[.], .+',
318
				' auct.+',
319
				' auct.+',
319
				',? part[.]',
320
				',? part[.]',
320
				' p[.] [0-9]{1,}',
321
				' p[.] [0-9]{1,}',
321
				' in .+|,? (?:non|an) .+',
322
				' in .+|,? (?:non|an) .+',
322
				'(?: Sp[.])? ed[.] [1-2]');
323
				'(?: Sp[.])? ed[.] [1-2]');
323
			$auteur = preg_replace('/(?:'.implode('|', $remplacementsRegExp).')$/', '', $auteurCoste);
324
			$auteur = preg_replace('/(?:'.implode('|', $remplacementsRegExp).')$/', '', $auteurCoste);
324
		}
325
		}
325
		return $auteur;
326
		return $auteur;
326
	}
327
	}
327
 
328
 
328
	private function ajouterAuteur($auteur) {
329
	private function ajouterAuteur($auteur) {
329
		if (!isset($this->auteurs[$auteur])) {
330
		if (!isset($this->auteurs[$auteur])) {
330
			$this->auteurs[$auteur] = 1;
331
			$this->auteurs[$auteur] = 1;
331
		} else {
332
		} else {
332
			$this->auteurs[$auteur]++;
333
			$this->auteurs[$auteur]++;
333
		}
334
		}
334
	}
335
	}
335
 
336
 
336
	private function obtenirNomAddendum($syno) {
337
	private function obtenirNomAddendum($syno) {
337
		$syno = $this->nettoyerEspacesNomSyno($syno);
338
		$syno = $this->nettoyerEspacesNomSyno($syno);
338
		$nomAddendum = array();
339
		$nomAddendum = array();
339
		if (preg_match('/^((?:compr|incl)[.]) /', $syno, $match)) {
340
		if (preg_match('/^((?:compr|incl)[.]) /', $syno, $match)) {
340
			$nomAddendum[] = '['.$match[1].']';
341
			$nomAddendum[] = '['.$match[1].']';
341
		}
342
		}
342
		if (preg_match('/ ([^ ]+ et auct[.], .+)$/', $syno, $match)) {
343
		if (preg_match('/ ([^ ]+ et auct[.], .+)$/', $syno, $match)) {
343
			$nomAddendum[] = '['.$match[1].']';
344
			$nomAddendum[] = '['.$match[1].']';
344
		} elseif (preg_match('/ (auct[.],? .+)$/', $syno, $match)) {
345
		} elseif (preg_match('/ (auct[.],? .+)$/', $syno, $match)) {
345
			$nomAddendum[] = '['.$match[1].']';
346
			$nomAddendum[] = '['.$match[1].']';
346
		} else if (preg_match('/,? ((?:non|an) .+)$/', $syno, $match)) {
347
		} else if (preg_match('/,? ((?:non|an) .+)$/', $syno, $match)) {
347
			$nomAddendum[] = '['.$match[1].']';
348
			$nomAddendum[] = '['.$match[1].']';
348
		} else if (preg_match('/ (p[.] p[.])$/', $syno, $match)) {
349
		} else if (preg_match('/ (p[.] p[.])$/', $syno, $match)) {
349
			$nomAddendum[] = '['.$match[1].']';
350
			$nomAddendum[] = '['.$match[1].']';
350
		} else if (preg_match('/ (saltem part[.])$/', $syno, $match)) {
351
		} else if (preg_match('/ (saltem part[.])$/', $syno, $match)) {
351
			$nomAddendum[] = '['.$match[1].']';
352
			$nomAddendum[] = '['.$match[1].']';
352
		} else if (preg_match('/,? (part[.])$/', $syno, $match)) {
353
		} else if (preg_match('/,? (part[.])$/', $syno, $match)) {
353
			$nomAddendum[] = '['.$match[1].']';
354
			$nomAddendum[] = '['.$match[1].']';
354
		}
355
		}
355
 
356
 
356
		$nomAddendum = implode(' ; ', $nomAddendum);
357
		$nomAddendum = implode(' ; ', $nomAddendum);
357
		return $nomAddendum;
358
		return $nomAddendum;
358
	}
359
	}
359
 
360
 
360
	private function remplacerAbreviationGenre($syno, $infos, $synonymes, $num) {
361
	private function remplacerAbreviationGenre($syno, $infos, $synonymes, $num) {
361
		$nomSci = $syno;
362
		$nomSci = $syno;
362
 
363
 
363
		if (preg_match('/^(([A-Zƌ])[.]) /', $syno, $matchSyno)) {
364
		if (preg_match('/^(([A-Zƌ])[.]) /', $syno, $matchSyno)) {
364
			if ($matchSyno[2] == substr($infos['nom_coste'], 0, 1)) {
365
			if ($matchSyno[2] == substr($infos['nom_coste'], 0, 1)) {
365
				if (preg_match('/^([^ ]+) /', $infos['nom_coste'], $matchNomRetenu)) {
366
				if (preg_match('/^([^ ]+) /', $infos['nom_coste'], $matchNomRetenu)) {
366
					$nomSci = str_replace($matchSyno[1], $matchNomRetenu[1], $syno);
367
					$nomSci = str_replace($matchSyno[1], $matchNomRetenu[1], $syno);
367
				}
368
				}
368
			} else {
369
			} else {
369
				$synoPrecedent = $this->obtenirSynoAvecGenreComplet($synonymes, $num);
370
				$synoPrecedent = $this->obtenirSynoAvecGenreComplet($synonymes, $num);
370
 
371
 
371
				if ($matchSyno[2] == substr($synoPrecedent, 0, 1)) {
372
				if ($matchSyno[2] == substr($synoPrecedent, 0, 1)) {
372
					if (preg_match('/^([^ ]+) /', $synoPrecedent, $matchSynoPrec)) {
373
					if (preg_match('/^([^ ]+) /', $synoPrecedent, $matchSynoPrec)) {
373
						$nomSci = str_replace($matchSyno[1], $matchSynoPrec[1], $syno);
374
						$nomSci = str_replace($matchSyno[1], $matchSynoPrec[1], $syno);
374
					}
375
					}
375
				} else {
376
				} else {
376
					$message = "L'initiale du synonyme ($syno) ne correspondant pas au nom retenu {$infos['num_nom_coste']} ({$infos['nom_coste']}) ".
377
					$message = "L'initiale du synonyme ($syno) ne correspondant pas au nom retenu {$infos['num_nom_coste']} ({$infos['nom_coste']}) ".
377
							"ni au synonyme précédent ($synoPrecedent).";
378
							"ni au synonyme précédent ($synoPrecedent).";
378
					$this->ajouterLogProbleme($message);
379
					$this->ajouterLogProbleme($message);
379
				}
380
				}
380
			}
381
			}
381
		}
382
		}
382
		return $nomSci;
383
		return $nomSci;
383
	}
384
	}
384
 
385
 
385
	private function obtenirSynoAvecGenreComplet($synonymes, $num) {
386
	private function obtenirSynoAvecGenreComplet($synonymes, $num) {
386
		$synoPrecedent = '';
387
		$synoPrecedent = '';
387
		$synoOk = false;
388
		$synoOk = false;
388
		while ($synoOk == false) {
389
		while ($synoOk == false) {
389
			if ($num < 0) {
390
			if ($num < 0) {
390
				$synoOk = true;
391
				$synoOk = true;
391
			}
392
			}
392
			$synoPrecedent = $this->obtenirSynoPrecedent($synonymes, $num);
393
			$synoPrecedent = $this->obtenirSynoPrecedent($synonymes, $num);
393
			if (preg_match('/^[A-Zƌ][.] /', $synoPrecedent)) {
394
			if (preg_match('/^[A-Zƌ][.] /', $synoPrecedent)) {
394
				$num = $num - 1;
395
				$num = $num - 1;
395
			} else {
396
			} else {
396
				$synoOk = true;
397
				$synoOk = true;
397
			}
398
			}
398
		}
399
		}
399
		return $synoPrecedent;
400
		return $synoPrecedent;
400
	}
401
	}
401
 
402
 
402
	private function obtenirSynoPrecedent($synonymes, $num) {
403
	private function obtenirSynoPrecedent($synonymes, $num) {
403
		$synoPrecedent = '';
404
		$synoPrecedent = '';
404
		if (isset($synonymes[($num - 1 )])) {
405
		if (isset($synonymes[($num - 1 )])) {
405
			$synoPrecedent = $this->traiterNomSyno($synonymes[($num - 1 )]);
406
			$synoPrecedent = $this->traiterNomSyno($synonymes[($num - 1 )]);
406
		}
407
		}
407
		return $synoPrecedent;
408
		return $synoPrecedent;
408
	}
409
	}
409
 
410
 
410
 
411
 
411
	private function obtenirNomSci($syno, $infos, $synonymes, $num) {
412
	private function obtenirNomSci($syno, $infos, $synonymes, $num) {
412
		$nomSci = $this->remplacerAbreviationGenre($syno, $infos, $synonymes, $num);
413
		$nomSci = $this->remplacerAbreviationGenre($syno, $infos, $synonymes, $num);
413
 
414
 
414
		if (preg_match('/^([^ ]+) ([^ ]+) (?:(?:var|V)[.] ([^ ]+)|(STELATUM||MINUS) )/', $nomSci, $match)) {
415
		if (preg_match('/^([^ ]+) ([^ ]+) (?:(?:var|V)[.] ([^ ]+)|(STELATUM||MINUS) )/', $nomSci, $match)) {
415
			$genre = $this->normaliserGenre($match[1]);
416
			$genre = $this->normaliserGenre($match[1]);
416
			$sp = $this->normaliserEpithete($match[2]);
417
			$sp = $this->normaliserEpithete($match[2]);
417
			$infrasp = isset($match[4]) ? $match[4] : $match[3];
418
			$infrasp = isset($match[4]) ? $match[4] : $match[3];
418
			$infrasp = $this->normaliserEpithete($infrasp);
419
			$infrasp = $this->normaliserEpithete($infrasp);
419
			$nomSci = "$genre $sp var. $infrasp";
420
			$nomSci = "$genre $sp var. $infrasp";
420
		} else if (preg_match('/^([^ ]+) ([^ ]+)(?: |$)/', $nomSci, $match)) {
421
		} else if (preg_match('/^([^ ]+) ([^ ]+)(?: |$)/', $nomSci, $match)) {
421
			$genre = $this->normaliserGenre($match[1]);
422
			$genre = $this->normaliserGenre($match[1]);
422
			$sp = $this->normaliserEpithete($match[2]);
423
			$sp = $this->normaliserEpithete($match[2]);
423
			$nomSci = "$genre $sp";
424
			$nomSci = "$genre $sp";
424
		} else {
425
		} else {
425
			$message = "Le synonyme ($nomSci) du nom {$infos['num_nom_coste']} a une structure étrange.";
426
			$message = "Le synonyme ($nomSci) du nom {$infos['num_nom_coste']} a une structure étrange.";
426
			$this->ajouterLogProbleme($message);
427
			$this->ajouterLogProbleme($message);
427
		}
428
		}
428
		return $nomSci;
429
		return $nomSci;
429
	}
430
	}
430
 
431
 
431
	private function normaliserGenre($genre) {
432
	private function normaliserGenre($genre) {
432
		$genre = mb_convert_case(mb_strtolower($genre), MB_CASE_TITLE);
433
		$genre = mb_convert_case(mb_strtolower($genre), MB_CASE_TITLE);
433
		$genre = str_replace('Æ', 'æ', $genre);
434
		$genre = str_replace('Æ', 'æ', $genre);
434
		return $genre;
435
		return $genre;
435
	}
436
	}
436
 
437
 
437
	private function normaliserEpithete($sp) {
438
	private function normaliserEpithete($sp) {
438
		$sp = mb_strtolower($sp);
439
		$sp = mb_strtolower($sp);
439
		$sp = str_replace('Æ', 'æ', $sp);
440
		$sp = str_replace('Æ', 'æ', $sp);
440
		return $sp;
441
		return $sp;
441
	}
442
	}
442
 
443
 
443
	private function obtenirRangNom($syno) {
444
	private function obtenirRangNom($syno) {
444
		$rang = 290;
445
		$rang = 290;
445
		if (strpos($syno, ' var. ')) {
446
		if (strpos($syno, ' var. ')) {
446
			$rang = 340;
447
			$rang = 340;
447
		}
448
		}
448
		return $rang;
449
		return $rang;
449
	}
450
	}
450
 
451
 
451
	private function creerFichierCsvCorrespondance() {
452
	private function creerFichierCsvCorrespondance() {
452
		$lignes[] = implode("\t", array_keys($this->infosCorrespondanceBase));
453
		$lignes[] = implode("\t", array_keys($this->infosCorrespondanceBase));
453
		foreach ($this->correspondance as $infos) {
454
		foreach ($this->correspondance as $infos) {
454
			$lignes[] = implode("\t", $infos);
455
			$lignes[] = implode("\t", $infos);
455
		}
456
		}
456
 
457
 
457
		$txt = '';
458
		$txt = '';
458
		$txt = implode("\n", $lignes);
459
		$txt = implode("\n", $lignes);
459
		return $txt;
460
		return $txt;
460
	}
461
	}
461
 
462
 
462
	private function genererFichier() {
463
	private function genererFichier() {
463
		$donnees = $this->analyserFichier();
464
		$donnees = $this->analyserFichier();
464
 
465
 
465
		$txt = $this->nettoyerDescription($donnees['texte']);
466
		$txt = $this->nettoyerDescription($donnees['texte']);
466
		$txt = $this->corrigerDescription($txt);
467
		$txt = $this->corrigerDescription($txt);
467
		$txt = $this->remplacerHtmlParSyntaxeWiki($txt);
468
		$txt = $this->remplacerHtmlParSyntaxeWiki($txt);
468
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.txt';
469
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.txt';
469
		file_put_contents($fichierTxt, $txt);
470
		file_put_contents($fichierTxt, $txt);
470
 
471
 
471
		unset($donnees['texte']);
472
		unset($donnees['texte']);
472
		$txt = implode("\n", $donnees);
473
		$txt = implode("\n", $donnees);
473
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.json';
474
		$fichierTxt = $this->dossierBase.self::DOSSIER_DSC_TXT.$this->fichierNum.'.json';
474
		file_put_contents($fichierTxt, $txt);
475
		file_put_contents($fichierTxt, $txt);
475
	}
476
	}
476
 
477
 
477
	private function analyserFichier() {
478
	private function analyserFichier() {
478
		$donnees = array('titre' => '', 'texte' => '', 'correspondance' => '');
479
		$donnees = array('titre' => '', 'texte' => '', 'correspondance' => '');
479
		if ($fichierOuvert = fopen($this->fichier, 'r')) {
480
		if ($fichierOuvert = fopen($this->fichier, 'r')) {
480
			$i = 1;
481
			$i = 1;
481
			while ($ligne = fgets($fichierOuvert)) {
482
			while ($ligne = fgets($fichierOuvert)) {
482
				if ($i == 24) {
483
				if ($i == 24) {
483
					$donnees['titre'] = $this->supprimerHtml($ligne);
484
					$donnees['titre'] = $this->supprimerHtml($ligne);
484
				} elseif ($i >= 45 && $i <= 60) {
485
				} elseif ($i >= 45 && $i <= 60) {
485
					$donnees['texte'] .= $this->traiterLigneDescription($ligne);
486
					$donnees['texte'] .= $this->traiterLigneDescription($ligne);
486
				} elseif ($i >= 61 && preg_match('/Bdnff /ui', $ligne)) {
487
				} elseif ($i >= 61 && preg_match('/Bdnff /ui', $ligne)) {
487
					$donnees['correspondance'] = $this->supprimerHtml($ligne);
488
					$donnees['correspondance'] = $this->supprimerHtml($ligne);
488
				}
489
				}
489
				$i++;
490
				$i++;
490
			}
491
			}
491
			fclose($fichierOuvert);
492
			fclose($fichierOuvert);
492
		} else {
493
		} else {
493
			$this->messages->traiterErreur("Le fichier {$this->fichier} n'a pas pu être ouvert.");
494
			$this->messages->traiterErreur("Le fichier {$this->fichier} n'a pas pu être ouvert.");
494
		}
495
		}
495
		return $donnees;
496
		return $donnees;
496
	}
497
	}
497
 
498
 
498
	private function supprimerHtml($txt) {
499
	private function supprimerHtml($txt) {
499
		$txt = strip_tags($txt,'<b>,<i>');
500
		$txt = strip_tags($txt,'<b>,<i>');
500
		$txt = str_replace('&#173;', '', $txt);
501
		$txt = str_replace('&#173;', '', $txt);
501
		$txt = str_ireplace('&nbsp;', ' ', $txt);
502
		$txt = str_ireplace('&nbsp;', ' ', $txt);
502
		$txt = trim($txt);
503
		$txt = trim($txt);
503
		$txt = preg_replace('/^<\/I>/', '', $txt);
504
		$txt = preg_replace('/^<\/I>/', '', $txt);
504
		$txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
505
		$txt = html_entity_decode($txt, ENT_NOQUOTES, 'UTF-8');
505
		return $txt;
506
		return $txt;
506
	}
507
	}
507
 
508
 
508
	private function traiterLigneDescription($txt) {
509
	private function traiterLigneDescription($txt) {
509
		$txt = $this->supprimerHtml($txt);
510
		$txt = $this->supprimerHtml($txt);
510
		$txt = $txt."\n";
511
		$txt = $txt."\n";
511
		return $txt;
512
		return $txt;
512
	}
513
	}
513
 
514
 
514
	private function nettoyerDescription($txt) {
515
	private function nettoyerDescription($txt) {
515
		$txt = preg_replace("/\n{2,}+/", "\n", $txt);
516
		$txt = preg_replace("/\n{2,}+/", "\n", $txt);
516
		$txt = trim($txt);
517
		$txt = trim($txt);
517
		return $txt;
518
		return $txt;
518
	}
519
	}
519
 
520
 
520
	private function corrigerDescription($txt) {
521
	private function corrigerDescription($txt) {
521
		$txt = preg_replace("/– <I>([^.]+?)[.] – <\/I>/", "– <I>$1</I>. – ", $txt);
522
		$txt = preg_replace("/– <I>([^.]+?)[.] – <\/I>/", "– <I>$1</I>. – ", $txt);
522
		$txt = preg_replace("/– <I>([^.]+?)[.] – ([A-Z])<\/I>/", "– <I>$1</I>. – $2", $txt);
523
		$txt = preg_replace("/– <I>([^.]+?)[.] – ([A-Z])<\/I>/", "– <I>$1</I>. – $2", $txt);
523
		$txt = preg_replace("/– <I>([^.]+?) – <\/I>/", "– <I>$1</I>. – ", $txt);
524
		$txt = preg_replace("/– <I>([^.]+?) – <\/I>/", "– <I>$1</I>. – ", $txt);
524
		return $txt;
525
		return $txt;
525
	}
526
	}
526
 
527
 
527
	private function remplacerHtmlParSyntaxeWiki($txt) {
528
	private function remplacerHtmlParSyntaxeWiki($txt) {
528
		$txt = str_replace(array('<B>', '</B>'), '**', $txt);
529
		$txt = str_replace(array('<B>', '</B>'), '**', $txt);
529
		$txt = str_replace(array('<I>', '</I>'), '//', $txt);
530
		$txt = str_replace(array('<I>', '</I>'), '//', $txt);
530
		return $txt;
531
		return $txt;
531
	}
532
	}
532
 
533
 
533
	private function ajouterLogAnalyse($txt) {
534
	private function ajouterLogAnalyse($txt) {
534
		if (isset($this->log['analyse']) == false) {
535
		if (isset($this->log['analyse']) == false) {
535
			$this->log['analyse'] = '';
536
			$this->log['analyse'] = '';
536
		}
537
		}
537
		$this->log['analyse'] .= "$txt\n";
538
		$this->log['analyse'] .= "$txt\n";
538
	}
539
	}
539
 
540
 
540
	private function ajouterLogSyno($txt) {
541
	private function ajouterLogSyno($txt) {
541
		if (isset($this->log['synonymes']) == false) {
542
		if (isset($this->log['synonymes']) == false) {
542
			$this->log['synonymes'] = '';
543
			$this->log['synonymes'] = '';
543
		}
544
		}
544
		$this->log['synonymes'] .= "$txt\n";
545
		$this->log['synonymes'] .= "$txt\n";
545
	}
546
	}
546
 
547
 
547
	private function ajouterLogAuteur($txt) {
548
	private function ajouterLogAuteur($txt) {
548
		if (isset($this->log['auteurs']) == false) {
549
		if (isset($this->log['auteurs']) == false) {
549
			$this->log['auteurs'] = '';
550
			$this->log['auteurs'] = '';
550
		}
551
		}
551
		$this->log['auteurs'] .= "$txt\n";
552
		$this->log['auteurs'] .= "$txt\n";
552
	}
553
	}
553
 
554
 
554
	private function ajouterLogProbleme($txt) {
555
	private function ajouterLogProbleme($txt) {
555
		if (isset($this->log['problemes']) == false) {
556
		if (isset($this->log['problemes']) == false) {
556
			$this->log['problemes'] = '';
557
			$this->log['problemes'] = '';
557
		}
558
		}
558
		$this->log['problemes'] .= "$txt\n";
559
		$this->log['problemes'] .= "$txt\n";
559
	}
560
	}
560
 
561
 
561
	private function ecrireLogs() {
562
	private function ecrireLogs() {
562
		foreach ($this->log as $nom => $log) {
563
		foreach ($this->log as $nom => $log) {
563
			$fichier = $this->dossierBase.self::DOSSIER_LOG.$nom.'.log';
564
			$fichier = $this->dossierBase.self::DOSSIER_LOG.$nom.'.log';
564
			file_put_contents($fichier, $log);
565
			file_put_contents($fichier, $log);
565
		}
566
		}
566
	}
567
	}
567
}
568
}
568
?>
569
?>