book_tree_recurse

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

modules/book/book.module, строка 558

Версии
5
book_tree_recurse($nid, $depth, $children, $unfold = array())

This is a helper function for book_tree()

▾ 2 функции вызывают book_tree_recurse()

book_tree in modules/book/book.module
Returns an HTML nested list (wrapped in a menu-class div) representing the book nodes as a tree.
book_tree_recurse in modules/book/book.module
This is a helper function for book_tree()

Код

<?php
function book_tree_recurse($nid, $depth, $children, $unfold = array()) {
  $output = '';
  if ($depth > 0) {
    if (isset($children[$nid])) {
      foreach ($children[$nid] as $foo => $node) {
        if (in_array($node->nid, $unfold)) {
          if ($tree = book_tree_recurse($node->nid, $depth - 1, $children, $unfold)) {
            $output .= '<li class="expanded">';
            $output .= l($node->title, 'node/'. $node->nid);
            $output .= '<ul class="menu">'. $tree .'</ul>';
            $output .= '</li>';
          }
          else {
            $output .= '<li class="leaf">'. l($node->title, 'node/'. $node->nid) .'</li>';
          }
        }
        else {
          if ($tree = book_tree_recurse($node->nid, 1, $children)) {
            $output .= '<li class="collapsed">'. l($node->title, 'node/'. $node->nid) .'</li>';
          }
          else {
            $output .= '<li class="leaf">'. l($node->title, 'node/'. $node->nid) .'</li>';
          }
        }
      }
    }
  }

  return $output;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему