You are here

function book_toc in Drupal 5

Same name and namespace in other branches
  1. 4 modules/book.module \book_toc()
  2. 6 modules/book/book.module \book_toc()
  3. 7 modules/book/book.module \book_toc()

Returns an array of titles and nid entries of book pages in table of contents order.

2 calls to book_toc()
book_form in modules/book/book.module
Implementation of hook_form().
book_outline in modules/book/book.module
Implementation of function book_outline() Handles all book outline operations.

File

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

Code

function book_toc($exclude = 0) {
  $result = db_query(db_rewrite_sql('SELECT n.nid, n.title, b.parent, b.weight FROM {node} n INNER JOIN {book} b ON n.vid = b.vid WHERE n.status = 1 ORDER BY b.weight, n.title'));
  $children = array();
  while ($node = db_fetch_object($result)) {
    if (!$children[$node->parent]) {
      $children[$node->parent] = array();
    }
    $children[$node->parent][] = $node;
  }
  $toc = array();

  // If the user has permission to create new books, add the top-level book page to the menu;
  if (user_access('create new books')) {
    $toc[0] = '<' . t('top-level') . '>';
  }
  $toc = book_toc_recurse(0, '', $toc, $children, $exclude);
  return $toc;
}