Subversion Repositories Applications.referentiel

Rev

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

Rev 51 Rev 54
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 : 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 Versionnage extends ScriptCommande {
19
class Versionnage extends ScriptCommande {
20
	
20
	
21
	const SCRIPT_NOM = 'versionnage';
21
	const SCRIPT_NOM = 'versionnage';
22
	
22
	
23
	private $projet = null;
23
	private $projet = null;
24
	private $traitement = null;
24
	private $traitement = null;
25
	private $meta = null;
25
	private $meta = null;
26
	private $messages = null;
26
	private $messages = null;
27
	private $manuel = null;
27
	private $manuel = null;
28
	private $noms = null;
28
	private $noms = null;
29
	private $noms_precedents = null;
29
	private $noms_precedents = null;
30
	private $noms_stat = null;
30
	private $noms_stat = null;
31
	private $champs_ordre = null;
31
	private $champs_ordre = null;
32
	private $champs_nom = null;
32
	private $champs_nom = null;
33
	private $diff_modif_types = null;
33
	private $diff_modif_types = null;
34
	private $signature_md5 = null;
34
	private $signature_md5 = null;
35
	
35
	
36
	private $resultatDao = null;
36
	private $resultatDao = null;
37
	private $traitementDao = null;
37
	private $traitementDao = null;
38
	private $metaDao = null;
38
	private $metaDao = null;
39
	private $tableStructureDao = null;
39
	private $tableStructureDao = null;
40
	private $referentielDao = null;
40
	private $referentielDao = null;
41
	
41
	
42
	public function executer() {
42
	public function executer() {
43
		// Récupération de paramêtres
43
		// Récupération de paramêtres
44
		$this->projet = $this->getParam('p');
44
		$this->projet = $this->getParam('p');
45
		
45
		
46
		// Récupération du dernier traitement demandé
46
		// Récupération du dernier traitement demandé
47
		$this->traitementDao = new TraitementDao();
47
		$this->traitementDao = new TraitementDao();
48
		$this->traitement = $this->traitementDao->getDernierTraitement($this->projet, self::SCRIPT_NOM);
48
		$this->traitement = $this->traitementDao->getDernierTraitement($this->projet, self::SCRIPT_NOM);
49
		if (isset($this->traitement)) {
49
		if (isset($this->traitement)) {
50
			Debug::printr($this->traitement);
50
			Debug::printr($this->traitement);
51
			// Écriture de la date de début du traitement
51
			// Écriture de la date de début du traitement
52
			Debug::printr('Debute:'.$this->traitementDao->debuterTraitement($this->traitement['id_traitement']));
52
			Debug::printr('Debute:'.$this->traitementDao->debuterTraitement($this->traitement['id_traitement']));
53
			
53
			
54
			// Nettoyage des traitements obsolètes
54
			// Nettoyage des traitements obsolètes
55
			$traitements_obsoletes = $this->traitementDao->getTraitementsObsoletes($this->projet, self::SCRIPT_NOM);
55
			$traitements_obsoletes = $this->traitementDao->getTraitementsObsoletes($this->projet, self::SCRIPT_NOM);
56
			if (isset($traitements_obsoletes)) {
56
			if (isset($traitements_obsoletes)) {
57
				Debug::printr('Supp. obsoletes:'.$this->traitementDao->supprimer($traitements_obsoletes));
57
				Debug::printr('Supp. obsoletes:'.$this->traitementDao->supprimer($traitements_obsoletes));
58
			}
58
			}
59
			
59
			
60
			// Lancement du test demandé
60
			// Lancement du test demandé
61
			$cmd = $this->getParam('a');
61
			$cmd = $this->getParam('a');
62
	    	switch ($cmd) {
62
	    	switch ($cmd) {
63
				case 'tout' :
63
				case 'tout' :
64
					$this->metaDao = new MetaDao();
64
					$this->metaDao = new MetaDao();
65
					$this->resultatDao = new ResultatDao();
65
					$this->resultatDao = new ResultatDao();
66
					$this->referentielDao = new ReferentielDao();
66
					$this->referentielDao = new ReferentielDao();
67
					$this->manuel = parse_ini_file(Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS.'referentiel_v2.1.ini');
67
					$this->manuel = parse_ini_file(Config::get('chemin_appli').DS.'..'.DS.'configurations'.DS.'referentiel_v2.1.ini');
68
					Debug::printr('Départ lancement versionnage:');
68
					Debug::printr('Départ lancement versionnage:');
69
					$this->lancerVersionnage();
69
					$this->lancerVersionnage();
70
					break;
70
					break;
71
				default :
71
				default :
72
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
72
					$this->traiterErreur('Erreur : la commande "%s" n\'existe pas!', array($cmd));
73
			}
73
			}
74
			// Écriture de la date de fin du traitement
74
			// Écriture de la date de fin du traitement
75
			Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
75
			Debug::printr('Termine:'.$this->traitementDao->terminerTraitement($this->traitement['id_traitement']));
76
		}
76
		}
77
    }
77
    }
78
 
78
 
79
    public function lancerVersionnage() {
79
    public function lancerVersionnage() {
80
		$this->chargerTraitementParametre();
80
		$this->chargerTraitementParametre();
81
		$this->archiver();
81
		$this->archiver();
82
    	$this->chargerNomsATraiter();
82
    	$this->chargerNomsATraiter();
83
    	$this->analyserNomsATraiter();
83
    	$this->analyserNomsATraiter();
84
		$this->creerFichiers();
84
		$this->creerFichiers();
85
		$this->traiterMessages();
85
		$this->traiterMessages();
86
	}
86
	}
87
	
87
	
88
	private function chargerTraitementParametre() {
88
	private function chargerTraitementParametre() {
89
		$this->meta = unserialize($this->traitement['script_parametres']);
89
		$this->meta = unserialize($this->traitement['script_parametres']);
90
	}
90
	}
91
	
91
	
92
	private function archiver() {
92
	private function archiver() {
93
		$ok = $this->referentielDao->archiver($this->projet, $this->meta['version']);
93
		$ok = $this->referentielDao->archiver($this->projet, $this->meta['version']);
94
		if ($ok) {
94
		if ($ok) {
95
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a réussi";
95
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a réussi";
96
			$this->ajouterMessage($m);
96
			$this->ajouterMessage($m);
97
		} else {
97
		} else {
98
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a échoué";
98
			$m = "L'archivage de la version '{$this->meta['version']}' du référentiel '{$this->projet}' a échoué";
99
			$this->ajouterMessage($m);
99
			$this->ajouterMessage($m);
100
		}
100
		}
101
	}
101
	}
102
	
102
	
103
	private function chargerNomsATraiter() {
103
	private function chargerNomsATraiter() {
104
		$archive_courante = strtolower($this->projet).'_v'.str_replace('.', '_', $this->meta['version']);
104
		$archive_courante = strtolower($this->projet).'_v'.str_replace('.', '_', $this->meta['version']);
105
		Debug::printr("Nom archive courante :".$archive_courante);
105
		Debug::printr("Nom archive courante :".$archive_courante);
106
		$this->noms = $this->referentielDao->getTout($archive_courante);
106
		$this->noms = $this->referentielDao->getTout($archive_courante);
107
	}
107
	}
108
	
108
	
109
	private function analyserNomsATraiter() {
109
	private function analyserNomsATraiter() {
110
		$this->noms_stat['combinaison'] = $this->getNombreCombinaison();
110
		$this->noms_stat['combinaison'] = $this->getNombreCombinaison();
111
		$this->noms_stat['taxon'] = $this->getNombreTaxon();
111
		$this->noms_stat['taxon'] = $this->getNombreTaxon();
112
		Debug::printr("Stats :".print_r($this->noms_stat, true));
112
		Debug::printr("Stats :".print_r($this->noms_stat, true));
113
	}
113
	}
114
	
114
	
115
	private function getNombreCombinaison() {
115
	private function getNombreCombinaison() {
116
		return count($this->noms);
116
		return count($this->noms);
117
	}
117
	}
118
	
118
	
119
	private function getNombreTaxon() {
119
	private function getNombreTaxon() {
120
		$nbre = 0;
120
		$nbre = 0;
121
		foreach ($this->noms as $nom) {
121
		foreach ($this->noms as $nom) {
122
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
122
			if ($nom['num_nom_retenu'] == $nom['num_nom']) {
123
				$nbre++;
123
				$nbre++;
124
			}
124
			}
125
		}
125
		}
126
		return $nbre;
126
		return $nbre;
127
	}
127
	}
128
	
128
	
129
	private function creerFichiers() {
129
	private function creerFichiers() {
130
		// Respecter l'ordre de traitement : BDNT puis DIFF puis META
130
		// Respecter l'ordre de traitement : BDNT puis DIFF puis META
131
		$this->creerFichierBdnt();
131
		$this->creerFichierBdnt();
132
		$this->creerFichierDiff();
132
		$this->creerFichierDiff();
133
		$this->creerFichierMeta();
133
		$this->creerFichierMeta();
134
	}
134
	}
135
	
135
	
136
	private function creerFichierBdnt() {
136
	private function creerFichierBdnt() {
-
 
137
		$noms =& $this->noms;
137
		Debug::printr("Element courrant du tableau des noms : ".print_r(current($this->noms),true));
138
		reset($this->noms);
138
		//Debug::printr("Taille mémoire du tableau des noms : ".Debug::tailleMemoireVar($this->noms));
139
		Debug::printr("Element courrant du tableau des noms : ".count($this->noms).'-'.print_r(current($this->noms),true));
-
 
140
		
139
		$this->determinerOrdreDesChamps();
141
		$this->determinerOrdreDesChamps();
140
		$this->definirNomDesChamps();
142
		$this->definirNomDesChamps();
141
		
143
		
142
		$donnees = array();
144
		$donnees = array();
143
		$donnees['champs'] = $this->champs_nom;
145
		$donnees['champs'] = $this->champs_nom;
144
		foreach ($this->noms as &$nom) {
146
		foreach ($this->noms as &$nom) {
145
			$infos = array();
147
			$infos = array();
146
			foreach ($nom as $champ => &$valeur) {
148
			foreach ($nom as $champ => &$valeur) {
147
				if (isset($this->champs_ordre[$champ])) {
149
				if (isset($this->champs_ordre[$champ])) {
148
					$ordre = $this->champs_ordre[$champ];
150
					$ordre = $this->champs_ordre[$champ];
149
					$infos[$ordre] = trim($valeur);
151
					$infos[(int) $ordre] = trim($valeur);
150
				} else {
152
				} else {
151
					$e = "Le champ '$champ' n'a pas été pris en compte dans l'attribution de l'ordre des champs.";
153
					$e = "Le champ '$champ' n'a pas été pris en compte dans l'attribution de l'ordre des champs.";
152
					$this->ajouterMessage($e);
154
					$this->ajouterMessage($e);
153
				}
155
				}
154
			}
156
			}
-
 
157
			ksort($infos);
155
			$donnees['noms'][] = $infos;
158
			$donnees['noms'][] = $infos;
156
		}
159
		}
157
		
-
 
-
 
160
		Debug::printr("Dernier element du tableau des noms [trié] : ".print_r($infos,true));
158
		$bdnt_tsv = $this->getVue('versionnage/squelettes/bdnt', $donnees, '.tpl.tsv');
161
		$bdnt_tsv = $this->getVue('versionnage/squelettes/bdnt', $donnees, '.tpl.tsv');
159
		$this->ecrireFichierBdnt($bdnt_tsv);
162
		$this->ecrireFichierBdnt($bdnt_tsv);
160
	}
163
	}
161
	
164
	
162
	private function determinerOrdreDesChamps() {
165
	private function determinerOrdreDesChamps() {
163
		$champs_ordre = explode(',', $this->manuel['champs']);
166
		$champs_ordre = explode(',', $this->manuel['champs']);
164
		$champs_ordre = array_flip($champs_ordre);
167
		$champs_ordre = array_flip($champs_ordre);
165
		$nom_courant = current($this->noms);
168
		$nom_courant = current($this->noms);
166
		$champs_ordre = $this->attribuerOrdreChampsSupplémentaires($champs_ordre, $nom_courant);
169
		$champs_ordre = $this->attribuerOrdreChampsSupplémentaires($champs_ordre, $nom_courant);
167
		asort($champs_ordre);
170
		asort($champs_ordre);
168
		$this->champs_ordre = $champs_ordre;
171
		$this->champs_ordre = $champs_ordre;
-
 
172
		Debug::printr("Ordre des champs : ".print_r($this->champs_ordre,true));
169
	}
173
	}
170
	
174
	
171
	private function definirNomDesChamps() {
175
	private function definirNomDesChamps() {
172
		$this->champs_nom = array_flip($this->champs_ordre);
176
		$this->champs_nom = array_flip($this->champs_ordre);
173
	}
177
	}
174
	
178
	
175
	private function attribuerOrdreChampsSupplémentaires($champs_ordre, $nom) {
179
	private function attribuerOrdreChampsSupplémentaires($champs_ordre, $nom) {
176
		foreach ($nom as $champ => $info) {
180
		foreach ($nom as $champ => $info) {
177
			if (!isset($champs_ordre[$champ])) {
181
			if (!isset($champs_ordre[$champ])) {
178
				$champs_ordre[$champ] = count($champs_ordre);
182
				$champs_ordre[$champ] = count($champs_ordre);
179
			}
183
			}
180
		}
184
		}
181
		return $champs_ordre;
185
		return $champs_ordre;
182
	}
186
	}
183
	
187
	
184
	private function ajouterMessage($message) {
188
	private function ajouterMessage($message) {
185
		$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
189
		$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
186
		$this->messages[] = array($titre, $message);
190
		$this->messages[] = array('message' => $message, 'resultat' => true);
187
	}
191
	}
188
	
192
	
189
	private function ecrireFichierBdnt($contenu) {
193
	private function ecrireFichierBdnt($contenu) {
190
		$fichier_nom = $this->getBaseNomFichier().'_ref.txt';
194
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_ref'];
191
		$fichier_chemin = Config::get('chemin_referentiel_zip').$fichier_nom;
195
		$fichier_chemin = Config::get('chemin_referentiel_zip').$fichier_nom;
192
		
196
		
193
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
197
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
194
			$this->ajouterMessage("Écriture du fichier bdnt réussie.");
198
			$this->ajouterMessage("Écriture du fichier bdnt réussie.");
195
			$this->signature_md5 = md5_file($fichier_chemin);
199
			$this->signature_md5 = md5_file($fichier_chemin);
196
			$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
200
			$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
197
			$this->ajouterMessage("Nombre de noms traités : ".count($noms));
201
			$this->ajouterMessage("Nombre de combinaisons traités : ".$this->noms_stat['combinaison']);
198
			
-
 
199
		}
202
		}
200
	}
