Menu callback; generates printer-friendly book page with all descendants.

1 string reference to 'book_print'
book_menu in modules/book.module
Implementation of hook_menu().

File

modules/book.module, line 604
Allows users to collaboratively author a book.

Code

function book_print($nid = 0, $depth = 1) {
  global $base_url;
  $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.weight FROM {node} n INNER JOIN {book} b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $nid);
  while ($page = db_fetch_object($result)) {

    // load the node:
    $node = node_load(array(
      'nid' => $page->nid,
    ));
    if ($node) {

      // output the content:
      if (node_hook($node, 'content')) {
        $node = node_invoke($node, 'content');
      }

      // Allow modules to change $node->body before viewing.
      node_invoke_nodeapi($node, 'view', $node->body, false);
      $output .= '<h1 id="' . $node->nid . '" name="' . $node->nid . '" class="book-h' . $depth . '">' . check_plain($node->title) . '</h1>';
      if ($node->body) {
        $output .= $node->body;
      }
    }
  }
  $output .= book_print_recurse($nid, $depth + 1);
  $html = '<html><head><title>' . check_plain($node->title) . '</title>';
  $html .= '<base href="' . $base_url . '/" />';
  $html .= theme_stylesheet_import('misc/print.css', 'print');
  $html .= '</head><body>' . $output . '</body></html>';
  print $html;
}