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 : utilisation de array_key_exists à la place de isset dans creerFichierBdnt() ????
|
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 = "2.1";
|
22 |
const MANUEL_VERSION = "4.1";
|
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 |
foreach ($this->noms as $id => &$nom) {
|
199 |
foreach ($this->noms as $id => &$nom) {
|
200 |
$infos = array();
|
200 |
$infos = array();
|
201 |
foreach ($this->champs_ordre as $champ => $ordre) {
|
201 |
foreach ($this->champs_ordre as $champ => $ordre) {
|
202 |
if (array_key_exists($champ, $nom)) {
|
202 |
if (array_key_exists($champ, $nom)) {
|
203 |
$infos[$champ] = trim($nom[$champ]);
|
203 |
$infos[$champ] = trim($nom[$champ]);
|
204 |
} else {
|
204 |
} else {
|
205 |
$e = "Le champ '$champ' n'a pas été trouvé dans les données du nom : $id.";
|
205 |
$e = "Le champ '$champ' n'a pas été trouvé dans les données du nom : $id.";
|
206 |
$this->ajouterMessage($e);
|
206 |
$this->ajouterMessage($e);
|
207 |
}
|
207 |
}
|
208 |
}
|
208 |
}
|
209 |
$infos = $this->remplacerTabulation($infos);
|
209 |
$infos = $this->remplacerTabulation($infos);
|
210 |
$infos = $this->remplacerSautsDeLigne($infos);
|
210 |
$infos = $this->remplacerSautsDeLigne($infos);
|
211 |
$donnees['noms'][$id] = $infos;
|
211 |
$donnees['noms'][$id] = $infos;
|
212 |
}
|
212 |
}
|
213 |
Debug::printr("Dernier element du tableau des noms [trié] : ".print_r($infos,true));
|
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');
|
214 |
$bdnt_tsv =& $this->getVue('versionnage/squelettes/bdnt', &$donnees, '.tpl.tsv');
|
215 |
$this->ecrireFichierBdnt($bdnt_tsv);
|
215 |
$this->ecrireFichierBdnt($bdnt_tsv);
|
216 |
return $donnees;
|
216 |
return $donnees;
|
217 |
}
|
217 |
}
|
218 |
|
218 |
|
219 |
private function determinerOrdreDesChamps() {
|
219 |
private function determinerOrdreDesChamps() {
|
220 |
$champs_ordre = explode(',', $this->manuel['champs']);
|
220 |
$champs_ordre = explode(',', $this->manuel['champs']);
|
221 |
$champs_ordre = array_flip($champs_ordre);
|
221 |
$champs_ordre = array_flip($champs_ordre);
|
222 |
$nom_courant = current($this->noms);
|
222 |
$nom_courant = current($this->noms);
|
223 |
$champs_ordre = $this->attribuerOrdreChampsSupplémentaires($champs_ordre, $nom_courant);
|
223 |
$champs_ordre = $this->attribuerOrdreChampsSupplémentaires($champs_ordre, $nom_courant);
|
224 |
asort($champs_ordre);
|
224 |
asort($champs_ordre);
|
225 |
$this->champs_ordre = $champs_ordre;
|
225 |
$this->champs_ordre = $champs_ordre;
|
226 |
Debug::printr("Ordre des champs : ".print_r($this->champs_ordre,true));
|
226 |
Debug::printr("Ordre des champs : ".print_r($this->champs_ordre,true));
|
227 |
}
|
227 |
}
|
228 |
|
228 |
|
229 |
private function attribuerOrdreChampsSupplémentaires($champs_ordre, $nom) {
|
229 |
private function attribuerOrdreChampsSupplémentaires($champs_ordre, $nom) {
|
230 |
foreach ($nom as $champ => $info) {
|
230 |
foreach ($nom as $champ => $info) {
|
231 |
if (!isset($champs_ordre[$champ])) {
|
231 |
if (!isset($champs_ordre[$champ])) {
|
232 |
$champs_ordre[$champ] = count($champs_ordre);
|
232 |
$champs_ordre[$champ] = count($champs_ordre);
|
233 |
}
|
233 |
}
|
234 |
}
|
234 |
}
|
235 |
return $champs_ordre;
|
235 |
return $champs_ordre;
|
236 |
}
|
236 |
}
|
237 |
|
237 |
|
238 |
private function definirNomDesChamps() {
|
238 |
private function definirNomDesChamps() {
|
239 |
$this->champs_nom = array_flip($this->champs_ordre);
|
239 |
$this->champs_nom = array_flip($this->champs_ordre);
|
240 |
}
|
240 |
}
|
241 |
|
241 |
|
242 |
private function definirNomDesChampsDiff() {
|
242 |
private function definirNomDesChampsDiff() {
|
243 |
$this->champs_diff = explode(',', $this->manuel['champs_diff']);
|
243 |
$this->champs_diff = explode(',', $this->manuel['champs_diff']);
|
244 |
$this->diff_champs_nom = array_merge($this->champs_nom, $this->champs_diff);
|
244 |
$this->diff_champs_nom = array_merge($this->champs_nom, $this->champs_diff);
|
245 |
}
|
245 |
}
|
246 |
|
246 |
|
247 |
private function ajouterMessage($message) {
|
247 |
private function ajouterMessage($message) {
|
248 |
$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
|
248 |
$titre = self::SCRIPT_NOM.' #'.$this->traitement['id_traitement'];
|
249 |
$this->messages[] = array('message' => $message, 'resultat' => true);
|
249 |
$this->messages[] = array('message' => $message, 'resultat' => true);
|
250 |
}
|
250 |
}
|
251 |
|
251 |
|
252 |
private function remplacerTabulation($doc) {
|
252 |
private function remplacerTabulation($doc) {
|
253 |
if (is_string($doc)) {
|
253 |
if (is_string($doc)) {
|
254 |
$doc = str_replace("\t", ' ', $doc);
|
254 |
$doc = str_replace("\t", ' ', $doc);
|
255 |
} else if (is_array($doc) && count($doc) > 0) {
|
255 |
} else if (is_array($doc) && count($doc) > 0) {
|
256 |
foreach ($doc as $cle => $valeur) {
|
256 |
foreach ($doc as $cle => $valeur) {
|
257 |
$doc[$cle] = $this->remplacerTabulation($valeur);
|
257 |
$doc[$cle] = $this->remplacerTabulation($valeur);
|
258 |
}
|
258 |
}
|
259 |
}
|
259 |
}
|
260 |
return $doc;
|
260 |
return $doc;
|
261 |
}
|
261 |
}
|
262 |
|
262 |
|
263 |
private function remplacerSautsDeLigne($doc) {
|
263 |
private function remplacerSautsDeLigne($doc) {
|
264 |
if (is_string($doc)) {
|
264 |
if (is_string($doc)) {
|
265 |
$a_remplacer = array("\r", "\n");
|
265 |
$a_remplacer = array("\r", "\n");
|
266 |
$doc = str_replace($a_remplacer, ' ', $doc);
|
266 |
$doc = str_replace($a_remplacer, ' ', $doc);
|
267 |
} else if (is_array($doc) && count($doc) > 0) {
|
267 |
} else if (is_array($doc) && count($doc) > 0) {
|
268 |
foreach ($doc as $cle => $valeur) {
|
268 |
foreach ($doc as $cle => $valeur) {
|
269 |
$doc[$cle] = $this->remplacerSautsDeLigne($valeur);
|
269 |
$doc[$cle] = $this->remplacerSautsDeLigne($valeur);
|
270 |
}
|
270 |
}
|
271 |
}
|
271 |
}
|
272 |
return $doc;
|
272 |
return $doc;
|
273 |
}
|
273 |
}
|
274 |
|
274 |
|
275 |
private function ecrireFichierBdnt(&$contenu) {
|
275 |
private function ecrireFichierBdnt(&$contenu) {
|
276 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
276 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
277 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
277 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
278 |
|
278 |
|
279 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
279 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
280 |
$this->ajouterMessage("Écriture du fichier bdnt réussie.");
|
280 |
$this->ajouterMessage("Écriture du fichier bdnt réussie.");
|
281 |
$this->signature_md5 = md5_file($fichier_chemin);
|
281 |
$this->signature_md5 = md5_file($fichier_chemin);
|
282 |
$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
|
282 |
$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
|
283 |
$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
|
283 |
$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
|
284 |
}
|
284 |
}
|
285 |
}
|
285 |
}
|
286 |
|
286 |
|
287 |
private function getBaseNomFichier() {
|
287 |
private function getBaseNomFichier() {
|
288 |
return strtolower($this->meta['acronyme'].'_v'.$this->meta['version']);
|
288 |
return strtolower($this->meta['acronyme'].'_v'.$this->meta['version']);
|
289 |
}
|
289 |
}
|
290 |
|
290 |
|
291 |
private function creerFichierBdntPartiel(&$donnees) {
|
291 |
private function creerFichierBdntPartiel(&$donnees) {
|
292 |
$this->definirChampsPartiel();
|
292 |
$this->definirChampsPartiel();
|
293 |
Debug::printr(current($donnees['noms']));
|
293 |
Debug::printr(current($donnees['noms']));
|
294 |
$donnees['champs_partiel'] = $this->champs_nom_partiel;
|
294 |
$donnees['champs_partiel'] = $this->champs_nom_partiel;
|
295 |
$donnees['dernier_champ'] = end($this->champs_nom_partiel);
|
295 |
$donnees['dernier_champ'] = end($this->champs_nom_partiel);
|
296 |
$bdnt_partielle_tsv =& $this->getVue('versionnage/squelettes/bdnt_partiel', &$donnees, '.tpl.tsv');
|
296 |
$bdnt_partielle_tsv =& $this->getVue('versionnage/squelettes/bdnt_partiel', &$donnees, '.tpl.tsv');
|
297 |
$this->ecrireFichierBdntPartielle($bdnt_partielle_tsv);
|
297 |
$this->ecrireFichierBdntPartielle($bdnt_partielle_tsv);
|
298 |
}
|
298 |
}
|
299 |
|
299 |
|
300 |
private function definirChampsPartiel() {
|
300 |
private function definirChampsPartiel() {
|
301 |
$this->champs_nom_partiel = explode(',', $this->manuel['champs_partiel']);
|
301 |
$this->champs_nom_partiel = explode(',', $this->manuel['champs_partiel']);
|
302 |
Debug::printr("Champs partiels : ".print_r($this->champs_nom_partiel,true));
|
302 |
Debug::printr("Champs partiels : ".print_r($this->champs_nom_partiel,true));
|
303 |
}
|
303 |
}
|
304 |
|
304 |
|
305 |
private function ecrireFichierBdntPartielle(&$contenu) {
|
305 |
private function ecrireFichierBdntPartielle(&$contenu) {
|
306 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
306 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
307 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
307 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
308 |
|
308 |
|
309 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
309 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
310 |
$this->ajouterMessage("Écriture du fichier de la bdnt partielle réussie.");
|
310 |
$this->ajouterMessage("Écriture du fichier de la bdnt partielle réussie.");
|
311 |
$this->signature_md5_partiel = md5_file($fichier_chemin);
|
311 |
$this->signature_md5_partiel = md5_file($fichier_chemin);
|
312 |
$this->ajouterMessage("Signature MD5 du fichier bdnt partiel :".$this->signature_md5_partiel);
|
312 |
$this->ajouterMessage("Signature MD5 du fichier bdnt partiel :".$this->signature_md5_partiel);
|
313 |
$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
|
313 |
$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
|
314 |
}
|
314 |
}
|
315 |
}
|
315 |
}
|
316 |
|
316 |
|
317 |
private function ecrireFichier($fichier_chemin, &$contenu) {
|
317 |
private function ecrireFichier($fichier_chemin, &$contenu) {
|
318 |
$retour = true;
|
318 |
$retour = true;
|
319 |
if (file_put_contents($fichier_chemin, $contenu) == false) {
|
319 |
if (file_put_contents($fichier_chemin, $contenu) == false) {
|
320 |
$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
|
320 |
$e = "Une erreur est survenu lors de l'écriture du fichier : $fichier_chemin";
|
321 |
$this->ajouterMessage($e);
|
321 |
$this->ajouterMessage($e);
|
322 |
$retour = false;
|
322 |
$retour = false;
|
323 |
}
|
323 |
}
|
324 |
$contenu = null;
|
324 |
$contenu = null;
|
325 |
return $retour;
|
325 |
return $retour;
|
326 |
}
|
326 |
}
|
327 |
|
327 |
|
328 |
private function creerFichierDiff() {
|
328 |
private function creerFichierDiff() {
|
329 |
$donnees = array();
|
329 |
$donnees = array();
|
330 |
$derniere_meta = $this->metaDao->getDerniere($this->projet);
|
330 |
$derniere_meta = $this->metaDao->getDerniere($this->projet);
|
331 |
if (is_null($derniere_meta === false)) {
|
331 |
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.");
|
332 |
$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)) {
|
333 |
} else if (is_null($derniere_meta)) {
|
334 |
$this->ajouterMessage("Premier versionnage pour ce projet, aucun fichier différentiel ne sera créé.");
|
334 |
$this->ajouterMessage("Premier versionnage pour ce projet, aucun fichier différentiel ne sera créé.");
|
335 |
} else {
|
335 |
} else {
|
336 |
$code_projet_precedent = strtolower($derniere_meta['code']).'_v'.str_replace('.', '_', $derniere_meta['version']);
|
336 |
$code_projet_precedent = strtolower($derniere_meta['code']).'_v'.str_replace('.', '_', $derniere_meta['version']);
|
337 |
if ($code_projet_precedent == $this->version_courante) {
|
337 |
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 ".
|
338 |
$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éé.";
|
339 |
"de la demande actuel ({$this->version_courante}) pour ce projet, aucun fichier différentiel ne sera créé.";
|
340 |
$this->ajouterMessage($e);
|
340 |
$this->ajouterMessage($e);
|
341 |
} else {
|
341 |
} else {
|
342 |
$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
|
342 |
$this->noms_precedents = $this->referentielDao->getTout($code_projet_precedent);
|
343 |
$donnees['diff'] = $this->realiserDiff();
|
343 |
$donnees['diff'] = $this->realiserDiff();
|
344 |
$donnees['champs'] = $this->diff_champs_nom;
|
344 |
$donnees['champs'] = $this->diff_champs_nom;
|
345 |
$diff_tsv =& $this->getVue('versionnage/squelettes/diff', &$donnees, '.tpl.tsv');
|
345 |
$diff_tsv =& $this->getVue('versionnage/squelettes/diff', &$donnees, '.tpl.tsv');
|
346 |
$this->ecrireFichierDiff($diff_tsv);
|
346 |
$this->ecrireFichierDiff($diff_tsv);
|
347 |
}
|
347 |
}
|
348 |
}
|
348 |
}
|
349 |
return $donnees;
|
349 |
return $donnees;
|
350 |
}
|
350 |
}
|
351 |
|
351 |
|
352 |
private function realiserDiff() {
|
352 |
private function realiserDiff() {
|
353 |
$this->chargerTableauChampsModifTypes();
|
353 |
$this->chargerTableauChampsModifTypes();
|
354 |
$this->noms_stat['modification'] = 0;
|
354 |
$this->noms_stat['modification'] = 0;
|
355 |
|
355 |
|
356 |
$diff = array();
|
356 |
$diff = array();
|
357 |
foreach ($this->noms as $id => $nom) {
|
357 |
foreach ($this->noms as $id => $nom) {
|
358 |
$this->noms[$id] = null;
|
358 |
$this->noms[$id] = null;
|
359 |
$infos = array();
|
359 |
$infos = array();
|
360 |
if (!isset($this->noms_precedents[$id])) {
|
360 |
if (!isset($this->noms_precedents[$id])) {
|
361 |
$infos = $this->traiterDiffAjout($nom);
|
361 |
$infos = $this->traiterDiffAjout($nom);
|
362 |
} else {
|
362 |
} else {
|
363 |
$nom_precedent = $this->noms_precedents[$id];
|
363 |
$nom_precedent = $this->noms_precedents[$id];
|
364 |
$this->noms_precedents[$id] = null;
|
364 |
$this->noms_precedents[$id] = null;
|
365 |
$infos = $this->traiterDiffModif($nom, $nom_precedent);
|
365 |
$infos = $this->traiterDiffModif($nom, $nom_precedent);
|
366 |
}
|
366 |
}
|
367 |
|
367 |
|
368 |
if (count($infos) > 0) {
|
368 |
if (count($infos) > 0) {
|
369 |
$infos = $this->remplacerTabulation($infos);
|
369 |
$infos = $this->remplacerTabulation($infos);
|
370 |
$infos = $this->remplacerSautsDeLigne($infos);
|
370 |
$infos = $this->remplacerSautsDeLigne($infos);
|
371 |
$diff[$id] = $infos;
|
371 |
$diff[$id] = $infos;
|
372 |
}
|
372 |
}
|
373 |
}
|
373 |
}
|
374 |
return $diff;
|
374 |
return $diff;
|
375 |
}
|
375 |
}
|
376 |
|
376 |
|
377 |
private function traiterDiffAjout(&$nom) {
|
377 |
private function traiterDiffAjout(&$nom) {
|
378 |
$infos = $nom;
|
378 |
$infos = $nom;
|
379 |
$infos['modification_type'] = 'A';
|
379 |
$infos['modification_type'] = 'A';
|
380 |
$infos['modification_type_1'] = '0';
|
380 |
$infos['modification_type_1'] = '0';
|
381 |
$infos['modification_type_2'] = '0';
|
381 |
$infos['modification_type_2'] = '0';
|
382 |
$infos['modification_type_3'] = '0';
|
382 |
$infos['modification_type_3'] = '0';
|
383 |
$this->noms_stat['modification']++;
|
383 |
$this->noms_stat['modification']++;
|
384 |
return $infos;
|
384 |
return $infos;
|
385 |
}
|
385 |
}
|
386 |
|
386 |
|
387 |
private function traiterDiffModif(&$nom, &$nom_precedent) {
|
387 |
private function traiterDiffModif(&$nom, &$nom_precedent) {
|
388 |
$infos = array();
|
388 |
$infos = array();
|
389 |
$nom_diff = array_diff_assoc($nom, $nom_precedent); $bdnt_partielle_tsv = 'trest';
|
389 |
$nom_diff = array_diff_assoc($nom, $nom_precedent); $bdnt_partielle_tsv = 'trest';
|
390 |
if (count($nom_diff) > 0) {
|
390 |
if (count($nom_diff) > 0) {
|
391 |
$modif['modification_type'] = 'M';
|
391 |
$modif['modification_type'] = 'M';
|
392 |
$modif['modification_type_1'] = '0';
|
392 |
$modif['modification_type_1'] = '0';
|
393 |
$modif['modification_type_2'] = '0';
|
393 |
$modif['modification_type_2'] = '0';
|
394 |
$modif['modification_type_3'] = '0';
|
394 |
$modif['modification_type_3'] = '0';
|
395 |
|
395 |
|
396 |
foreach ($this->champs_nom as $champ) {
|
396 |
foreach ($this->champs_nom as $champ) {
|
397 |
if (isset($nom_diff[$champ])) {
|
397 |
if (isset($nom_diff[$champ])) {
|
398 |
$infos[$champ] = $nom_diff[$champ];
|
398 |
$infos[$champ] = $nom_diff[$champ];
|
399 |
$type = $this->getDiffType($champ);
|
399 |
$type = $this->getDiffType($champ);
|
400 |
$modif['modification_type_'.$type] = '1';
|
400 |
$modif['modification_type_'.$type] = '1';
|
401 |
} else {
|
401 |
} else {
|
402 |
if ($champ == 'num_nom') {
|
402 |
if ($champ == 'num_nom') {
|
403 |
$infos[$champ] = $nom[$champ];
|
403 |
$infos[$champ] = $nom[$champ];
|
404 |
} else {
|
404 |
} else {
|
405 |
$infos[$champ] = '';
|
405 |
$infos[$champ] = '';
|
406 |
}
|
406 |
}
|
407 |
}
|
407 |
}
|
408 |
}
|
408 |
}
|
409 |
|
409 |
|
410 |
foreach ($modif as $cle => $val) {
|
410 |
foreach ($modif as $cle => $val) {
|
411 |
$infos[$cle] = $val;
|
411 |
$infos[$cle] = $val;
|
412 |
}
|
412 |
}
|
413 |
|
413 |
|
414 |
$this->noms_stat['modification']++;
|
414 |
$this->noms_stat['modification']++;
|
415 |
}
|
415 |
}
|
416 |
return $infos;
|
416 |
return $infos;
|
417 |
}
|
417 |
}
|
418 |
|
418 |
|
419 |
private function chargerTableauChampsModifTypes() {
|
419 |
private function chargerTableauChampsModifTypes() {
|
420 |
$champs = explode(',', $this->manuel['champs_diff_type']);
|
420 |
$champs = explode(',', $this->manuel['champs_diff_type']);
|
421 |
foreach ($champs as $champ) {
|
421 |
foreach ($champs as $champ) {
|
422 |
list($champ_nom, $type) = explode('=', trim($champ));
|
422 |
list($champ_nom, $type) = explode('=', trim($champ));
|
423 |
$this->diff_modif_types[$champ_nom] = $type;
|
423 |
$this->diff_modif_types[$champ_nom] = $type;
|
424 |
}
|
424 |
}
|
425 |
}
|
425 |
}
|
426 |
|
426 |
|
427 |
private function getDiffType($champ_nom) {
|
427 |
private function getDiffType($champ_nom) {
|
428 |
$type = isset($this->diff_modif_types[$champ_nom]) ? $this->diff_modif_types[$champ_nom] : '3';
|
428 |
$type = isset($this->diff_modif_types[$champ_nom]) ? $this->diff_modif_types[$champ_nom] : '3';
|
429 |
return $type;
|
429 |
return $type;
|
430 |
}
|
430 |
}
|
431 |
|
431 |
|
432 |
private function ecrireFichierDiff(&$contenu) {
|
432 |
private function ecrireFichierDiff(&$contenu) {
|
433 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
|
433 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
|
434 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
434 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
435 |
|
435 |
|
436 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
436 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
437 |
$this->ajouterMessage("Écriture du fichier diff réussie.");
|
437 |
$this->ajouterMessage("Écriture du fichier diff réussie.");
|
438 |
}
|
438 |
}
|
439 |
}
|
439 |
}
|
440 |
|
440 |
|
441 |
private function creerFichierDiffPartiel(&$donnees) {
|
441 |
private function creerFichierDiffPartiel(&$donnees) {
|
442 |
if (count($donnees) > 0) {
|
442 |
if (count($donnees) > 0) {
|
443 |
$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
|
443 |
$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
|
444 |
$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
|
444 |
$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
|
445 |
$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
|
445 |
$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
|
446 |
$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
|
446 |
$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
|
447 |
}
|
447 |
}
|
448 |
}
|
448 |
}
|
449 |
|
449 |
|
450 |
private function ecrireFichierDiffPartiel(&$contenu) {
|
450 |
private function ecrireFichierDiffPartiel(&$contenu) {
|
451 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
|
451 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
|
452 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
452 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
453 |
|
453 |
|
454 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
454 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
455 |
$this->ajouterMessage("Écriture du fichier diff partiel réussie.");
|
455 |
$this->ajouterMessage("Écriture du fichier diff partiel réussie.");
|
456 |
}
|
456 |
}
|
457 |
}
|
457 |
}
|
458 |
|
458 |
|
459 |
private function creerFichierMeta() {
|
459 |
private function creerFichierMeta() {
|
460 |
$donnees = array();
|
460 |
$donnees = array();
|
461 |
$donnees = $this->meta;
|
461 |
$donnees = $this->meta;
|
462 |
$donnees['stats'] = $this->noms_stat;
|
462 |
$donnees['stats'] = $this->noms_stat;
|
463 |
$donnees['signature'] = $this->signature_md5;
|
463 |
$donnees['signature'] = $this->signature_md5;
|
464 |
|
464 |
|
465 |
$donnees = $this->remplacerTabulation($donnees);
|
465 |
$donnees = $this->remplacerTabulation($donnees);
|
466 |
$donnees = $this->remplacerSautsDeLigne($donnees);
|
466 |
$donnees = $this->remplacerSautsDeLigne($donnees);
|
467 |
|
467 |
|
468 |
$meta_tsv =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
|
468 |
$meta_tsv =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
|
469 |
$this->ecrireFichierMeta($meta_tsv);
|
469 |
$this->ecrireFichierMeta($meta_tsv);
|
470 |
return $donnees;
|
470 |
return $donnees;
|
471 |
}
|
471 |
}
|
472 |
|
472 |
|
473 |
private function ecrireFichierMeta(&$contenu) {
|
473 |
private function ecrireFichierMeta(&$contenu) {
|
474 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
|
474 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
|
475 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
475 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
476 |
|
476 |
|
477 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
477 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
478 |
$this->ajouterMessage("Écriture du fichier meta réussie.");
|
478 |
$this->ajouterMessage("Écriture du fichier meta réussie.");
|
479 |
$this->archiverMetadonnees();
|
479 |
$this->archiverMetadonnees();
|
480 |
}
|
480 |
}
|
481 |
}
|
481 |
}
|
482 |
|
482 |
|
483 |
private function creerFichierMetaPartiel(&$donnees) {
|
483 |
private function creerFichierMetaPartiel(&$donnees) {
|
484 |
$donnees['signature'] = $this->signature_md5_partiel;
|
484 |
$donnees['signature'] = $this->signature_md5_partiel;
|
485 |
$meta_tsv_partiel =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
|
485 |
$meta_tsv_partiel =& $this->getVue('versionnage/squelettes/meta', &$donnees, '.tpl.tsv');
|
486 |
$this->ecrireFichierMetaPartiel($meta_tsv_partiel);
|
486 |
$this->ecrireFichierMetaPartiel($meta_tsv_partiel);
|
487 |
}
|
487 |
}
|
488 |
|
488 |
|
489 |
private function ecrireFichierMetaPartiel(&$contenu) {
|
489 |
private function ecrireFichierMetaPartiel(&$contenu) {
|
490 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
|
490 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_meta'];
|
491 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
491 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
492 |
|
492 |
|
493 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
493 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
494 |
$this->ajouterMessage("Écriture du fichier meta partiel réussie.");
|
494 |
$this->ajouterMessage("Écriture du fichier meta partiel réussie.");
|
495 |
}
|
495 |
}
|
496 |
}
|
496 |
}
|
497 |
|
497 |
|
498 |
private function archiverMetadonnees() {
|
498 |
private function archiverMetadonnees() {
|
499 |
$metadonnees = $this->meta;
|
499 |
$metadonnees = $this->meta;
|
500 |
$metadonnees['code'] = $this->meta['acronyme'];
|
500 |
$metadonnees['code'] = $this->meta['acronyme'];
|
501 |
unset($metadonnees['acronyme']);
|
501 |
unset($metadonnees['acronyme']);
|
502 |
$metadonnees['domaine_taxo'] = $this->meta['dom_tax'];
|
502 |
$metadonnees['domaine_taxo'] = $this->meta['dom_tax'];
|
503 |
unset($metadonnees['dom_tax']);
|
503 |
unset($metadonnees['dom_tax']);
|
504 |
$metadonnees['domaine_geo'] = $this->meta['dom_geo'];
|
504 |
$metadonnees['domaine_geo'] = $this->meta['dom_geo'];
|
505 |
unset($metadonnees['dom_geo']);
|
505 |
unset($metadonnees['dom_geo']);
|
506 |
$metadonnees['domaine_nom'] = $this->meta['dom_code'];
|
506 |
$metadonnees['domaine_nom'] = $this->meta['dom_code'];
|
507 |
unset($metadonnees['dom_code']);
|
507 |
unset($metadonnees['dom_code']);
|
508 |
$metadonnees['auteur'] = $this->meta['auteur_principal'];
|
508 |
$metadonnees['auteur'] = $this->meta['auteur_principal'];
|
509 |
unset($metadonnees['auteur_principal']);
|
509 |
unset($metadonnees['auteur_principal']);
|
510 |
$metadonnees['date_production'] = $this->meta['date_prod'];
|
510 |
$metadonnees['date_production'] = $this->meta['date_prod'];
|
511 |
unset($metadonnees['date_prod']);
|
511 |
unset($metadonnees['date_prod']);
|
512 |
$metadonnees['droit'] = $this->meta['copyright'];
|
512 |
$metadonnees['droit'] = $this->meta['copyright'];
|
513 |
unset($metadonnees['copyright']);
|
513 |
unset($metadonnees['copyright']);
|
514 |
|
514 |
|
515 |
$ok = $this->metaDao->ajouter($metadonnees);
|
515 |
$ok = $this->metaDao->ajouter($metadonnees);
|
516 |
if ($ok === false) {
|
516 |
if ($ok === false) {
|
517 |
$this->ajouterMessage("L'archivage des métadonnées a échoué.");
|
517 |
$this->ajouterMessage("L'archivage des métadonnées a échoué.");
|
518 |
}
|
518 |
}
|
519 |
}
|
519 |
}
|
520 |
|
520 |
|
521 |
private function nettoyerMemoire() {
|
521 |
private function nettoyerMemoire() {
|
522 |
$this->noms = null;
|
522 |
$this->noms = null;
|
523 |
$this->noms_precedents = null;
|
523 |
$this->noms_precedents = null;
|
524 |
$this->noms_stat = null;
|
524 |
$this->noms_stat = null;
|
525 |
}
|
525 |
}
|
526 |
|
526 |
|
527 |
private function copierManuel() {
|
527 |
private function copierManuel() {
|
528 |
$fichier_source = $this->manuel_chemin.$this->manuel_nom;
|
528 |
$fichier_source = $this->manuel_chemin.$this->manuel_nom;
|
529 |
$fichiers_destination[] = $this->zip_chemin_dossier.$this->manuel_nom;
|
529 |
$fichiers_destination[] = $this->zip_chemin_dossier.$this->manuel_nom;
|
530 |
$fichiers_destination[] = $this->zip_chemin_dossier_partiel.$this->manuel_nom;
|
530 |
$fichiers_destination[] = $this->zip_chemin_dossier_partiel.$this->manuel_nom;
|
531 |
foreach ($fichiers_destination as $destination) {
|
531 |
foreach ($fichiers_destination as $destination) {
|
532 |
if (copy($fichier_source, $destination) === false) {
|
532 |
if (copy($fichier_source, $destination) === false) {
|
533 |
$this->ajouterMessage("La copie du manuel vers '$destination' a échouée.");
|
533 |
$this->ajouterMessage("La copie du manuel vers '$destination' a échouée.");
|
534 |
}
|
534 |
}
|
535 |
}
|
535 |
}
|
536 |
}
|
536 |
}
|
537 |
|
537 |
|
538 |
private function creerFichiersZip() {
|
538 |
private function creerFichiersZip() {
|
539 |
$this->zipper($this->zip_chemin_fichier, $this->zip_chemin_dossier);
|
539 |
$this->zipper($this->zip_chemin_fichier, $this->zip_chemin_dossier);
|
540 |
$this->zipper($this->zip_chemin_fichier_partiel, $this->zip_chemin_dossier_partiel);
|
540 |
$this->zipper($this->zip_chemin_fichier_partiel, $this->zip_chemin_dossier_partiel);
|
541 |
}
|
541 |
}
|
542 |
|
542 |
|
543 |
private function zipper($fichier_zip, $dossier_a_zipper) {
|
543 |
private function zipper($fichier_zip, $dossier_a_zipper) {
|
544 |
$zip = new PclZip($fichier_zip);
|
544 |
$zip = new PclZip($fichier_zip);
|
545 |
if ($zip->add($dossier_a_zipper, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
|
545 |
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);
|
546 |
$e = "La création du fichier zip '$fichier_zip' a échoué avec l'erreur : ".$zip->errorInfo(true);
|
547 |
$this->ajouterMessage($e);
|
547 |
$this->ajouterMessage($e);
|
548 |
}
|
548 |
}
|
549 |
}
|
549 |
}
|
550 |
|
550 |
|
551 |
private function nettoyerFichiers() {
|
551 |
private function nettoyerFichiers() {
|
552 |
Fichier::supprimerDossier($this->zip_chemin_dossier);
|
552 |
Fichier::supprimerDossier($this->zip_chemin_dossier);
|
553 |
Fichier::supprimerDossier($this->zip_chemin_dossier_partiel);
|
553 |
Fichier::supprimerDossier($this->zip_chemin_dossier_partiel);
|
554 |
}
|
554 |
}
|
555 |
|
555 |
|
556 |
private function traiterMessages() {
|
556 |
private function traiterMessages() {
|
557 |
if (isset($this->messages)) {
|
557 |
if (isset($this->messages)) {
|
558 |
$num_message = 1;
|
558 |
$num_message = 1;
|
559 |
foreach ($this->messages as $message) {
|
559 |
foreach ($this->messages as $message) {
|
560 |
$message['nom'] = 'Message #'.$num_message++;
|
560 |
$message['nom'] = 'Message #'.$num_message++;
|
561 |
$this->resultatDao->ajouter($this->traitement['id_traitement'], $message);
|
561 |
$this->resultatDao->ajouter($this->traitement['id_traitement'], $message);
|
562 |
}
|
562 |
}
|
563 |
}
|
563 |
}
|
564 |
}
|
564 |
}
|
565 |
}
|
565 |
}
|
566 |
?>
|
566 |
?>
|