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