Example #1
0
 private function makeUrl($matches)
 {
     if (substr($matches[1], 0, 5) == 'data:') {
         return $matches[0];
     }
     if (substr($matches[1], 0, 4) == 'http') {
         return $matches[0];
     }
     if (substr($matches[1], 0, 2) == '//') {
         return $matches[0];
     }
     $exploded = explode('?', $matches[1]);
     $realPath = realpath($this->basePath . '/' . $exploded[0]);
     if ($realPath === false) {
         return 'url(' . str_replace(array('http://', 'https://'), '//', $this->baseUrl) . '/' . $matches[1] . ')';
     }
     $realPath = N2Filesystem::fixPathSeparator($realPath);
     $assetPath = N2Filesystem::fixPathSeparator($this->getAssetFileFolder());
     return 'url(' . N2Filesystem::toLinux($this->find_relative_path($assetPath, $realPath)) . (isset($exploded[1]) ? '?' . $exploded[1] : '') . ')';
 }
Example #2
0
 private function relative($path, $root)
 {
     return substr(N2Filesystem::fixPathSeparator($path), strlen($root));
 }