/**
  * Display the diff in changeset
  *
  * @return string The text to display
  */
 public function fetchDiff($previous, $next, $format)
 {
     $string = '';
     switch ($format) {
         case 'text':
             $diff = new Codendi_Diff($previous, $next);
             $f = new Codendi_UnifiedDiffFormatter();
             $string .= PHP_EOL . $f->format($diff);
             break;
         case 'html':
             $formated_diff = $this->getFormatedDiff($previous, $next);
             if ($formated_diff) {
                 $string = $this->fetchDiffInFollowUp($formated_diff);
             }
             break;
         case 'modal':
             $formated_diff = $this->getFormatedDiff($previous, $next);
             if ($formated_diff) {
                 $string = '<div class="diff">' . $formated_diff . '</div>';
             }
         default:
             break;
     }
     return $string;
 }
Exemplo n.º 2
0
 function __construct($context_lines = 4)
 {
     parent::__construct($context_lines);
     $this->_html = '';
 }
 /**
  * Display the diff in changeset
  *
  * @return string The text to display
  */
 public function fetchDiff($previous, $next, $format)
 {
     $string = '';
     switch ($format) {
         case 'html':
             $callback = array(Codendi_HTMLPurifier::instance(), 'purify');
             $d = new Codendi_Diff(array_map($callback, $previous, array_fill(0, count($previous), CODENDI_PURIFIER_CONVERT_HTML)), array_map($callback, $next, array_fill(0, count($next), CODENDI_PURIFIER_CONVERT_HTML)));
             $f = new Codendi_HtmlUnifiedDiffFormatter();
             $diff = $f->format($d);
             if ($diff) {
                 $string .= '<div class="diff">' . $diff . '</div>';
             }
             break;
         case 'text':
             $diff = new Codendi_Diff($previous, $next);
             $f = new Codendi_UnifiedDiffFormatter();
             $string .= PHP_EOL . $f->format($diff);
             break;
         default:
             break;
     }
     return $string;
 }