You are here

function _xmlsitemap_output_chunk in XML sitemap 5

Same name and namespace in other branches
  1. 5.2 xmlsitemap/xmlsitemap.module \_xmlsitemap_output_chunk()

Generate a chunk of the site map.

Parameters

$chunk:: An integer specifying which chunk of the site map to display

Return value

A string containing a chunk of the site map

Related topics

1 call to _xmlsitemap_output_chunk()
_xmlsitemap_update_cache in ./xmlsitemap.module
Update the cached site map files.

File

./xmlsitemap.module, line 480
Creates a site map compatible with the sitemaps.org schema.

Code

function _xmlsitemap_output_chunk($chunk) {
  $output = '';
  if (!ini_get('safe_mode')) {
    set_time_limit(240);
  }
  $xsl_path = file_directory_path() . '/xmlsitemap/gss.xsl';
  $xsl_path = file_exists($xsl_path) ? _xmlsitemap_file_create_url($xsl_path) : base_path() . drupal_get_path('module', 'xmlsitemap') . '/gss/gss.xsl';
  $output .= '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
  $output .= '<?xml-stylesheet type="text/xsl" href="' . $xsl_path . '" ?>' . "\n";
  $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"' . "\n";
  $output .= '        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' . "\n";
  $output .= '        xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9' . "\n";
  $output .= '                            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . "\n";
  $chunk_size = variable_get('xmlsitemap_chunk_size', 50000);
  $previous = $chunk * $chunk_size;
  $output .= implode("\n", _xmlsitemap_format(array_slice(_xmlsitemap_links(), $previous, $chunk_size)));
  $output .= "\n</urlset>";
  return $output;
}