function locale_translation_batch_status_fetch_remote

Batch operation callback: Check the availability of a remote po file.

Checks the presence and creation time of one po file per batch process. The file URL and timestamp are stored.

Parameters

array $source: A translation source object of the project for which to check the state of a remote po file.

array $context: The batch context array. The collected state is stored in the 'results' parameter of the context.

See also

locale_translation_batch_status_fetch_local()

locale_translation_batch_status_compare()

1 string reference to 'locale_translation_batch_status_fetch_remote'
_locale_translation_batch_status_operations in drupal/core/modules/locale/locale.compare.inc
Helper function to construct batch operations checking remote translation status.

File

drupal/core/modules/locale/locale.batch.inc, line 34
Batch process to check the availability of remote or local po files.

Code

function locale_translation_batch_status_fetch_remote($source, &$context) {
  $t = get_t();

  // Check the translation file at the remote server and update the source
  // data with the remote status.
  if (isset($source->files[LOCALE_TRANSLATION_REMOTE])) {
    $remote_file = $source->files[LOCALE_TRANSLATION_REMOTE];
    $result = locale_translation_http_check($remote_file->uri);
    if ($result) {

      // Update the file object with the result data. In case of a redirect we
      // store the resulting uri. If a file is not found we don't update the
      // file object, and store it unchanged.
      if (isset($result['last_modified'])) {
        $remote_file->uri = isset($result['location']) ? $result['location'] : $remote_file->uri;
        $remote_file->timestamp = $result['last_modified'];
        $source->files[LOCALE_TRANSLATION_REMOTE] = $remote_file;
      }

      // Record success.
      $context['results']['files'][$source->name] = $source->name;
    }
    else {

      // An error occured when checking the file. Record the failure for
      // reporting at the end of the batch.
      $context['results']['failed_files'][] = $source->name;
    }
    $context['results']['sources'][$source->name][$source->langcode] = $source;
    $context['message'] = $t('Checked translation for %project.', array(
      '%project' => $source->project,
    ));
  }
}