You are here

function apachesolr_settings in Apache Solr Search 5.2

Same name and namespace in other branches
  1. 8 apachesolr.admin.inc \apachesolr_settings()
  2. 5 apachesolr.module \apachesolr_settings()
  3. 6.3 apachesolr.admin.inc \apachesolr_settings()
  4. 6 apachesolr.admin.inc \apachesolr_settings()
  5. 6.2 apachesolr.admin.inc \apachesolr_settings()
  6. 7 apachesolr.admin.inc \apachesolr_settings()

@file Administrative pages for the Apache Solr framework.

2 string references to 'apachesolr_settings'
apachesolr_menu in ./apachesolr.module
Implementation of hook_menu().
apachesolr_search_form_alter in ./apachesolr_search.module
Implementation of hook_form_alter().

File

./apachesolr.admin.inc, line 8
Administrative pages for the Apache Solr framework.

Code

function apachesolr_settings() {
  $form = array();

  // Perform a check to ensure the server is there
  if (empty($_POST)) {

    // update_help() loads install.inc via include_once, so not much
    // point in working around it.
    include_once './includes/install.inc';
    include_once drupal_get_path('module', 'apachesolr') . '/apachesolr.install';
    foreach (apachesolr_requirements('runtime') as $requirement) {
      $status = $requirement['severity'] == REQUIREMENT_ERROR ? 'error' : 'status';
      drupal_set_message($requirement['title'] . ': ' . $requirement['value'], $status);
    }
  }
  $form['apachesolr_host'] = array(
    '#type' => 'textfield',
    '#title' => t('Solr host name'),
    '#default_value' => variable_get('apachesolr_host', 'localhost'),
    '#description' => t('Host name of your Solr server, e.g. <code>localhost</code> or <code>example.com</code>.'),
    '#required' => TRUE,
  );
  $form['apachesolr_port'] = array(
    '#type' => 'textfield',
    '#title' => t('Solr port'),
    '#default_value' => variable_get('apachesolr_port', '8983'),
    '#description' => t('Port on which the Solr server listens. The Jetty example server is 8983, while Tomcat is 8080 by default.'),
    '#required' => TRUE,
  );
  $form['apachesolr_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Solr path'),
    '#default_value' => variable_get('apachesolr_path', '/solr'),
    '#description' => t('Path that identifies the Solr request handler to be used.'),
  );
  $numbers = drupal_map_assoc(array(
    1,
    5,
    10,
    20,
    50,
    100,
    200,
  ));
  $form['apachesolr_cron_limit'] = array(
    '#type' => 'select',
    '#title' => t('Number of items to index per cron run'),
    '#default_value' => variable_get('apachesolr_cron_limit', 50),
    '#options' => $numbers,
    '#description' => t('The maximum number of items indexed in each pass of a <a href="@cron">cron maintenance task</a>. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array(
      '@cron' => url('admin/logs/status'),
    )),
  );
  $options = drupal_map_assoc(array(
    5,
    10,
    15,
    20,
    25,
    30,
    40,
    50,
    60,
    70,
    80,
    90,
    100,
  ));
  $form['apachesolr_rows'] = array(
    '#type' => 'select',
    '#title' => t('Results per page'),
    '#default_value' => variable_get('apachesolr_rows', 10),
    '#options' => $options,
    '#description' => t('The number of results that will be shown per page.'),
  );
  $form['apachesolr_failure'] = array(
    '#type' => 'select',
    '#title' => t('On failure'),
    '#options' => array(
      'show_error' => t('Show error message'),
      'show_drupal_results' => t('Show core Drupal results'),
      'show_no_results' => t('Show no results'),
    ),
    '#default_value' => variable_get('apachesolr_failure', 'show_error'),
    '#description' => t('What to display if Apache Solr search is not available.'),
  );

  // Add a link to add more mlt blocks.
  $form['mlt_link'] = array(
    '#type' => 'item',
    '#value' => l(t('Add a new content recommendation block'), 'admin/settings/apachesolr/mlt/add_block'),
    '#description' => format_plural(count(apachesolr_mlt_list_blocks()), 'You currently have 1 block.', 'You currenly have @count blocks.'),
  );
  $form['advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('Advanced configuration'),
    '#collapsed' => TRUE,
    '#collapsible' => TRUE,
  );
  $form['advanced']['apachesolr_set_nodeapi_messages'] = array(
    '#type' => 'radios',
    '#title' => t('Extra help messages for administrators'),
    '#default_value' => variable_get('apachesolr_set_nodeapi_messages', 1),
    '#options' => array(
      0 => t('Disabled'),
      1 => t('Enabled'),
    ),
  );
  return system_settings_form($form);
}