function _googleanalytics_cache in Google Analytics 5
Same name and namespace in other branches
- 6.4 googleanalytics.module \_googleanalytics_cache()
- 6 googleanalytics.module \_googleanalytics_cache()
- 6.2 googleanalytics.module \_googleanalytics_cache()
- 6.3 googleanalytics.module \_googleanalytics_cache()
- 7.2 googleanalytics.module \_googleanalytics_cache()
- 7 googleanalytics.module \_googleanalytics_cache()
Download and cache the urchin.js file locally.
Parameters
$location: The full URL to the external javascript file.
Return value
mixed The path to the local javascript file on success, boolean FALSE on failure.
1 call to _googleanalytics_cache()
File
- ./
googleanalytics.module, line 568
Code
function _googleanalytics_cache($location) {
$directory = file_directory_path() . '/googleanalytics';
$file_destination = $directory . '/' . basename($location);
if (!file_exists($file_destination)) {
$result = drupal_http_request($location);
if ($result->code == 200) {
// Check that the files directory is writable
if (file_check_directory($directory, FILE_CREATE_DIRECTORY)) {
return file_save_data($result->data, $directory . '/' . basename($location), FILE_EXISTS_REPLACE);
}
}
}
else {
return $file_destination;
}
}