Subversion Repositories Applications.referentiel

Rev

Rev 215 | Rev 217 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 215 Rev 216
Line 34... Line 34...
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;
Line 36... Line 36...
36
	
36
	
37
	private $noms = null;
37
	private $noms = null;
-
 
38
	private $noms_precedents = null;
38
	private $noms_precedents = null;
39
	private $noms_supprimes = null;
39
	private $noms_stat = null;
40
	private $noms_stat = null;
40
	private $noms_stat_partiel = null;
41
	private $noms_stat_partiel = null;
41
	private $champs_ordre = null;
42
	private $champs_ordre = null;
42
	private $champs_nom = null;
43
	private $champs_nom = null;
-
 
44
	private $champs_nom_partiel = null;
43
	private $champs_nom_partiel = null;
45
	private $champs_courants = null;
44
	private $champs_diff = null;
46
	private $champs_diff = null;
45
	private $diff_champs_nom = null;
47
	private $diff_champs_nom = null;
46
	private $diff_modif_types = null;
48
	private $diff_modif_types = null;
47
	private $signature_md5 = null;
49
	private $signature_md5 = null;
48
	private $signature_md5_partiel = null;
-
 
Line 49... Line 50...
49
	private $exclure_taxref = null;
50
	private $signature_md5_partiel = null;
50
	
51
	
51
	private $resultatDao = null;
52
	private $resultatDao = null;
52
	private $traitementDao = null;
53
	private $traitementDao = null;
Line 393... Line 394...
393
	
394
	
394
	private function realiserDiff() {
395
	private function realiserDiff() {
395
		$this->chargerTableauChampsModifTypes();
396
		$this->chargerTableauChampsModifTypes();
Line -... Line 397...
-
 
397
		$this->noms_stat['modification'] = 0;
-
 
398
		
396
		$this->noms_stat['modification'] = 0;
399
		$this->verifierNomsSupprimes();
397
		
-
 
398
		$diff = array();
400
		$this->champs_courants = $this->champs_nom; 
-
 
401
		$diff = array();
399
		$i = 0;
402
		foreach ($this->noms as $id => $nom) {
-
 
403
			if ($this->noms[$id]['exclure_taxref'] == '1') {
-
 
404
				unset($this->noms[$id]);
-
 
405
			} else {
-
 
406
				foreach ($this->noms[$id] as $champ => $valeur) {
-
 
407
					if (! in_array($champ, $this->champs_nom_partiel)) {
-
 
408
						unset($this->noms[$id][$champ]);
-
 
409
					}
400
		foreach ($this->noms as $id => $nom) {
410
				}
-
 
411
			}
-
 
412
			$infos = array();
401
			$this->noms[$id] = null;
413
			if (isset($this->noms_supprimes[$id])) {
402
			$infos = array();
414
					$infos = $this->traiterDiffSuppression($nom);
403
			if (!isset($this->noms_precedents[$id])) {
415
			} else if (!isset($this->noms_precedents[$id])) {
404
				$infos = $this->traiterDiffAjout($nom);
416
				$infos = $this->traiterDiffAjout($nom);
-
 
417
			} else {
405
			} else {
418
				$nom_precedent = $this->noms_precedents[$id];
-
 
419
				if ($this->noms_precedents[$id]['exclure_taxref'] == '1') {
-
 
420
					unset($this->noms_precedents[$id]);
-
 
421
				} else {
-
 
422
					foreach ($this->noms_precedents[$id] as $champ => $valeur) {
-
 
423
						if (! in_array($champ, $this->champs_nom_partiel)) {
-
 
424
							unset($this->noms_precedents[$id][$champ]);
-
 
425
						}
406
				$nom_precedent = $this->noms_precedents[$id];
426
					}
407
				unset($this->noms_precedents[$id]);
427
				}
408
				array_walk($nom_precedent, create_function('&$val', '$val = trim($val);')); 
428
				array_walk($nom_precedent, create_function('&$val', '$val = trim($val);')); 
409
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
-
 
410
			}
-
 
411
			if ($nom['exclure_taxref'] == '1') {
-
 
Line 412... Line 429...
412
				$this->exclure_taxref[] = $id;
429
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
-
 
430
			}
413
			}
431
			
414
			
432
			if (count($infos) > 0) {
415
			if (count($infos) > 0) {
433
				$this->noms_stat['modification']++;
416
				$infos = $this->remplacerTabulation($infos);
434
				$infos = $this->remplacerTabulation($infos);
417
				$infos = $this->remplacerSautsDeLigne($infos);
435
				$infos = $this->remplacerSautsDeLigne($infos);
418
				$diff[$id] = $infos;
-
 
Line 419... Line 436...
419
			}
436
				$diff[$id] = $infos;
420
		}
437
			}
Line 421... Line 438...
421
		$this->verifierLignesSupprimees();
438
		}
-
 
439
		
422
		
440
		return $diff;
423
		return $diff;
441
	}
-
 
442
	
424
	}
