function node_import_check_boolean in Node import 6
Check if the value is a valid boolean (1, 0, true, false, yes, no, on, off).
Uses: nothing.
Related topics
1 string reference to 'node_import_check_boolean'
- node_import_fields in ./
node_import.inc - Returns a list of available content fields for given node_import type.
File
- ./
node_import.inc, line 1151 - Public API of the Node import module.
Code
function node_import_check_boolean(&$value, $field, $options, $preview) {
static $trues;
static $falses;
if (!isset($trues)) {
$trues = array(
'1',
'on',
drupal_strtolower(t('On')),
'yes',
drupal_strtolower(t('Yes')),
'true',
drupal_strtolower(t('True')),
);
$falses = array(
'0',
'off',
drupal_strtolower(t('Off')),
'no',
drupal_strtolower(t('No')),
'false',
drupal_strtolower(t('False')),
);
}
if (in_array(drupal_strtolower($value), $trues, TRUE)) {
$value = '1';
return TRUE;
}
else {
if (in_array(drupal_strtolower($value), $falses, TRUE)) {
$value = '0';
return TRUE;
}
}
node_import_input_error(t('Input error: %value is not allowed for %name (not a boolean).', array(
'%value' => $value,
'%name' => $field['title'],
)));
return FALSE;
}