3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2013 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
13 if (!defined("_ECRIRE_INC_VERSION")) return;
15 include_spip('inc/diff');
18 * Afficher le diff d'un champ texte generique
19 * @param string $champ
22 * @param string $format
23 * apercu, diff ou complet
26 function afficher_diff_champ_dist($champ,$old,$new,$format='diff'){
27 // ne pas se compliquer la vie !
29 $out = ($format!='complet'?
'':$new);
32 $diff = new Diff(new DiffTexte
);
33 $n = preparer_diff($new);
34 $o = preparer_diff($old);
36 $out = afficher_diff($diff->comparer($n,$o));
37 if ($format == 'diff' OR $format == 'apercu')
38 $out = afficher_para_modifies($out, ($format == 'apercu'));
45 * http://doc.spip.org/@afficher_para_modifies
47 * @param string $texte
51 function afficher_para_modifies ($texte, $court = false) {
52 // Limiter la taille de l'affichage
53 if ($court) $max = 200;
57 $paras = explode ("\n",$texte);
58 for ($i = 0; $i < count($paras) AND strlen($texte_ret) < $max; $i++
) {
59 if (strpos($paras[$i], '"diff-')) $texte_ret .= $paras[$i]."\n\n";
60 # if (strlen($texte_ret) > $max) $texte_ret .= '(...)';