You are here

function _spaces_core_block_book in Spaces 6

Same name and namespace in other branches
  1. 5.2 spaces_core/spaces_core.module \_spaces_core_block_book()
  2. 5 spaces_core/spaces_core.module \_spaces_core_block_book()

Spaces version of the book nav block -- shows all root books in a group

1 call to _spaces_core_block_book()
spaces_core_block in spaces_core/spaces_core.module
Implementation of hook_block().

File

spaces_core/spaces_core.module, line 284

Code

function _spaces_core_block_book() {
  $space = spaces_get_space();
  $block = array();
  if ($space) {
    if ($node = menu_get_object()) {
      $current_bid = empty($node->book['bid']) ? 0 : $node->book['bid'];
    }

    // Set customized title
    $features = spaces_features();
    $feature_menu = space_customizer_menu::customize($space, 'book', $features['book']->spaces['menu']);
    $block['subject'] = isset($feature_menu['documents']['title']) ? $feature_menu['documents']['title'] : t('Documents');

    // Generate book tree per book node in current space
    $output = '';
    if ($view = views_get_view('spaces_book_current')) {
      $view
        ->set_display();
      $view
        ->set_items_per_page(0);
      $view
        ->execute();
      if (is_array($view->result) && count($view->result)) {
        foreach ($view->result as $row) {
          $output .= menu_tree(book_menu_name($row->nid));
        }
      }
    }
    $block['content'] = $output;
  }
  return $block;
}