You are here

function redis_settings_form in Redis 7.2

Same name and namespace in other branches
  1. 7.3 redis.admin.inc \redis_settings_form()
  2. 7 redis.admin.inc \redis_settings_form()

Main settings and review administration screen.

1 string reference to 'redis_settings_form'
redis_menu in ./redis.module
Implements hook_menu().

File

./redis.admin.inc, line 11
Redis module administration pages.

Code

function redis_settings_form($form, &$form_state) {
  $form['connection'] = array(
    '#type' => 'fieldset',
    '#title' => t("Connection information"),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['connection']['scheme'] = array(
    '#type' => 'textfield',
    '#title' => t("Scheme"),
    '#default_value' => 'tcp',
    '#disabled' => TRUE,
    '#description' => t("Connection scheme.") . " " . t("Only <em>tcp</em> is currently supported. This is ignored when using a UNIX socket."),
  );
  $form['connection']['redis_client_host'] = array(
    '#type' => 'textfield',
    '#title' => t("Host"),
    '#default_value' => variable_get('redis_client_host', NULL),
    '#description' => t("Redis server host. Default is <em>@default</em>.", array(
      '@default' => Redis_Client::REDIS_DEFAULT_HOST,
    )),
  );
  $form['connection']['redis_client_port'] = array(
    '#type' => 'textfield',
    '#title' => t("Port"),
    '#default_value' => variable_get('redis_client_port', NULL),
    '#description' => t("Redis server port. Default is <em>@default</em>.", array(
      '@default' => Redis_Client::REDIS_DEFAULT_PORT,
    )),
  );
  $form['connection']['redis_client_socket'] = array(
    '#type' => 'textfield',
    '#title' => t("UNIX socket"),
    '#default_value' => variable_get('redis_client_socket', NULL),
    '#description' => t("Redis UNIX socket for connection. If set remote server host and port will be ignored."),
  );
  $form['connection']['redis_client_base'] = array(
    '#type' => 'textfield',
    '#title' => t("Database"),
    '#default_value' => variable_get('redis_client_base', NULL),
    '#description' => t("Redis server database. Default is none, Redis server will autoselect the database 0."),
  );
  $form['connection']['redis_client_interface'] = array(
    '#type' => 'radios',
    '#title' => t("Client"),
    '#options' => array(
      NULL => t("None or automatic"),
      'PhpRedis' => t("PhpRedis PHP extension"),
      'Predis' => t("Predis PHP library"),
    ),
    '#default_value' => variable_get('redis_client_interface', NULL),
    '#description' => t("Redis low level backend."),
  );
  $form = system_settings_form($form);

  // Enforce empty values drop from the $form_state in order to avoid empty
  // values saving. Empty values would cause the isset() checks in client
  // options to see false positives and fail upon connection.
  array_unshift($form['#submit'], 'redis_settings_form_submit_clean_values');
  return $form;
}