function _piwik_cache in Piwik Web Analytics 5
Same name and namespace in other branches
- 8 piwik.module \_piwik_cache()
- 6.2 piwik.module \_piwik_cache()
- 6 piwik.module \_piwik_cache()
- 7.2 piwik.module \_piwik_cache()
- 7 piwik.module \_piwik_cache()
Download and cache the piwik.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 _piwik_cache()
- piwik_menu in ./
piwik.module
File
- ./
piwik.module, line 450
Code
function _piwik_cache($location) {
$directory = file_directory_path() . '/piwik';
$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;
}
}