function _suggestion_admin_submit_stopwords in Autocomplete Search Suggestions 7
Process stopwords.
1 call to _suggestion_admin_submit_stopwords()
- suggestion_admin_settings_form_submit in ./
suggestion.admin.inc - Custom submit function for the suggestion setting form.
File
- ./
suggestion.admin.inc, line 537 - Administration form for suggestion module.
Code
function _suggestion_admin_submit_stopwords(&$form_data) {
$stopwords = array();
foreach (preg_split('/\\s*[\\n\\r]+\\s*/s', $form_data['values']['suggestion_stopwords']) as $txt) {
$stopwords += array_flip(preg_split('/\\s+/', SuggestionHelper::tokenize($txt, variable_get('suggestion_min', 4))));
}
$stopwords = array_fill_keys(array_keys($stopwords), 1);
ksort($stopwords);
$file_path = drupal_realpath(variable_get('suggestion_stopword_uri', file_default_scheme() . '://suggestion/suggestion_stopword.txt'));
$stopwords = implode("\n", array_keys($stopwords));
$hash = drupal_hash_base64($stopwords);
if ($hash != variable_get('suggestion_stopword_hash', '')) {
variable_set('suggestion_stopword_hash', $hash);
variable_set('suggestion_synced', FALSE);
}
file_unmanaged_save_data($stopwords, $file_path, FILE_EXISTS_REPLACE);
unset($form_data['input']['suggestion_stopwords']);
unset($form_data['values']['suggestion_stopwords']);
}