Commit 999d76e7 authored by Dries's avatar Dries

- Patch #524476 by Scott Reynolds: improper FAPI handling for search settings...

- Patch #524476 by Scott Reynolds: improper FAPI handling for search settings form and minor clean-up of function names.
parent efd1a973
......@@ -1073,7 +1073,7 @@ function node_delete_multiple($nids) {
// because node module is implementing search module's API, not the other
// way around.
if (module_exists('search')) {
search_wipe($nid, 'node');
search_reindex($nid, 'node');
}
}
......
......@@ -9,7 +9,7 @@
/**
* Menu callback: confirm wiping of the index.
*/
function search_wipe_confirm() {
function search_reindex_confirm() {
return confirm_form(array(), t('Are you sure you want to re-index the site?'),
'admin/settings/search', t(' The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed. This action cannot be undone.'), t('Re-index site'), t('Cancel'));
}
......@@ -17,9 +17,9 @@ function search_wipe_confirm() {
/**
* Handler for wipe confirmation
*/
function search_wipe_confirm_submit(&$form, &$form_state) {
function search_reindex_confirm_submit(&$form, &$form_state) {
if ($form['confirm']) {
search_wipe();
search_reindex();
drupal_set_message(t('The index will be rebuilt.'));
$form_state['redirect'] = 'admin/settings/search';
return;
......@@ -31,7 +31,8 @@ function search_wipe_confirm_submit(&$form, &$form_state) {
*
* @ingroup forms
* @see system_settings_form()
* @see search_admin_settings_validate()
* @see search_admin_settings_submit()
* @see search_admin_reindex_submit()
*/
function search_admin_settings() {
// Collect some stats
......@@ -48,7 +49,7 @@ function search_admin_settings() {
$status = '<p><strong>' . t('%percentage of the site has been indexed.', array('%percentage' => $percentage)) . ' ' . $count . '</strong></p>';
$form['status'] = array('#type' => 'fieldset', '#title' => t('Indexing status'));
$form['status']['status'] = array('#markup' => $status);
$form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'));
$form['status']['wipe'] = array('#type' => 'submit', '#value' => t('Re-index site'), '#submit' => array('search_admin_reindex_submit'));
$items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500));
......@@ -87,7 +88,7 @@ function search_admin_settings() {
'#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')
);
$form['#validate'] = array('search_admin_settings_validate');
$form['#submit'][] = 'search_admin_settings_submit';
// Per module settings
$form = array_merge($form, module_invoke_all('search', 'admin'));
......@@ -95,16 +96,21 @@ function search_admin_settings() {
}
/**
* Validate callback.
* Submit callback.
*/
function search_admin_settings_validate($form, &$form_state) {
if ($form_state['values']['op'] == t('Re-index site')) {
drupal_goto('admin/settings/search/wipe');
}
function search_admin_settings_submit($form, &$form_state) {
// If these settings change, the index needs to be rebuilt.
if ((variable_get('minimum_word_size', 3) != $form_state['values']['minimum_word_size']) ||
(variable_get('overlap_cjk', TRUE) != $form_state['values']['overlap_cjk'])) {
drupal_set_message(t('The index will be rebuilt.'));
search_wipe();
search_reindex();
}
}
/**
* Submit callback.
*/
function search_admin_reindex_submit($form, &$form_state) {
// send the user to the confirmation page
$form_state['redirect'] = 'admin/settings/search/reindex';
}
\ No newline at end of file
......@@ -199,10 +199,10 @@ function search_menu() {
'access arguments' => array('administer search'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/search/wipe'] = array(
$items['admin/settings/search/reindex'] = array(
'title' => 'Clear index',
'page callback' => 'drupal_get_form',
'page arguments' => array('search_wipe_confirm'),
'page arguments' => array('search_reindex_confirm'),
'access arguments' => array('administer search'),
'type' => MENU_CALLBACK,
);
......@@ -243,7 +243,7 @@ function _search_menu($name) {
* @param $type
* (optional) The type of item to wipe.
*/
function search_wipe($sid = NULL, $type = NULL, $reindex = FALSE) {
function search_reindex($sid = NULL, $type = NULL, $reindex = FALSE) {
if ($type == NULL && $sid == NULL) {
module_invoke_all('search', 'reset');
}
......@@ -575,7 +575,7 @@ function search_index($sid, $type, $text) {
$tag = !$tag;
}
search_wipe($sid, $type, TRUE);
search_reindex($sid, $type, TRUE);
// Insert cleaned up data into dataset
db_query("INSERT INTO {search_dataset} (sid, type, data, reindex) VALUES (%d, '%s', '%s', %d)", $sid, $type, $accum, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment