function node_export in Node export 7.3
Same name and namespace in other branches
- 6.3 node_export.module \node_export()
Export nodes.
Parameters
$nids: A node ID or array of node IDs to export.
$format: The format to use for export.
$msg_t: Function used to translate.
$reset: Whether to reset the node_load_multiple cache.
Return value
An array with keys 'success' which is a boolean value representing whether the export was successful and 'output' which contains the code string or an array of translated error messages to be shown to the user.
3 calls to node_export()
- drupal_node_export_callback_export in ./
node_export.drush.inc - Drush command callback.
- node_export_features_features_export_render in modules/
node_export_features/ node_export_features.module - Implements hook_features_export_render().
- node_export_gui in ./
node_export.pages.inc - Export GUI function.
11 string references to 'node_export'
- hook_node_export_format_handlers in ./
node_export.api.php - Register a format handler.
- NodeExportXmlDecoder::decode in formats/
xml.inc - NodeExportXMLTestCase::setUp in ./
node_export.test - Sets up a Drupal site for running functional and integration tests.
- node_export_bulk_operation in ./
node_export.module - Callback for use with hook_node_operations().
- node_export_feeds_feeds_importer_default in modules/
node_export_feeds/ node_export_feeds.module - Implementation of hook_feeds_importer_default().
File
- ./
node_export.module, line 331 - The Node export module.
Code
function node_export($nids, $format = NULL, $msg_t = 't', $reset = FALSE) {
global $user;
// Make $nids an array if it isn't.
if (is_int($nids)) {
$nids = array(
$nids,
);
}
elseif (is_object($nids)) {
$nids = array(
$nids->nid,
);
}
$nodes = array();
foreach ($nids as $nid) {
$original_node = node_load($nid, NULL, $reset);
if (!node_export_access_export($original_node, $reset)) {
// Halt exporting.
$error = $msg_t("You do not have permission to perform a Node export on one or more of these nodes. No nodes exported.");
return array(
'success' => FALSE,
'output' => array(
$error,
),
);
}
$node = node_export_prepare_node($original_node);
$nodes[] = $node;
}
// Get the node code from the format handler
$format_handlers = node_export_format_handlers();
$node_export_format = variable_get('node_export_format', array(
'drupal' => 'drupal',
));
$format_handler = $format ? $format : reset($node_export_format);
if (!isset($format_handlers[$format_handler])) {
$format_handler = 'drupal';
}
// Let other modules do special fixing up.
drupal_alter('node_export', $nodes, $format_handler);
// If any nodes are set to FALSE, then an error was triggered in another module.
// Currently modules doing this should also leave a watchdog warning.
if (in_array(FALSE, $nodes)) {
// Halt exporting.
$error = $msg_t('An error occurred when processing nodes, please check your logs. No nodes exported.');
return array(
'success' => FALSE,
'output' => array(
$error,
),
);
}
if (!empty($format_handlers[$format_handler]['#file']) && is_file($format_handlers[$format_handler]['#file'])) {
require_once $format_handlers[$format_handler]['#file'];
}
$code_string = call_user_func($format_handlers[$format_handler]['#export_callback'], $nodes, $format_handler);
// Let modules modify the node code.
drupal_alter('node_export_encode', $code_string, $nodes, $format_handler);
return array(
'success' => TRUE,
'output' => $code_string,
'format' => $format_handler,
);
}