203
	}
201
	
204
	
202
	private function getBaseNomFichier() {
205
	private function getBaseNomFichier() {
203
		return strtolower($this->meta['acronyme'].'_v'.$this->meta['version']);
206
		return strtolower($this->meta['acronyme'].'_v'.$this->meta['version']);
204
	}
207
	}
205
	
208
	
206
	private function ecrireFichier($fichier_chemin, $contenu) {
209
	private function ecrireFichier($fichier_chemin, $contenu) {
207
		$retour = true;
210
		$retour = true;
208
		if (file_put_contents($fichier_chemin, $contenu) == false) {
211
		if (file_put_contents($fichier_chemin, $contenu) == false) {
209
			$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
212
			$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
210
			$this->ajouterMessage($e);
213
			$this->ajouterMessage($e);
211
			$retour = false;
214
			$retour = false;
212
		}
215
		}
213
		return $retour;
216
		return $retour;
214
	}
217
	}
215
	
218
	
216
	private function creerFichierDiff() {
219
	private function creerFichierDiff() {
217
		$derniere_meta = $this->metaDao->getDerniere($this->projet);
220
		$derniere_meta = $this->metaDao->getDerniere($this->projet);
218
		if ($derniere_meta === false) {
221
		if (is_null($derniere_meta === false)) {
-
 
222
			$this->ajouterMessage("Un problème est survenu lors de la récupération des métadonnées précédentes.");
-
 
223
		} else if (is_null($derniere_meta)) {
219
			$this->ajouterMessage("Premier versionnage pour ce projet, aucun fichier différentiel ne sera créé.");
224
			$this->ajouterMessage("Premier versionnage pour ce projet, aucun fichier différentiel ne sera créé.");
220
		} else {
225
		} else {
-
 
226
			Debug::printr("Méta dernier enregistrement : ".print_r($derniere_meta,true));
221
			$code_projet_precedent = strtolower($derniere_meta['code']).'_v'.str_replace('.', '_', $derniere_meta['version']);
227
			$code_projet_precedent = strtolower($derniere_meta['code']).'_v'.str_replace('.', '_', $derniere_meta['version']);
-
 
228
			Debug::printr("Code projet précédent : $code_projet_precedent");
222
			$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
229
			$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
223
			$donnees = array();
230
			$donnees = array();
224
			$donnees['diff'] = $this->realiserDiff();
231
			$donnees['diff'] = $this->realiserDiff();
225
			$donnees['champs'] = $this->champs_nom;
232
			$donnees['champs'] = $this->champs_nom;
226
			$diff_tsv = $this->getVue('versionnage/squelettes/diff', $donnees, '.tpl.tsv');
233
			$diff_tsv = $this->getVue('versionnage/squelettes/diff', $donnees, '.tpl.tsv');
227
			$this->ecrireFichierDiff($diff_tsv);
234
			$this->ecrireFichierDiff($diff_tsv);
228
		}
235
		}
229
	}
236
	}
