Commit cb6caf1d authored by Dave Reid's avatar Dave Reid

by Dave Reid: Reworked xmlsitemap_get_chunk_file().

parent 76c5f408
......@@ -77,7 +77,7 @@ function xmlsitemap_settings_form() {
);
$path = variable_get('xmlsitemap_path', 'xmlsitemap');
if (!xmlsitemap_check_directory()) {
form_set_error('xmlsitemap_path', t('The directory %directory does not exist or is not writable.', array('%directory' => file_directory_path() . '/' . $path)));
form_set_error('xmlsitemap_path', t('The directory %directory does not exist or is not writable.', array('%directory' => xmlsitemap_get_directory())));
}
$form['advanced']['xmlsitemap_path'] = array(
'#type' => 'textfield',
......
......@@ -171,7 +171,7 @@ function xmlsitemap_generate($chunk = 0, $language = NULL) {
$language = language_default();
}
$file = xmlsitemap_get_chunk_file($chunk, $language);
$file = xmlsitemap_get_chunk_file($chunk, $language->language);
if (!$handle = fopen($file, 'wb')) {
trigger_error(t('Could not open file @file for writing.', array('@file' => $file)));
......@@ -191,7 +191,7 @@ function xmlsitemap_generate($chunk = 0, $language = NULL) {
trigger_error(t('Unknown error occurred while writing to file @file.', array('@file' => $file)));
}
elseif (xmlsitemap_var('gz')) {
$file_gz = xmlsitemap_get_chunk_file($chunk, $language, TRUE);
$file_gz = xmlsitemap_get_chunk_file($chunk, $language->language, 'gz');
file_put_contents($file_gz, gzencode(file_get_contents($file), 9));
}
......
......@@ -540,14 +540,14 @@ function xmlsitemap_delete_link(array $conditions) {
* @param $chunk
* An integer representing the integer of the sitemap page chunk.
* @param $language
* A language object, defaults to the default language.
* A string with a language code.
* @return
* A file path to the expected chunk file.
*
* @todo Move to xmlsitemap.inc
*/
function xmlsitemap_get_chunk_file($chunk = 0, $language, $compressed = FALSE) {
return xmlsitemap_get_directory() . '/xmlsitemap-' . $language->language . '-' . $chunk . ($compressed ? '.gz' : '.xml');
function xmlsitemap_get_chunk_file($chunk = 0, $language = LANGUAGE_NONE, $extension = 'xml') {
return xmlsitemap_get_directory() . "/xmlsitemap-{$language}-{$chunk}.{$extension}";
}
/**
......
......@@ -22,7 +22,7 @@ function xmlsitemap_output_chunk($chunk = 0) {
xmlsitemap_generate($chunk, $language);
}
$file = xmlsitemap_get_chunk_file($chunk, $language);
$file = xmlsitemap_get_chunk_file($chunk, $language->language);
xmlsitemap_output_file($file);
}
......
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