You are here

function xmlsitemap_regenerate_batch in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_regenerate_batch()
  2. 6.2 xmlsitemap.generate.inc \xmlsitemap_regenerate_batch()
  3. 2.x xmlsitemap.module \xmlsitemap_regenerate_batch()

BATCH OPERATIONS -----------------------------------------------------------.

Batch information callback for regenerating the sitemap files.

Parameters

array $smids: An optional array of XML sitemap IDs. If not provided, it will load all existing XML sitemaps.

2 calls to xmlsitemap_regenerate_batch()
xmlsitemap_rebuild_batch in ./xmlsitemap.generate.inc
Batch information callback for rebuilding the sitemap data.
xmlsitemap_sitemap_multiple_update in ./xmlsitemap.xmlsitemap.inc
XML sitemap operation callback; regenerate sitemap files using the batch API.
2 string references to 'xmlsitemap_regenerate_batch'
drush_xmlsitemap_regenerate in ./xmlsitemap.drush.inc
Regenerate the sitemap files from existing data.
xmlsitemap_cron in ./xmlsitemap.module
Implements hook_cron().

File

./xmlsitemap.generate.inc, line 309
Sitemap generation and rebuilding functions for the xmlsitemap module.

Code

function xmlsitemap_regenerate_batch(array $smids = array()) {
  if (empty($smids)) {
    $smids = db_query("SELECT smid FROM {xmlsitemap_sitemap}")
      ->fetchCol();
  }
  $batch = array(
    'operations' => array(),
    'finished' => 'xmlsitemap_regenerate_batch_finished',
    'title' => t('Regenerating Sitemap'),
    'file' => drupal_get_path('module', 'xmlsitemap') . '/xmlsitemap.generate.inc',
  );

  // Set the regenerate flag in case something fails during file generation.
  $batch['operations'][] = array(
    'xmlsitemap_batch_variable_set',
    array(
      array(
        'xmlsitemap_regenerate_needed' => TRUE,
      ),
    ),
  );

  // @todo Get rid of this batch operation.
  $batch['operations'][] = array(
    '_xmlsitemap_regenerate_before',
    array(),
  );

  // Generate all the sitemap pages for each context.
  foreach ($smids as $smid) {
    $batch['operations'][] = array(
      'xmlsitemap_regenerate_batch_generate',
      array(
        $smid,
      ),
    );
    $batch['operations'][] = array(
      'xmlsitemap_regenerate_batch_generate_index',
      array(
        $smid,
      ),
    );
  }

  // Clear the regeneration flag.
  $batch['operations'][] = array(
    'xmlsitemap_batch_variable_set',
    array(
      array(
        'xmlsitemap_regenerate_needed' => FALSE,
      ),
    ),
  );
  return $batch;
}