230
	
237
	
231
	private function realiserDiff() {
238
	private function realiserDiff() {
232
		$diff = array();
239
		$diff = array();
233
		$this->noms_stat['modification'] = 0;
240
		$this->noms_stat['modification'] = 0;
234
		foreach ($this->noms as $id => &$nom) {
241
		foreach ($this->noms as $id => &$nom) {
235
			if (!isset($this->noms_precedents[$id])) {
242
			if (!isset($this->noms_precedents[$id])) {
236
				$diff[$id] = $nom;
243
				$diff[$id] = $nom;
237
				$diff[$id]['modification_type'] = 'A';
244
				$diff[$id]['modification_type'] = 'A';
238
				$diff[$id]['modification_type_1'] = '0';
245
				$diff[$id]['modification_type_1'] = '0';
239
				$diff[$id]['modification_type_2'] = '0';
246
				$diff[$id]['modification_type_2'] = '0';
240
				$diff[$id]['modification_type_3'] = '0';
247
				$diff[$id]['modification_type_3'] = '0';
241
				$this->noms_stat['modification']++;
248
				$this->noms_stat['modification']++;
242
			} else {
249
			} else {
243
				$nom_precedent =& $this->noms_precedents[$id];
250
				$nom_precedent =& $this->noms_precedents[$id];
244
				$nom_diff = array_diff_assoc($noms, $nom_precedent);
251
				$nom_diff = array_diff_assoc($nom, $nom_precedent);
245
				if (count($nom_diff) > 0) {
252
				if (count($nom_diff) > 0) {
246
					$this->noms_stat['modification']++;
253
					$this->noms_stat['modification']++;
247
					$modif['modification_type'] = 'M';
254
					$modif['modification_type'] = 'M';
248
					$modif['modification_type_1'] = '0';
255
					$modif['modification_type_1'] = '0';
249
					$modif['modification_type_2'] = '0';
256
					$modif['modification_type_2'] = '0';
250
					$modif['modification_type_3'] = '0';
257
					$modif['modification_type_3'] = '0';
251
					$this->chargerTableauChampsModifTypes();
258
					$this->chargerTableauChampsModifTypes();
252
					foreach ($this->champs_nom as $champ) {
259
					foreach ($this->champs_nom as $champ) {
253
						if (isset($nom_diff[$champ])) {
260
						if (isset($nom_diff[$champ])) {
254
							$diff[$id][$champ] = $nom_diff[$champ];
261
							$diff[$id][$champ] = $nom_diff[$champ];
255
							$type = $this->getDiffType($champ);
262
							$type = $this->getDiffType($champ);
256
							$modif['modification_type_'.$type] = '1';
263
							$modif['modification_type_'.$type] = '1';
257
						} else {
264
						} else {
258
							$diff[$id][$champ] = '';
265
							$diff[$id][$champ] = '';
259
						}
266
						}
260
					}
267
					}
261
					foreach ($modif as $cle => $val) {
268
					foreach ($modif as $cle => $val) {
262
						$diff[$id][$cle] = $val;
269
						$diff[$id][$cle] = $val;
263
					}
270
					}
264
				}
271
				}
265
			}
272
			}
266
		}
273
		}
267
		return $diff;
274
		return $diff;
268
	}
275
	}
