You are here

function TableDiffFormatter::_changed in Diff 5

Overrides DiffFormatter::_changed

File

./DiffEngine.php, line 1101

Class

TableDiffFormatter
Wikipedia Table style diff formatter. @todo document @private @subpackage DifferenceEngine

Code

function _changed($orig, $closing) {
  $diff = new WordLevelDiff($orig, $closing);
  $del = $diff
    ->orig();
  $add = $diff
    ->closing();

  # Notice that WordLevelDiff returns HTML-escaped output.

  # Hence, we will be calling addedLine/deletedLine without HTML-escaping.
  while ($line = array_shift($del)) {
    $aline = array_shift($add);
    echo '<tr>' . $this
      ->deletedLine($line) . $this
      ->addedLine($aline) . "</tr>\n";
  }
  foreach ($add as $line) {

    # If any leftovers
    echo '<tr>' . $this
      ->emptyLine() . $this
      ->addedLine($line) . "</tr>\n";
  }
}