You are here

function _filefield_paths_updater_process in File (Field) Paths 6.2

1 string reference to '_filefield_paths_updater_process'
_filefield_paths_include_updater_widget_settings_alter in includes/updater.inc
Implements hook_widget_settings_alter().

File

includes/updater.inc, line 65

Code

function _filefield_paths_updater_process($nodes, $field, &$context) {
  if (!isset($context['sandbox']['progress'])) {
    $context['sandbox']['progress'] = 0;
    $context['sandbox']['max'] = count($nodes);
    $context['sandbox']['nodes'] = $nodes;
  }

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

    // For each nid, load the node, update the files and save it.
    $nid = array_shift($context['sandbox']['nodes']);
    $node = node_load($nid);
    foreach ($node->{$field['field_name']} as $count => &$file) {
      if (is_array($file) && !empty($file['filepath'])) {
        filefield_paths_process_file($file, $field['widget'], $node);
      }
    }

    // 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'];
  }
}