443
	private function verifierNomsSupprimes($edition = '«Complète»') {
425
	
444
		$this->noms_supprimes = array_diff_key($this->noms, $this->noms_precedents);
Line -... Line 445...
-
 
445
		$e = count($this->noms_supprimes)." lignes ont été supprimées vis à vis de la version ".
-
 
446
			"précédentes pour l'édition $edition. Cela concerne les noms : ".implode(', ', array_keys($this->noms_supprimes));
-
 
447
		Debug::printr($e);
-
 
448
		$this->ajouterMessage($e);
-
 
449
	} 
-
 
450
	
-
 
451
	private function traiterDiffSuppression(&$nom) {
-
 
452
		$infos = $nom;
-
 
453
		$infos['modification_type'] = 'S';
426
	private function verifierLignesSupprimees() {
454
		$infos['modification_type_1'] = '0';
427
		$e = count($this->noms_precedents)." lignes ont été supprimées vis à vis de la version ".
455
		$infos['modification_type_2'] = '0';
428
			"précédentes. Cela concerne les noms : ".implode(', ', array_keys($this->noms_precedents));
456
		$infos['modification_type_3'] = '0';
429
		$this->ajouterMessage($e);
457
		return $infos;
430
	} 
458
	}
431
	
459
	
432
	private function traiterDiffAjout(&$nom) {
-
 
433
		$infos = $nom;
460
	private function traiterDiffAjout(&$nom) {
434
		$infos['modification_type'] = 'A';
461
		$infos = $nom;
Line 435... Line 462...
435
		$infos['modification_type_1'] = '0';
462
		$infos['modification_type'] = 'A';
436
		$infos['modification_type_2'] = '0';
463
		$infos['modification_type_1'] = '0';
Line 447... Line 474...
447
			$modif['modification_type'] = 'M';
474
			$modif['modification_type'] = 'M';
448
			$modif['modification_type_1'] = '0';
475
			$modif['modification_type_1'] = '0';
449
			$modif['modification_type_2'] = '0';
476
			$modif['modification_type_2'] = '0';
450
			$modif['modification_type_3'] = '0';
477
			$modif['modification_type_3'] = '0';
Line 451... Line 478...
451
			
478
			
452
			foreach ($this->champs_nom as $champ) {
479
			foreach ($this->champs_courants as $champ) {
453
				if (isset($nom_diff[$champ])) {
480
				if (isset($nom_diff[$champ])) {
454
					// Si le champ modifié est vide nous retournons le mot clé "NULL" pour identifier le champ modifié
481
					// Si le champ modifié est vide nous retournons le mot clé "NULL" pour identifier le champ modifié
455
					$infos[$champ] = ($nom_diff[$champ] != '') ? $nom_diff[$champ] : 'NULL';
482
					$infos[$champ] = ($nom_diff[$champ] != '') ? $nom_diff[$champ] : 'NULL';
456
					$type = $this->getDiffType($champ);
483
					$type = $this->getDiffType($champ);
Line 465... Line 492...
465
			}
492
			}
Line 466... Line 493...
466
			
493
			
467
			foreach ($modif as $cle => $val) {
494
			foreach ($modif as $cle => $val) {
468
				$infos[$cle] = $val;
495
				$infos[$cle] = $val;
469
			}
-
 
470
			
-
 
471
			$this->noms_stat['modification']++;
496
			}
472
		}
497
		}
473
		return $infos;
498
		return $infos;
Line 474... Line 499...
474
	}
499
	}
