/**
  * In CSS content, rewrite file relative URIs as root relative
  *
  * @param string $css
  *
  * @param string $currentDir The directory of the current CSS file.
  *
  * @param string $docRoot The document root of the web site in which
  * the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']).
  *
  * @param array $symlinks (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.:
  * <code>
  * array('//symlink' => '/real/target/path') // unix
  * array('//static' => 'D:\\staticStorage')  // Windows
  * </code>
  *
  * @return string
  */
 public static function rewrite($css, $options)
 {
     self::$_prependPath = null;
     if (!isset($options['prependRelativePath']) && !isset($options['currentDir'])) {
         return $css;
     }
     self::$_browserCacheId = isset($options['browserCacheId']) ? $options['browserCacheId'] : 0;
     self::$_browserCacheExtensions = isset($options['browserCacheExtensions']) ? $options['browserCacheExtensions'] : array();
     if (isset($options['currentDir'])) {
         $document_root = isset($options['docRoot']) ? $options['docRoot'] : $_SERVER['DOCUMENT_ROOT'];
         $symlinks = isset($options['symlinks']) ? $options['symlinks'] : array();
         $prependAbsolutePath = isset($options['prependAbsolutePath']) ? $options['prependAbsolutePath'] : '';
         $prependAbsolutePathCallback = isset($options['prependAbsolutePathCallback']) ? $options['prependAbsolutePathCallback'] : '';
         $css = self::_rewrite($css, $options['currentDir'], $prependAbsolutePath, $prependAbsolutePathCallback, $document_root, $symlinks);
     } elseif (isset($options['prependRelativePath'])) {
         $css = self::prepend($css, $options['prependRelativePath']);
     }
     return $css;
 }
 /**
  * Prepend a path to relative URIs in CSS files
  *
  * @param string $css
  * @param string $path The path to prepend.
  * @param integer $browserCacheId
  * @param array $browserCacheExtensions
  *
  * @return string
  */
 private static function _prepend($css, $path, $browserCacheId = 0, $browserCacheExtensions = array())
 {
     self::$_prependRelativePath = $path;
     self::$_browserCacheId = $browserCacheId;
     self::$_browserCacheExtensions = $browserCacheExtensions;
     $css = self::_trimUrls($css);
     // append
     $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/', array(self::$className, '_processUriCB'), $css);
     $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/', array(self::$className, '_processUriCB'), $css);
     return $css;
 }