You are here

function scanner_undo_confirm_form in Search and Replace Scanner 7

Same name and namespace in other branches
  1. 5.2 scanner.module \scanner_undo_confirm_form()
  2. 6 scanner.module \scanner_undo_confirm_form()

Form constructor for the undo confirmation form.

See also

scanner_undo_confirm_form_submit()

1 string reference to 'scanner_undo_confirm_form'
scanner_menu in ./scanner.module
Implements hook_menu().

File

./scanner.module, line 588
Search and Replace Scanner - works on all nodes text content.

Code

function scanner_undo_confirm_form($form, &$form_state) {
  $undo_id = $_GET['undo_id'];
  if ($undo_id > 0) {
    $query = db_select('scanner', 's');
    $query
      ->fields('s', array(
      'undo_id',
      'searched',
      'replaced',
    ))
      ->condition('undo_id', $undo_id, '=');
    $result = $query
      ->execute();
    foreach ($result as $undo) {
      $undo = $undo;
    }
  }
  if ($undo->undo_id > 0) {
    $form['info'] = array(
      '#markup' => '<h2>' . t('Do you want to undo:') . '</h2>' . '<h3>' . t('Searched for:') . '</h3>' . '<p>[<em>' . check_plain($undo->searched) . '</em>]</p>' . '<h3>' . t('Replaced with:') . '</h3>' . '<p>[<em>' . check_plain($undo->replaced) . '</em>]</p>',
    );
    $form['undo_id'] = array(
      '#type' => 'hidden',
      '#value' => $undo->undo_id,
    );
    $form['confirm'] = array(
      '#type' => 'submit',
      '#value' => t('Yes, Continue'),
    );
    $form['cancel'] = array(
      '#type' => 'submit',
      '#value' => t('No, Cancel'),
    );
  }
  else {
    $form['info'] = array(
      '#value' => '<h2>' . t('No undo event was found') . '</h2>',
    );
  }
  return $form;
}