You are here

function diff_node_form_build_preview_changes in Diff 7.3

Same name and namespace in other branches
  1. 6.2 diff.module \diff_node_form_build_preview_changes()
  2. 6 diff.module \diff_node_form_build_preview_changes()
  3. 7.2 diff.module \diff_node_form_build_preview_changes()

Submit handler for the 'View changes' action.

See also

node_form_build_preview()

1 string reference to 'diff_node_form_build_preview_changes'
diff_form_node_form_alter in ./diff.module
Implements hook_form_BASE_FORM_ID_alter().

File

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

Code

function diff_node_form_build_preview_changes($form, &$form_state) {
  module_load_include('inc', 'diff', 'diff.pages');
  $old_node = clone node_load($form_state['values']['nid']);
  $node = node_form_submit_build_node($form, $form_state);

  // Create diff of old node and edited node.
  $state = variable_get('diff_default_state_node', 'raw');
  $rows = _diff_body_rows($old_node, $node, $state);
  $header = _diff_default_header(t('Original'), t('Changes'));
  $changes = theme('table__diff__preview', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'diff',
      ),
    ),
    'colgroups' => _diff_default_cols(),
    'sticky' => FALSE,
  ));

  // Prepend diff to edit form.
  $form_state['node_preview'] = $changes;
  $form_state['rebuild'] = TRUE;
}