rewriteRelative() public static method

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'
public static rewriteRelative ( string $uri, string $realCurrentDir, string $realDocRoot, array $symlinks = [] ) : string
$uri string file relative URI
$realCurrentDir string realpath of the current file's directory.
$realDocRoot string realpath of the site document root.
$symlinks array (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.: array('/home/foo/www/not/real/path' => '/real/target/path') // unix array('C:\\htdocs\\not\\real' => 'D:\\real\\target\\path') // Windows
return string
コード例 #1
0
function test_Minify_CSS_UriRewriter()
{
    global $thisDir;
    Minify_CSS_UriRewriter::$debugText = '';
    $in = file_get_contents($thisDir . '/_test_files/css_uriRewriter/in.css');
    $expected = file_get_contents($thisDir . '/_test_files/css_uriRewriter/exp.css');
    $actual = Minify_CSS_UriRewriter::rewrite($in, $thisDir . '/_test_files/css_uriRewriter', $thisDir);
    $passed = assertTrue($expected === $actual, 'Minify_CSS_UriRewriter');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . strlen($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . strlen($expected) . " bytes\n\n{$expected}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
    Minify_CSS_UriRewriter::$debugText = '';
    $in = '../../../../assets/skins/sam/sprite.png';
    $exp = '/yui/assets/skins/sam/sprite.png';
    $actual = Minify_CSS_UriRewriter::rewriteRelative($in, 'sf_root_dir\\web\\yui\\menu\\assets\\skins\\sam', 'sf_root_dir\\web');
    $passed = assertTrue($exp === $actual, 'Minify_CSS_UriRewriter : Issue 99');
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Input:\n\n{$in}\n";
        echo "\n---Output: " . strlen($actual) . " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " . strlen($exp) . " bytes\n\n{$exp}\n\n\n";
        }
        // show debugging only when test run directly
        echo "--- Minify_CSS_UriRewriter::\$debugText\n\n", Minify_CSS_UriRewriter::$debugText;
    }
}