Commit edf2d69d authored by Dave Reid's avatar Dave Reid Committed by Dave Reid

Issue #2244449 by Chris Burge, Dave Reid, philsward, ecvandenberg: Use...

Issue #2244449 by Chris Burge, Dave Reid, philsward, ecvandenberg: Use Protocol-less URL for XSL File
parent 04bc0a9d
......@@ -56,11 +56,25 @@ class XMLSitemapWriter extends XMLWriter {
return $result;
}
public function getSitemapUrl($path, array $options = array()) {
$options += $this->sitemap->uri['options'];
$options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
'language' => language_default(),
'alias' => TRUE,
);
if (!empty($options['protocol_relative'])) {
$options['base_url'] = preg_replace('~^https?:~', '', $options['base_url']);
}
return url($path, $options);
}
/**
* Add the XML stylesheet to the XML page.
*/
public function writeXSL() {
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . url('sitemap.xsl', $this->sitemap->uri['options']) . '"');
$this->writePi('xml-stylesheet', 'type="text/xsl" href="' . $this->getSitemapUrl('sitemap.xsl', array('protocol_relative' => TRUE)) . '"');
$this->writeRaw(PHP_EOL);
}
......@@ -184,18 +198,10 @@ class XMLSitemapIndexWriter extends XMLSitemapWriter {
public function generateXML() {
$lastmod_format = variable_get('xmlsitemap_lastmod_format', XMLSITEMAP_LASTMOD_MEDIUM);
$url_options = $this->sitemap->uri['options'];
$url_options += array(
'absolute' => TRUE,
'base_url' => variable_get('xmlsitemap_base_url', $GLOBALS['base_url']),
'language' => language_default(),
'alias' => TRUE,
);
for ($i = 1; $i <= $this->sitemap->chunks; $i++) {
$url_options['query']['page'] = $i;
$element = array(
'loc' => url('sitemap.xml', $url_options),
'loc' => $this->getSitemapUrl('sitemap.xml'),
// @todo Use the actual lastmod value of the chunk file.
'lastmod' => gmdate($lastmod_format, REQUEST_TIME),
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment