function taxonomy_node_import_global in Node import 5
Implementation of hook_node_import_global().
File
- supported/
taxonomy.inc, line 214
Code
function taxonomy_node_import_global($type, $globals) {
$form = array();
$vocabs = taxonomy_get_vocabularies($type);
if ($vocabs && count($vocabs) > 0) {
$taxonomy = $globals['node_import_taxonomy']['taxonomy'];
$taxonomy = isset($taxonomy) ? $taxonomy : array();
$handler = $globals['node_import_taxonomy']['handler'];
$handler = isset($handler) ? $handler : 'no-import';
$form['node_import_taxonomy'] = array(
'#type' => 'fieldset',
'#title' => t('Taxonomy options'),
'#description' => t('Select the terms of each vocabulary that will be assigned to each node.'),
'#tree' => TRUE,
);
if (module_exists('category')) {
$node = (object) array(
'type' => $type,
'category' => _node_import_taxonomy_form2node($taxonomy),
);
$subform = array(
'type' => array(
'#value' => $type,
),
'#node' => $node,
);
category_form_alter($type . '_node_form', $subform);
$form['node_import_taxonomy']['taxonomy'] = $subform['category'];
}
else {
$node = (object) array(
'type' => $type,
'taxonomy' => _node_import_taxonomy_form2node($taxonomy),
);
$subform = array(
'type' => array(
'#value' => $type,
),
'#node' => $node,
);
taxonomy_form_alter($type . '_node_form', $subform);
$form['node_import_taxonomy']['taxonomy'] = $subform['taxonomy'];
}
$options = array(
'add' => t('Add non-existing terms to the vocabulary'),
'ignore' => t('Ignore non-existing terms'),
'warn' => t('Warn me about non-existing terms before the import'),
'no-import' => t('Do not import the node if there are non-existing terms'),
);
$form['node_import_taxonomy']['handler'] = array(
'#type' => 'select',
'#title' => t('How to handle non-existing terms?'),
'#options' => $options,
'#default_value' => $handler,
'#description' => t('Select how to handle non-existing terms in the vocabularies. If unsure, select %no-import.', array(
'%no-import' => t('Do not import the node if there are non-existing terms'),
)),
);
}
return $form;
}