function book_export_html

Generates HTML for export when invoked by book_export().

The given node is embedded to its absolute depth in a top level section. For example, a child node with depth 2 in the hierarchy is contained in (otherwise empty) <div> elements corresponding to depth 0 and depth 1. This is intended to support WYSIWYG output - e.g., level 3 sections always look like level 3 sections, no matter their depth relative to the node selected to be exported as printer-friendly HTML.

Parameters

\Drupal\node\Plugin\Core\Entity\Node: The node to export.

Return value

A string containing HTML representing the node and its children in the book hierarchy.

Throws

\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

\Symfony\Component\HttpKernel\Exception\NotFoundHttpException

File

drupal/core/modules/book/book.pages.inc, line 70
User page callbacks for the book module.

Code

function book_export_html(EntityInterface $node) {
  if (user_access('access printer-friendly version')) {
    if (isset($node->book)) {
      $tree = book_menu_subtree_data($node->book);
      $contents = book_export_traverse($tree, 'book_node_export');
      $book_exported_html = array(
        '#theme' => 'book_export_html',
        '#title' => $node
          ->label(),
        '#contents' => $contents,
        '#depth' => $node->book['depth'],
      );
      return drupal_render($book_exported_html);
    }
    else {
      throw new NotFoundHttpException();
    }
  }
  else {
    throw new AccessDeniedHttpException();
  }
}