function export_node_export in Node export 5.2
Same name and namespace in other branches
- 5 export.module \export_node_export()
- 6 export.pages.inc \export_node_export()
Exports a node - return export code in a textarea
1 call to export_node_export()
- export_node_bulk in ./
export.module - Callback for 'export' node operation.
1 string reference to 'export_node_export'
- export_menu in ./
export.module - Implementation of hook_menu().
File
- ./
export.pages.inc, line 52
Code
function export_node_export($original_node, $return_code = FALSE, $iteration = 0) {
if (isset($original_node->nid)) {
global $user;
if (export_is_permitted($original_node->type)) {
$node = drupal_clone($original_node);
$node->nid = NULL;
$node->vid = NULL;
$node->name = $user->name;
$node->uid = $user->uid;
//$node->created = NULL;
$node->menu = NULL;
$node->path = NULL;
$node->files = array();
$node->title = t('!title', array(
'!title' => $node->title,
));
drupal_set_title(check_plain($node->title));
if (variable_get('export_reset_' . $node->type, FALSE)) {
$node_options = variable_get('node_options_' . $node->type, array(
'status',
'promote',
));
// fill in the default values
foreach (array(
'status',
'moderate',
'promote',
'sticky',
'revision',
) as $key) {
$node->{$key} = in_array($key, $node_options);
}
}
// Fix taxonomy array
if (isset($node->taxonomy) && count($node->taxonomy)) {
$vocabularies = taxonomy_get_vocabularies();
$new_taxonomy = array();
foreach ($node->taxonomy as $term) {
// Free-tagging vocabularies need a different format
if ($vocabularies[$term->vid]->tags) {
$new_taxonomy['tags'][$term->vid][] = $term->name;
}
else {
$new_taxonomy[$term->vid][$term->tid] = $term->tid;
}
}
if (isset($new_taxonomy['tags']) && count($new_taxonomy['tags'])) {
// Comma seperate the tags
foreach ($new_taxonomy['tags'] as $vid => $tags) {
$new_taxonomy['tags'][$vid] = implode(', ', $tags);
}
}
$node->taxonomy = $new_taxonomy;
}
// Let other modules do special fixing up.
// The function signature is: hook_export_node_alter(&$node, $original_node, $method)
foreach (module_implements('export_node_alter') as $module) {
$function = $module . '_export_node_alter';
$function($node, $original_node, "export");
}
$node_code = export_node_encode($node, $iteration);
return $return_code ? $node_code : drupal_get_form('export_form', $node_code);
}
}
}