You are here

public function AbstractSearchApiSolrMultilingualBackend::buildConfigurationForm in Search API Multilingual Solr Search 8

File

src/Plugin/search_api/backend/AbstractSearchApiSolrMultilingualBackend.php, line 64

Class

AbstractSearchApiSolrMultilingualBackend
A abstract base class for all multilingual Solr Search API backends.

Namespace

Drupal\search_api_solr_multilingual\Plugin\search_api\backend

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['multilingual'] = array(
    '#type' => 'fieldset',
    '#title' => $this
      ->t('Multilingual'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['multilingual']['sasm_limit_search_page_to_content_language'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Limit to current content language.'),
    '#description' => $this
      ->t('Limit all search results for custom queries or search pages not managed by Views to current content language if no language is specified in the query.'),
    '#default_value' => isset($this->configuration['sasm_limit_search_page_to_content_language']) ? $this->configuration['sasm_limit_search_page_to_content_language'] : FALSE,
  );
  $form['multilingual']['sasm_search_page_include_language_independent'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include language independent content in search results.'),
    '#description' => $this
      ->t('This option will include content without a language assigned in the results of custom queries or search pages not managed by Views. For example, if you search for English content, but have an article with languague of "undefined", you will see those results as well. If you disable this option, you will only see content that matches the language.'),
    '#default_value' => isset($this->configuration['sasm_search_page_include_language_independent']) ? $this->configuration['sasm_search_page_include_language_independent'] : FALSE,
  );
  $form['multilingual']['sasm_language_unspecific_fallback_on_schema_issues'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Use language fallbacks.'),
    '#description' => $this
      ->t('This option is suitable for two use-cases. First, if you have languages like "de" and "de-at", both could be handled by a shared configuration for "de". Second, new languages will be handled by language-unspecific fallback configuration until the schema gets updated on your Solr server.'),
    '#default_value' => isset($this->configuration['sasm_language_unspecific_fallback_on_schema_issues']) ? $this->configuration['sasm_language_unspecific_fallback_on_schema_issues'] : TRUE,
  );
  $domains = SolrFieldType::getAvailableDomains();
  $form['multilingual']['sasm_domain'] = array(
    '#type' => 'select',
    '#options' => array_combine($domains, $domains),
    '#title' => $this
      ->t('Targeted content domain'),
    '#description' => $this
      ->t('For example "UltraBot3000" would be indexed as "Ultra" "Bot" "3000" in a generic domain, "CYP2D6" has to stay like it is in a scientific domain.'),
    '#default_value' => isset($this->configuration['sasm_domain']) ? $this->configuration['sasm_domain'] : 'generic',
  );
  return $form;
}