You are here

function _xmlsitemap_node_batch_process in XML sitemap 6

Node operations batch process callback.

1 string reference to '_xmlsitemap_node_batch_process'
_xmlsitemap_node_priority_operations in xmlsitemap_node/xmlsitemap_node.module
Node operations callback.

File

xmlsitemap_node/xmlsitemap_node.module, line 445
Adds nodes to the sitemap.

Code

function _xmlsitemap_node_batch_process($nodes, $priority, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($nodes);
    $context['sandbox']['nodes'] = $nodes;
    if (module_exists('comment')) {
      $context['sandbox']['maxcomments'] = (int) db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'));
    }
  }
  $nid = array_shift($context['sandbox']['nodes']);
  if ($node = xmlsitemap_node_set_priority($nid, $priority)) {
    $context['results'][] = l($node->title, 'node/' . $nid);
    if (count($context['results']) > 6) {
      array_shift($context['results']);
    }
  }
  $context['sandbox']['progress']++;
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
  else {
    xmlsitemap_flag_sitemap();
  }
}