You are here

function node_reference_export_alter in Default Content 7.2

Same name and namespace in other branches
  1. 7 plugins/node_reference.inc \node_reference_export_alter()

Handles the change to the node need for exporting node references

Change the node_ref field to refer to the machine_name of the references nodes

File

plugins/node_reference.inc, line 18

Code

function node_reference_export_alter(&$node) {
  $fields = get_ref_fields();
  foreach ($fields as $field_name => $field) {
    if (isset($node->{$field_name})) {
      foreach ($node->{$field_name} as $lang => $items) {
        foreach ($items as $key => $item) {
          if (($nid = $item['nid']) && ($machine_name = defaultcontent_get_default($nid))) {
            $node->{$field_name}[$lang][$key]['machine_name'] = $machine_name;
            unset($node->{$field_name}[$lang][$key]['nid']);
          }
          elseif (isset($item['machine_name'])) {

            //TODO remove
          }
          else {
            unset($node->{$field_name}[$lang][$key]);
          }
        }
      }
    }
  }
}