X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fplugins-dist%2Frevisions%2Fafficher_diff%2Fchamp.php;h=314b36d29870985b8a5dc00d2b47904dd6b4f2f8;hb=4f443dce95ff6f8221c189880a70c74ce1c1f238;hp=9b3814174ec572a1fc53469a9b19ec01b0b84943;hpb=4a628e9b277d3617535f99d663ca79fa2e891177;p=lhc%2Fweb%2Fwww.git diff --git a/www/plugins-dist/revisions/afficher_diff/champ.php b/www/plugins-dist/revisions/afficher_diff/champ.php index 9b381417..314b36d2 100644 --- a/www/plugins-dist/revisions/afficher_diff/champ.php +++ b/www/plugins-dist/revisions/afficher_diff/champ.php @@ -10,12 +10,15 @@ * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * \***************************************************************************/ -if (!defined("_ECRIRE_INC_VERSION")) return; +if (!defined('_ECRIRE_INC_VERSION')) { + return; +} include_spip('inc/diff'); /** * Afficher le diff d'un champ texte generique + * * @param string $champ * @param string $old * @param string $new @@ -23,23 +26,25 @@ include_spip('inc/diff'); * apercu, diff ou complet * @return string */ -function afficher_diff_champ_dist($champ,$old,$new,$format='diff'){ +function afficher_diff_champ_dist($champ, $old, $new, $format = 'diff') { // ne pas se compliquer la vie ! - if ($old==$new) - $out = ($format!='complet'?'':$new); - else { - if($f = charger_fonction($champ,'afficher_diff', true)){ + if ($old == $new) { + $out = ($format != 'complet' ? '' : $new); + } else { + if ($f = charger_fonction($champ, 'afficher_diff', true)) { return $f($champ, $old, $new, $format); } - + $diff = new Diff(new DiffTexte); $n = preparer_diff($new); $o = preparer_diff($old); - $out = afficher_diff($diff->comparer($n,$o)); - if ($format == 'diff' OR $format == 'apercu') + $out = afficher_diff($diff->comparer($n, $o)); + if ($format == 'diff' or $format == 'apercu') { $out = afficher_para_modifies($out, ($format == 'apercu')); + } } + return $out; } @@ -51,17 +56,23 @@ function afficher_diff_champ_dist($champ,$old,$new,$format='diff'){ * @param bool $court * @return string */ -function afficher_para_modifies ($texte, $court = false) { +function afficher_para_modifies($texte, $court = false) { // Limiter la taille de l'affichage - if ($court) $max = 200; - else $max = 2000; + if ($court) { + $max = 200; + } else { + $max = 2000; + } - $texte_ret = ""; - $paras = explode ("\n",$texte); - for ($i = 0; $i < count($paras) AND strlen($texte_ret) < $max; $i++) { - if (strpos($paras[$i], '"diff-')) $texte_ret .= $paras[$i]."\n\n"; + $texte_ret = ''; + $paras = explode("\n", $texte); + for ($i = 0; $i < count($paras) and strlen($texte_ret) < $max; $i++) { + if (strpos($paras[$i], '"diff-')) { + $texte_ret .= $paras[$i] . "\n\n"; + } # if (strlen($texte_ret) > $max) $texte_ret .= '(...)'; } $texte = $texte_ret; + return $texte; }