function _pugpig_relative_urls_to_download_array($relative_path, $relative_urls, $base_url, $base_path) { $entries = array(); foreach ($relative_urls as $relative_url) { // Remove any domains $relative_url = _pugpig_package_url_remove_domain($relative_url); // Get the URL that needs to be CURLed $url = url_to_absolute($base_url, $relative_url); // Take the domain off $root_url = _pugpig_package_url_remove_domain($url); // Get the path to save the file at $path = $base_path . _pugpig_package_path($root_url, '/' . $relative_path); // In case we've got 2 slashes next to each other in the disk path $path = str_replace("//", "/", $path); // Convert folders to index.html files if (substr($path, -1) === '/') { $path = $path . 'index.html'; } // We need to store the files on disk without %20s and the like // At present there is a bug in the client that appears to need these escaped // It does mean URLs with spaces don't work in a web browser after unzipping // $entries[$url] = rawurldecode($path); $entries[$url] = $path; } return $entries; }
function pugpig_get_local_save_path($root, $absolute_download_url) { return $root . _pugpig_package_url_remove_domain($absolute_download_url); }