You are here

function template_preprocess_site_map in Site map 7

Same name and namespace in other branches
  1. 8 site_map.theme.inc \template_preprocess_site_map()
  2. 6.2 site_map.theme.inc \template_preprocess_site_map()

Preprocesses the variables for site-map.tpl.php.

See also

site-map.tpl.php

File

includes/site_map.theme.inc, line 181
site_map.theme.inc

Code

function template_preprocess_site_map(&$variables) {
  $message = variable_get('site_map_message', array());
  if (!empty($message)) {
    $variables['message'] = check_markup($message['value'], $message['format']);
  }
  if (variable_get('site_map_show_rss_links', 1) != 0 && module_exists('commentrss') && variable_get('commentrss_site', COMMENTRSS_SITE_FRONT_PAGE)) {
    $variables['rss_legend'] = theme('site_map_rss_legend');
  }
  if (variable_get('site_map_show_titles', 1)) {
    $variables['show_titles'] = TRUE;
  }
  $variables['site_map'] = '';
  $site_map_order = variable_get('site_map_order', array());
  asort($site_map_order);
  foreach ($site_map_order as $content => $weight) {

    // Get type of content.
    $type = substr($content, 0, strpos($content, '_'));
    $id = substr($content, strpos($content, '_') + 1);
    if (empty($type)) {
      $type = $content;
      $id = NULL;
    }
    switch ($type) {
      case 'front':
        if (variable_get('site_map_show_front', 1)) {
          $variables['site_map'] .= _site_map_front_page();
        }
        break;
      case 'blogs':
        if (variable_get('site_map_show_blogs', 1)) {
          $variables['site_map'] .= _site_map_blogs();
        }
        break;
      case 'books':
        $books = variable_get('site_map_show_books', array());
        if (!empty($books)) {
          $variables['site_map'] .= _site_map_books();
        }
        break;
      case 'menus':

        // Get the list of menus we'll be displaying.
        $menus = variable_get('site_map_show_menus', array());

        // Allow other modules to alter it.
        drupal_alter('site_map_menu_list', $menus);
        if (!empty($menus[$id])) {
          $variables['site_map'] .= _site_map_menus($id);
        }
        break;
      case 'faq':
        if (variable_get('site_map_show_faq', 0)) {
          $variables['site_map'] .= _site_map_faq();
        }
        break;
      case 'vocabularies':
        $vocabulary = taxonomy_vocabulary_machine_name_load($id);
        $vocabularies = variable_get('site_map_show_vocabularies', array());
        if (!empty($vocabularies[$vocabulary->machine_name])) {
          $variables['site_map'] .= _site_map_taxonomys($vocabulary);
        }
        break;
    }
  }

  // Invoke all custom modules and integrate themed HTML into the site map.
  $additional = module_invoke_all('site_map');
  foreach ($additional as $themed_site_map_code) {
    $variables['additional'] .= $themed_site_map_code;
  }
}