3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2014 *
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);
31 if($f = charger_fonction($champ,'afficher_diff'))
32 return $f($champ,$old,$new,$format='diff');
33 $diff = new Diff(new DiffTexte
);
34 $n = preparer_diff($new);
35 $o = preparer_diff($old);
37 $out = afficher_diff($diff->comparer($n,$o));
38 if ($format == 'diff' OR $format == 'apercu')
39 $out = afficher_para_modifies($out, ($format == 'apercu'));
46 * http://doc.spip.org/@afficher_para_modifies
48 * @param string $texte
52 function afficher_para_modifies ($texte, $court = false) {
53 // Limiter la taille de l'affichage
54 if ($court) $max = 200;
58 $paras = explode ("\n",$texte);
59 for ($i = 0; $i < count($paras) AND strlen($texte_ret) < $max; $i++
) {
60 if (strpos($paras[$i], '"diff-')) $texte_ret .= $paras[$i]."\n\n";
61 # if (strlen($texte_ret) > $max) $texte_ret .= '(...)';