book.inc in Node import 5
Same filename and directory in other branches
Support file for book module.
File
supported/book.incView source
<?php
/**
* @file
* Support file for book module.
*/
/**
* Implementation of hook_node_import_fields().
*/
function book_node_import_fields($type) {
if ($type == 'book') {
return array(
'node_import_book_parent' => t('Book page: Parent link'),
'weight' => t('Book page: Page weight'),
);
}
}
/**
* Implementation of hook_node_import_prepare().
*/
function book_node_import_prepare(&$node, $preview = FALSE) {
$errors = array();
if (isset($node->node_import_book_parent)) {
$parent = trim($node->node_import_book_parent);
unset($node->node_import_book_parent);
if (strlen($parent) == 0) {
$node->parent = 0;
}
else {
if ($nid = node_import_nodereference($parent)) {
$node->parent = $nid;
}
else {
$errors[] = t('Unable to set parent of book page: no node matching %title found.', array(
'%title' => $parent,
));
}
}
}
return $errors;
}
/**
* Implementation of hook_node_import_static().
*/
function book_node_import_static($type) {
if ($type == 'book') {
return array(
'parent' => 0,
'weight' => 0,
);
}
}
Functions
Name | Description |
---|---|
book_node_import_fields | Implementation of hook_node_import_fields(). |
book_node_import_prepare | Implementation of hook_node_import_prepare(). |
book_node_import_static | Implementation of hook_node_import_static(). |