function node_node_import_defaults in Node import 6
Implementation of hook_node_import_defaults().
File
- supported/
node.inc, line 182 - Support file for the core node module.
Code
function node_node_import_defaults($type, $defaults, $fields, $map) {
$form = array();
if (($node_type = node_import_type_is_node($type)) !== FALSE) {
global $user;
$type_info = node_get_types('type', $node_type);
if ($type_info->has_body) {
$form['format'] = array(
'#title' => t('Input format'),
'#type' => 'radios',
'#options' => node_import_extract_property(filter_formats(), 'name'),
'#default_value' => isset($defaults['format']) ? $defaults['format'] : filter_resolve_format(FILTER_FORMAT_DEFAULT),
);
}
if (user_access('administer nodes')) {
$form['uid'] = array(
'#title' => t('Authored by'),
'#type' => 'textfield',
'#maxlength' => 60,
'#autocomplete_path' => 'user/autocomplete',
'#default_value' => isset($defaults['uid']) ? $defaults['uid'] : $user->name,
);
$form['created'] = array(
'#title' => t('Authored on'),
'#type' => 'textfield',
'#maxlength' => 25,
);
$form['log'] = array(
'#title' => t('Log message'),
'#type' => 'textarea',
'#rows' => 2,
'#default_value' => isset($defaults['log']) ? $defaults['log'] : t('Imported with node_import.'),
);
$workflow = array(
'status' => t('Published'),
'promote' => t('Promoted to front page'),
'sticky' => t('Sticky at top of lists'),
);
$node_options = variable_get('node_options_' . $node_type, array(
'status',
'promote',
));
foreach ($workflow as $key => $title) {
$form[$key] = array(
'#title' => $title,
'#type' => 'radios',
'#options' => array(
0 => t('No'),
1 => t('Yes'),
),
'#default_value' => isset($defaults[$key]) ? $defaults[$key] : (in_array($key, $node_options) ? 1 : 0),
);
}
}
}
return $form;
}