269
	
276
	
270
	private function chargerTableauChampsModifTypes() {
277
	private function chargerTableauChampsModifTypes() {
271
		$champs = explode(',', $this->manuel['champs_diff_type']);
278
		$champs = explode(',', $this->manuel['champs_diff_type']);
272
		foreach ($champs as $champ) {
279
		foreach ($champs as $champ) {
273
			list($champ_nom, $type) = explode('=', $champ);
280
			list($champ_nom, $type) = explode('=', $champ);
274
			$this->diff_modif_types[$champ_nom] = $type;
281
			$this->diff_modif_types[$champ_nom] = $type;
275
		}
282
		}
276
	}
283
	}
277
	
284
	
278
	private function getDiffType($champ_nom) {
285
	private function getDiffType($champ_nom) {
279
		$type = isset($this->diff_modif_types[$champ_nom]) ? $this->diff_modif_types[$champ_nom] : '3';
286
		$type = isset($this->diff_modif_types[$champ_nom]) ? $this->diff_modif_types[$champ_nom] : '3';
280
		return $type;
287
		return $type;
281
	}
288
	}
282
	
289
	
283
	private function ecrireFichierDiff($contenu) {
290
	private function ecrireFichierDiff($contenu) {
284
		$fichier_nom = $this->getBaseNomFichier().'diff.txt';
291
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
285
		$fichier_chemin = Config::get('chemin_referentiel_zip').$fichier_nom;
292
		$fichier_chemin = Config::get('chemin_referentiel_zip').$fichier_nom;
286
		
293
		
287
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
294
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
288
			$this->ajouterMessage("Écriture du fichier diff réussie.");
295
			$this->ajouterMessage("Écriture du fichier diff réussie.");
289
		}
296
		}
