You are here

function _book_copy_render_tree in Book Copy 7

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

Typically this is going to be a theme_book_copy_render_tree function, that way you call it with theme('book_copy_render_tree') and would allow others to overload it via a theme specific implementation if they wanted to

1 call to _book_copy_render_tree()
book_copy_show_history in ./book_copy.module
This function while being very small is doing quite a bit, describe what it's doing This is also a page callback for 'book_copy/history/%node' so indicate it's a Callback function in the commment

File

./book_copy.module, line 229

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');
    }

    // add copy data to output if it is set
    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;
}