function apachesolr_environment_edit_form in Apache Solr Search 7
Same name and namespace in other branches
- 8 apachesolr.admin.inc \apachesolr_environment_edit_form()
- 6.3 apachesolr.admin.inc \apachesolr_environment_edit_form()
Form builder for adding/editing a Solr environment used as a menu callback.
2 string references to 'apachesolr_environment_edit_form'
- apachesolr_environment_settings_page in ./
apachesolr.admin.inc - Settings page for a specific environment (or default one if not provided)
- apachesolr_menu in ./
apachesolr.module - Implements hook_menu().
File
- ./
apachesolr.admin.inc, line 136 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_environment_edit_form(array $form, array &$form_state, array $environment = array()) {
if (empty($environment)) {
$environment = array();
}
$environment += array(
'env_id' => '',
'name' => '',
'url' => '',
'service_class' => '',
'conf' => array(),
);
$form['#environment'] = $environment;
$form['url'] = array(
'#type' => 'textfield',
'#title' => t('Solr server URL'),
'#default_value' => $environment['url'],
'#description' => t('Example: http://localhost:8983/solr'),
'#required' => TRUE,
);
$is_default = $environment['env_id'] == apachesolr_default_environment();
$form['make_default'] = array(
'#type' => 'checkbox',
'#title' => t('Make this Solr search environment the default'),
'#default_value' => $is_default,
'#disabled' => $is_default,
);
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $environment['name'],
'#required' => TRUE,
);
$form['env_id'] = array(
'#type' => 'machine_name',
'#title' => t('Environment id'),
'#machine_name' => array(
'exists' => 'apachesolr_environment_load',
),
'#default_value' => $environment['env_id'],
'#disabled' => !empty($environment['env_id']),
// Cannot change it once set.
'#description' => t('Unique, machine-readable identifier for this Solr environment.'),
'#required' => TRUE,
);
$form['service_class'] = array(
'#type' => 'value',
'#value' => $environment['service_class'],
);
$form['conf'] = array(
'#tree' => TRUE,
);
$form['conf']['apachesolr_read_only'] = array(
'#type' => 'radios',
'#title' => t('Index write access'),
'#default_value' => isset($environment['conf']['apachesolr_read_only']) ? $environment['conf']['apachesolr_read_only'] : APACHESOLR_READ_WRITE,
'#options' => array(
APACHESOLR_READ_WRITE => t('Read and write (normal)'),
APACHESOLR_READ_ONLY => t('Read only'),
),
'#description' => t('<em>Read only</em> stops this site from sending updates to this search environment. Useful for development sites.'),
);
$form['conf']['apachesolr_direct_commit'] = array(
'#type' => 'checkbox',
'#title' => t('Commit changes after the index process has submitted them'),
'#description' => t('Commits the updates to solr. Uses soft commits where possible'),
'#default_value' => isset($environment['conf']['apachesolr_direct_commit']) ? $environment['conf']['apachesolr_direct_commit'] : false,
);
$form['conf']['apachesolr_soft_commit'] = array(
'#type' => 'checkbox',
'#title' => t('Commit changes to memory.'),
'#description' => t(' Reduces the load on your disk. Also known as Soft Commits, recommended for Solr 4.'),
'#default_value' => isset($environment['conf']['apachesolr_soft_commit']) ? $environment['conf']['apachesolr_soft_commit'] : false,
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['save'] = array(
'#type' => 'submit',
'#validate' => array(
'apachesolr_environment_edit_validate',
),
'#submit' => array(
'apachesolr_environment_edit_submit',
),
'#value' => t('Save'),
);
$form['actions']['save_edit'] = array(
'#type' => 'submit',
'#validate' => array(
'apachesolr_environment_edit_validate',
),
'#submit' => array(
'apachesolr_environment_edit_submit',
),
'#value' => t('Save and edit'),
);
$form['actions']['test'] = array(
'#type' => 'submit',
'#validate' => array(
'apachesolr_environment_edit_validate',
),
'#submit' => array(
'apachesolr_environment_edit_test_submit',
),
'#value' => t('Test connection'),
);
if (!empty($environment['env_id']) && !$is_default) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#submit' => array(
'apachesolr_environment_edit_delete_submit',
),
'#value' => t('Delete'),
);
}
// Ensures destination is an internal URL, builds "cancel" link.
if (isset($_GET['destination']) && !url_is_external($_GET['destination'])) {
$destination = $_GET['destination'];
}
else {
$destination = 'admin/config/search/apachesolr/settings';
}
$form['actions']['cancel'] = array(
'#type' => 'link',
'#title' => t('Cancel'),
'#href' => $destination,
);
return $form;
}