Subversion Repositories Applications.referentiel

Rev

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

Rev 193 Rev 195
1
<?php
1
<?php
2
// Encodage : UTF-8
2
// Encodage : UTF-8
3
// +-------------------------------------------------------------------------------------------------------------------+
3
// +-------------------------------------------------------------------------------------------------------------------+
4
/**
4
/**
5
* Versionnage de référentiels de nomenclature et taxonomie
5
* Versionnage de référentiels de nomenclature et taxonomie
6
*
6
*
7
* Description : classe permettant de versionner les référentiels selon le manuel technique
7
* Description : classe permettant de versionner les référentiels selon le manuel technique
8
* Utilisation : php script.php versionnage -p bdnff -a tout
8
* Utilisation : php script.php versionnage -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 : utilisation de array_key_exists à la place de isset dans creerFichierBdnt() ????
18
// TODO : lors de la génération de la version 2 de la BDTFX tester les diff! Il se peut que la mémoire soit dépassée.
19
class Versionnage extends ScriptCommande {
19
class Versionnage extends ScriptCommande {
20
	
20
	
21
	const SCRIPT_NOM = 'versionnage';
21
	const SCRIPT_NOM = 'versionnage';
22
	const MANUEL_VERSION = "4.1";
22
	const MANUEL_VERSION = '4.2';
23
	
23
	
24
	private $projet = null;
24
	private $projet = null;
25
	private $traitement = null;
25
	private $traitement = null;
26
	private $meta = null;
26
	private $meta = null;
27
	private $version_courante = null;
27
	private $version_courante = null;
28
	private $messages = null;
28
	private $messages = null;
29
	private $manuel = null;
29
	private $manuel = null;
30
	private $manuel_nom = null;
30
	private $manuel_nom = null;
31
	private $manuel_chemin = null;
31
	private $manuel_chemin = null;
32
	private $zip_chemin_dossier = null;
32
	private $zip_chemin_dossier = null;
33
	private $zip_chemin_fichier = null;
33
	private $zip_chemin_fichier = null;
34
	private $zip_chemin_dossier_partiel = null;
34
	private $zip_chemin_dossier_partiel = null;
35
	private $zip_chemin_fichier_partiel = null;
35
	private $zip_chemin_fichier_partiel = null;
36
	
36
	
37
	private $noms = null;
37
	private $noms = null;
38
	private $noms_precedents = null;
38
	private $noms_precedents = null;
39
	private $noms_stat = null;
39
	private $noms_stat = null;
40
	private $champs_ordre = null;
40
	private $champs_ordre = null;
41
	private $champs_nom = null;
41
	private $champs_nom = null;
42
	private $champs_nom_partiel = null;
42
	private $champs_nom_partiel = null;
43
	private $champs_diff = null;
43
	private $champs_diff = null;
44
	private $diff_champs_nom = null;
44
	private $diff_champs_nom = null;
45
	private $diff_modif_types = null;
45
	private $diff_modif_types = null;
46
	private $signature_md5 = null;
46
	private $signature_md5 = null;
47
	private $signature_md5_partiel = null;
47
	private $signature_md5_partiel = null;
48
	
48
	
49
	private $resultatDao = null;
49
	private $resultatDao = null;
50
	private $traitementDao = null;
50
	private $traitementDao = null;
51
	private $metaDao = null;
51
	private $metaDao = null;
52
	private $tableStructureDao = null;
52
	private $tableStructureDao = null;
53
	private $referentielDao = null;
53
	private $referentielDao = null;
54
	
54
	
55
	public function executer() {
55
	public function executer() {
56
		// Récupération du dernier traitement demandé
56
		// Récupération du dernier traitement demandé
57
		$this->traitementDao = new TraitementDao();
57
		$this->traitementDao = new TraitementDao();
58
		$this->traitement = $this->traitementDao->getDernierTraitement('tout', self::SCRIPT_NOM);
58
		$this->traitement = $this->traitementDao->getDernierTraitement('tout', self::SCRIPT_NOM);
59
		if (isset($this->traitement)) {
59
		if (isset($this->traitement)) {
60
			$this->projet = $this->traitement['referentiel_code']; // Récupération du nom de projet
60
			$this->projet = $this->traitement['referentiel_code']; // Récupération du nom de projet
61
			Debug::printr($this->traitement);
61
			Debug::printr($this->traitement);
62
			// Écriture de la date de début du traitement
62
			// Écriture de la date de début du traitement
63
			Debug::printr('Debute:'.$this->traitementDao->debuterTraitement($this->traitement['id_traitement']));
63
			Debug::printr('Debute:'.$this->traitementDao->debuterTraitement($this->traitement['id_traitement']));
64
			
64
			
65
			// Nettoyage des traitements obsolètes
65
			// Nettoyage des traitements obsolètes
66
			$traitements_obsoletes = $this->traitementDao->getTraitementsObsoletes($this->projet, self::SCRIPT_NOM);
66
			$traitements_obsoletes = $this->traitementDao->getTraitementsObsoletes($this->projet, self::SCRIPT_NOM);
67
			if (isset($traitements_obsoletes)) {
67
			if (isset($traitements_obsoletes)) {
68
				Debug::printr('Supp. obsoletes:'.$this->traitementDao->supprimer($traitements_obsoletes));
68
				Debug::printr('Supp. obsoletes:'.$this->traitementDao->supprimer($traitements_obsoletes));
69
			}
69
			}
70
			
70
			
71
			// Lancement du test demandé
71
			// Lancement du test demandé
72
			$cmd = $this->getParam('a');
72
			$cmd = $this->getParam('a');
73
	    	switch ($cmd) {
73
	    	switch ($cmd) {
74
				case 'tout' :
74
				case 'tout' :
75
					$this->initialiserScript();
75
					$this->initialiserScript();
76
					Debug::printr('Départ lancement versionnage:');
76
					Debug::printr('Départ lancement versionnage:');
77
					$this->lancerVersionnage();
77
					$this->lancerVersionnage();
78
					break;
78
					break;
79
				default :
79
				default :
80
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
80
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
81
			}
81
			}
82
			// Écriture de la date de fin du traitement
82
			// Écriture de la date de fin du traitement
83
			Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
83
			Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
84
		}
84
		}
85
    }
85
    }
86
	
86
	
87
    private function initialiserScript() {
87
    private function initialiserScript() {
88
		$this->metaDao = new MetaDao();
88
		$this->metaDao = new MetaDao();
89
		$this->resultatDao = new ResultatDao();
89
		$this->resultatDao = new ResultatDao();
90
		$this->referentielDao = new ReferentielDao();
90
		$this->referentielDao = new ReferentielDao();
91
		
91
		
92
		$this->manuel_nom = 'mtpr_v'.str_replace('.', '_', self::MANUEL_VERSION).'.pdf';
92
		$this->manuel_nom = 'mtpr_v'.str_replace('.', '_', self::MANUEL_VERSION).'.pdf';
93
		$this->manuel_chemin = Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS;
93
		$this->manuel_chemin = Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS;
94
		
94
		
95
		$manuel_config_nom = 'referentiel_v'.self::MANUEL_VERSION.'.ini';
95
		$manuel_config_nom = 'referentiel_v'.self::MANUEL_VERSION.'.ini';
96
		$this->manuel = parse_ini_file($this->manuel_chemin.$manuel_config_nom);
96
		$this->manuel = parse_ini_file($this->manuel_chemin.$manuel_config_nom);
97
	}
97
	}
98
	
98
	
99
    public function lancerVersionnage() {
99
    public function lancerVersionnage() {
100
		$this->chargerTraitementParametre();
100
		$this->chargerTraitementParametre();
101
		$this->initialiserNomVersionCOurante();
101
		$this->initialiserNomVersionCOurante();
102
		$this->initialiserCheminsZip();
102
		$this->initialiserCheminsZip();
103
		$this->creerDossiersZip();
103
		$this->creerDossiersZip();
104
		$this->archiver();
104
		$this->archiver();
105
    	$this->chargerNomsATraiter();
105
    	$this->chargerNomsATraiter();
106
    	$this->analyserNomsATraiter();
106
    	$this->analyserNomsATraiter();
107
		$this->creerFichiers();
107
		$this->creerFichiers();
108
		$this->nettoyerFichiers();
108
		$this->nettoyerFichiers();
109
		$this->traiterMessages();
109
		$this->traiterMessages();
110
	}
110
	}
111
	
111
	
112
	private function chargerTraitementParametre() {
112
	private function chargerTraitementParametre() {
113
		$this->meta = unserialize($this->traitement['script_parametres']);
113
		$this->meta = unserialize($this->traitement['script_parametres']);
114
	}
114
	}
115
	
115
	
116
	private function archiver() {
116
	private function archiver() {
117
		$ok = $this->referentielDao->archiver($this->projet, $this->meta['version']);
117
		$ok = $this->referentielDao->archiver($this->projet, $this->meta['version']);
118
		if ($ok) {
118
		if ($ok) {
119
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a réussi";
119
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a réussi";
120
			$this->ajouterMessage($m);
120
			$this->ajouterMessage($m);
121
		} else {
121
		} else {
122
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a échoué";
122
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a échoué";
123
			$this->ajouterMessage($m);
123
			$this->ajouterMessage($m);
124
		}
124
		}
125
	}
125
	}
126
	
126
	
127
	private function initialiserNomVersionCOurante() {
127
	private function initialiserNomVersionCOurante() {
128
		$this->version_courante = strtolower($this->projet).'_v'.str_replace('.', '_', $this->meta['version']);
128
		$this->version_courante = strtolower($this->projet).'_v'.str_replace('.', '_', $this->meta['version']);
129
		Debug::printr("Nom archive courante :".$this->version_courante);
129
		Debug::printr("Nom archive courante :".$this->version_courante);
130
	}
130
	}
131
	
131
	
132
	private function initialiserCheminsZip() {
132
	private function initialiserCheminsZip() {
133
		$this->zip_chemin_dossier = Config::get('chemin_referentiel_zip').$this->version_courante.DIRECTORY_SEPARATOR;
133
		$this->zip_chemin_dossier = Config::get('chemin_referentiel_zip').$this->version_courante.DIRECTORY_SEPARATOR;
134
		$this->zip_chemin_fichier = Config::get('chemin_referentiel_zip').$this->version_courante.'.zip';
134
		$this->zip_chemin_fichier = Config::get('chemin_referentiel_zip').$this->version_courante.'.zip';
135
		$this->zip_chemin_dossier_partiel = Config::get('chemin_referentiel_zip').$this->version_courante.'_partiel'.DIRECTORY_SEPARATOR;
135
		$this->zip_chemin_dossier_partiel = Config::get('chemin_referentiel_zip').$this->version_courante.'_partiel'.DIRECTORY_SEPARATOR;
136
		$this->zip_chemin_fichier_partiel = Config::get('chemin_referentiel_zip').$this->version_courante.'_partiel.zip';
136
		$this->zip_chemin_fichier_partiel = Config::get('chemin_referentiel_zip').$this->version_courante.'_partiel.zip';
137
	}
137
	}
138
	
138
	
139
	private function creerDossiersZip() {
139
	private function creerDossiersZip() {
140
		$recursivite = true;
140
		$recursivite = true;
141
		if (mkdir($this->zip_chemin_dossier, 0777, $recursivite) === false) {
141
		if (mkdir($this->zip_chemin_dossier, 0777, $recursivite) === false) {
142
			$this->ajouterMessage("La création du dossier '$this->zip_chemin_dossier' devant contenir les fichiers a échouée.");
142
			$this->ajouterMessage("La création du dossier '$this->zip_chemin_dossier' devant contenir les fichiers a échouée.");
143
		}
143
		}
144
		if (mkdir($this->zip_chemin_dossier_partiel, 0777, $recursivite) === false) {
144
		if (mkdir($this->zip_chemin_dossier_partiel, 0777, $recursivite) === false) {
145
			$this->ajouterMessage("La création du dossier '$this->zip_chemin_dossier_partiel' devant contenir les fichiers partiels a échouée.");
145
			$this->ajouterMessage("La création du dossier '$this->zip_chemin_dossier_partiel' devant contenir les fichiers partiels a échouée.");
146
		}
146
		}
147
	}
147
	}
148
	
148
	
149
	private function chargerNomsATraiter() {
149
	private function chargerNomsATraiter() {
150
		$this->noms = $this->referentielDao->getTout($this->version_courante);
150
		$this->noms = $this->referentielDao->getTout($this->version_courante);
151
	}
151
	}
152
	
152
	
153
	private function analyserNomsATraiter() {
153
	private function analyserNomsATraiter() {
154
		$this->noms_stat['combinaison'] = $this->getNombreCombinaison();
154
		$this->noms_stat['combinaison'] = $this->getNombreCombinaison();
155
		$this->noms_stat['taxon'] = $this->getNombreTaxon();
155
		$this->noms_stat['taxon'] = $this->getNombreTaxon();
156
		Debug::printr("Stats :".print_r($this->noms_stat, true));
156
		Debug::printr("Stats :".print_r($this->noms_stat, true));
157
	}
157
	}
158
	
158
	
159
	private function getNombreCombinaison() {
159
	private function getNombreCombinaison() {
160
		return count($this->noms);
160
		return count($this->noms);
161
	}
161
	}
162
	
162
	
163
	private function getNombreTaxon() {
163
	private function getNombreTaxon() {
164
		$nbre = 0;
164
		$nbre = 0;
165
		foreach ($this->noms as $nom) {
165
		foreach ($this->noms as $nom) {
166
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
166
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
167
				$nbre++;
167
				$nbre++;
168
			}
168
			}
169
		}
169
		}
170
		return $nbre;
170
		return $nbre;
171
	}
171
	}
172
	
172
	
173
	private function creerFichiers() {
173
	private function creerFichiers() {
174
		// Respecter l'ordre de traitement : BDNT puis DIFF puis META
174
		// Respecter l'ordre de traitement : BDNT puis DIFF puis META
175
		$donnees =& $this->creerFichierBdnt();
175
		$donnees =& $this->creerFichierBdnt();
176
		$this->creerFichierBdntPartiel($donnees);
176
		$this->creerFichierBdntPartiel($donnees);
177
		$donnees = null;
177
		$donnees = null;
178
		$donnees =& $this->creerFichierDiff();
178
		$donnees =& $this->creerFichierDiff();
179
		$this->creerFichierDiffPartiel($donnees);
179
		$this->creerFichierDiffPartiel($donnees);
180
		$donnees = null;
180
		$donnees = null;
181
		$donnees =& $this->creerFichierMeta();
181
		$donnees =& $this->creerFichierMeta();
182
		$this->creerFichierMetaPartiel($donnees);
182
		$this->creerFichierMetaPartiel($donnees);
183
		$donnees = null;
183
		$donnees = null;
184
		$this->nettoyerMemoire();
184
		$this->nettoyerMemoire();
185
		$this->copierManuel();
185
		$this->copierManuel();
186
		$this->creerFichiersZip();
186
		$this->creerFichiersZip();
187
	}
187
	}
188
	
188
	
189
	private function creerFichierBdnt() {
189
	private function creerFichierBdnt() {
190
		reset($this->noms);
190
		reset($this->noms);
191
		Debug::printr("Element courrant du tableau des noms : ".count($this->noms).'-'.print_r(current($this->noms),true));
191
		Debug::printr("Element courrant du tableau des noms : ".count($this->noms).'-'.print_r(current($this->noms),true));
192
		
192
		
193
		$this->determinerOrdreDesChamps();
193
		$this->determinerOrdreDesChamps();
194
		$this->definirNomDesChamps();
194
		$this->definirNomDesChamps();
195
		$this->definirNomDesChampsDiff();
195
		$this->definirNomDesChampsDiff();
196
		
196
		
197
		$donnees = array();
197
		$donnees = array();
198
		$donnees['champs'] = $this->champs_nom;
198
		$donnees['champs'] = $this->champs_nom;
-
 
199
		
-
 
200
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
-
 
201
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
-
 
202
		$bdnt_tsv_entete = $this->getVue('versionnage/squelettes/bdnt_entete', array('champs' => $donnees['champs']), '.tpl.tsv');
-
 
203
		$this->ecrireFichier($fichier_chemin, $bdnt_tsv_entete);
-
 
204
			
199
		foreach ($this->noms as $id => &$nom) {
205
		foreach ($this->noms as $id => &$nom) {
200
			$infos = array();
206
			$infos = array();
201
			foreach ($this->champs_ordre as $champ => $ordre) {
207
			foreach ($this->champs_ordre as $champ => $ordre) {
202
				if (array_key_exists($champ, $nom)) {
208
				if (array_key_exists($champ, $nom)) {
203
					$infos[$champ] = trim($nom[$champ]);
209
					$infos[$champ] = trim($nom[$champ]);
204
				} else {
210
				} else {
205
					$e = "Le champ '$champ' n'a pas été trouvé dans les données du nom : $id.";
211
					$e = "Le champ '$champ' n'a pas été trouvé dans les données du nom : $id.";
206
					$this->ajouterMessage($e);
212
					$this->ajouterMessage($e);
207
				}
213
				}
208
			}
214
			}
209
			$infos = $this->remplacerTabulation($infos);
215
			$infos = $this->remplacerTabulation($infos);
210
			$infos = $this->remplacerSautsDeLigne($infos);
216
			$infos = $this->remplacerSautsDeLigne($infos);
211
			$donnees['noms'][$id] = $infos;
217
			$this->noms[$id] = $infos;
-
 
218
			
-
 
219
			$bdnt_tsv_ligne = $this->getVue('versionnage/squelettes/bdnt_ligne', array('nom_infos' => $infos), '.tpl.tsv');
-
 
220
			$this->ajouterAuFichier($fichier_chemin, $bdnt_tsv_ligne);
212
		}
221
		}
213
		Debug::printr("Dernier element du tableau des noms [trié] : ".print_r($infos,true));
-
 
214
		$bdnt_tsv =& $this->getVue('versionnage/squelettes/bdnt', &$donnees, '.tpl.tsv');
-
 
215
		$this->ecrireFichierBdnt($bdnt_tsv);
222
		$this->ecrireComplementFichierBdnt($fichier_chemin);
216
		return $donnees;
223
		return $donnees;
217
	}
224
	}
218
	
225
	
219
	private function determinerOrdreDesChamps() {
226
	private function determinerOrdreDesChamps() {
220
		$champs_ordre = explode(',', $this->manuel['champs']);
227
		$champs_ordre = explode(',', $this->manuel['champs']);
221
		$champs_ordre = array_flip($champs_ordre);
228
		$champs_ordre = array_flip($champs_ordre);
222
		$nom_courant = current($this->noms);
229
		$nom_courant = current($this->noms);
223
		$champs_ordre = $this->attribuerOrdreChampsSupplémentaires($champs_ordre, $nom_courant);
230
		$champs_ordre = $this->attribuerOrdreChampsSupplémentaires($champs_ordre, $nom_courant);
224
		asort($champs_ordre);
231
		asort($champs_ordre);
225
		$this->champs_ordre = $champs_ordre;
232
		$this->champs_ordre = $champs_ordre;
226
		Debug::printr("Ordre des champs : ".print_r($this->champs_ordre,true));
233
		Debug::printr("Ordre des champs : ".print_r($this->champs_ordre,true));
227
	}
234
	}
228
	
235
	
229
	private function attribuerOrdreChampsSupplémentaires($champs_ordre, $nom) {
236
	private function attribuerOrdreChampsSupplémentaires($champs_ordre, $nom) {
230
		foreach ($nom as $champ => $info) {
237
		foreach ($nom as $champ => $info) {
231
			if (!isset($champs_ordre[$champ])) {
238
			if (!isset($champs_ordre[$champ])) {
232
				$champs_ordre[$champ] = count($champs_ordre);
239
				$champs_ordre[$champ] = count($champs_ordre);
233
			}
240
			}
234
		}
241
		}
235
		return $champs_ordre;
242
		return $champs_ordre;
236
	}
243
	}
237
	
244
	
238
	private function definirNomDesChamps() {
245
	private function definirNomDesChamps() {
239
		$this->champs_nom = array_flip($this->champs_ordre);
246
		$this->champs_nom = array_flip($this->champs_ordre);
240
	}
247
	}
241
	
248
	
242
	private function definirNomDesChampsDiff() {
249
	private function definirNomDesChampsDiff() {
243
		$this->champs_diff = explode(',', $this->manuel['champs_diff']);
250
		$this->champs_diff = explode(',', $this->manuel['champs_diff']);
244
		$this->diff_champs_nom = array_merge($this->champs_nom, $this->champs_diff);
251
		$this->diff_champs_nom = array_merge($this->champs_nom, $this->champs_diff);
245
	}
252
	}
246
	
253
	
247
	private function ajouterMessage($message) {
254
	private function ajouterMessage($message) {
248
		$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
255
		$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
249
		$this->messages[] = array('message' => $message, 'resultat' => true);
256
		$this->messages[] = array('message' => $message, 'resultat' => true);
250
	}
257
	}
251
	
258
	
252
	private function remplacerTabulation($doc) {
259
	private function remplacerTabulation($doc) {
253
		if (is_string($doc)) {
260
		if (is_string($doc)) {
254
			$doc = str_replace("\t", ' ', $doc);
261
			$doc = str_replace("\t", ' ', $doc);
255
		} else if (is_array($doc) && count($doc) > 0) {
262
		} else if (is_array($doc) && count($doc) > 0) {
256
			foreach ($doc as $cle => $valeur) {
263
			foreach ($doc as $cle => $valeur) {
257
				$doc[$cle] = $this->remplacerTabulation($valeur);
264
				$doc[$cle] = $this->remplacerTabulation($valeur);
258
			}
265
			}
259
		}
266
		}
260
		return $doc;
267
		return $doc;
261
	}
268
	}
262
	
269
	
263
	private function remplacerSautsDeLigne($doc) {
270
	private function remplacerSautsDeLigne($doc) {
264
		if (is_string($doc)) {
271
		if (is_string($doc)) {
265
			$a_remplacer = array("\r", "\n");
272
			$a_remplacer = array("\r", "\n");
266
			$doc = str_replace($a_remplacer, ' ', $doc);
273
			$doc = str_replace($a_remplacer, ' ', $doc);
267
		} else if (is_array($doc) && count($doc) > 0) {
274
		} else if (is_array($doc) && count($doc) > 0) {
268
			foreach ($doc as $cle => $valeur) {
275
			foreach ($doc as $cle => $valeur) {
269
				$doc[$cle] = $this->remplacerSautsDeLigne($valeur);
276
				$doc[$cle] = $this->remplacerSautsDeLigne($valeur);
270
			}
277
			}
271
		}
278
		}
272
		return $doc;
279
		return $doc;
273
	}
280
	}
274
	
281
	
275
	private function ecrireFichierBdnt(&$contenu) {
-
 
276
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
-
 
277
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
-
 
278
		
282
	private function ecrireComplementFichierBdnt($fichier_chemin) {
279
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
283
		if (file_exists($fichier_chemin)) {
280
			$this->ajouterMessage("Écriture du fichier bdnt réussie.");
284
			$this->ajouterMessage("Écriture du fichier bdnt réussie.");
281
			$this->signature_md5 = md5_file($fichier_chemin);
285
			$this->signature_md5 = md5_file($fichier_chemin);
282
			$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
286
			$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
283
			$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
287
			$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
284
		}
288
		}
285
	}
289
	}
286
	
290
	
287
	private function getBaseNomFichier() {
291
	private function getBaseNomFichier() {
288
		return strtolower($this->meta['acronyme'].'_v'.str_replace('.', '_', $this->meta['version']));
292
		return strtolower($this->meta['acronyme'].'_v'.str_replace('.', '_', $this->meta['version']));
289
	}
293
	}
290
		
294
		
291
	private function creerFichierBdntPartiel(&$donnees) {
295
	private function creerFichierBdntPartiel(&$donnees) {
292
		$this->definirChampsPartiel();
296
		$this->definirChampsPartiel();
293
		Debug::printr(current($donnees['noms']));
297
		Debug::printr(current($donnees['noms']));
294
		$donnees['champs_partiel'] = $this->champs_nom_partiel;
298
		$donnees['champs_partiel'] = $this->champs_nom_partiel;
295
		$donnees['dernier_champ'] = end($this->champs_nom_partiel);
299
		$donnees['dernier_champ'] = end($this->champs_nom_partiel);
296
		$bdnt_partielle_tsv =& $this->getVue('versionnage/squelettes/bdnt_partiel', &$donnees, '.tpl.tsv');
-
 
297
		$this->ecrireFichierBdntPartielle($bdnt_partielle_tsv);
300
		$this->ecrireFichierBdntPartielle($donnees);
298
	}
301
	}
299
	
302
	
300
	private function definirChampsPartiel() {
303
	private function definirChampsPartiel() {
301
		$this->champs_nom_partiel = explode(',', $this->manuel['champs_partiel']);
304
		$this->champs_nom_partiel = explode(',', $this->manuel['champs_partiel']);
302
		Debug::printr("Champs partiels : ".print_r($this->champs_nom_partiel,true));
305
		Debug::printr("Champs partiels : ".print_r($this->champs_nom_partiel,true));
303
	}
306
	}
304
	
307
	
305
	private function ecrireFichierBdntPartielle(&$contenu) {
308
	private function ecrireFichierBdntPartielle(&$donnees) {
306
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
309
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
-
 
310
		$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
-
 
311
		$bdnt_tsv_entete = $this->getVue('versionnage/squelettes/bdnt_partiel_entete', array('champs_partiel' => $donnees['champs_partiel']), '.tpl.tsv');
-
 
312
		$this->ecrireFichier($fichier_chemin, $bdnt_tsv_entete);
-
 
313
			
-
 
314
		foreach ($this->noms as $id => &$nom) {
-
 
315
			$donnees['nom_infos'] = $nom;
-
 
316
			$bdnt_tsv_ligne = $this->getVue('versionnage/squelettes/bdnt_partiel_ligne', $donnees, '.tpl.tsv');
-
 
317
			if ($bdnt_tsv_ligne != '') {
-
 
318
				$this->ajouterAuFichier($fichier_chemin, $bdnt_tsv_ligne);
-
 
319
			}
307
		$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
320
		}
308
		
321
		
309
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
322
		if (file_exists($fichier_chemin)) {
310
			$this->ajouterMessage("Écriture du fichier de la bdnt partielle réussie.");
323
			$this->ajouterMessage("Écriture du fichier de la bdnt partielle réussie.");
311
			$this->signature_md5_partiel = md5_file($fichier_chemin);
324
			$this->signature_md5_partiel = md5_file($fichier_chemin);
312
			$this->ajouterMessage("Signature MD5 du fichier bdnt partiel :".$this->signature_md5_partiel);
325
			$this->ajouterMessage("Signature MD5 du fichier bdnt partiel :".$this->signature_md5_partiel);
313
			$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
326
			$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
314
		}
327
		}
315
	}
328
	}
316
	
329
	
317
	private function ecrireFichier($fichier_chemin, &$contenu) {
330
	private function ecrireFichier($fichier_chemin, &$contenu) {
318
		$retour = true;
331
		$retour = true;
319
		if (file_put_contents($fichier_chemin, $contenu) == false) {
332
		if (file_put_contents($fichier_chemin, $contenu) == false) {
320
			$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
333
			$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
321
			$this->ajouterMessage($e);
334
			$this->ajouterMessage($e);
322
			$retour = false;
335
			$retour = false;
323
		}
336
		}
324
		$contenu = null;
337
		$contenu = null;
325
		return $retour;
338
		return $retour;
326
	}
339
	}
-
 
340
	
-
 
341
	private function ajouterAuFichier($fichier_chemin, &$contenu) {
-
 
342
		$retour = true;
-
 
343
		if (file_put_contents($fichier_chemin, $contenu, FILE_APPEND) == false) {
-
 
344
			$e = "Une erreur est survenu lors de l'ajout de données dans le fichier : $fichier_chemin";
-
 
345
			$this->ajouterMessage($e);
-
 
346
			$retour = false;
-
 
347
		}
-
 
348
		$contenu = null;
-
 
349
		return $retour;
-
 
350
	}	
327
	
351
	
328
	private function creerFichierDiff() {
352
	private function creerFichierDiff() {
329
		$donnees = array();
353
		$donnees = array();
330
		$derniere_meta = $this->metaDao->getDerniere($this->projet);
354
		$derniere_meta = $this->metaDao->getDerniere($this->projet);
331
		if (is_null($derniere_meta === false)) {
355
		if (is_null($derniere_meta === false)) {
332
			$this->ajouterMessage("Un problème est survenu lors de la récupération des métadonnées précédentes.");
356
			$this->ajouterMessage("Un problème est survenu lors de la récupération des métadonnées précédentes.");
333
		} else if (is_null($derniere_meta)) {
357
		} else if (is_null($derniere_meta)) {
334
			$this->ajouterMessage("Premier versionnage pour ce projet, aucun fichier différentiel ne sera créé.");
358
			$this->ajouterMessage("Premier versionnage pour ce projet, aucun fichier différentiel ne sera créé.");
335
		} else {
359
		} else {
336
			$code_projet_precedent = strtolower($derniere_meta['code']).'_v'.str_replace('.', '_', $derniere_meta['version']);
360
			$code_projet_precedent = strtolower($derniere_meta['code']).'_v'.str_replace('.', '_', $derniere_meta['version']);
337
			if ($code_projet_precedent == $this->version_courante) {
361
			if ($code_projet_precedent == $this->version_courante) {
338
				$e = "La code de la version préalablement versionnée ($code_projet_precedent) est le même que celui ".
362
				$e = "La code de la version préalablement versionnée ($code_projet_precedent) est le même que celui ".
339
					"de la demande actuel ({$this->version_courante}) pour ce projet, aucun fichier différentiel ne sera créé.";
363
					"de la demande actuel ({$this->version_courante}) pour ce projet, aucun fichier différentiel ne sera créé.";
340
				$this->ajouterMessage($e);
364
				$this->ajouterMessage($e);
341
			} else {
365
			} else {
342
				$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
366
				$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
343
				$donnees['diff'] = $this->realiserDiff();
367
				$donnees['diff'] = $this->realiserDiff();
344
				$donnees['champs'] = $this->diff_champs_nom;
368
				$donnees['champs'] = $this->diff_champs_nom;
345
				$diff_tsv =& $this->getVue('versionnage/squelettes/diff', &$donnees, '.tpl.tsv');
369
				$diff_tsv =& $this->getVue('versionnage/squelettes/diff', &$donnees, '.tpl.tsv');
346
				$this->ecrireFichierDiff($diff_tsv);
370
				$this->ecrireFichierDiff($diff_tsv);
347
			}
371
			}
348
		}
372
		}
349
		return $donnees;
373
		return $donnees;
350
	}
374
	}
351
	
375
	
352
	private function realiserDiff() {
376
	private function realiserDiff() {
353
		$this->chargerTableauChampsModifTypes();
377
		$this->chargerTableauChampsModifTypes();
354
		$this->noms_stat['modification'] = 0;
378
		$this->noms_stat['modification'] = 0;
355
		
379
		
356
		$diff = array();
380
		$diff = array();
357
		foreach ($this->noms as $id => $nom) {
381
		foreach ($this->noms as $id => $nom) {
358
			$this->noms[$id] = null;
382
			$this->noms[$id] = null;
359
			$infos = array();
383
			$infos = array();
360
			if (!isset($this->noms_precedents[$id])) {
384
			if (!isset($this->noms_precedents[$id])) {
361
				$infos = $this->traiterDiffAjout($nom);
385
				$infos = $this->traiterDiffAjout($nom);
362
			} else {
386
			} else {
363
				$nom_precedent = $this->noms_precedents[$id];
387
				$nom_precedent = $this->noms_precedents[$id];
364
				$this->noms_precedents[$id] = null;
388
				$this->noms_precedents[$id] = null;
365
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
389
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
366
			}
390
			}
367
			
391
			
368
			if (count($infos) > 0) {
392
			if (count($infos) > 0) {
369
				$infos = $this->remplacerTabulation($infos);
393
				$infos = $this->remplacerTabulation($infos);
370
				$infos = $this->remplacerSautsDeLigne($infos);
394
				$infos = $this->remplacerSautsDeLigne($infos);
371
				$diff[$id] = $infos;
395
				$diff[$id] = $infos;
372
			}
396
			}
373
		}
397
		}
374
		return $diff;
398
		return $diff;
375
	}
399
	}
376
	
400
	
377
	private function traiterDiffAjout(&$nom) {
401
	private function traiterDiffAjout(&$nom) {
378
		$infos = $nom;
402
		$infos = $nom;
379
		$infos['modification_type'] = 'A';
403
		$infos['modification_type'] = 'A';
380
		$infos['modification_type_1'] = '0';
404
		$infos['modification_type_1'] = '0';
381
		$infos['modification_type_2'] = '0';
405
		$infos['modification_type_2'] = '0';
382
		$infos['modification_type_3'] = '0';
406
		$infos['modification_type_3'] = '0';
383
		$this->noms_stat['modification']++;
407
		$this->noms_stat['modification']++;
384
		return $infos;
408
		return $infos;
385
	}
409
	}
386
	
410
	
387
	private function traiterDiffModif(&$nom, &$nom_precedent) {
411
	private function traiterDiffModif(&$nom, &$nom_precedent) {
388
		$infos = array();
412
		$infos = array();
389
		$nom_diff = array_diff_assoc($nom, $nom_precedent);		$bdnt_partielle_tsv = 'trest';
413
		$nom_diff = array_diff_assoc($nom, $nom_precedent);		$bdnt_partielle_tsv = 'trest';
390
		if (count($nom_diff) > 0) {
414
		if (count($nom_diff) > 0) {
391
			$modif['modification_type'] = 'M';
415
			$modif['modification_type'] = 'M';
392
			$modif['modification_type_1'] = '0';
416
			$modif['modification_type_1'] = '0';
393
			$modif['modification_type_2'] = '0';
417
			$modif['modification_type_2'] = '0';
394
			$modif['modification_type_3'] = '0';
418
			$modif['modification_type_3'] = '0';
395
			
419
			
396
			foreach ($this->champs_nom as $champ) {
420
			foreach ($this->champs_nom as $champ) {
397
				if (isset($nom_diff[$champ])) {
421
				if (isset($nom_diff[$champ])) {
398
					$infos[$champ] = $nom_diff[$champ];
422
					$infos[$champ] = $nom_diff[$champ];
399
					$type = $this->getDiffType($champ);
423
					$type = $this->getDiffType($champ);
400
					$modif['modification_type_'.$type] = '1';
424
					$modif['modification_type_'.$type] = '1';
401
				} else {
425
				} else {
402
					if ($champ == 'num_nom') {
426
					if ($champ == 'num_nom') {
403
						$infos[$champ] = $nom[$champ];
427
						$infos[$champ] = $nom[$champ];
404
					} else {
428
					} else {
405
						$infos[$champ] = '';
429
						$infos[$champ] = '';
406
					}
430
					}
407
				}
431
				}
408
			}
432
			}
409
			
433
			
410
			foreach ($modif as $cle => $val) {
434
			foreach ($modif as $cle => $val) {
411
				$infos[$cle] = $val;
435
				$infos[$cle] = $val;
412
			}
436
			}
413
			
437
			
414
			$this->noms_stat['modification']++;
438
			$this->noms_stat['modification']++;
415
		}
439
		}
416
		return $infos;
440
		return $infos;
417
	}
441
	}
418
	
442
	
419
	private function chargerTableauChampsModifTypes() {
443
	private function chargerTableauChampsModifTypes() {
420
		$champs = explode(',', $this->manuel['champs_diff_type']);
444
		$champs = explode(',', $this->manuel['champs_diff_type']);
421
		foreach ($champs as $champ) {
445
		foreach ($champs as $champ) {
422
			list($champ_nom, $type) = explode('=', trim($champ));
446
			list($champ_nom, $type) = explode('=', trim($champ));
423
			$this->diff_modif_types[$champ_nom] = $type;
447
			$this->diff_modif_types[$champ_nom] = $type;
424
		}
448
		}
425
	}
449
	}
426
	
450
	
427
	private function getDiffType($champ_nom) {
451
	private function getDiffType($champ_nom) {
428
		$type = isset($this->diff_modif_types[$champ_nom]) ? $this->diff_modif_types[$champ_nom] : '3';
452
		$type = isset($this->diff_modif_types[$champ_nom]) ? $this->diff_modif_types[$champ_nom] : '3';
429
		return $type;
453
		return $type;
430
	}
454
	}
431
	
455
	
432
	private function ecrireFichierDiff(&$contenu) {
456
	private function ecrireFichierDiff(&$contenu) {
433
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
457
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
434
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
458
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
435
		
459
		
436
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
460
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
437
			$this->ajouterMessage("Écriture du fichier diff réussie.");
461
			$this->ajouterMessage("Écriture du fichier diff réussie.");
438
		}
462
		}
439
	}
463
	}
440
	
464
	
441
	private function creerFichierDiffPartiel(&$donnees) {
465
	private function creerFichierDiffPartiel(&$donnees) {
442
		if (count($donnees) > 0) {
466
		if (count($donnees) > 0) {
443
			$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
467
			$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
444
			$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
468
			$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
445
			$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
469
			$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
446
			$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
470
			$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
447
		}
471
		}
448
	}
472
	}
449
	
473
	
450
	private function ecrireFichierDiffPartiel(&$contenu) {
474
	private function ecrireFichierDiffPartiel(&$contenu) {
451
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
475
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
452
		$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
476
		$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
453
		
477
		
454
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
478
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
455
			$this->ajouterMessage("Écriture du fichier diff partiel réussie.");
479
			$this->ajouterMessage("Écriture du fichier diff partiel réussie.");
456
		}
480
		}
457
	}
481
	}
458
	
482
	
459
	private function creerFichierMeta() {
483
	private function creerFichierMeta() {
460
		$donnees = array();
484
		$donnees = array();
461
		$donnees = $this->meta;
485
		$donnees = $this->meta;
462
		$donnees['stats'] = $this->noms_stat;
486
		$donnees['stats'] = $this->noms_stat;
463
		$donnees['signature'] = $this->signature_md5;
487
		$donnees['signature'] = $this->signature_md5;
464
		
488
		
465
		$donnees = $this->remplacerTabulation($donnees);
489
		$donnees = $this->remplacerTabulation($donnees);
466
		$donnees = $this->remplacerSautsDeLigne($donnees);
490
		$donnees = $this->remplacerSautsDeLigne($donnees);
467
		
491
		
468
		$meta_tsv =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
492
		$meta_tsv =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
469
		$this->ecrireFichierMeta($meta_tsv);
493
		$this->ecrireFichierMeta($meta_tsv);
470
		return $donnees;
494
		return $donnees;
471
	}
495
	}
472
	
496
	
473
	private function ecrireFichierMeta(&$contenu) {
497
	private function ecrireFichierMeta(&$contenu) {
474
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
498
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
475
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
499
		$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
476
		
500
		
477
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
501
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
478
			$this->ajouterMessage("Écriture du fichier meta réussie.");
502
			$this->ajouterMessage("Écriture du fichier meta réussie.");
479
			$this->archiverMetadonnees();
503
			$this->archiverMetadonnees();
480
		}
504
		}
481
	}
505
	}
482
	
506
	
483
	private function creerFichierMetaPartiel(&$donnees) {
507
	private function creerFichierMetaPartiel(&$donnees) {
484
		$donnees['signature'] = $this->signature_md5_partiel;
508
		$donnees['signature'] = $this->signature_md5_partiel;
485
		$meta_tsv_partiel =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
509
		$meta_tsv_partiel =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
486
		$this->ecrireFichierMetaPartiel($meta_tsv_partiel);
510
		$this->ecrireFichierMetaPartiel($meta_tsv_partiel);
487
	}
511
	}
488
	
512
	
489
	private function ecrireFichierMetaPartiel(&$contenu) {
513
	private function ecrireFichierMetaPartiel(&$contenu) {
490
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
514
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
491
		$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
515
		$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
492
		
516
		
493
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
517
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
494
			$this->ajouterMessage("Écriture du fichier meta partiel réussie.");
518
			$this->ajouterMessage("Écriture du fichier meta partiel réussie.");
495
		}
519
		}
496
	}
520
	}
497
	
521
	
498
	private function archiverMetadonnees() {
522
	private function archiverMetadonnees() {
499
		$metadonnees = $this->meta;
523
		$metadonnees = $this->meta;
500
		$metadonnees['code'] = $this->meta['acronyme'];
524
		$metadonnees['code'] = $this->meta['acronyme'];
501
		unset($metadonnees['acronyme']);
525
		unset($metadonnees['acronyme']);
502
		$metadonnees['domaine_taxo'] = $this->meta['dom_tax'];
526
		$metadonnees['domaine_taxo'] = $this->meta['dom_tax'];
503
		unset($metadonnees['dom_tax']);
527
		unset($metadonnees['dom_tax']);
504
		$metadonnees['domaine_geo'] = $this->meta['dom_geo'];
528
		$metadonnees['domaine_geo'] = $this->meta['dom_geo'];
505
		unset($metadonnees['dom_geo']);
529
		unset($metadonnees['dom_geo']);
506
		$metadonnees['domaine_nom'] = $this->meta['dom_code'];
530
		$metadonnees['domaine_nom'] = $this->meta['dom_code'];
507
		unset($metadonnees['dom_code']);
531
		unset($metadonnees['dom_code']);
508
		$metadonnees['auteur'] = $this->meta['auteur_principal'];
532
		$metadonnees['auteur'] = $this->meta['auteur_principal'];
509
		unset($metadonnees['auteur_principal']);
533
		unset($metadonnees['auteur_principal']);
510
		$metadonnees['date_production'] = $this->meta['date_prod'];
534
		$metadonnees['date_production'] = $this->meta['date_prod'];
511
		unset($metadonnees['date_prod']);
535
		unset($metadonnees['date_prod']);
512
		$metadonnees['droit'] = $this->meta['copyright'];
536
		$metadonnees['droit'] = $this->meta['copyright'];
513
		unset($metadonnees['copyright']);
537
		unset($metadonnees['copyright']);
514
		
538
		
515
		$ok = $this->metaDao->ajouter($metadonnees);
539
		$ok = $this->metaDao->ajouter($metadonnees);
516
		if ($ok === false) {
540
		if ($ok === false) {
517
			$this->ajouterMessage("L'archivage des métadonnées a échoué.");
541
			$this->ajouterMessage("L'archivage des métadonnées a échoué.");
518
		}
542
		}
519
	}
543
	}
520
	
544
	
521
	private function nettoyerMemoire() {
545
	private function nettoyerMemoire() {
522
		$this->noms = null;
546
		$this->noms = null;
523
		$this->noms_precedents = null;
547
		$this->noms_precedents = null;
524
		$this->noms_stat = null; 
548
		$this->noms_stat = null; 
525
	}
549
	}
526
	
550
	
527
	private function copierManuel() {
551
	private function copierManuel() {
528
		$fichier_source = $this->manuel_chemin.$this->manuel_nom;
552
		$fichier_source = $this->manuel_chemin.$this->manuel_nom;
529
		$fichiers_destination[] = $this->zip_chemin_dossier.$this->manuel_nom;
553
		$fichiers_destination[] = $this->zip_chemin_dossier.$this->manuel_nom;
530
		$fichiers_destination[] = $this->zip_chemin_dossier_partiel.$this->manuel_nom;
554
		$fichiers_destination[] = $this->zip_chemin_dossier_partiel.$this->manuel_nom;
531
		foreach ($fichiers_destination as $destination) {
555
		foreach ($fichiers_destination as $destination) {
532
			if (copy($fichier_source, $destination) === false) {
556
			if (copy($fichier_source, $destination) === false) {
533
				$this->ajouterMessage("La copie du manuel vers '$destination' a échouée.");
557
				$this->ajouterMessage("La copie du manuel vers '$destination' a échouée.");
534
			}
558
			}
535
		}
559
		}
536
	}
560
	}
537
	
561
	
538
	private function creerFichiersZip() {
562
	private function creerFichiersZip() {
539
		$this->zipper($this->zip_chemin_fichier, $this->zip_chemin_dossier);
563
		$this->zipper($this->zip_chemin_fichier, $this->zip_chemin_dossier);
540
		$this->zipper($this->zip_chemin_fichier_partiel, $this->zip_chemin_dossier_partiel);
564
		$this->zipper($this->zip_chemin_fichier_partiel, $this->zip_chemin_dossier_partiel);
541
	}
565
	}
542
	
566
	
543
	private function zipper($fichier_zip, $dossier_a_zipper) {
567
	private function zipper($fichier_zip, $dossier_a_zipper) {
544
		$zip = new PclZip($fichier_zip);
568
		$zip = new PclZip($fichier_zip);
545
		if ($zip->add($dossier_a_zipper, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
569
		if ($zip->add($dossier_a_zipper, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
546
			$e = "La création du fichier zip '$fichier_zip' a échoué avec l'erreur : ".$zip->errorInfo(true);
570
			$e = "La création du fichier zip '$fichier_zip' a échoué avec l'erreur : ".$zip->errorInfo(true);
547
			$this->ajouterMessage($e);
571
			$this->ajouterMessage($e);
548
		}
572
		}
549
	}
573
	}
550
	
574
	
551
	private function nettoyerFichiers() {
575
	private function nettoyerFichiers() {
552
		Fichier::supprimerDossier($this->zip_chemin_dossier);
576
		Fichier::supprimerDossier($this->zip_chemin_dossier);
553
		Fichier::supprimerDossier($this->zip_chemin_dossier_partiel);
577
		Fichier::supprimerDossier($this->zip_chemin_dossier_partiel);
554
	}
578
	}
555
	
579
	
556
	private function traiterMessages() {
580
	private function traiterMessages() {
557
		if (isset($this->messages)) {
581
		if (isset($this->messages)) {
558
			$num_message = 1;
582
			$num_message = 1;
559
			foreach ($this->messages as $message) {
583
			foreach ($this->messages as $message) {
560
				$message['nom'] = 'Message #'.$num_message++;
584
				$message['nom'] = 'Message #'.$num_message++;
561
				$this->resultatDao->ajouter($this->traitement['id_traitement'], $message);
585
				$this->resultatDao->ajouter($this->traitement['id_traitement'], $message);
562
			}
586
			}
563
		}
587
		}
564
	}
588
	}
565
}
589
}
566
?>
590
?>