You are here

function book_node_import_defaults in Node import 6

Implementation of hook_node_import_defaults().

File

supported/book.inc, line 104
Support file for the core book module.

Code

function book_node_import_defaults($type, $defaults, $fields, $map) {
  $form = array();
  if (($node_type = node_import_type_is_node($type)) !== FALSE && book_type_is_allowed($node_type) && (user_access('administer book outlines') || user_access('add content to books'))) {
    $book_options = array(
      '<new>' => '<' . t('create a new book') . '>',
      '<none>' => '<' . t('none') . '>',
    ) + node_import_extract_property(book_get_books());
    $form['book:book'] = array(
      '#title' => t('Book'),
      '#type' => 'select',
      '#options' => $book_options,
      '#default_value' => isset($defaults['book:book']) ? $defaults['book:book'] : ($type == 'node:book' ? '<new>' : '<none>'),
    );
    $form['book:weight'] = array(
      '#title' => t('Weight'),
      '#type' => 'weight',
      '#delta' => 15,
      '#default_value' => isset($defaults['book:weight']) ? $defaults['book:weight'] : '0',
    );
  }
  return $form;
}