You are here

public function SearchApiTokenizer::configurationForm in Search API 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_tokenizer.inc, line 24
Contains SearchApiTokenizer.

Class

SearchApiTokenizer
Processor for tokenizing fulltext data by replacing (configurable) non-letters with spaces.

Code

public function configurationForm() {
  $form = parent::configurationForm();

  // Only make fulltext fields available as options.
  $fields = $this->index
    ->getFields();
  $field_options = array();
  foreach ($fields as $name => $field) {
    if (empty($field['real_type']) && search_api_is_text_type($field['type'])) {
      $field_options[$name] = $field['name'];
    }
  }
  $form['fields']['#options'] = $field_options;
  $form += array(
    'spaces' => array(
      '#type' => 'textfield',
      '#title' => t('Whitespace characters'),
      '#description' => t('Specify the characters that should be regarded as whitespace and therefore used as word-delimiters. ' . 'Specify the characters as a <a href="@link">PCRE character class</a>. ' . 'Note: For non-English content, the default setting might not be suitable.', array(
        '@link' => url('http://www.php.net/manual/en/regexp.reference.character-classes.php'),
      )),
      '#default_value' => "[^[:alnum:]]",
    ),
    'ignorable' => array(
      '#type' => 'textfield',
      '#title' => t('Ignorable characters'),
      '#description' => t('Specify characters which should be removed from fulltext fields and search strings (e.g., "-"). The same format as above is used.'),
      '#default_value' => "[']",
    ),
  );
  if (!empty($this->options)) {
    $form['spaces']['#default_value'] = $this->options['spaces'];
    $form['ignorable']['#default_value'] = $this->options['ignorable'];
  }
  return $form;
}