You are here

function fuzzysearch_admin_form_validate in Fuzzy Search 6

File

./fuzzysearch.admin.inc, line 180
Admin settings and related functions

Code

function fuzzysearch_admin_form_validate($form, &$form_state) {
  if (!is_numeric($form_state['values']['fuzzysearch_ngram_length'])) {
    form_set_error('fuzzysearch_ngram_length', t('Ngram length must be an integer.'));
  }
  if (!is_numeric($form_state['values']['fuzzysearch_index_cron'])) {
    form_set_error('fuzzysearch_index_cron', t('Cron index number must be an integer.'));
  }
  if (!is_numeric($form_state['values']['fuzzysearch_completeness'])) {
    form_set_error('fuzzysearch_completeness', t('Minimum match completeness must be an integer.'));
  }
  if (!is_numeric($form_state['values']['fuzzysearch_missing_letters']) || $form_state['values']['missing_letters'] < 0 || $form_state['values']['missing_letters'] > 9) {
    form_set_error('fuzzysearch_missing_letters', t('Assumed missing letters value must be an integer between 0 and 9 inclusive.'));
  }
  if (!is_numeric($form_state['values']['fuzzysearch_extra_letters']) || $form_state['values']['extra_letters'] < 0 || $form_state['values']['extra_letters'] > 9) {
    form_set_error('fuzzysearch_extra_letters', t('Assumed extra letters value match completeness must be an integer between 0 and 9 inclusive.'));
  }
  $path = _menu_find_router_path($form_state['values']['fuzzysearch_path_name']);
  if (!empty($path) && $path != 'fuzzysearch/results' && $path != variable_get('fuzzysearch_path_name', 'fuzzysearch/results')) {
    form_set_error('fuzzysearch_path_name', t('The search results path is already in use.'));
  }
  if (!is_numeric($form_state['values']['fuzzysearch_excerpt'])) {
    form_set_error('fuzzysearch_spelling', t('Excerpt length must be an integer.'));
  }
  if (!is_numeric($form_state['values']['fuzzysearch_max_result'])) {
    form_set_error('fuzzysearch_max_result', t('Maximum result length must be an integer.'));
  }
  if ($form_state['values']['fuzzysearch_excerpt'] > $form_state['values']['fuzzysearch_max_result'] && $form_state['values']['fuzzysearch_max_result'] != 0) {
    drupal_set_message(t('The maximum result length has been set smaller than the excerpt length. Any results will display the result\'s teaser instead of the found excerpt.'), 'warning');
  }
  if (!is_numeric($form_state['values']['fuzzysearch_spelling'])) {
    form_set_error('spelling', t('Minimum spelling score must be an integer.'));
  }
}