290
	}
297
	}
291
	
298
	
292
	private function creerFichierMeta() {
299
	private function creerFichierMeta() {
293
		$donnees = array();
300
		$donnees = array();
294
		$donnees = $this->meta;
301
		$donnees = $this->meta;
295
		$donnees['stats'] = $this->noms_stat;
302
		$donnees['stats'] = $this->noms_stat;
296
		$donnees['signature'] = $this->signature_md5;
303
		$donnees['signature'] = $this->signature_md5;
297
		$meta_tsv = $this->getVue('versionnage/squelettes/meta', $donnees, '.tpl.tsv');
304
		$meta_tsv = $this->getVue('versionnage/squelettes/meta', $donnees, '.tpl.tsv');
298
		$this->ecrireFichierMeta($meta_tsv);
305
		$this->ecrireFichierMeta($meta_tsv);
299
	}
306
	}
300
	
307
	
301
	private function ecrireFichierMeta($contenu) {
308
	private function ecrireFichierMeta($contenu) {
302
		$fichier_nom = $this->getBaseNomFichier().'_meta.txt';
309
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
303
		$fichier_chemin = Config::get('chemin_referentiel_zip').$fichier_nom;
310
		$fichier_chemin = Config::get('chemin_referentiel_zip').$fichier_nom;
304
		
311
		
305
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
312
		if ($this->ecrireFichier($fichier_chemin, $contenu)) {
306
			$this->ajouterMessage("Écriture du fichier meta réussie.");
313
			$this->ajouterMessage("Écriture du fichier meta réussie.");
307
			$this->archiverMetadonnees();
314
			$this->archiverMetadonnees();
308
		}
315
		}
309
	}
