You are here

function flexinode_node_import_prepare in Node import 5

Implementation of hook_node_import_prepare().

File

supported/flexinode.inc, line 44

Code

function flexinode_node_import_prepare(&$node, $preview = FALSE) {
  $type = explode('-', $node->type);
  if ($type[0] == 'flexinode') {
    $content_type = flexinode_load_content_type($type[1]);
    foreach ($content_type->fields as $field) {
      if ($field->field_type == 'timestamp' && isset($node->{'flexinode_' . $field->field_id})) {
        if (($time = strtotime($node->{'flexinode_' . $field->field_id})) == -1) {
          form_set_error($node->{'flexinode_' . $field->field_id}, t('Date is in an unrecognisable format, for example use "9/24/2005 8:02pm"'));
        }
        else {
          $time = getdate($time);
          $node->{'flexinode_' . $field->field_id . '_year'} = $time['year'];
          $node->{'flexinode_' . $field->field_id . '_month'} = $time['mon'];
          $node->{'flexinode_' . $field->field_id . '_day'} = $time['mday'];
          $node->{'flexinode_' . $field->field_id . '_hour'} = $time['hours'];
          $node->{'flexinode_' . $field->field_id . '_minute'} = $time['minutes'];
        }

        // Hmm.
        unset($node->{$whatdate});
      }
    }
  }
}