function book_node_view_link

Adds relevant book links to the node's links.

Parameters

Drupal\node\Node $node: The book page node to add links to.

$view_mode: The view mode of the node.

1 call to book_node_view_link()
book_node_view in drupal/core/modules/book/book.module
Implements hook_node_view().

File

drupal/core/modules/book/book.module, line 94
Allows users to create and organize related content in an outline.

Code

function book_node_view_link(Node $node, $view_mode) {
  $links = array();
  if (isset($node->book['depth'])) {
    if ($view_mode == 'full' && node_is_page($node)) {
      $child_type = config('book.settings')
        ->get('child_type');
      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/' . $child_type,
          'query' => array(
            'parent' => $node->book['mlid'],
          ),
        );
      }
      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.'),
          ),
        );
      }
    }
  }
  if (!empty($links)) {
    $node->content['links']['book'] = array(
      '#theme' => 'links__node__book',
      '#links' => $links,
      '#attributes' => array(
        'class' => array(
          'links',
          'inline',
        ),
      ),
    );
  }
}