You are here

function node_gallery_batch_node_save in Node Gallery 6.3

3 string references to 'node_gallery_batch_node_save'
node_gallery_manage_images_submit in ./node_gallery.pages.inc
_node_gallery_set_publish in ./node_gallery.module
Publishes the child image nodes when publishing a gallery.
_node_gallery_update_group_settings in ./node_gallery.module
Updates the organic group settings of all gallery images when the settings in the gallery changed.

File

./node_gallery.module, line 933
Node gallery module file.

Code

function node_gallery_batch_node_save($nodes, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($nodes);
  }
  if (!isset($context['sandbox']['nodes'])) {
    if (is_array($nodes)) {
      $context['sandbox']['nodes'] = $nodes;
    }
    else {
      $context['sandbox']['nodes'] = array(
        $nodes,
      );
    }
  }
  $count = 0;
  while (!empty($context['sandbox']['nodes']) && $count <= NODE_GALLERY_BATCH_CHUNK_SIZE) {
    $count++;
    $node = array_shift($context['sandbox']['nodes']);
    $node = (object) array_merge((array) node_load($node->nid), (array) $node);
    node_save_action($node);
    $context['sandbox']['progress']++;
  }

  // Let the batch engine know how close we are to completion.
  if ($context['sandbox']['progress'] == $context['sandbox']['max']) {

    // Done!
    $context['finished'] = 1;
  }
  else {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}