You are here

function node_import_create_node in Node import 6

Create a new node by submitting $type_node_form.

1 string reference to 'node_import_create_node'
node_node_import_types in supported/node.inc
Implementation of hook_node_import_types().

File

supported/node.inc, line 44
Support file for the core node module.

Code

function node_import_create_node($type, &$values, $preview) {
  $output = $preview ? '' : FALSE;
  if (($node_type = node_import_type_is_node($type)) !== FALSE) {
    module_load_include('inc', 'node', 'node.pages');
    $form_id = $node_type . '_node_form';
    $values['op'] = $preview ? t('Preview') : t('Save');
    $form_state = array(
      'values' => $values,
    );
    $node = (object) array(
      'type' => $node_type,
      'name' => isset($values['name']) ? $values['name'] : '',
    );
    node_import_drupal_execute($form_id, $form_state, $node);
    if ($preview) {
      $output = isset($form_state['node_preview']) ? $form_state['node_preview'] : '';
    }
    else {
      $output = $values['nid'] = $form_state['nid'];
    }
  }
  return $output;
}