You are here

function node_export_prepare_node in Node export 6.3

Same name and namespace in other branches
  1. 7.3 node_export.module \node_export_prepare_node()

Prepare a single node during export.

2 calls to node_export_prepare_node()
node_export in ./node_export.module
Export nodes.
node_export_relation_node_reference_load in modules/node_export_relation/node_export_relation.node_reference.inc
Recursively load node references.

File

./node_export.module, line 327
The Node export module.

Code

function node_export_prepare_node(&$original_node) {

  // Create UUID if it's not there.
  // Currently this uses a module_exists() until UUID becomes a dependency.
  if (!uuid_get_uuid('node', 'nid', $original_node->nid)) {
    $original_node->uuid = uuid_set_uuid('node', 'nid', $original_node->nid);

    // Save it so future node exports are consistent.
    node_save($original_node);
  }
  $node = drupal_clone($original_node);

  // 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;
  }

  // Fix menu array
  $node->menu = node_export_get_menu($original_node);
  $node = node_export_remove_recursion($node);

  // Let other modules do special fixing up.
  drupal_alter('node_export_node', $node, $original_node, 'export');
  return $node;
}