*/ class CssRewriteFilter extends BaseCssFilter { public function filterLoad(AssetInterface $asset) { } public function filterDump(AssetInterface $asset) { $sourceBase = $asset->getSourceRoot(); $sourcePath = $asset->getSourcePath(); $targetPath = $asset->getTargetPath(); if (null === $sourcePath || null === $targetPath || $sourcePath == $targetPath) { return; } // learn how to get from the target back to the source if (false !== strpos($sourceBase, '://')) { list($scheme, $url) = explode('://', $sourceBase.'/'.$sourcePath, 2); list($host, $path) = explode('/', $url, 2); $host = $scheme.'://'.$host.'/'; $path = false === strpos($path, '/') ? '' : dirname($path); $path .= '/'; } else { // assume source and target are on the same host $host = ''; // pop entries off the target until it fits in the source if ('.' == dirname($sourcePath)) { $path = str_repeat('../', substr_count($targetPath, '/')); } elseif ('.' == $targetDir = dirname($targetPath)) { $path = dirname($sourcePath).'/'; } else { $path = ''; while (0 !== strpos($sourcePath, $targetDir)) { if (false !== $pos = strrpos($targetDir, '/')) { $targetDir = substr($targetDir, 0, $pos); $path .= '../'; } else { $targetDir = ''; $path .= '../'; break; } } $path .= ltrim(substr(dirname($sourcePath).'/', strlen($targetDir)), '/'); } } $content = $this->filterReferences($asset->getContent(), function($matches) use ($host, $path) { if (false !== strpos($matches['url'], '://') || 0 === strpos($matches['url'], '//') || 0 === strpos($matches['url'], 'data:')) { // absolute or protocol-relative or data uri return $matches[0]; } if ('/' == $matches['url'][0]) { // root relative return str_replace($matches['url'], $host.$matches['url'], $matches[0]); } // document relative $url = $matches['url']; while (0 === strpos($url, '../') && 2 <= substr_count($path, '/')) { $path = substr($path, 0, strrpos(rtrim($path, '/'), '/') + 1); $url = substr($url, 3); } return str_replace($matches['url'], $host.$path.$url, $matches[0]); }); $asset->setContent($content); } } __halt_compiler();----SIGNATURE:----1cJaGOBg0V4CERCpCY/QxmdzOAnXP1w2I8ixyd2XNirSlE07q//slTq0YogND/i3WkZOuEhKBabXRxOkxAph0LonJwLr/lPvqN0ifz2JWg0nNVDJZWyfuU5ID6tyQjPlzCkNj9HLHa8AanAnPhTrNAQ0WrKeC9nA9HOZCLm4xgexX+XcqhLOae0PuzN+BrnszREE4UwWHAOBmpFdlMPAiOHQnxThJ6ZRlw+Xkm3kD9uKsa1V0h9zeEkyyzmL2u69N9+He3RwMM23Pn9xqatuTR9KNKfETFHyxayvITXW3lWRPeNzFoB769FtxPeyB4SfL6NZmEu0oikKJGfrX0msj+ycO1p3jn9fe/GvWj8zWjjcACbZS3da0BrqlFMgFC3/sakAKmIH0kxP4V7X1lSwA2Uw/YU3sTeioKgZ37HXjf7e58AWo0G5L8/k3EeecUpoyCy8k/hPgqUu9oXMujXjLFfU6r3Jk9IHVvndOB7i/u0b16GNguUahxW9raCwVfBoxx7ndXzY4QWFXTvWk1fCb/GeL1lleiTmOi7nR8Q6G3GOrLkjm3xhrjSHyUTAbB5eyLZ820+g3BFzQDCGNlEJkjwB+2pbcBuBXMqS0IDo6sEkvOUtGIqp+GtbsNZGfET5aL+MYyIxPYRe5/umzYOAKhc3OFBGVdXSkdFctKaiS4s=----ATTACHMENT:----NTYyNzQyODA2MDE1NzczNiA3MDMwNzc1MjA5OTgzOTA0IDc4MjY0NjkwODQwMDQwMDM=