You are here

function _diff_table_body in Diff 5

Create the table body of the diff between $old_node and $new_node. The result is a html table part enclosed in <tbody> tags.

Parameters

$old_node: Node for comparison which will be displayed on the left side.

$new_node: Node for comparison which will be displayed on the right side.

2 calls to _diff_table_body()
diff_diffs_show in ./diff.module
Create output string for a comparison of 'node' between versions 'old_vid' and 'new_vid'.
diff_node_form_add_changes in ./diff.module
Callback for node edit form to add the 'Preview changes' output.

File

./diff.module, line 364

Code

function _diff_table_body(&$old_node, &$new_node) {
  drupal_add_css(drupal_get_path('module', 'diff') . '/diff.css', 'module', 'all', FALSE);
  include_once 'DiffEngine.php';
  include_once 'node.inc';
  if (module_exists('upload')) {
    include_once 'upload.inc';
  }
  if (module_exists('content')) {
    include_once 'cck.inc';
  }
  $output = '<tbody>';
  $any_visible_change = false;
  $node_diffs = module_invoke_all('diff', $old_node, $new_node);
  foreach ($node_diffs as $node_diff) {
    $diff = new Diff($node_diff['old'], $node_diff['new']);
    $formatter = new TableDiffFormatter();
    if (isset($node_diff['format'])) {
      $formatter->show_header = $node_diff['format']['show_header'];
    }
    $formatter_output = $formatter
      ->format($diff);
    if ($formatter_output) {
      $output .= '<tr><td colspan="4" class="diff-section-title">' . t('Changes to %name', array(
        '%name' => $node_diff['name'],
      )) . '</td></tr>';
      $output .= $formatter_output;
      $any_visible_change = true;
    }
  }
  if (!$any_visible_change) {
    $output .= '<tr><td colspan="4" class="diff-section-title">' . t('No visible changes') . '</td></tr>';
  }
  $output .= '</tbody>';
  return $output;
}