update_manager_batch_project_get($project, $url, &$context)Batch operation: download, unpack, and verify a project.
This function assumes that the provided URL points to a file archive of some sort. The URL can have any scheme that we have a file stream wrapper to support. The file is downloaded to a local cache.
update_manager_download_page()
string $project The short name of the project to download.
string $url The URL to download a specific project release archive file.
array &$context Reference to an array used for BatchAPI storage.
modules/update/update.manager.inc, line 742
<?php
function update_manager_batch_project_get($project, $url, &$context) {
// This is here to show the user that we are in the process of downloading.
if (!isset($context['sandbox']['started'])) {
$context['sandbox']['started'] = TRUE;
$context['message'] = t('Downloading %project', array('%project' => $project));
$context['finished'] = 0;
return;
}
// Actually try to download the file.
if (!($local_cache = update_manager_file_get($url))) {
$context['results']['errors'][$project] = t('Failed to download %project from %url', array('%project' => $project, '%url' => $url));
return;
}
// Extract it.
$extract_directory = _update_manager_extract_directory();
try {
update_manager_archive_extract($local_cache, $extract_directory);
}
catch (Exception $e) {
$context['results']['errors'][$project] = $e->getMessage();
return;
}
// Verify it.
try {
update_manager_archive_verify($project, $local_cache, $extract_directory);
}
catch (Exception $e) {
$context['results']['errors'][$project] = $e->getMessage();
return;
}
// Yay, success.
$context['results']['projects'][$project] = $url;
$context['finished'] = 1;
}
?>