You are here

class XMLSitemapIndexWriter in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap.xmlsitemap.inc \XMLSitemapIndexWriter

XML Sitemap Index Writer.

Hierarchy

Expanded class hierarchy of XMLSitemapIndexWriter

File

./xmlsitemap.xmlsitemap.inc, line 248
XML sitemap integration functions for xmlsitemap.module.

View source
class XMLSitemapIndexWriter extends XMLSitemapWriter {
  protected $rootElement = 'sitemapindex';

  /**
   * Construct.
   */
  public function __construct(stdClass $sitemap, $page = 'index') {
    parent::__construct($sitemap, 'index');
  }

  /**
   * Get Root Attributes.
   */
  public function getRootAttributes() {
    $attributes['xmlns'] = 'http://www.sitemaps.org/schemas/sitemap/0.9';
    if (variable_get('xmlsitemap_developer_mode', 0)) {
      $attributes['xmlns:xsi'] = 'http://www.w3.org/2001/XMLSchema-instance';
      $attributes['xsi:schemaLocation'] = 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd';
    }
    drupal_alter('xmlsitemap_root_attributes', $attributes, $this->sitemap);
    return $attributes;
  }

  /**
   * Generate XML.
   *
   * @codingStandardsIgnoreStart
   */
  public function generateXML() {

    // @codingStandardsIgnoreEnd
    $lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
    for ($i = 1; $i <= $this->sitemap->chunks; $i++) {
      $element = array(
        'loc' => $this
          ->getSitemapUrl('sitemap.xml', array(
          'query' => array(
            'page' => $i,
          ),
        )),
        // @todo Use the actual lastmod value of the chunk file.
        'lastmod' => gmdate($lastmod_format, REQUEST_TIME),
      );
      $this
        ->writeSitemapElement('sitemap', $element);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
XMLSitemapIndexWriter::$rootElement protected property Root Element. Overrides XMLSitemapWriter::$rootElement
XMLSitemapIndexWriter::generateXML public function Generate XML. Overrides XMLSitemapWriter::generateXML
XMLSitemapIndexWriter::getRootAttributes public function Get Root Attributes. Overrides XMLSitemapWriter::getRootAttributes
XMLSitemapIndexWriter::__construct public function Construct. Overrides XMLSitemapWriter::__construct
XMLSitemapWriter::$linkCountFlush protected property
XMLSitemapWriter::$sitemap protected property
XMLSitemapWriter::$sitemapElementCount protected property
XMLSitemapWriter::$sitemap_page protected property Sitemap Page.
XMLSitemapWriter::$uri protected property
XMLSitemapWriter::endDocument public function Document.
XMLSitemapWriter::getSitemapElementCount public function Get Count Sitemap Element.
XMLSitemapWriter::getSitemapUrl public function Get Sitemap URL.
XMLSitemapWriter::getURI public function Get URI.
XMLSitemapWriter::openUri public function Open URI.
XMLSitemapWriter::startDocument public function Start Document.
XMLSitemapWriter::startElement public function Start Element.
XMLSitemapWriter::writeElement public function Write full element tag including support for nested elements.
XMLSitemapWriter::writeSitemapElement public function Write an full XML sitemap element tag.
XMLSitemapWriter::writeXSL public function Add the XML stylesheet to the XML page.