Wrapper around file_create_url() to do post-processing on the created url.
Paramètres
string $path: Path to check.
array $aggregate_settings: Array of settings used.
bool $run_file_create_url: If TRUE then run the given path through file_create_url().
string $source_type: CSS or JS; if empty url in not embedded in another file.
Return value
string The file uri.
6 calls to advagg_file_create_url()
- advagg_add_preload_link dans ./
advagg.module - Add preload link to the top of the html head.
- advagg_generate_location_uri dans ./
advagg.missing.inc - Given the filename, type, and settings, create absolute URL for 307 redirect.
- advagg_pre_render_scripts dans ./
advagg.module - Callback for pre_render to add elements needed for JavaScript to be rendered.
- advagg_pre_render_styles dans ./
advagg.module - A #pre_render callback to add elements needed for CSS tags to be rendered.
- advagg_relocate_advagg_relocate_process_http_request_alter dans advagg_relocate/
advagg_relocate.advagg.inc - Implements hook_advagg_relocate_process_http_request_alter().
Fichier
-
./
advagg.module, line 5008
Code
function advagg_file_create_url($path, array $aggregate_settings = array(), $run_file_create_url = TRUE, $source_type = '') {
$file_uri = $path;
if ($run_file_create_url) {
// This calls hook_file_url_alter().
$file_uri = file_create_url($path);
}
elseif (strpos($path, '/') !== 0 && !advagg_is_external($path)) {
$file_uri = '/' . $path;
}
// Ideally convert to relative path.
if (isset($aggregate_settings['variables']['advagg_convert_absolute_to_relative_path']) && $aggregate_settings['variables']['advagg_convert_absolute_to_relative_path'] || !isset($aggregate_settings['variables']['advagg_convert_absolute_to_relative_path']) && variable_get('advagg_convert_absolute_to_relative_path', ADVAGG_CONVERT_ABSOLUTE_TO_RELATIVE_PATH)) {
$file_uri = advagg_convert_abs_to_rel($file_uri);
}
// Next try protocol relative path.
if (isset($aggregate_settings['variables']['advagg_convert_absolute_to_protocol_relative_path']) && $aggregate_settings['variables']['advagg_convert_absolute_to_protocol_relative_path'] || !isset($aggregate_settings['variables']['advagg_convert_absolute_to_protocol_relative_path']) && variable_get('advagg_convert_absolute_to_protocol_relative_path', ADVAGG_CONVERT_ABSOLUTE_TO_PROTOCOL_RELATIVE_PATH)) {
$file_uri = advagg_convert_abs_to_protocol($file_uri);
}
if ($source_type === 'css' && !advagg_is_external($file_uri) && (isset($aggregate_settings['variables']['advagg_css_absolute_path']) && $aggregate_settings['variables']['advagg_css_absolute_path'] || !isset($aggregate_settings['variables']['advagg_css_absolute_path']) && variable_get('advagg_css_absolute_path', ADVAGG_CSS_ABSOLUTE_PATH))) {
// Get public dir.
list($css_path) = advagg_get_root_files_dir();
$parsed = parse_url($css_path[0]);
$new_parsed = array();
if (!empty($parsed['host'])) {
$new_parsed['host'] = $parsed['host'];
}
if (!empty($parsed['path'])) {
$new_parsed['path'] = $parsed['path'];
}
$css_path_0 = advagg_glue_url($new_parsed);
$parsed = parse_url($css_path[1]);
$new_parsed = array();
if (!empty($parsed['host'])) {
$new_parsed['host'] = $parsed['host'];
}
if (!empty($parsed['path'])) {
$new_parsed['path'] = $parsed['path'];
}
$css_path_1 = advagg_glue_url($new_parsed);
$pos = strpos($css_path_1, $css_path_0);
if (!empty($pos)) {
$public_dir = substr($css_path_1, 0, $pos);
// If public dir is not in the file uri, use absolute URL.
if (strpos($file_uri, $public_dir) === FALSE) {
$file_uri = url($path, array(
'absolute' => TRUE,
));
}
}
}
// Finally force https.
if (isset($aggregate_settings['variables']['advagg_force_https_path']) && $aggregate_settings['variables']['advagg_force_https_path'] || !isset($aggregate_settings['variables']['advagg_force_https_path']) && variable_get('advagg_force_https_path', ADVAGG_FORCE_HTTPS_PATH)) {
$file_uri = advagg_force_https_path($file_uri);
}
return $file_uri;
}