You are here

function _book_copy_render_tree in Book Copy 6

Same name and namespace in other branches
  1. 7 book_copy.module \_book_copy_render_tree()

Function responsible for generating book history

Parameters

array $tree formatted book hierarchy from _book_copy_get_book_history():

int $bid The nid of the book we are viewing history for:

1 call to _book_copy_render_tree()
book_copy_show_history in ./book_copy.module
Initial function to render a books copy history

File

./book_copy.module, line 314

Code

function _book_copy_render_tree($tree, $bid) {
  foreach ($tree as $nid => $info) {
    if ($nid == $bid) {
      $class = 'class="messages"';
    }
    else {
      $class = '';
    }
    $output .= '<li>';
    $output .= '<span ' . $class . '>';
    $node = node_load($nid);
    if ($node) {
      $output .= l($node->title, 'node/' . $nid);
    }
    else {
      $output .= t('Book Deleted');
    }
    if (!empty($info['copied'])) {
      $output .= ' ' . t('Copied') . ': ' . format_date($info['copied']);
    }
    else {
      $output .= ' ' . t('Originating Source');
    }
    $output .= '</span>';
    if (!empty($info['children'])) {
      $output .= '<ul class="book-children">';
      foreach ($info['children'] as $key => $child) {
        $output .= _book_copy_render_tree(array(
          $key => $child,
        ), $bid);
      }
      $output .= '</ul>';
    }
    $output .= '</li>';
  }
  return $output;
}