function node_gallery_api_batch_node_save in Node Gallery 7
Batch API save callback.
2 string references to 'node_gallery_api_batch_node_save'
- node_gallery_api_manage_items_submit in ./
node_gallery_api.pages.inc - Submit handler for Manage Items form.
- _node_gallery_api_set_publish in ./
node_gallery_api.inc - Publishes the child image nodes when publishing a gallery.
File
- ./
node_gallery_api.inc, line 341 - Node Gallery API function
Code
function node_gallery_api_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);
watchdog('batch_save', print_r($node, TRUE));
node_save_action($node);
watchdog('batch_save', print_r($node, TRUE));
$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'];
}
}