diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-23 06:03:43 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-23 06:03:43 +0400 |
commit | ce90029718501c1cc4fd231e20531210c7372c54 (patch) | |
tree | 847fd54485f29fa2c3c1a1a5a6e09475e9d7d536 /core | |
parent | 6c753c5d8358009e07146d4bc77e49ef082f6dce (diff) |
Refs #4127 Themes can now override icons from any other plugin. eg to override: plugins/CoreHome/images/search.png put new icon in: plugins/Morpheus/images/search.png -- in case there are two icons called the same in two different plugins please let me know and we will rename them so all icon names are unique across plugins.
Diffstat (limited to 'core')
-rw-r--r-- | core/Theme.php | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/core/Theme.php b/core/Theme.php index 3ae44431de..604cfa5543 100644 --- a/core/Theme.php +++ b/core/Theme.php @@ -73,7 +73,8 @@ class Theme $pathAsset = $src[2]; // Basic health check, we dont replace if not starting with plugins/ - if( strpos($pathAsset, 'plugins') !== 0) { + $posPluginsInPath = strpos($pathAsset, 'plugins'); + if( $posPluginsInPath !== 0) { return $source; } @@ -82,7 +83,17 @@ class Theme return $source; } - $defaultThemePath = "plugins/" . \Piwik\Plugin\Manager::DEFAULT_THEME; + $pathPluginName = substr($pathAsset, strlen('plugins/')); + $nextSlash = strpos($pathPluginName, '/'); + if($nextSlash === false) { + return $source; + } + $pathPluginName = substr($pathPluginName, 0, $nextSlash); + + // replace all plugin assets to the theme, if the theme overrides this asset + // when there are name conflicts (two plugins define the same asset name in same folder), + // we shall rename so there is no more conflict. + $defaultThemePath = "plugins/" . $pathPluginName; $newThemePath = "plugins/" . $this->themeName; $overridingAsset = str_replace($defaultThemePath, $newThemePath, $pathAsset); |