function scanner_confirm_form in Search and Replace Scanner 6
Same name and namespace in other branches
- 5.2 scanner.module \scanner_confirm_form()
- 7 scanner.module \scanner_confirm_form()
Scanner confirmation form to prevent people from accidentally replacing things they don't intend to.
1 string reference to 'scanner_confirm_form'
- scanner_menu in ./
scanner.module - Implementation of hook_menu().
File
- ./
scanner.module, line 426 - Search and Replace Scanner - works on all nodes text content.
Code
function scanner_confirm_form() {
//using set_html_head because it seems unecessary to load a separate css
// file for just one declaration:
//you can override the styles by declaring with something "higher up"
// the chain, like: #wrapper #scanner-confirm-form .scanner-buttons .scanner-button-msg {...}
drupal_set_html_head('
<style type="text/css">
#scanner-confirm-form .scanner-buttons .scanner-button-msg {
position:absolute;
top:0; left:0; z-index:100;
width:100%; height:100%;
background-color:#000; opacity:0.75;
font-size:1.2em;
}
#scanner-confirm-form .scanner-buttons .scanner-button-msg p {
color:#fff;
}
</style>
');
//javascript to prevent further clicks on confirmation button after it's clicked once.
//unfortunately we can't just use css disable to disable the button because then
// the op values aren't sent to drupal correctly.
drupal_add_js("\n \$(document).ready(function() {\n \$('input[@type=submit][@value=Yes, Continue]').click(function() {\n \$('.scanner-buttons').css('position','relative')\n .append('<div class=\"scanner-button-msg\"><p>Replacing items... please wait...</p></div>')\n \$('.scanner-button-msg').click(function() { return false; });\n return true;\n });\n });\n ", 'inline');
$form = array();
$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' => 'markup',
'#value' => $msg,
);
$form['confirm'] = array(
'#type' => 'submit',
'#value' => t('Yes, Continue'),
'#prefix' => '<div class="scanner-buttons">',
);
$form['cancel'] = array(
'#type' => 'submit',
'#value' => t('No, Cancel'),
'#suffix' => '</div>',
);
return $form;
}