You are here

function xmlsitemap_output in XML sitemap 5.2

Same name and namespace in other branches
  1. 6 xmlsitemap.pages.inc \xmlsitemap_output()

Menu callback; display the sitemap.

Parameters

$chunk:: An integer specifying which chunk of the sitemap is being requested. If not set and there is more than one chunk, display the sitemap index.

Return value

None

1 string reference to 'xmlsitemap_output'
xmlsitemap_menu in xmlsitemap/xmlsitemap.module
Implementation of hook_menu().

File

xmlsitemap/xmlsitemap.module, line 209
Creates a sitemap compatible with the sitemaps.org schema.

Code

function xmlsitemap_output($chunk = NULL) {
  global $user;
  if (!$user->uid && variable_get('xmlsitemap_update', FALSE)) {
    _xmlsitemap_update();
  }
  drupal_set_header('Content-type: text/xml; charset=utf-8');
  $chunk_size = variable_get('xmlsitemap_chunk_size', 50000);
  $link_count = xmlsitemap_link_count();
  if ($link_count / $chunk_size > 1000) {
    $chunk_size = (int) $link_count / 1000;
    if ($chunk_size != variable_get('xmlsitemap_chunk_size', 50000)) {
      variable_set('xmlsitemap_chunk_size', $chunk_size);
    }
  }
  if (isset($chunk)) {
    if ($chunk < $link_count / $chunk_size) {
      _xmlsitemap_output_chunk($chunk);
    }
    else {
      drupal_not_found();
    }
  }
  else {
    if ($link_count > $chunk_size) {
      _xmlsitemap_output_index();
    }
    else {
      _xmlsitemap_output_chunk();
    }
  }
  drupal_page_footer();
  exit;
}