Same name and namespace in other branches
  1. 8.x-2.x advagg.module \advagg_get_relative_path() 1 commentaire

Given a uri, get the relative_path.

Paramètres

string $uri: The uri for the stream wrapper.

string $type: (Optional) String: css or js.

Return value

string The relative path of the uri.

Voir aussi

https://www.drupal.org/node/837794#comment-9124435

10 calls to advagg_get_relative_path()
advagg_create_subfile dans ./advagg.inc
Write CSS parts to disk; used when CSS selectors in one file is > 4096.
advagg_ext_compress_execute_cmd dans advagg_ext_compress/advagg_ext_compress.module
Compress Javascript using via command line.
advagg_ext_compress_string dans advagg_ext_compress/advagg_ext_compress.module
Compress CSS using via command line.
advagg_get_root_files_dir dans ./advagg.module
Get the CSS and JS path for advagg.
advagg_load_css_stylesheet dans ./advagg.inc
Loads the stylesheet and resolves all @import commands.

... See full list

Fichier

./advagg.module, line 3711

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;
}