You are here

function diff_node_view_alter in Diff 7.3

Same name and namespace in other branches
  1. 7.2 diff.module \diff_node_view_alter()

Implements hook_node_view_alter().

File

./diff.module, line 349
Provides functionality to show a diff between two node revisions.

Code

function diff_node_view_alter(&$build) {
  $node = $build['#node'];
  if (user_access('view revisions') && in_array($node->type, variable_get('diff_show_diff_inline_node_bundles', array()), TRUE)) {

    // Ugly but cheap way to check that we are viewing a node's revision page.
    if (arg(2) === 'revisions' && arg(3) === $node->vid) {
      module_load_include('inc', 'diff', 'diff.pages');
      $old_vid = _diff_get_previous_vid(node_revision_list($node), $node->vid);
      $build = array(
        '#markup' => diff_inline_show($node, $old_vid),
      );
    }
    $build['#prefix'] = isset($build['#prefix']) ? "<div id='diff-inline-{$node->nid}'>" . $build['#prefix'] : "<div id='diff-inline-{$node->nid}'>";
    $build['#suffix'] = isset($build['#suffix']) ? $build['#suffix'] . "</div>" : "</div>";
  }
}