You are here

public function FuzzysearchExcerpt::configurationForm in Fuzzy Search 7

Display a form for configuring this processor. Since forcing users to specify options for disabled processors makes no sense, none of the form elements should have the '#required' attribute set.

Return value

array A form array for configuring this processor, or FALSE if no configuration is possible.

Overrides SearchApiAbstractProcessor::configurationForm

File

includes/processor_excerpt.inc, line 23
File for processor excerpt.

Class

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

Code

public function configurationForm() {
  $form['debug_score'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display scoring'),
    '#description' => t('If selected, the completeness and score of the results will be shown below each result, which may be helpful for tuning the display.'),
    '#default_value' => FALSE,
  );
  $form['excerpt_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Result excerpt length'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Set the length of the displayed text excerpt containing a found search term. Applies per found term.'),
    '#default_value' => 200,
  );
  $form['max_result_length'] = array(
    '#type' => 'textfield',
    '#title' => t('Maximum result length'),
    '#size' => 4,
    '#maxlength' => 4,
    '#description' => t('Set the maximum length of the displayed result. Set to 0 for unlimited length. Applies per result.'),
    '#default_value' => 400,
  );
  $form['spelling'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum spelling score'),
    '#size' => 3,
    '#maxlength' => 3,
    '#description' => t('Fuzzysearch tries to highlight search terms that may be misspelled. You can set the minimum threshold, which is calculated as a ratio of ngram hits to misses in a term. 0 may cause a misspelling to highlight everything, and 100 will only highlight exact terms. Enter value between 0 and 100. Changing this setting does not require reindexing.'),
    '#default_value' => 30,
  );
  if (!empty($this->options)) {
    $form['debug_score']['#default_value'] = $this->options['debug_score'];
    $form['excerpt_length']['#default_value'] = $this->options['excerpt_length'];
    $form['max_result_length']['#default_value'] = $this->options['max_result_length'];
    $form['spelling']['#default_value'] = $this->options['spelling'];
  }
  return $form;
}