You are here

function _file_entity_mass_update_batch_process in File Entity (fieldable files) 7.2

Same name and namespace in other branches
  1. 7.3 file_entity.admin.inc \_file_entity_mass_update_batch_process()

File Mass Update Batch operation.

1 string reference to '_file_entity_mass_update_batch_process'
file_entity_mass_update in ./file_entity.admin.inc
Make mass update of files.

File

./file_entity.admin.inc, line 230

Code

function _file_entity_mass_update_batch_process($files, $updates, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($files);
    $context['sandbox']['files'] = $files;
  }

  // Process files by groups of 5.
  $count = min(5, count($context['sandbox']['files']));
  for ($i = 1; $i <= $count; $i++) {

    // For each fid, load the file, reset the values, and save it.
    $fid = array_shift($context['sandbox']['files']);
    $file = _file_entity_mass_update_helper($fid, $updates);

    // Store result for post-processing in the finished callback.
    $context['results'][] = l($file->filename, 'file/' . $file->fid);

    // Update our progress information.
    $context['sandbox']['progress']++;
  }

  // Inform the batch engine that we are not finished,
  // and provide an estimation of the completion level we reached.
  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
  }
}