You are here

function search_api_federated_solr_admin in Search API Federated Solr 7

Same name and namespace in other branches
  1. 7.3 search_api_federated_solr.admin.inc \search_api_federated_solr_admin()
  2. 7.2 search_api_federated_solr.admin.inc \search_api_federated_solr_admin()

Create search_api_federated_solr config form.

1 string reference to 'search_api_federated_solr_admin'
search_api_federated_solr_menu in ./search_api_federated_solr.module
Implements hook_menu().

File

./search_api_federated_solr.module, line 197
search_api_federated_solr.module Contains hook implementations for the Federated Solr Search API Module.

Code

function search_api_federated_solr_admin($form, &$form_state) {

  // Get search indexes.
  $indexes = [];
  foreach (search_api_index_load_multiple(FALSE) as $index) {
    $indexes[$index->machine_name] = $index->name;
  }
  $form['#prefix'] = '<div id="search-api-federated-solr-config-form">';
  $form['#suffix'] = '</div>';
  $form['search_api_federated_solr_path'] = [
    '#type' => 'textfield',
    '#title' => t('Search app path'),
    '#default_value' => variable_get('search_api_federated_solr_path', 'search-app'),
    '#description' => t('The path for the search app (Default: "search-app").'),
  ];
  $form['search_api_federated_solr_search_index'] = [
    '#type' => 'select',
    '#title' => t('Search API index'),
    '#description' => t('Defines <a href="/admin/config/search/search-api">which search_api index and server</a> the search app should use.'),
    '#options' => $indexes,
    '#default_value' => variable_get('search_api_federated_solr_search_index'),
    '#required' => TRUE,
    '#ajax' => [
      'callback' => 'get_site_name',
      'wrapper' => 'search-api-federated-solr-config-form',
    ],
  ];
  $form['search_api_federated_solr_has_site_name_property'] = [
    '#type' => 'hidden',
    '#default_value' => variable_get('search_api_federated_solr_has_site_name_property') ? 'true' : NULL,
  ];
  $form['search_api_federated_solr_set_search_site'] = [
    '#type' => 'checkbox',
    '#title' => t('Set the "Site name" facet to this site'),
    '#default_value' => variable_get('search_api_federated_solr_set_search_site'),
    '#description' => t('When checked, only search results from this site will be shown, by default, until this site\'s checkbox is unchecked in the search app\'s "Site name" facet.'),
    '#states' => [
      'visible' => [
        ':input[name="search_api_federated_solr_has_site_name_property"]' => [
          'value' => "true",
        ],
      ],
    ],
  ];
  $form['search_api_federated_solr_search_index_basic_auth'] = [
    '#type' => 'fieldset',
    '#title' => t('Search Index Basic Authentication'),
    '#description' => t('If your Solr server is protected by basic HTTP authentication, enter the login data here. This will be accessible to the client in an obscured, but non-secure method. It should, therefore, only provide read access to the index AND be different from that provided when configuring the server in Search API. The Password field is intentionally not obscured to emphasize this distinction.'),
  ];
  $form['search_api_federated_solr_search_index_basic_auth']['search_api_federated_solr_search_index_basic_auth_username'] = [
    '#type' => 'textfield',
    '#title' => t('Username'),
    '#default_value' => variable_get('search_api_federated_solr_search_index_basic_auth_username'),
  ];
  $form['search_api_federated_solr_search_index_basic_auth']['search_api_federated_solr_search_index_basic_auth_password'] = [
    '#type' => 'textfield',
    '#title' => t('Password'),
    '#default_value' => variable_get('search_api_federated_solr_search_index_basic_auth_password'),
  ];
  $form['search_api_federated_solr_show_empty_search_results'] = [
    '#type' => 'checkbox',
    '#title' => t('Show results for empty search'),
    '#default_value' => variable_get('search_api_federated_solr_show_empty_search_results'),
    '#description' => t('When checked, this option allows users to see all results when no search term is entered. By default, empty searches are disabled and yield no results.'),
  ];
  $form['search_api_federated_solr_no_results_text'] = [
    '#type' => 'textfield',
    '#title' => t('No results text'),
    '#default_value' => variable_get('search_api_federated_solr_no_results_text'),
    '#description' => t('This text is shown when a query returns no results. (Default: "Your search yielded no results.")'),
  ];
  $form['search_api_federated_solr_search_prompt_text'] = [
    '#type' => 'textfield',
    '#title' => t('Search prompt text'),
    '#default_value' => variable_get('search_api_federated_solr_search_prompt_text'),
    '#description' => t('This text is shown when no query term has been entered. (Default: "Please enter a search term.")'),
  ];
  $form['search_api_federated_solr_rows'] = [
    '#type' => 'textfield',
    '#attributes' => array(
      ' type' => 'number',
    ),
    '#title' => t('Number of search results per page'),
    '#default_value' => variable_get('search_api_federated_solr_rows'),
    '#description' => t('The max number of results to render per search results page. (Default: 20)'),
  ];
  $form['search_api_federated_solr_page_buttons'] = [
    '#type' => 'textfield',
    '#attributes' => array(
      ' type' => 'number',
    ),
    '#title' => t('Number of pagination buttons'),
    '#default_value' => variable_get('search_api_federated_solr_page_buttons'),
    '#description' => t('The max number of numbered pagination buttons to show at a given time. (Default: 5)'),
  ];
  $form['#cache'] = [
    'max-age' => 0,
  ];
  return system_settings_form($form);
}