_book_toc_recurse

Versions
6 – 7
_book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit)

A recursive helper function for book_toc().

▾ 2 functions call _book_toc_recurse()

book_toc in modules/book/book.module
Returns an array of book pages in table of contents order.
_book_toc_recurse in modules/book/book.module
A recursive helper function for book_toc().

Code

modules/book/book.module, line 1003

<?php
function _book_toc_recurse($tree, $indent, &$toc, $exclude, $depth_limit) {
  foreach ($tree as $data) {
    if ($data['link']['depth'] > $depth_limit) {
      // Don't iterate through any links on this level.
      break;
    }

    if (!in_array($data['link']['mlid'], $exclude)) {
      $toc[$data['link']['mlid']] = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, TRUE);
      if ($data['below']) {
        _book_toc_recurse($data['below'], $indent . '--', $toc, $exclude, $depth_limit);
      }
    }
  }
}
?>
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.