function file_force_create_url in File Force Download 7
Same name and namespace in other branches
- 6.2 file_force.module \file_force_create_url()
Simplified version of the default file_create_url method to avoid private download method dependency.
Parameters
$path: String, file uri
$add_query: Boolean, add a query (pass FALSE if url will be appended with download=1 query)
Return value
String, file url
2 calls to file_force_create_url()
- file_force_field_formatter_view in ./
file_force.module - Implements hook_field_formatter_view().
- theme_file_force_file_link in ./
file_force_formatter.inc - Returns HTML for a link to a file.
File
- ./
file_force.module, line 260 - File Force Download module.
Code
function file_force_create_url($path, $add_query = TRUE) {
if (empty($path)) {
return '';
}
$scheme = file_uri_scheme($path);
if ($scheme == 'public') {
$url = file_create_url('system/files_force/' . file_uri_target($path));
}
else {
$url = file_create_url($path);
}
if ($add_query) {
// '&' for private uploads in non-clean URLs. Public downloads or clean URLs need '?' as there is no query.
$separator = variable_get('clean_url', FALSE) || $scheme == 'public' ? '?' : '&';
$url .= $separator . 'download=1';
}
return $url;
}