You are here

function diff_inline_form in Diff 7.3

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

Form builder: Inline diff controls.

1 string reference to 'diff_inline_form'
diff_block_view in ./diff.module
Implements hook_block_view().

File

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

Code

function diff_inline_form($form, $form_state, $node, $revisions) {
  $form = array();
  $form['node'] = array(
    '#type' => 'value',
    '#value' => $node,
  );
  $form['revision'] = array(
    '#type' => 'select',
    '#options' => array(
      0 => t('- No highlighting -'),
    ),
    '#default_value' => arg(2) === 'revisions' && arg(3) === $node->vid ? $node->vid : 0,
    '#ajax' => array(
      'callback' => 'diff_inline_ajax',
      'wrapper' => "node-{$node->nid}",
      'method' => 'replace',
    ),
  );
  foreach ($revisions as $revision) {
    $form['revision']['#options'][$revision->vid] = t('@revision by @name', array(
      '@revision' => format_date($revision->timestamp, 'short'),
      '@name' => format_username($revision),
    ));
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('View'),
    '#submit' => array(
      'diff_inline_form_submit',
    ),
    '#attributes' => array(
      'class' => array(
        'diff-js-hidden',
      ),
    ),
  );
  return $form;
}