function node_gallery_image_delete_process in Node Gallery 6.3
Deletes batches of images for batch API. _node_gallery_delete
Parameters
$imagenids: Array of nids to delete.
$context: Array provided by batch API.
2 string references to 'node_gallery_image_delete_process'
- node_gallery_manage_images_submit in ./
node_gallery.pages.inc - _node_gallery_delete in ./
node_gallery.module - Deletes the child image nodes when deleting a gallery.
File
- ./
node_gallery.module, line 903 - Node gallery module file.
Code
function node_gallery_image_delete_process($imagenids, &$context) {
if (!isset($context['sandbox']['progress'])) {
$context['sandbox']['progress'] = 0;
$context['sandbox']['max'] = count($imagenids);
}
if (!isset($context['sandbox']['imagenids'])) {
if (is_array($imagenids)) {
$context['sandbox']['imagenids'] = $imagenids;
}
else {
$context['sandbox']['imagenids'] = array(
$imagenids,
);
}
}
$count = 0;
while (!empty($context['sandbox']['imagenids']) && $count <= NODE_GALLERY_BATCH_CHUNK_SIZE) {
$count++;
$nid = array_shift($context['sandbox']['imagenids']);
node_delete($nid);
$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'];
}
}