Commit fbc8e265 by Klimov Paul

Method "AssetController::adjustCssUrl()" has been implemented in basic.

parent ce6b73c8
...@@ -536,10 +536,31 @@ EOD ...@@ -536,10 +536,31 @@ EOD
*/ */
protected function adjustCssUrl($cssContent, $inputFilePath, $outputFilePath) protected function adjustCssUrl($cssContent, $inputFilePath, $outputFilePath)
{ {
$callback = function($matches) use ($inputFilePath, $outputFilePath) { $sharedPath = '';
return $matches[0]; for ($i = 0; $i < strlen($inputFilePath); $i++) {
if (!isset($outputFilePath[$i])) {
break;
}
if ($inputFilePath[$i] == $outputFilePath[$i]) {
$sharedPath .= $inputFilePath[$i];
}
}
$inputFileRelativePath = trim(str_replace($sharedPath, '', $inputFilePath), '/');
$outputFileRelativePath = trim(str_replace($sharedPath, '', $outputFilePath), '/');
$inputFileRelativePathParts = explode('/', $inputFileRelativePath);
$outputFileRelativePathParts = explode('/', $outputFileRelativePath);
$callback = function($matches) use ($inputFileRelativePathParts, $outputFileRelativePathParts) {
$fullMatch = $matches[0];
$inputUrl = $matches[1];
$urlPrefix = str_repeat('../', count($outputFileRelativePathParts));
$urlPrefix .= implode('/', $inputFileRelativePathParts);
$outputUrl = $urlPrefix . '/' . $inputUrl;
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;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment