function node_export_get_file in Node export 6.2
Same name and namespace in other branches
- 6.3 node_export.pages.inc \node_export_get_file()
- 7.3 node_export.pages.inc \node_export_get_file()
Generate text file.
Parameters
$nodes: An array of nids.
$node_code: The text output.
2 calls to node_export_get_file()
- node_export_node_bulk in ./
node_export.module - Callback for 'node_export' node operation.
- node_export_node_export in ./
node_export.module - Exports a node - populate a node code form set $return_code to TRUE to not return form but the code instead. set $format to some string if encoding should be handled by some module that will recognise the string.
File
- ./
node_export.module, line 184 - The Node Export module.
Code
function node_export_get_file($nodes, $node_code, $bulk = FALSE) {
$filename_data = array();
$filename_data['count'] = count($nodes);
$filename_data['time'] = time();
// Add a list of nids
if (count($nodes) <= variable_get('node_export_file_list', 10)) {
$filename_data['list'] = '[' . implode(',', $nodes) . ']';
}
if ($bulk) {
$name = variable_get('node_export_bulk_filename', 'node-export[nid-list]([node-count]-nodes).[timestamp].export');
}
else {
$name = variable_get('node_export_node_filename', 'node-export[nid-list].[timestamp].export');
}
if (module_exists('token')) {
$name = token_replace($name, 'Node export filename', $filename_data, '[', ']');
}
else {
// So it works without token.
$name = str_replace('[nid-list]', $filename_data['list'], $name);
$name = str_replace('[node-count]', $filename_data['count'], $name);
$name = str_replace('[timestamp]', $filename_data['time'], $name);
}
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="' . $name . '"');
print $node_code;
// Clean exit.
module_invoke_all('exit');
exit;
}