function nodejs_config_form in Node.js integration 7
Same name and namespace in other branches
- 6 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, &$form_state) {
$suggestion = variable_get('nodejs_config_js_suggestion', '');
$file_path = drupal_get_path('module', 'nodejs') . '/nodejs.config.js';
$config_path_message = t('<ol><li>Configure your server settings in the SETTINGS form below.</li><li>Click the <b>Save Configuration</b> button</li><li>Copy the suggested configuration lines to <b>!file</b>, you need to do it manually.</li></ol>', array(
'!file' => $file_path,
));
$form['config_suggestion'] = array(
'#type' => 'fieldset',
'#title' => 'Configuration builder',
'#description' => $config_path_message,
);
$form['config_suggestion']['nodejs_config_js'] = array(
'#type' => 'textarea',
'#title' => 'Suggested configuration:',
'#default_value' => $suggestion,
);
$form['config'] = array(
'#type' => 'fieldset',
'#title' => 'Settings',
);
$form['config']['nodejs_config_host'] = array(
'#type' => 'textfield',
'#title' => 'Host',
'#required' => TRUE,
'#description' => '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' => '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' => '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' => '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' => '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' => 'http path on which the node.js server should accept messages from the Drupal site.',
'#default_value' => variable_get('nodejs_config_publishUrl', 'publish'),
);
$form['config']['nodejs_service_key'] = array(
'#type' => 'textfield',
'#title' => 'Service Key',
'#description' => 'An arbitrary string used as a secret between the Node.js server and the Drupal site. The key can be changed on the Node.js module configuration page.',
'#default_value' => variable_get('nodejs_service_key', ''),
'#disabled' => TRUE,
);
$form['config']['nodejs_config_write_channels'] = array(
'#type' => 'checkbox',
'#title' => 'Client write to channels',
'#description' => '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' => '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' => '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' => '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_messagePath'] = array(
'#type' => 'textfield',
'#title' => 'Auth Path',
'#description' => 'http path on which the Drupal node.js module listens for authentication check
requests. Must end with /.',
'#default_value' => variable_get('nodejs_config_backend_messagePath', '/nodejs/message'),
);
$form['config']['backend']['nodejs_config_debug'] = array(
'#type' => 'checkbox',
'#title' => 'Debug',
'#description' => 'Show debug information from the node.js process.',
'#default_value' => variable_get('nodejs_config_debug', FALSE),
);
$form['ext'] = array(
'#type' => 'fieldset',
'#title' => 'Extensions',
'#description' => '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' => '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);
}