PHP Class Minify_CSS_UriRewriter, minify

Author: Stephen Clay ([email protected])
Show file Open project: mrclay/minify Class Usage Examples

Public Properties

Property Type Description
$debugText string rewrite() and rewriteRelative() append debugging information here

Protected Properties

Property Type Description
$className string Defines which class to call as part of callbacks, change this if you extend Minify_CSS_UriRewriter

Public Methods

Method Description
prepend ( string $css, string $path ) : string In CSS content, prepend a path to relative URIs
removeDots ( string $uri ) : string Remove instances of "./" and ".
rewrite ( string $css, string $currentDir, string $docRoot = null, array $symlinks = [] ) : string In CSS content, rewrite file relative URIs as root relative
rewriteRelative ( string $uri, string $realCurrentDir, string $realDocRoot, array $symlinks = [] ) : string Get a root relative URI from a file relative URI

Protected Methods

Method Description
_realpath ( string $path ) : mixed Get realpath with any trailing slash removed. If realpath() fails, just remove the trailing slash.

Private Methods

Method Description
_owlifySvgPaths ( string $css ) : string Mungs some inline SVG URL declarations so they won't be touched
_processUriCB ( array $m ) : string
_trimUrls ( string $css ) : string
_unOwlify ( string $css ) : string Undo work of _owlify

Method Details

_realpath() protected static method

Get realpath with any trailing slash removed. If realpath() fails, just remove the trailing slash.
protected static _realpath ( string $path ) : mixed
$path string
return mixed path with no trailing slash

prepend() public static method

In CSS content, prepend a path to relative URIs
public static prepend ( string $css, string $path ) : string
$css string
$path string The path to prepend.
return string

removeDots() public static method

./" where possible from a root-relative URI
public static removeDots ( string $uri ) : string
$uri string
return string

rewrite() public static method

In CSS content, rewrite file relative URIs as root relative
public static rewrite ( string $css, string $currentDir, string $docRoot = null, array $symlinks = [] ) : string
$css string
$currentDir string The directory of the current CSS file.
$docRoot string The document root of the web site in which the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
$symlinks array (default = array()) If the CSS file is stored in a symlink-ed directory, provide an array of link paths to target paths, where the link paths are within the document root. Because paths need to be normalized for this to work, use "//" to substitute the doc root in the link paths (the array keys). E.g.: array('//symlink' => '/real/target/path') // unix array('//static' => 'D:\\staticStorage') // Windows
return string

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

Property Details

$className protected static property

Defines which class to call as part of callbacks, change this if you extend Minify_CSS_UriRewriter
protected static string $className
return string

$debugText public static property

rewrite() and rewriteRelative() append debugging information here
public static string $debugText
return string