function node_node_import_fields in Node import 6
Same name and namespace in other branches
- 5 supported/node.inc \node_node_import_fields()
Implementation of hook_node_import_fields().
File
- supported/
node.inc, line 77 - Support file for the core node module.
Code
function node_node_import_fields($type) {
$fields = array();
if (($node_type = node_import_type_is_node($type)) !== FALSE) {
global $user;
$type_info = node_get_types('type', $node_type);
$administer_nodes = user_access('administer nodes');
$node_options = variable_get('node_options_' . $node_type, array(
'status',
'promote',
));
$fields['type'] = array(
'title' => t('Content type'),
'module' => 'node',
'is_mappable' => FALSE,
'default_value' => $node_type,
);
if ($type_info->has_title) {
$fields['title'] = array(
'title' => $type_info->title_label,
'module' => 'node',
'weight' => -5,
'map_required' => TRUE,
'default_value' => '',
);
}
if ($type_info->has_body) {
$fields['body'] = array(
'title' => $type_info->body_label,
'group' => $type_info->body_label,
'module' => 'node',
'map_required' => $type_info->min_word_count > 0,
'default_value' => '',
);
$fields['format'] = array(
'title' => t('Input format'),
'group' => $type_info->body_label,
'module' => 'node',
'allowed_values' => node_import_extract_property(filter_formats(), 'name'),
'default_value' => filter_resolve_format(FILTER_FORMAT_DEFAULT),
);
}
$fields['uid'] = array(
'title' => t('Authored by'),
'group' => t('Authoring information'),
'module' => 'node',
'weight' => 20,
'is_mappable' => $administer_nodes,
'input_format' => 'user_reference',
'default_value' => $user->uid,
);
$fields['created'] = array(
'title' => t('Authored on'),
'group' => t('Authoring information'),
'module' => 'node',
'weight' => 20,
'is_mappable' => $administer_nodes,
'input_format' => 'date',
'output_format' => DATE_UNIX,
);
$fields['log'] = array(
'title' => t('Log message'),
'group' => t('Revision information'),
'module' => 'node',
'weight' => 20,
'is_mappable' => FALSE,
'default_value' => '',
);
$fields['revision'] = array(
'title' => t('Create new revision'),
'group' => t('Revision information'),
'module' => 'node',
'weight' => 20,
'is_mappable' => FALSE,
'default_value' => in_array('revision', $node_options) ? '1' : '0',
);
$workflow = array(
'status' => t('Published'),
'promote' => t('Promoted to front page'),
'sticky' => t('Sticky at top of lists'),
);
foreach ($workflow as $key => $title) {
$fields[$key] = array(
'title' => $title,
'group' => t('Publishing options'),
'module' => 'node',
'weight' => 25,
'is_mappable' => $administer_nodes,
'input_format' => 'boolean',
'default_value' => in_array($key, $node_options) ? '1' : '0',
);
}
}
return $fields;
}