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.
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.
locale_translation_batch_status_fetch_local()
locale_translation_batch_status_compare()
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,
));
}
}