function scanner_confirm_form in Search and Replace Scanner 7
Same name and namespace in other branches
- 5.2 scanner.module \scanner_confirm_form()
- 6 scanner.module \scanner_confirm_form()
Form constructor for the confirmation form.
See also
1 string reference to 'scanner_confirm_form'
- scanner_menu in ./
scanner.module - Implements hook_menu().
File
- ./
scanner.module, line 441 - Search and Replace Scanner - works on all nodes text content.
Code
function scanner_confirm_form($form, &$form_state) {
$form = array();
$form['#attached']['js'][] = drupal_get_path('module', 'scanner') . '/scanner.js';
$form['#attached']['css'][] = drupal_get_path('module', 'scanner') . '/scanner.css';
$search = $_SESSION['scanner_search'];
$replace = $_SESSION['scanner_replace'];
$preceded = $_SESSION['scanner_preceded'];
$followed = $_SESSION['scanner_followed'];
$wholeword = $_SESSION['scanner_wholeword'];
$regex = $_SESSION['scanner_regex'];
$mode = $_SESSION['scanner_mode'];
$modetxt = $mode ? t('Case sensitive') : t('Not case sensitive: will replace any matches regardless of capitalization.');
$msg = '<p>' . t('Are you sure you want to make the following replacement?') . '</p>' . '<div class="scanner-confirm">' . ' <label>' . t('Search for') . ':</label> [' . check_plain($search) . ']' . '</div>';
if ($preceded) {
$msg .= '<div class="scanner-confirm">' . ' <label>' . t('Preceded by') . ':</label> [' . check_plain($preceded) . ']' . '</div>';
}
if ($followed) {
$msg .= '<div class="scanner-confirm">' . ' <label>' . t('Followed by') . ':</label> [' . check_plain($followed) . ']' . '</div>';
}
$msg .= '<div class="scanner-confirm">' . ' <label>' . t('Replace with') . ':</label> [' . check_plain($replace) . ']';
if ($replace === '') {
$msg .= ' <span class="warning">This will delete any occurences of the search terms!</span>';
}
$msg .= '</div>' . '<div class="scanner-confirm">' . ' <label>' . t('Mode') . ':</label> ' . $modetxt . '</div>';
if ($wholeword) {
$msg .= '<div class="scanner-confirm">' . ' <label>' . t('Match whole word') . ':</label> ' . t('Yes') . '</div>';
}
if ($regex) {
$msg .= '<div class="scanner-confirm">' . ' <label>' . t('Use regular expressions') . ':</label> ' . t('Yes') . '</div>';
}
$form['warning'] = array(
'#type' => 'item',
'#markup' => $msg,
);
$form['confirm'] = array(
'#type' => 'submit',
'#value' => t('Yes, Continue'),
// see suffix in cancel button element.
'#prefix' => '<div class="scanner-buttons">',
);
$form['cancel'] = array(
'#type' => 'submit',
'#value' => t('No, Cancel'),
// see prefix in confirm button element.
'#suffix' => '</div>',
);
return $form;
}