Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas ZILLIOX <thomas@zilliox.me>2013-08-09 22:34:32 +0400
committerThomas ZILLIOX <thomas@zilliox.me>2013-08-09 22:34:32 +0400
commit9b3305306f7db26e05341d589b365307dd2b99d2 (patch)
tree700b89e2cd0ce72bc2a1c91cd40417c1497563ab /core/AssetManager.php
parent71c7d9838ff389b9d19114c6a4d8b011a11462c0 (diff)
parent302ddbfd3aad22f5da3ab1a3fc78dad7bba1d9ac (diff)
Merge with master
Diffstat (limited to 'core/AssetManager.php')
-rw-r--r--core/AssetManager.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/core/AssetManager.php b/core/AssetManager.php
index eca2e76ef8..79f81fafe1 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -152,8 +152,8 @@ class AssetManager
$mergedContent =
$firstLineCompileHash . "\n"
- . "/* Piwik CSS file is compiled with Less. You may be interested in writing a custom Theme for Piwik! */\n"
- . $mergedContent;
+ . "/* Piwik CSS file is compiled with Less. You may be interested in writing a custom Theme for Piwik! */\n"
+ . $mergedContent;
self::writeAssetToFile($mergedContent, self::MERGED_CSS_FILE);
}
@@ -169,7 +169,7 @@ class AssetManager
/*
* Rewrite css url directives
- * - assumes these are all relative paths
+ * - rewrites relative paths
* - rewrite windows directory separator \\ to /
*/
protected static function rewriteCssPathsDirectives($relativePath, $content)
@@ -179,15 +179,21 @@ class AssetManager
$rootDirectoryLength = self::countDirectoriesInPathToRoot();
}
+ $baseDirectory = dirname($relativePath);
$content = preg_replace_callback(
"/(url\(['\"]?)([^'\")]*)/",
- create_function(
- '$matches',
- "return \$matches[1] . str_replace('\\\\', '/', substr(realpath(PIWIK_DOCUMENT_ROOT . '/' . \$matches[2]), $rootDirectoryLength));"
- ),
+ function ($matches) use ($rootDirectoryLength, $baseDirectory) {
+ $absolutePath = substr(realpath(PIWIK_DOCUMENT_ROOT . "/$baseDirectory/" . $matches[2]), $rootDirectoryLength);
+ $rewritten = str_replace('\\', '/', $absolutePath);
+
+ if (is_file($rewritten)) { // only rewrite the URL if transforming it points to a valid file
+ return $matches[1] . $rewritten;
+ } else {
+ return $matches[1] . $matches[2];
+ }
+ },
$content
);
-
return $content;
}