function node_export_book_node_export_node_alter in Node export 7.3
Implements hook_node_export_node_alter().
File
- modules/
node_export_book/ node_export_book.module, line 10 - Adds Book support to the Node export module.
Code
function node_export_book_node_export_node_alter(&$node, $original_node) {
module_load_include('inc', 'node_export_book', 'node_export_book_utils');
// Throw errors if the node doesn't have a UUID
if (module_exists('uuid') and drupal_strlen(_node_export_book_nid_to_uuid($node->nid)) < 1) {
drupal_set_message(t('The node %nid does not have a UUID; unable to export!', array(
'%nid' => $node->nid,
)), 'error');
watchdog('node_export_book', 'Unable to export %nid because it is missing a UUID.', array(
'%nid' => $node->nid,
), WATCHDOG_CRITICAL);
}
elseif (module_exists('book') and property_exists($original_node, 'book')) {
// Create a namespace for our export info in the book node
if (!property_exists($node, 'node_export_book')) {
$node->node_export_book = array();
}
// Dereference the Parent Link ID (PLID) and write the parent node's UUID
if (array_key_exists('plid', $original_node->book) and menu_link_load($original_node->book['plid'])) {
$node->node_export_book['#parent_uuid'] = _node_export_book_mlid_to_uuid($original_node->book['plid']);
}
// Dereference the Book ID (BID) and write the book node's UUID
if (array_key_exists('bid', $original_node->book) and node_load($original_node->book['bid'])) {
$node->node_export_book['#book_uuid'] = _node_export_book_nid_to_uuid($original_node->book['bid']);
}
// Add the weight of this page in the book heirarchy
if (array_key_exists('weight', $original_node->book)) {
$node->node_export_book['weight'] = intval($original_node->book['weight']);
}
if ($original_node->book['bid'] == $original_node->nid) {
$node->node_export_book['#is_root'] = TRUE;
}
else {
$node->node_export_book['#is_root'] = FALSE;
}
// When we're done, unset the book info in the node, so it isn't exported
// and book.module on the destination site can't get confused
unset($node->book);
}
}