book_print_recurse

Versions
4.6
book_print_recurse($parent = '', $depth = 1)

▾ 2 functions call book_print_recurse()

book_print in modules/book.module
Menu callback; generates printer-friendly book page with all descendants.
book_print_recurse in modules/book.module

Code

modules/book.module, line 638

<?php
function book_print_recurse($parent = '', $depth = 1) {
  $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 b.parent = %d AND n.moderate = 0 ORDER BY b.weight, n.title'), $parent);

  while ($page = db_fetch_object($result)) {
    // Load the node:
    $node = node_load(array('nid' => $page->nid));

    // Take the most recent approved revision:
    if ($node->moderate) {
      $node = book_revision_load($node, array('moderate' => 0, 'status' => 1));
    }

    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 .= '<ul>'. $node->body .'</ul>';
      }

      $output .= book_print_recurse($node->nid, $depth + 1);
    }
  }

  return $output;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.