316
	}
310
	
317
	
311
	private function archiverMetadonnees() {
318
	private function archiverMetadonnees() {
312
		$metadonnees = $this->meta;
319
		$metadonnees = $this->meta;
313
		$metadonnees['code'] = $this->meta['acronyme'];
320
		$metadonnees['code'] = $this->meta['acronyme'];
314
		unset($metadonnees['acronyme']);
321
		unset($metadonnees['acronyme']);
315
		$metadonnees['domaine_taxo'] = $this->meta['dom_tax'];
322
		$metadonnees['domaine_taxo'] = $this->meta['dom_tax'];
316
		unset($metadonnees['dom_tax']);
323
		unset($metadonnees['dom_tax']);
317
		$metadonnees['domaine_geo'] = $this->meta['dom_geo'];
324
		$metadonnees['domaine_geo'] = $this->meta['dom_geo'];
318
		unset($metadonnees['dom_geo']);
325
		unset($metadonnees['dom_geo']);
319
		$metadonnees['domaine_nom'] = $this->meta['dom_code'];
326
		$metadonnees['domaine_nom'] = $this->meta['dom_code'];
320
		unset($metadonnees['dom_code']);
327
		unset($metadonnees['dom_code']);
321
		$metadonnees['auteur'] = $this->meta['auteur_principal'];
328
		$metadonnees['auteur'] = $this->meta['auteur_principal'];
322
		unset($metadonnees['auteur_principal']);
329
		unset($metadonnees['auteur_principal']);
323
		$metadonnees['date_production'] = $this->meta['date_prod'];
330
		$metadonnees['date_production'] = $this->meta['date_prod'];
324
		unset($metadonnees['date_prod']);
331
		unset($metadonnees['date_prod']);
325
		$metadonnees['droit'] = $this->meta['copyright'];
332
		$metadonnees['droit'] = $this->meta['copyright'];
326
		unset($metadonnees['copyright']);
333
		unset($metadonnees['copyright']);
327
		
334
		
328
		$ok = $this->metaDao->ajouter($metadonnees);
335
		$ok = $this->metaDao->ajouter($metadonnees);
329
		if ($ok === false) {
336
		if ($ok === false) {
330
			$this->ajouterMessage("L'archivage des métadonnées a échoué.");
337
			$this->ajouterMessage("L'archivage des métadonnées a échoué.");
331
		}
338
		}
332
	}
339
	}
333
	
340
	
334
	private function traiterMessages() {
341
	private function traiterMessages() {
335
		if (isset($this->messages)) {
342
		if (isset($this->messages)) {
-
 
343
			$num_message = 1;
336
			foreach ($this->messages as $message) {
344
			foreach ($this->messages as $message) {
-
 
345
				$message['nom'] = 'Message #'.$num_message++;
337
				$this->resultatDao->ajouter($this->traitement['id_traitement'], $message);
346
				$this->resultatDao->ajouter($this->traitement['id_traitement'], $message);
338
			}
347
			}
339
		}
348
		}
340
	}
349
	}
341
}
350
}
342
?>
351
?>