public function ElasticsearchConnectorSearchApiHighlight::configurationForm in Elasticsearch Connector 7.2
Same name and namespace in other branches
- 7.5 modules/elasticsearch_connector_search_api/includes/processor_highlight.inc \ElasticsearchConnectorSearchApiHighlight::configurationForm()
- 7 modules/elasticsearch_connector_search_api/includes/processor_highlight.inc \ElasticsearchConnectorSearchApiHighlight::configurationForm()
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
- modules/
elasticsearch_connector_search_api/ includes/ processor_highlight.inc, line 32 - Contains the SearchApiHighlight class.
Class
- ElasticsearchConnectorSearchApiHighlight
- @file Contains the SearchApiHighlight class.
Code
public function configurationForm() {
$this->options += array(
'prefix' => '<strong>',
'suffix' => '</strong>',
'excerpt' => TRUE,
'excerpt_length' => 256,
'excerpt_fragments' => 3,
'concatenator' => '...',
'highlight' => 'always',
);
$form['prefix'] = array(
'#type' => 'textfield',
'#title' => t('Highlighting prefix'),
'#description' => t('Text/HTML that will be prepended to all occurrences of search keywords in highlighted text.'),
'#default_value' => $this->options['prefix'],
);
$form['suffix'] = array(
'#type' => 'textfield',
'#title' => t('Highlighting suffix'),
'#description' => t('Text/HTML that will be appended to all occurrences of search keywords in highlighted text.'),
'#default_value' => $this->options['suffix'],
);
$form['excerpt'] = array(
'#type' => 'checkbox',
'#title' => t('Create excerpt'),
'#description' => t('When enabled, an excerpt will be created for searches with keywords, containing all occurrences of keywords in a fulltext field.'),
'#default_value' => $this->options['excerpt'],
);
$form['excerpt_length'] = array(
'#type' => 'textfield',
'#title' => t('Excerpt length'),
'#description' => t('The requested length of the excerpt, in characters. This is equivalent of Elasticsearch\'s fragment_size option.'),
'#default_value' => $this->options['excerpt_length'],
'#element_validate' => array(
'element_validate_integer_positive',
),
'#states' => array(
'visible' => array(
'#edit-processors-search-api-highlighting-settings-excerpt' => array(
'checked' => TRUE,
),
),
),
);
$form['excerpt_fragments'] = array(
'#type' => 'textfield',
'#title' => t('Excerpt fragments'),
'#description' => t('The number of highlighted excerpt fragments.'),
'#default_value' => $this->options['excerpt_fragments'],
'#element_validate' => array(
'element_validate_integer_positive',
),
'#states' => array(
'visible' => array(
'#edit-processors-search-api-highlighting-settings-excerpt' => array(
'checked' => TRUE,
),
),
),
);
$form['concatenator'] = array(
'#type' => 'textfield',
'#title' => t('Concatenator'),
'#description' => t('The concatenator between different excerpt fragments used for both the excerpt and fields highlighting.'),
'#default_value' => $this->options['concatenator'],
);
$form['highlight'] = array(
'#type' => 'select',
'#title' => t('Highlight returned field data'),
'#description' => t('Select whether returned fields should be highlighted.'),
'#options' => array(
'always' => t('Always'),
'server' => t('If the server returns fields'),
'never' => t('Never'),
),
'#default_value' => $this->options['highlight'],
);
return $form;
}