You are here

public function FuzzysearchSearch::configurationForm in Fuzzy Search 7

Return the processor configuration form.

Return value

array Associative configuration form array.

Overrides SearchApiAbstractProcessor::configurationForm

File

includes/processor_search.inc, line 27

Class

FuzzysearchSearch
Processor to set the index and search settings. Requires FuzzySearchService.

Code

public function configurationForm() {
  $form['ngram_length'] = array(
    '#type' => 'select',
    '#title' => t('Ngram length'),
    '#description' => t('Choose 3 unless you have special requirements.'),
    '#options' => drupal_map_assoc(array(
      2,
      3,
      4,
      5,
      6,
    )),
    '#default_value' => 3,
  );
  $form['missing_letters'] = array(
    '#type' => 'select',
    '#title' => t('Assume missing letters in search terms'),
    '#description' => t('A search term as entered by a user may be missing letters. Up to how many missing letters in the term do you want to assume? 0 means the term will not return longer words in the results. 1 means a 4 letter search term will also check 5 letters words in the index.'),
    '#options' => drupal_map_assoc(range(0, 50)),
    '#default_value' => 5,
  );
  $form['extra_letters'] = array(
    '#type' => 'select',
    '#title' => t('Assume extra letters in search terms'),
    '#description' => t('A search term as entered by a user may have extra letters. Up to how many extra letters in the term do you want to assume? 0 means the term will not return shorter words in the results. 1 means a 4 letter search term will also check 3 letters words in the index.'),
    '#options' => drupal_map_assoc(range(0, 50)),
    '#default_value' => 5,
  );
  $form['completeness'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum completeness'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Enter a value between 0 and 100 to set the minimum match completeness required in the returned results.'),
    '#default_value' => 40,
  );
  $form['sort_score'] = array(
    '#type' => 'checkbox',
    '#title' => t('Sort by score'),
    '#description' => t('If selected, the results will be sorted by score first and completeness second, which can make tag scores even more important. The default is to sort by completeness first.'),
    '#default_value' => FALSE,
  );
  if (!empty($this->options)) {
    $form['ngram_length']['#default_value'] = $this->options['ngram_length'];
    $form['missing_letters']['#default_value'] = $this->options['missing_letters'];
    $form['extra_letters']['#default_value'] = $this->options['extra_letters'];
    $form['completeness']['#default_value'] = $this->options['completeness'];
    $form['sort_score']['#default_value'] = $this->options['sort_score'];
  }
  return $form;
}