36,17 → 36,18 |
|
private $noms = null; |
private $noms_precedents = null; |
private $noms_supprimes = null; |
private $noms_stat = null; |
private $noms_stat_partiel = null; |
private $champs_ordre = null; |
private $champs_nom = null; |
private $champs_nom_partiel = null; |
private $champs_courants = null; |
private $champs_diff = null; |
private $diff_champs_nom = null; |
private $diff_modif_types = null; |
private $signature_md5 = null; |
private $signature_md5_partiel = null; |
private $exclure_taxref = null; |
|
private $resultatDao = null; |
private $traitementDao = null; |
395,40 → 396,67 |
$this->chargerTableauChampsModifTypes(); |
$this->noms_stat['modification'] = 0; |
|
$this->verifierNomsSupprimes(); |
$this->champs_courants = $this->champs_nom; |
$diff = array(); |
$i = 0; |
foreach ($this->noms as $id => $nom) { |
$this->noms[$id] = null; |
if ($this->noms[$id]['exclure_taxref'] == '1') { |
unset($this->noms[$id]); |
} else { |
foreach ($this->noms[$id] as $champ => $valeur) { |
if (! in_array($champ, $this->champs_nom_partiel)) { |
unset($this->noms[$id][$champ]); |
} |
} |
} |
$infos = array(); |
if (!isset($this->noms_precedents[$id])) { |
if (isset($this->noms_supprimes[$id])) { |
$infos = $this->traiterDiffSuppression($nom); |
} else if (!isset($this->noms_precedents[$id])) { |
$infos = $this->traiterDiffAjout($nom); |
} else { |
$nom_precedent = $this->noms_precedents[$id]; |
if ($this->noms_precedents[$id]['exclure_taxref'] == '1') { |
unset($this->noms_precedents[$id]); |
} else { |
foreach ($this->noms_precedents[$id] as $champ => $valeur) { |
if (! in_array($champ, $this->champs_nom_partiel)) { |
unset($this->noms_precedents[$id][$champ]); |
} |
} |
} |
array_walk($nom_precedent, create_function('&$val', '$val = trim($val);')); |
$infos = $this->traiterDiffModif($nom, $nom_precedent); |
} |
if ($nom['exclure_taxref'] == '1') { |
$this->exclure_taxref[] = $id; |
} |
|
if (count($infos) > 0) { |
$this->noms_stat['modification']++; |
$infos = $this->remplacerTabulation($infos); |
$infos = $this->remplacerSautsDeLigne($infos); |
$diff[$id] = $infos; |
} |
} |
$this->verifierLignesSupprimees(); |
|
return $diff; |
} |
|
private function verifierLignesSupprimees() { |
$e = count($this->noms_precedents)." lignes ont été supprimées vis à vis de la version ". |
"précédentes. Cela concerne les noms : ".implode(', ', array_keys($this->noms_precedents)); |
private function verifierNomsSupprimes($edition = '«Complète»') { |
$this->noms_supprimes = array_diff_key($this->noms, $this->noms_precedents); |
$e = count($this->noms_supprimes)." lignes ont été supprimées vis à vis de la version ". |
"précédentes pour l'édition $edition. Cela concerne les noms : ".implode(', ', array_keys($this->noms_supprimes)); |
Debug::printr($e); |
$this->ajouterMessage($e); |
} |
|
private function traiterDiffSuppression(&$nom) { |
$infos = $nom; |
$infos['modification_type'] = 'S'; |
$infos['modification_type_1'] = '0'; |
$infos['modification_type_2'] = '0'; |
$infos['modification_type_3'] = '0'; |
return $infos; |
} |
|
private function traiterDiffAjout(&$nom) { |
$infos = $nom; |
$infos['modification_type'] = 'A'; |
435,7 → 463,6 |
$infos['modification_type_1'] = '0'; |
$infos['modification_type_2'] = '0'; |
$infos['modification_type_3'] = '0'; |
$this->noms_stat['modification']++; |
return $infos; |
} |
|
449,7 → 476,7 |
$modif['modification_type_2'] = '0'; |
$modif['modification_type_3'] = '0'; |
|
foreach ($this->champs_nom as $champ) { |
foreach ($this->champs_courants as $champ) { |
if (isset($nom_diff[$champ])) { |
// Si le champ modifié est vide nous retournons le mot clé "NULL" pour identifier le champ modifié |
$infos[$champ] = ($nom_diff[$champ] != '') ? $nom_diff[$champ] : 'NULL'; |
467,8 → 494,6 |
foreach ($modif as $cle => $val) { |
$infos[$cle] = $val; |
} |
|
$this->noms_stat['modification']++; |
} |
return $infos; |
} |
497,33 → 522,45 |
|
private function creerFichierDiffPartiel(&$donnees) { |
$this->noms_stat_partiel['modification'] = 0; |
if (count($donnees) > 0 && count($donnees['diff']) > 0) { |
foreach ($donnees['diff'] as $id => $nom) { |
if (!in_array($id, $this->exclure_taxref)) { |
if ($nom['modification_type'] == 'A') { |
$donnees['diff_partiel'][$id] = $nom; |
} else { |
foreach ($nom as $champ => $valeur) { |
$ok = false; |
if ($valeur != '' && $champ != 'num_nom' && in_array($champ, $this->champs_nom_partiel)) { |
$donnees['diff_partiel'][$id] = $nom; |
Debug::printr($id.":".$champ."/".$valeur); |
break; |
if (! is_null($derniere_meta) && $derniere_meta !== false) { |
$donnees['diff_partiel'] = $this->realiserDiff(); |
$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff); |
$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']); |
$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv'); |
$this->ecrireFichierDiffPartiel($diff_tsv_partiel); |
} |
} |
|
private function realiserDiffPartiel() { |
$this->noms_stat_partiel['modification'] = 0; |
|
$this->champs_courants = $this->champs_nom_partiel; |
$this->verifierNomsSupprimes('«Partielle»'); |
$diff = array(); |
foreach ($this->noms as $id => $nom) { |
unset($this->noms[$id]); |
$infos = array(); |
if (isset($this->noms_supprimes[$id])) { |
$infos = $this->traiterDiffSuppression($nom); |
} else if (!isset($this->noms_precedents[$id])) { |
$infos = $this->traiterDiffAjout($nom); |
} else { |
$nom_precedent = $this->noms_precedents[$id]; |
unset($this->noms_precedents[$id]); |
array_walk($nom_precedent, create_function('&$val', '$val = trim($val);')); |
$infos = $this->traiterDiffModif($nom, $nom_precedent); |
} |
if (array_key_exists($id, $donnees['diff_partiel'])) { |
|
if (count($infos) > 0) { |
$this->noms_stat_partiel['modification']++; |
$infos = $this->remplacerTabulation($infos); |
$infos = $this->remplacerSautsDeLigne($infos); |
$diff[$id] = $infos; |
} |
} |
unset($donnees['diff'][$id]); |
|
return $diff; |
} |
$donnees['champs_partiel_diff'] = array_merge($this->champs_nom_partiel, $this->champs_diff); |
$donnees['dernier_champ'] = end($donnees['champs_partiel_diff']); |
$diff_tsv_partiel =& $this->getVue('versionnage/squelettes/diff_partiel', &$donnees, '.tpl.tsv'); |
$this->ecrireFichierDiffPartiel($diff_tsv_partiel); |
} |
} |
|
private function ecrireFichierDiffPartiel(&$contenu) { |
$fichier_nom = $this->getBaseNomFichier().$this->manuel['ext_fichier_diff']; |