function _node_import_sanitize_file_options in Node import 6
Related topics
2 calls to _node_import_sanitize_file_options()
- node_import_read_from_file in ./
node_import.inc - Returns one record from the file starting at file offset using the supplied file options.
- node_import_write_to_string in ./
node_import.inc - Returns one line in the specified file format of the array of values.
File
- ./
node_import.inc, line 1932 - Public API of the Node import module.
Code
function _node_import_sanitize_file_options(&$file_options) {
// When file_format is not '', we need to load the options from the
// predefined file_format.
if (isset($file_options['file_format']) && $file_options['file_format'] !== '') {
$file_formats = node_import_format_options('file formats');
$file_options = array_merge($file_options, $file_formats[$file_options['file_format']]);
}
// The default options (CSV).
$options = array(
'record separator' => '<newline>',
'field separator' => ',',
'text delimiter' => '"',
'escape character' => '"',
);
// Use 'other ...' when selected.
foreach ($options as $key => $default) {
if (isset($file_options[$key]) && drupal_strlen($file_options[$key]) > 0) {
$options[$key] = $file_options[$key];
}
else {
if (isset($file_options['other ' . $key]) && drupal_strlen($file_options['other ' . $key]) > 0) {
$options[$key] = $file_options['other ' . $key];
}
}
}
// Replace our special characters.
$replaces = array(
'<newline>' => "\n",
'<none>' => '',
'<space>' => ' ',
'<tab>' => "\t",
);
$file_options = str_replace(array_keys($replaces), array_values($replaces), $options);
}