| Line 13... |
Line 13... |
| 13 |
* @link http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel
|
13 |
* @link http://www.tela-botanica.org/wikini/RTaxMethodo/wakka.php?wiki=MaNuel
|
| 14 |
* @licence GPL v3 & CeCILL v2
|
14 |
* @licence GPL v3 & CeCILL v2
|
| 15 |
* @version $Id$
|
15 |
* @version $Id$
|
| 16 |
*/
|
16 |
*/
|
| 17 |
// +-------------------------------------------------------------------------------------------------------------------+
|
17 |
// +-------------------------------------------------------------------------------------------------------------------+
|
| 18 |
// TODO : utilisation de array_key_exists à la place de isset dans creerFichierBdnt() ????
|
18 |
// TODO : lors de la génération de la version 2 de la BDTFX tester les diff! Il se peut que la mémoire soit dépassée.
|
| 19 |
class Versionnage extends ScriptCommande {
|
19 |
class Versionnage extends ScriptCommande {
|
| Line 20... |
Line 20... |
| 20 |
|
20 |
|
| 21 |
const SCRIPT_NOM = 'versionnage';
|
21 |
const SCRIPT_NOM = 'versionnage';
|
| Line 22... |
Line 22... |
| 22 |
const MANUEL_VERSION = "4.1";
|
22 |
const MANUEL_VERSION = '4.2';
|
| 23 |
|
23 |
|
| 24 |
private $projet = null;
|
24 |
private $projet = null;
|
| 25 |
private $traitement = null;
|
25 |
private $traitement = null;
|
| Line 194... |
Line 194... |
| 194 |
$this->definirNomDesChamps();
|
194 |
$this->definirNomDesChamps();
|
| 195 |
$this->definirNomDesChampsDiff();
|
195 |
$this->definirNomDesChampsDiff();
|
| Line 196... |
Line 196... |
| 196 |
|
196 |
|
| 197 |
$donnees = array();
|
197 |
$donnees = array();
|
| - |
|
198 |
$donnees['champs'] = $this->champs_nom;
|
| - |
|
199 |
|
| - |
|
200 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
| - |
|
201 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
| - |
|
202 |
$bdnt_tsv_entete = $this->getVue('versionnage/squelettes/bdnt_entete', array('champs' => $donnees['champs']), '.tpl.tsv');
|
| - |
|
203 |
$this->ecrireFichier($fichier_chemin, $bdnt_tsv_entete);
|
| 198 |
$donnees['champs'] = $this->champs_nom;
|
204 |
|
| 199 |
foreach ($this->noms as $id => &$nom) {
|
205 |
foreach ($this->noms as $id => &$nom) {
|
| 200 |
$infos = array();
|
206 |
$infos = array();
|
| 201 |
foreach ($this->champs_ordre as $champ => $ordre) {
|
207 |
foreach ($this->champs_ordre as $champ => $ordre) {
|
| 202 |
if (array_key_exists($champ, $nom)) {
|
208 |
if (array_key_exists($champ, $nom)) {
|
| Line 206... |
Line 212... |
| 206 |
$this->ajouterMessage($e);
|
212 |
$this->ajouterMessage($e);
|
| 207 |
}
|
213 |
}
|
| 208 |
}
|
214 |
}
|
| 209 |
$infos = $this->remplacerTabulation($infos);
|
215 |
$infos = $this->remplacerTabulation($infos);
|
| 210 |
$infos = $this->remplacerSautsDeLigne($infos);
|
216 |
$infos = $this->remplacerSautsDeLigne($infos);
|
| 211 |
$donnees['noms'][$id] = $infos;
|
217 |
$this->noms[$id] = $infos;
|
| - |
|
218 |
|
| - |
|
219 |
$bdnt_tsv_ligne = $this->getVue('versionnage/squelettes/bdnt_ligne', array('nom_infos' => $infos), '.tpl.tsv');
|
| - |
|
220 |
$this->ajouterAuFichier($fichier_chemin, $bdnt_tsv_ligne);
|
| 212 |
}
|
221 |
}
|
| 213 |
Debug::printr("Dernier element du tableau des noms [trié] : ".print_r($infos,true));
|
- |
|
| 214 |
$bdnt_tsv =& $this->getVue('versionnage/squelettes/bdnt', &$donnees, '.tpl.tsv');
|
- |
|
| 215 |
$this->ecrireFichierBdnt($bdnt_tsv);
|
222 |
$this->ecrireComplementFichierBdnt($fichier_chemin);
|
| 216 |
return $donnees;
|
223 |
return $donnees;
|
| 217 |
}
|
224 |
}
|
| Line 218... |
Line 225... |
| 218 |
|
225 |
|
| 219 |
private function determinerOrdreDesChamps() {
|
226 |
private function determinerOrdreDesChamps() {
|
| Line 270... |
Line 277... |
| 270 |
}
|
277 |
}
|
| 271 |
}
|
278 |
}
|
| 272 |
return $doc;
|
279 |
return $doc;
|
| 273 |
}
|
280 |
}
|
| Line 274... |
Line 281... |
| 274 |
|
281 |
|
| 275 |
private function ecrireFichierBdnt(&$contenu) {
|
- |
|
| 276 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
- |
|
| 277 |
$fichier_chemin = $this->zip_chemin_dossier.$fichier_nom;
|
- |
|
| 278 |
|
282 |
private function ecrireComplementFichierBdnt($fichier_chemin) {
|
| 279 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
283 |
if (file_exists($fichier_chemin)) {
|
| 280 |
$this->ajouterMessage("Écriture du fichier bdnt réussie.");
|
284 |
$this->ajouterMessage("Écriture du fichier bdnt réussie.");
|
| 281 |
$this->signature_md5 = md5_file($fichier_chemin);
|
285 |
$this->signature_md5 = md5_file($fichier_chemin);
|
| 282 |
$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
|
286 |
$this->ajouterMessage("Signature MD5 du fichier bdnt :".$this->signature_md5);
|
| 283 |
$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
|
287 |
$this->ajouterMessage("Nombre de combinaisons traitées : ".$this->noms_stat['combinaison']);
|
| Line 291... |
Line 295... |
| 291 |
private function creerFichierBdntPartiel(&$donnees) {
|
295 |
private function creerFichierBdntPartiel(&$donnees) {
|
| 292 |
$this->definirChampsPartiel();
|
296 |
$this->definirChampsPartiel();
|
| 293 |
Debug::printr(current($donnees['noms']));
|
297 |
Debug::printr(current($donnees['noms']));
|
| 294 |
$donnees['champs_partiel'] = $this->champs_nom_partiel;
|
298 |
$donnees['champs_partiel'] = $this->champs_nom_partiel;
|
| 295 |
$donnees['dernier_champ'] = end($this->champs_nom_partiel);
|
299 |
$donnees['dernier_champ'] = end($this->champs_nom_partiel);
|
| 296 |
$bdnt_partielle_tsv =& $this->getVue('versionnage/squelettes/bdnt_partiel', &$donnees, '.tpl.tsv');
|
- |
|
| 297 |
$this->ecrireFichierBdntPartielle($bdnt_partielle_tsv);
|
300 |
$this->ecrireFichierBdntPartielle($donnees);
|
| 298 |
}
|
301 |
}
|
| Line 299... |
Line 302... |
| 299 |
|
302 |
|
| 300 |
private function definirChampsPartiel() {
|
303 |
private function definirChampsPartiel() {
|
| 301 |
$this->champs_nom_partiel = explode(',', $this->manuel['champs_partiel']);
|
304 |
$this->champs_nom_partiel = explode(',', $this->manuel['champs_partiel']);
|
| 302 |
Debug::printr("Champs partiels : ".print_r($this->champs_nom_partiel,true));
|
305 |
Debug::printr("Champs partiels : ".print_r($this->champs_nom_partiel,true));
|
| Line 303... |
Line 306... |
| 303 |
}
|
306 |
}
|
| 304 |
|
307 |
|
| 305 |
private function ecrireFichierBdntPartielle(&$contenu) {
|
308 |
private function ecrireFichierBdntPartielle(&$donnees) {
|
| - |
|
309 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
| - |
|
310 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
| - |
|
311 |
$bdnt_tsv_entete = $this->getVue('versionnage/squelettes/bdnt_partiel_entete', array('champs_partiel' => $donnees['champs_partiel']), '.tpl.tsv');
|
| - |
|
312 |
$this->ecrireFichier($fichier_chemin, $bdnt_tsv_entete);
|
| - |
|
313 |
|
| - |
|
314 |
foreach ($this->noms as $id => &$nom) {
|
| - |
|
315 |
$donnees['nom_infos'] = $nom;
|
| - |
|
316 |
$bdnt_tsv_ligne = $this->getVue('versionnage/squelettes/bdnt_partiel_ligne', $donnees, '.tpl.tsv');
|
| - |
|
317 |
if ($bdnt_tsv_ligne != '') {
|
| - |
|
318 |
$this->ajouterAuFichier($fichier_chemin, $bdnt_tsv_ligne);
|
| Line 306... |
Line 319... |
| 306 |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_bdnt'];
|
319 |
}
|
| 307 |
$fichier_chemin = $this->zip_chemin_dossier_partiel.$fichier_nom;
|
320 |
}
|
| 308 |
|
321 |
|
| 309 |
if ($this->ecrireFichier($fichier_chemin, $contenu)) {
|
322 |
if (file_exists($fichier_chemin)) {
|
| 310 |
$this->ajouterMessage("Écriture du fichier de la bdnt partielle réussie.");
|
323 |
$this->ajouterMessage("Écriture du fichier de la bdnt partielle réussie.");
|
| 311 |
$this->signature_md5_partiel = md5_file($fichier_chemin);
|
324 |
$this->signature_md5_partiel = md5_file($fichier_chemin);
|
| Line 323... |
Line 336... |
| 323 |
}
|
336 |
}
|
| 324 |
$contenu = null;
|
337 |
$contenu = null;
|
| 325 |
return $retour;
|
338 |
return $retour;
|
| 326 |
}
|
339 |
}
|
| Line -... |
Line 340... |
| - |
|
340 |
|
| - |
|
341 |
private function ajouterAuFichier($fichier_chemin, &$contenu) {
|
| - |
|
342 |
$retour = true;
|
| - |
|
343 |
if (file_put_contents($fichier_chemin, $contenu, FILE_APPEND) == false) {
|
| - |
|
344 |
$e = "Une erreur est survenu lors de l'ajout de données dans le fichier : $fichier_chemin";
|
| - |
|
345 |
$this->ajouterMessage($e);
|
| - |
|
346 |
$retour = false;
|
| - |
|
347 |
}
|
| - |
|
348 |
$contenu = null;
|
| - |
|
349 |
return $retour;
|
| - |
|
350 |
}
|
| 327 |
|
351 |
|
| 328 |
private function creerFichierDiff() {
|
352 |
private function creerFichierDiff() {
|
| 329 |
$donnees = array();
|
353 |
$donnees = array();
|
| 330 |
$derniere_meta = $this->metaDao->getDerniere($this->projet);
|
354 |
$derniere_meta = $this->metaDao->getDerniere($this->projet);
|
| 331 |
if (is_null($derniere_meta === false)) {
|
355 |
if (is_null($derniere_meta === false)) {
|