lib/Minify/CSS/UriRewriter.php
public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
    {
        // prepend path with current dir separator (OS-independent)
        $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR);
        $path .= DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);

        self::$debugText .= "file-relative URI  : {$uri}\n"
                          . "path prepended     : {$path}\n";

        // "unresolve" a symlink back to doc root
        foreach ($symlinks as $link => $target) {
            if (0 === strpos($path, $target)) {
                // replace $target with $link
                $path = $link . substr($path, strlen($target));

                self::$debugText .= "symlink unresolved : {$path}\n";

                break;
            }
        }
        // strip doc root
        $path = substr($path, strlen($realDocRoot));

        self::$debugText .= "docroot stripped   : {$path}\n";

        // fix to root-relative URI
        $uri = strtr($path, '/\\', '//');
        $uri = self::removeDots($uri);

        self::$debugText .= "traversals removed : {$uri}\n\n";

        return $uri;
    }
public static function rewriteRelative($uri, $realCurrentDir, $realDocRoot, $symlinks = array())
    {
        // prepend path with current dir separator (OS-independent)
        $path = strtr($realCurrentDir, '/', DIRECTORY_SEPARATOR);
        $path .= DIRECTORY_SEPARATOR . strtr($uri, '/', DIRECTORY_SEPARATOR);

        self::$debugText .= "file-relative URI  : {$uri}\n"
                          . "path prepended     : {$path}\n";

        // "unresolve" a symlink back to doc root
        foreach ($symlinks as $link => $target) {
            if (0 === strpos($path, $target)) {
                // replace $target with $link
                $path = $link . substr($path, strlen($target));

                self::$debugText .= "symlink unresolved : {$path}\n";

                break;
            }
        }
        // strip doc root
        $path = substr($path, strlen($realDocRoot));

        self::$debugText .= "docroot stripped   : {$path}\n";

        // fix to root-relative URI
        $uri = strtr($path, '/\\', '//');
        $uri = self::removeDots($uri);

        self::$debugText .= "traversals removed : {$uri}\n\n";

        return $uri;
    }
public static function rewriteRelative ( $ uri , $ realCurrentDir , $ realDocRoot , $ symlinks = array ( ) ) { // prepend path with current dir separator (OS-independent) $ path = strtr ( $ realCurrentDir , '/' , DIRECTORY_SEPARATOR ) ; $ path .= DIRECTORY_SEPARATOR . strtr ( $ uri , '/' , DIRECTORY_SEPARATOR ) ; self :: $ debugText .= "file-relative URI  : {$uri}\n" . "path prepended     : {$path}\n" ; // "unresolve" a symlink back to doc root foreach ( $ symlinks as $ link => $ target ) { if ( 0 === strpos ( $ path , $ target ) ) { // replace $target with $link $ path = $ link . substr ( $ path , strlen ( $ target ) ) ; self :: $ debugText .= "symlink unresolved : {$path}\n" ; break ; } } // strip doc root $ path = substr ( $ path , strlen ( $ realDocRoot ) ) ; self :: $ debugText .= "docroot stripped   : {$path}\n" ; // fix to root-relative URI $ uri = strtr ( $ path , '/\\' , '//' ) ; $ uri = self :: removeDots ( $ uri ) ; self :: $ debugText .= "traversals removed : {$uri}\n\n" ; return $ uri ; }
Get a root relative URI from a file relative URI

<code>
Minify_CSS_UriRewriter::rewriteRelative(
'../img/hello.gif'
, '/home/user/www/css'  // path of CSS file
, '/home/user/www'      // doc root
);
// returns '/img/hello.gif'

// example where static files are stored in a symlinked directory
Minify_CSS_UriRewriter::rewriteRelative(
'hello.gif'
, '/var/staticFiles/theme'
, '/home/user/www'
, array('/home/user/www/static' => '/var/staticFiles')
);
// returns '/static/theme/hello.gif'
</code>

@param string $uri file relative URI

@param string $realCurrentDir realpath of the current file's directory.

@param string $realDocRoot realpath of the site document root.

@param array $symlinks (default = array()) If the file is stored in
a symlink-ed directory, provide an array of link paths to
real target paths, where the link paths "appear" to be within the document
root. E.g.:
<code>
array('/home/foo/www/not/real/path' => '/real/target/path') // unix
array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path')  // Windows
</code>

@return string
Get a root relative URI from a file relative URI