book_toc

Versions
4.6 – 5
book_toc($exclude = 0)
6
book_toc($bid, $exclude = array(), $depth_limit)
7
book_toc($bid, $depth_limit, $exclude = array())

▾ 2 functions call book_toc()

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

Code

modules/book.module, line 509

<?php
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.nid = b.nid WHERE n.status = 1 ORDER BY b.weight, n.title'));

  while ($node = db_fetch_object($result)) {
    if (!$children[$node->parent]) {
      $children[$node->parent] = array();
    }
    $children[$node->parent][] = $node;
  }

  $toc = array();

  // If the user is an administrator, add the top-level book page;
  // only administrators can start new books.
  if (user_access('administer nodes')) {
    $toc[0] = '<'. t('top-level') .'>';
  }

  $toc = book_toc_recurse(0, '', $toc, $children, $exclude);

  return $toc;
}
?>
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.