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', true)){
32 return $f($champ, $old, $new, $format);
35 $diff = new Diff(new DiffTexte
);
36 $n = preparer_diff($new);
37 $o = preparer_diff($old);
39 $out = afficher_diff($diff->comparer($n,$o));
40 if ($format == 'diff' OR $format == 'apercu')
41 $out = afficher_para_modifies($out, ($format == 'apercu'));
48 * http://doc.spip.org/@afficher_para_modifies
50 * @param string $texte
54 function afficher_para_modifies ($texte, $court = false) {
55 // Limiter la taille de l'affichage
56 if ($court) $max = 200;
60 $paras = explode ("\n",$texte);
61 for ($i = 0; $i < count($paras) AND strlen($texte_ret) < $max; $i++
) {
62 if (strpos($paras[$i], '"diff-')) $texte_ret .= $paras[$i]."\n\n";
63 # if (strlen($texte_ret) > $max) $texte_ret .= '(...)';