|
|
@ -536,15 +536,20 @@ EOD |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function adjustCssUrl($cssContent, $inputFilePath, $outputFilePath) |
|
|
|
protected function adjustCssUrl($cssContent, $inputFilePath, $outputFilePath) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$sharedPath = ''; |
|
|
|
$sharedPathParts = array(); |
|
|
|
for ($i = 0; $i < strlen($inputFilePath); $i++) { |
|
|
|
$inputFilePathParts = explode('/', $inputFilePath); |
|
|
|
if (!isset($outputFilePath[$i])) { |
|
|
|
$inputFilePathPartsCount = count($inputFilePathParts); |
|
|
|
|
|
|
|
$outputFilePathParts = explode('/', $outputFilePath); |
|
|
|
|
|
|
|
$outputFilePathPartsCount = count($outputFilePathParts); |
|
|
|
|
|
|
|
for ($i =0; $i < $inputFilePathPartsCount && $i < $outputFilePathPartsCount; $i++) { |
|
|
|
|
|
|
|
if ($inputFilePathParts[$i] == $outputFilePathParts[$i]) { |
|
|
|
|
|
|
|
$sharedPathParts[] = $inputFilePathParts[$i]; |
|
|
|
|
|
|
|
} else { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($inputFilePath[$i] == $outputFilePath[$i]) { |
|
|
|
|
|
|
|
$sharedPath .= $inputFilePath[$i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$sharedPath = implode('/', $sharedPathParts); |
|
|
|
|
|
|
|
|
|
|
|
$inputFileRelativePath = trim(str_replace($sharedPath, '', $inputFilePath), '/'); |
|
|
|
$inputFileRelativePath = trim(str_replace($sharedPath, '', $inputFilePath), '/'); |
|
|
|
$outputFileRelativePath = trim(str_replace($sharedPath, '', $outputFilePath), '/'); |
|
|
|
$outputFileRelativePath = trim(str_replace($sharedPath, '', $outputFilePath), '/'); |
|
|
|
$inputFileRelativePathParts = explode('/', $inputFileRelativePath); |
|
|
|
$inputFileRelativePathParts = explode('/', $inputFileRelativePath); |
|
|
@ -554,12 +559,26 @@ EOD |
|
|
|
$fullMatch = $matches[0]; |
|
|
|
$fullMatch = $matches[0]; |
|
|
|
$inputUrl = $matches[1]; |
|
|
|
$inputUrl = $matches[1]; |
|
|
|
|
|
|
|
|
|
|
|
$urlPrefix = str_repeat('../', count($outputFileRelativePathParts)); |
|
|
|
$outputUrlParts = array_fill(0, count($outputFileRelativePathParts), '..'); |
|
|
|
$urlPrefix .= implode('/', $inputFileRelativePathParts); |
|
|
|
$outputUrlParts = array_merge($outputUrlParts, $inputFileRelativePathParts); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (strpos($inputUrl, '/') !== false) { |
|
|
|
|
|
|
|
$inputUrlParts = explode('/', $inputUrl); |
|
|
|
|
|
|
|
foreach ($inputUrlParts as $key => $inputUrlPart) { |
|
|
|
|
|
|
|
if ($inputUrlPart == '..') { |
|
|
|
|
|
|
|
array_pop($outputUrlParts); |
|
|
|
|
|
|
|
unset($inputUrlParts[$key]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$outputUrlParts[] = implode('/', $inputUrlParts); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$outputUrlParts[] = $inputUrl; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$outputUrl = implode('/', $outputUrlParts); |
|
|
|
|
|
|
|
|
|
|
|
$outputUrl = $urlPrefix . '/' . $inputUrl; |
|
|
|
|
|
|
|
return str_replace($inputUrl, $outputUrl, $fullMatch); |
|
|
|
return str_replace($inputUrl, $outputUrl, $fullMatch); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$cssContent = preg_replace_callback('/[\w\-]:\s*url\("([^"]*)"\)+/is', $callback, $cssContent); |
|
|
|
$cssContent = preg_replace_callback('/[\w\-]:\s*url\("([^"]*)"\)+/is', $callback, $cssContent); |
|
|
|
|
|
|
|
|
|
|
|
return $cssContent; |
|
|
|
return $cssContent; |
|
|
|