function book_copy_node_view in Book Copy 7
Implementatin of hook_node_view()
File
- ./
book_copy.module, line 53
Code
function book_copy_node_view($node, $view_mode) {
global $user;
$links = array();
//ensure that we have child pages
if (isset($node->book['depth'])) {
if ($view_mode == 'full' && node_is_page($node)) {
$child_type = variable_get('book_child_type', 'book');
// makre sure this is a valid piece of content for nesting
if ((user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && $node->book['depth'] < MENU_MAX_DEPTH) {
$links['book_add_child'] = array(
'title' => t('Add child page'),
'href' => 'node/add/' . str_replace('_', '-', $child_type),
'query' => array(
'parent' => $node->book['mlid'],
),
);
}
// link to view history if allowed
if (user_access('view book history')) {
$links['book_copy_history'] = array(
'title' => t('Show Book History'),
'href' => 'book_copy/history/' . $node->book['bid'],
);
}
// link to copy book if allowed
if (user_access('copy books')) {
$links['book_copy_copy'] = array(
'title' => t('Derive a Copy'),
'href' => 'book_copy/copy/' . $node->book['bid'],
);
// link to copy sub-tree / book child pages if allowed
if ($node->book['bid'] != $node->nid) {
$links['book_copy_subtree'] = array(
'title' => t('Copy subtree'),
'href' => 'book_copy/copy/' . $node->book['bid'] . '/' . $node->nid,
);
}
}
// keep in the same container
if (user_access('access printer-friendly version')) {
$links['book_printer'] = array(
'title' => t('Printer-friendly version'),
'href' => 'book/export/html/' . $node->nid,
'attributes' => array(
'title' => t('Show a printer-friendly version of this book page and its sub-pages.'),
),
);
}
}
}
// theme the links if there are any allowed
if (!empty($links)) {
$node->content['links']['book'] = array(
'#theme' => 'links__node__book',
'#links' => $links,
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
}
return $node;
}