You are here

function node_gallery_api_batch_sorting_callback in Node Gallery 7

Batch API sorting callback.

2 string references to 'node_gallery_api_batch_sorting_callback'
node_gallery_api_sort_items_form_set_chronological_sorting in ./node_gallery_api.pages.inc
Submit function to set image weights reflecting chronological order of their making
node_gallery_api_sort_items_form_submit in ./node_gallery_api.pages.inc
Submit handler for sort form.

File

./node_gallery_api.inc, line 259
Node Gallery API function

Code

function node_gallery_api_batch_sorting_callback($images, &$context) {
  if (empty($context['sandbox'])) {
    $context['sandbox']['iterator'] = 0;
    $context['sandbox']['count'] = count($images);
    $context['results']['ngid'] = $images[0]['ngid'];
  }
  $context['results'][] = drupal_write_record('node_gallery_relationship', $images[$context['sandbox']['iterator']], 'nid');
  $context['sandbox']['iterator']++;
  if ($context['sandbox']['iterator'] < $context['sandbox']['count']) {
    $context['finished'] = $context['sandbox']['iterator'] / (double) $context['sandbox']['count'];
  }
  else {
    $context['finished'] = 1;
  }
}