Line 495... Line 520...
495
		}
520
		}
496
	}
521
	}
Line 497... Line 522...
497
	
522
	
498
	private function creerFichierDiffPartiel(&$donnees) {
523
	private function creerFichierDiffPartiel(&$donnees) {
499
		$this->noms_stat_partiel['modification'] = 0;
524
		$this->noms_stat_partiel['modification'] = 0;
500
		if (count($donnees) > 0 && count($donnees['diff']) > 0) {
-
 
501
			foreach ($donnees['diff'] as $id => $nom) {
-
 
502
				if (!in_array($id, $this->exclure_taxref)) {
-
 
503
					if ($nom['modification_type'] == 'A') {
525
		if (! is_null($derniere_meta) && $derniere_meta !== false) {
504
						$donnees['diff_partiel'][$id] = $nom;
-
 
505
					} else {
-
 
506
						foreach ($nom as $champ => $valeur) {
-
 
507
							$ok = false;
-
 
508
							if ($valeur != '' && $champ != 'num_nom' && in_array($champ, $this->champs_nom_partiel)) {
-
 
509
								$donnees['diff_partiel'][$id] = $nom;
-
 
510
								Debug::printr($id.":".$champ."/".$valeur);
-
 
511
								break;
-
 
512
							}
-
 
513
						}
-
 
514
					}
-
 
515
					if (array_key_exists($id, $donnees['diff_partiel'])) {
-
 
516
						$this->noms_stat_partiel['modification']++;
-
 
517
					}
-
 
518
				}
-
 
519
				unset($donnees['diff'][$id]);
-
 
520
			}
526
			$donnees['diff_partiel'] = $this->realiserDiff();
521
			$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
527
			$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff);
522
			$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
528
			$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']);
523
			$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
529
			$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv');
524
			$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
530
			$this->ecrireFichierDiffPartiel($diff_tsv_partiel);
525
		}
531
		}
Line -... Line 532...
-
 
532
	}
-
 
533
	
-
 
534
	private function realiserDiffPartiel() {
-
 
535
		$this->noms_stat_partiel['modification'] = 0;
-
 
536
		
-
 
537
		$this->champs_courants = $this->champs_nom_partiel;
-
 
538
		$this->verifierNomsSupprimes('«Partielle»');
-
 
539
		$diff = array();
-
 
540
		foreach ($this->noms as $id => $nom) {
-
 
541
			unset($this->noms[$id]);
-
 
542
			$infos = array();
-
 
543
			if (isset($this->noms_supprimes[$id])) {
-
 
544
				$infos = $this->traiterDiffSuppression($nom);
-
 
545
			} else if (!isset($this->noms_precedents[$id])) {
-
 
546
				$infos = $this->traiterDiffAjout($nom);
-
 
547
			} else {
-
 
548
				$nom_precedent = $this->noms_precedents[$id];
-
 
549
				unset($this->noms_precedents[$id]);
-
 
550
				array_walk($nom_precedent, create_function('&$val', '$val = trim($val);')); 
-
 
551
				$infos = $this->traiterDiffModif($nom, $nom_precedent);
-
 
552
			}
-
 
553
			
-
 
554
			if (count($infos) > 0) {
-
 
555
				$this->noms_stat_partiel['modification']++;
-
 
556
				$infos = $this->remplacerTabulation($infos);
-
 
557
				$infos = $this->remplacerSautsDeLigne($infos);
-
 
558
				$diff[$id] = $infos;
-
 
559
			}
-
 
560
		}
-
 
561
		
-
 
562
		return $diff;
526
	}
563
	}
527
	
564
	
528
	private function ecrireFichierDiffPartiel(&$contenu) {
565
	private function ecrireFichierDiffPartiel(&$contenu) {
Line 529... Line 566...
529
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];
566
		$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff'];