You are here

function _site_map_books in Site map 7

Same name and namespace in other branches
  1. 8 site_map.module \_site_map_books()
  2. 5 site_map.module \_site_map_books()
  3. 6.2 site_map.module \_site_map_books()
  4. 6 site_map.module \_site_map_books()

Render the latest maps for books.

Return value

string Returns HTML string of site map for video.

1 call to _site_map_books()
template_preprocess_site_map in includes/site_map.theme.inc
Preprocesses the variables for site-map.tpl.php.

File

./site_map.module, line 429
site_map.module

Code

function _site_map_books() {
  $output = '';
  $options = array();
  $book_titles = array();
  $mlid = array_filter(variable_get('site_map_show_books', array()));
  if (module_exists('book') && !empty($mlid)) {
    $books_expanded = variable_get('site_map_books_expanded', 1);
    $title = t('Books');
    $description = '<div class="description">' . t('Books at %sn.', array(
      '%sn' => variable_get('site_name', 'Drupal'),
    )) . '</div>';
    foreach (book_get_books() as $book) {
      if (in_array($book['mlid'], $mlid)) {

        // Use menu_tree_all_data to retrieve the expanded tree.
        $tree = menu_tree_all_data($book['menu_name']);
        if (module_exists('i18n_menu')) {
          $tree = i18n_menu_localize_tree($tree, $GLOBALS['language']->language);
        }

        // Add an alter hook so other modules can manipulate the book tree prior
        // to rendering.
        drupal_alter('site_map_book_tree', $tree);
        if ($books_expanded) {
          $tree_output = _site_map_menu_tree_output($tree);
          $output .= drupal_render($tree_output);
        }
        else {
          $data = array_shift($tree);
          $book_titles[] = theme('book_title_link', array(
            'link' => $data['link'],
          ));
        }
      }
    }
    _site_map_set_option($options, 'site_map_show_titles', 1, 1, 'show_titles', TRUE);
    if (!$books_expanded && !empty($book_titles)) {
      $output .= theme('item_list', array(
        'items' => $book_titles,
      ));
    }
    if (!empty($output)) {
      $attributes = array(
        'class' => array(
          'site-map-box-book',
        ),
      );
      $output = theme('site_map_box', array(
        'title' => $title,
        'content' => $description . $output,
        'attributes' => $attributes,
        'options' => $options,
      ));
    }
  }
  return $output;
}