function apachesolr_settings_validate in Apache Solr Search 6.2
Same name and namespace in other branches
- 5.2 apachesolr.admin.inc \apachesolr_settings_validate()
- 6 apachesolr.admin.inc \apachesolr_settings_validate()
Validation function for the apachesolr_settings form.
See also
File
- ./
apachesolr.admin.inc, line 121 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_settings_validate($form, &$form_state) {
if (isset($form['apachesolr_port'])) {
$port = $form_state['values']['apachesolr_port'];
// TODO: Port range should be 0-65535, but 0 crashes apachesolr
if (!ctype_digit($port) || $port < 1 || $port > 65535) {
form_set_error('apachesolr_port', t('The port has to be an integer between 1 and 65535.'));
}
else {
$form_state['values']['apachesolr_host'] = trim($form_state['values']['apachesolr_host']);
$form_state['values']['apachesolr_port'] = trim($form_state['values']['apachesolr_port']);
$form_state['values']['apachesolr_path'] = '/' . trim($form_state['values']['apachesolr_path'], "/ \t\r\n\0\v");
}
}
$intval = intval($form_state['values']['apachesolr_rows']);
// TODO: does the max need to be variable?
$max = 200;
if (!is_numeric($form_state['values']['apachesolr_rows']) || $intval < 0 || $intval > $max) {
form_set_error('apachesolr_rows', t('Results per page should be non-negative integer less than @max.', array(
'@max' => $max,
)));
}
else {
// Set the integer value as the one we are saving to the variable.
$form_state['values']['apachesolr_rows'] = $intval;
}
}