flexinode.inc in Node import 5
File
supported/flexinode.inc
View source
<?php
function flexinode_node_import_types() {
$types = array();
foreach (flexinode_content_types() as $id => $type) {
$types['flexinode-' . $id] = $type->name;
}
return $types;
}
function flexinode_node_import_fields($type) {
$type = explode('-', $type);
if ($type[0] == 'flexinode') {
$content_type = flexinode_load_content_type($type[1]);
$fields = array(
'title' => t('Title'),
);
foreach ($content_type->fields as $field) {
$fields['flexinode_' . $field->field_id] = $field->label;
}
return $fields;
}
}
function flexinode_node_import_static($type) {
$type = explode('-', $type);
if ($type[0] == 'flexinode') {
return array(
'ctype_id' => $type[1],
);
}
}
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'];
}
unset($node->{$whatdate});
}
}
}
}