Commit 557cefe0 authored by Darren Oh's avatar Darren Oh

Prevent language prefixes from being added to file URLs.

parent 996635b9
......@@ -433,7 +433,7 @@ function _xmlsitemap_output_index($link_count) {
$output = '';
global $base_path;
$xsl_path = file_directory_path() .'/xmlsitemap/gss.xsl';
$xsl_path = file_exists($xsl_path) ? file_create_url($xsl_path) : $base_path . drupal_get_path('module', 'gsitemap') .'/gss/gss.xsl';
$xsl_path = file_exists($xsl_path) ? _xmlsitemap_file_create_url($xsl_path) : $base_path . drupal_get_path('module', 'gsitemap') .'/gss/gss.xsl';
$output .= '<?xml version="1.0" encoding="UTF-8"?>'."\n";
$output .= '<?xml-stylesheet type="text/xsl" href="'. $xsl_path .'" ?>'."\n";
$output .= '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">'."\n";
......@@ -477,7 +477,7 @@ function _xmlsitemap_output_chunk($chunk) {
set_time_limit(240);
}
$xsl_path = file_directory_path() .'/xmlsitemap/gss.xsl';
$xsl_path = file_exists($xsl_path) ? file_create_url($xsl_path) : $base_path . drupal_get_path('module', 'gsitemap') .'/gss/gss.xsl';
$xsl_path = file_exists($xsl_path) ? _xmlsitemap_file_create_url($xsl_path) : $base_path . drupal_get_path('module', 'gsitemap') .'/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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">'."\n";
......@@ -488,6 +488,22 @@ function _xmlsitemap_output_chunk($chunk) {
return $output;
}
/**
* Modified version of file_create_url(). Allows us to remove language
* prefixes.
* @param $path: the path to the file
* @return A URL to the file
*/
function _xmlsitemap_file_create_url($path) {
$path = trim(substr($path, strlen(file_directory_path())), '\\/');
switch (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC)) {
case FILE_DOWNLOADS_PUBLIC:
return $GLOBALS['base_url'] .'/'. file_directory_path() .'/'. str_replace('\\', '/', $path);
case FILE_DOWNLOADS_PRIVATE:
return xmlsitemap_url('system/files/'. $path, NULL, NULL, TRUE);
}
}
/**
* Implementation of hook_file_download().
*/
......
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