function advagg_get_relative_path in Advanced CSS/JS Aggregation 7.2
Same name and namespace in other branches
- 8.2 advagg.module \advagg_get_relative_path()
Given a uri, get the relative_path.
Parameters
string $uri: The uri for the stream wrapper.
string $type: (Optional) String: css or js.
Return value
string The relative path of the uri.
See also
https://www.drupal.org/node/837794#comment-9124435
10 calls to advagg_get_relative_path()
- advagg_create_subfile in ./
advagg.inc - Write CSS parts to disk; used when CSS selectors in one file is > 4096.
- advagg_ext_compress_execute_cmd in advagg_ext_compress/
advagg_ext_compress.module - Compress Javascript using via command line.
- advagg_ext_compress_string in advagg_ext_compress/
advagg_ext_compress.module - Compress CSS using via command line.
- advagg_get_root_files_dir in ./
advagg.module - Get the CSS and JS path for advagg.
- advagg_load_css_stylesheet in ./
advagg.inc - Loads the stylesheet and resolves all @import commands.
File
- ./
advagg.module, line 3710 - Advanced CSS/JS aggregation module.
Code
function advagg_get_relative_path($uri, $type = '') {
$wrapper = file_stream_wrapper_get_instance_by_uri($uri);
if ($wrapper instanceof DrupalLocalStreamWrapper) {
$relative_path = $wrapper
->getDirectoryPath() . '/' . file_uri_target($uri);
}
else {
$relative_path = parse_url(file_create_url($uri), PHP_URL_PATH);
if (empty($relative_path) && !empty($uri)) {
$filename = advagg_generate_advagg_filename_from_db($type);
$relative_path = parse_url(file_create_url("{$uri}/{$filename}"), PHP_URL_PATH);
$end = strpos($relative_path, "/{$filename}");
if ($end !== FALSE) {
$relative_path = substr($relative_path, 0, $end);
}
}
if (substr($relative_path, 0, strlen($GLOBALS['base_path'])) == $GLOBALS['base_path']) {
$relative_path = substr($relative_path, strlen($GLOBALS['base_path']));
}
$relative_path = ltrim($relative_path, '/');
}
return $relative_path;
}