Commit 86a33cae authored by Dave Reid's avatar Dave Reid

by Dave Reid: Split generation functions into xmlsitemap.generate.inc.

parent 813176dc
...@@ -270,7 +270,7 @@ function xmlsitemap_rebuild_form_submit($form, &$form_state) { ...@@ -270,7 +270,7 @@ function xmlsitemap_rebuild_form_submit($form, &$form_state) {
// Set the rebuild flag incase something fails during the rebuild. // Set the rebuild flag incase something fails during the rebuild.
variable_set('xmlsitemap_rebuild_needed', TRUE); variable_set('xmlsitemap_rebuild_needed', TRUE);
module_load_include('inc', 'xmlsitemap'); module_load_include('inc', 'xmlsitemap', 'xmlsitemap.generate');
$batch = xmlsitemap_rebuild_batch($form_state['values']['entities'], $form_state['values']['callbacks'], $form_state['values']['save_custom']); $batch = xmlsitemap_rebuild_batch($form_state['values']['entities'], $form_state['values']['callbacks'], $form_state['values']['save_custom']);
batch_set($batch); batch_set($batch);
$form_state['redirect'] = 'admin/config/search/xmlsitemap'; $form_state['redirect'] = 'admin/config/search/xmlsitemap';
......
...@@ -34,7 +34,7 @@ function xmlsitemap_drush_command() { ...@@ -34,7 +34,7 @@ function xmlsitemap_drush_command() {
* Regenerate the sitemap files from existing data. * Regenerate the sitemap files from existing data.
*/ */
function drush_xmlsitemap_regenerate() { function drush_xmlsitemap_regenerate() {
module_load_include('inc', 'xmlsitemap'); module_load_include('inc', 'xmlsitemap', 'xmlsitemap.generate');
xmlsitemap_regenerate(); xmlsitemap_regenerate();
$vars = array( $vars = array(
...@@ -48,7 +48,7 @@ function drush_xmlsitemap_regenerate() { ...@@ -48,7 +48,7 @@ function drush_xmlsitemap_regenerate() {
* Dump and rebuild all the sitemap data, then regenerate the files. * Dump and rebuild all the sitemap data, then regenerate the files.
*/ */
function drush_xmlsitemap_rebuild() { function drush_xmlsitemap_rebuild() {
module_load_include('inc', 'xmlsitemap'); module_load_include('inc', 'xmlsitemap', 'xmlsitemap.generate');
timer_start('xmlsitemap_rebuild'); timer_start('xmlsitemap_rebuild');
// Set the rebuild flag incase something fails during the rebuild. // Set the rebuild flag incase something fails during the rebuild.
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,6 +7,7 @@ files[] = xmlsitemap.module ...@@ -7,6 +7,7 @@ files[] = xmlsitemap.module
files[] = xmlsitemap.inc files[] = xmlsitemap.inc
files[] = xmlsitemap.admin.inc files[] = xmlsitemap.admin.inc
files[] = xmlsitemap.drush.inc files[] = xmlsitemap.drush.inc
files[] = xmlsitemap.generate.inc
files[] = xmlsitemap.pages.inc files[] = xmlsitemap.pages.inc
files[] = xmlsitemap.install files[] = xmlsitemap.install
files[] = xmlsitemap.test files[] = xmlsitemap.test
......
...@@ -145,7 +145,7 @@ function xmlsitemap_cron() { ...@@ -145,7 +145,7 @@ function xmlsitemap_cron() {
} }
// Regenerate the sitemap XML files. // Regenerate the sitemap XML files.
module_load_include('inc', 'xmlsitemap'); module_load_include('inc', 'xmlsitemap', 'xmlsitemap.generate');
xmlsitemap_regenerate(); xmlsitemap_regenerate();
} }
...@@ -177,7 +177,6 @@ function xmlsitemap_xmlsitemap_link_alter(&$link) { ...@@ -177,7 +177,6 @@ function xmlsitemap_xmlsitemap_link_alter(&$link) {
* Implements hook_robotstxt(). * Implements hook_robotstxt().
*/ */
function xmlsitemap_robotstxt() { function xmlsitemap_robotstxt() {
module_load_include('inc', 'xmlsitemap');
$sitemaps = xmlsitemap_get_sitemaps(); $sitemaps = xmlsitemap_get_sitemaps();
foreach ($sitemaps as $index => $sitemap) { foreach ($sitemaps as $index => $sitemap) {
$sitemaps[$index] = 'Sitemap: ' . $sitemap; $sitemaps[$index] = 'Sitemap: ' . $sitemap;
...@@ -564,22 +563,6 @@ function xmlsitemap_link_delete_multiple(array $conditions) { ...@@ -564,22 +563,6 @@ function xmlsitemap_link_delete_multiple(array $conditions) {
return $query->execute(); return $query->execute();
} }
/**
* Get the filename of a specific sitemap page chunk.
*
* @param $chunk
* An integer representing the integer of the sitemap page chunk.
* @param $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 = LANGUAGE_NONE, $extension = 'xml') {
return xmlsitemap_get_directory() . "/xmlsitemap-{$language}-{$chunk}.{$extension}";
}
/** /**
* Implements hook_form_alter(). * Implements hook_form_alter().
* *
......
...@@ -14,15 +14,11 @@ ...@@ -14,15 +14,11 @@
* @see xmlsitemap_file_transfer() * @see xmlsitemap_file_transfer()
*/ */
function xmlsitemap_output_chunk() { function xmlsitemap_output_chunk() {
global $language; $context = module_invoke_all('xmlsitemap_context');
drupal_alter('xmlsitemap_context', $context);
$context = array();
if (module_exists('xmlsitemap_i18n')) {
$context['language'] = $language->language;
}
// Check if we should be displaing the index. // Check if we should be displaing the index.
if (!isset($_GET['page'])) { if (!isset($_GET['page']) || !is_numeric($_GET['page'])) {
$index_file = xmlsitemap_get_file_from_context($context, 'index'); $index_file = xmlsitemap_get_file_from_context($context, 'index');
if (file_exists($index_file)) { if (file_exists($index_file)) {
$chunk = 'index'; $chunk = 'index';
...@@ -35,8 +31,10 @@ function xmlsitemap_output_chunk() { ...@@ -35,8 +31,10 @@ function xmlsitemap_output_chunk() {
$chunk = (int) $_GET['page']; $chunk = (int) $_GET['page'];
} }
// Fallback to non-context sitemap?
$file = xmlsitemap_get_file_from_context($context, $chunk); $file = xmlsitemap_get_file_from_context($context, $chunk);
xmlsitemap_output_file($file); return xmlsitemap_output_file($file);
} }
/** /**
......
...@@ -62,7 +62,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase { ...@@ -62,7 +62,7 @@ class XMLSitemapTestHelper extends DrupalWebTestCase {
protected function regenerateSitemap() { protected function regenerateSitemap() {
variable_set('xmlsitemap_regenerate_needed', TRUE); variable_set('xmlsitemap_regenerate_needed', TRUE);
variable_set('xmlsitemap_generated_last', 0); variable_set('xmlsitemap_generated_last', 0);
module_load_include('inc', 'xmlsitemap'); module_load_include('inc', 'xmlsitemap', 'xmlsitemap.generate');
xmlsitemap_regenerate(); xmlsitemap_regenerate();
$this->assertTrue(variable_get('xmlsitemap_generated_last', 0) && !variable_get('xmlsitemap_regenerate_needed', FALSE), t('XML sitemaps regenerated and flag cleared.')); $this->assertTrue(variable_get('xmlsitemap_generated_last', 0) && !variable_get('xmlsitemap_regenerate_needed', FALSE), t('XML sitemaps regenerated and flag cleared.'));
} }
......
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