You are here

function nodejs_config_form in Node.js integration 6

Same name and namespace in other branches
  1. 7 nodejs_config/nodejs_config.module \nodejs_config_form()

Node.js server configuration form.

Parameters

mixed $form :

mixed $form_state :

Return value

array

1 string reference to 'nodejs_config_form'
nodejs_config_menu in nodejs_config/nodejs_config.module
Implements hook_menu().

File

nodejs_config/nodejs_config.module, line 25

Code

function nodejs_config_form() {
  $form['config'] = array(
    '#type' => 'fieldset',
    '#title' => 'Settings',
  );
  $form['config']['nodejs_config_host'] = array(
    '#type' => 'textfield',
    '#title' => 'Host',
    '#required' => TRUE,
    '#description' => t('Specify the host name or IP address that the node.js server should listen on.
                       Leave blank to listen for any host name. Otherwise, the server will only respond
                       to names that match the IP address given (or resolved from the given name).'),
    '#default_value' => variable_get('nodejs_config_host', 'localhost'),
  );
  $form['config']['nodejs_config_port'] = array(
    '#type' => 'textfield',
    '#title' => 'Port',
    '#required' => TRUE,
    '#description' => t('Specify the TCP port that the node.js server should listen on.'),
    '#default_value' => variable_get('nodejs_config_port', '8080'),
  );
  $scheme = variable_get('nodejs_server_scheme', 'http');
  $form['config']['nodejs_config_key'] = array(
    '#type' => $scheme == 'https' ? 'textfield' : 'hidden',
    '#title' => 'Key',
    '#required' => TRUE,
    '#description' => t('File system path to a key used for https communication with the server and clients.'),
    '#default_value' => variable_get('nodejs_config_key', '/path/to/key/file'),
  );
  $form['config']['nodejs_config_cert'] = array(
    '#type' => $scheme == 'https' ? 'textfield' : 'hidden',
    '#title' => 'Cert',
    '#required' => TRUE,
    '#description' => t('File system path to a certificate used for https communication with the server and clients.'),
    '#default_value' => variable_get('nodejs_config_cert', '/path/to/cert/file'),
  );
  $form['config']['nodejs_config_resource'] = array(
    '#type' => 'textfield',
    '#title' => 'Resource',
    '#required' => TRUE,
    '#description' => t('http path that the node.js server should respond to.
                       This value needs to match the Drupal node.js configuration.'),
    '#default_value' => variable_get('nodejs_config_resource', '/socket.io'),
  );
  $form['config']['nodejs_config_publishUrl'] = array(
    '#type' => 'textfield',
    '#title' => 'Publish URL',
    '#required' => TRUE,
    '#description' => t('http path on which the node.js server should accept messages from the Drupal site.'),
    '#default_value' => variable_get('nodejs_config_publishUrl', base_path() . 'nodejs/publish'),
  );
  $form['config']['nodejs_config_serviceKey'] = array(
    '#type' => 'textfield',
    '#title' => 'Service Key',
    '#description' => t('An arbitrary string used as a secret between the node.js server and the Drupal site.'),
    '#default_value' => variable_get('nodejs_config_serviceKey', ''),
  );
  $form['config']['nodejs_config_write_channels'] = array(
    '#type' => 'checkbox',
    '#title' => 'Client write to channels',
    '#description' => t('Global flag that allows all channels to be written to by client sockets without
                       going via the backend. defaults to false'),
    '#default_value' => variable_get('nodejs_config_write_channels', FALSE),
  );
  $form['config']['nodejs_config_write_clients'] = array(
    '#type' => 'checkbox',
    '#title' => 'Client write to clients',
    '#description' => t('Global flag that allows all clients to be written to by client sockets
                       without going via the backend. defaults to false'),
    '#default_value' => variable_get('nodejs_config_write_clients', FALSE),
  );
  $form['config']['backend'] = array(
    '#type' => 'fieldset',
    '#title' => 'Backend',
  );
  $form['config']['backend']['nodejs_config_backend_host'] = array(
    '#type' => 'textfield',
    '#title' => 'Host',
    '#required' => TRUE,
    '#description' => t('Host name of the Drupal site.'),
    '#default_value' => variable_get('nodejs_config_backend_host', 'localhost'),
  );
  $form['config']['backend']['nodejs_config_backend_port'] = array(
    '#type' => 'textfield',
    '#title' => 'Port',
    '#required' => TRUE,
    '#description' => t('TCP port of the server running the Drupal site. Usually 80.'),
    '#default_value' => variable_get('nodejs_config_backend_port', '80'),
  );
  $form['config']['backend']['nodejs_config_backend_authPath'] = array(
    '#type' => 'textfield',
    '#title' => 'Auth Path',
    '#description' => t('http path on which the Drupal node.js module listens for authentication check
                       requests. Must end with /.'),
    '#default_value' => variable_get('nodejs_config_backend_authPath', '/nodejs/auth/'),
  );
  $form['config']['backend']['nodejs_config_debug'] = array(
    '#type' => 'checkbox',
    '#title' => 'Debug',
    '#description' => t('Show debug information from the node.js process.'),
    '#default_value' => variable_get('nodejs_config_debug', FALSE),
  );
  $form['ext'] = array(
    '#type' => 'fieldset',
    '#title' => 'Extensions',
    '#description' => t('An array of names of node.js modules that should be loaded as extensions to the
                       node.js server.'),
  );
  $form['ext']['nodejs_config_extensions'] = array(
    '#type' => 'textarea',
    '#title' => 'Extension file paths',
    '#description' => t('A list of node.js extension files paths, one per line'),
    '#default_value' => variable_get('nodejs_config_extensions', ''),
  );
  $form['#submit'][] = 'nodejs_config_form_submit';
  return system_settings_form($form);
}