diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-22 09:41:49 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-22 10:17:12 +0400 |
commit | 3178109ca1d61cde8371426096767141f732428d (patch) | |
tree | 09bcf07ec49752148de90fca5b546a9921479724 | |
parent | 48a733b3c8c133af1960ce23dd4d23dcca5a7a04 (diff) |
Enabling Morpheus Theme in a branch to see generated UI screenhots tests refs #4127
-rw-r--r-- | config/global.ini.php | 1 | ||||
-rw-r--r-- | core/Plugin/Manager.php | 1 | ||||
-rw-r--r-- | core/Theme.php | 4 | ||||
-rw-r--r-- | plugins/API/API.php | 59 |
4 files changed, 37 insertions, 28 deletions
diff --git a/config/global.ini.php b/config/global.ini.php index 07f0b68dd8..9b0ebca3f4 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -541,6 +541,7 @@ Plugins[] = Annotations Plugins[] = MobileMessaging Plugins[] = Overlay Plugins[] = SegmentEditor +Plugins[] = Morpheus [PluginsInstalled] PluginsInstalled[] = Login diff --git a/core/Plugin/Manager.php b/core/Plugin/Manager.php index 7fb6fe2ccc..7273ab18ad 100644 --- a/core/Plugin/Manager.php +++ b/core/Plugin/Manager.php @@ -74,7 +74,6 @@ class Manager extends Singleton 'ExamplePluginTemplate', 'ExampleTheme', 'LeftMenu', - 'Morpheus', ); public function getCorePluginsDisabledByDefault() diff --git a/core/Theme.php b/core/Theme.php index 1efcc4f70a..76fdd57303 100644 --- a/core/Theme.php +++ b/core/Theme.php @@ -59,10 +59,10 @@ class Theme '~(src|href)=[\'"]([^\'"]+)[\'"]~', // rewrite images in CSS files, i.e. url(plugins/Morpheus/overrides/themes/default/images/help.png); - '~(url\()[\'"]([^\)]?[themes|plugins]+[^\)]+[.jpg|png|gif]?)[\'"][\)]~', + '~(url\()[\'"]([^\)]?[themes|plugins]+[^\)]+[.jpg|png|gif|svg]?)[\'"][\)]~', // rewrites images in JS files - '~(=)[\s]?[\'"]([^\'"]+[.jpg|.png|.gif]?)[\'"]~', + '~(=)[\s]?[\'"]([^\'"]+[.jpg|.png|.gif|svg]?)[\'"]~', ); return preg_replace_callback($pattern, array($this,'rewriteAssetPathIfOverridesFound'), $output); } diff --git a/plugins/API/API.php b/plugins/API/API.php index 94637c4748..077e8e257d 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -323,16 +323,10 @@ class API extends \Piwik\Plugin\API */ public function getLogoUrl($pathOnly = false) { - $logo = 'plugins/Zeitgeist/images/logo.png'; - if (Config::getInstance()->branding['use_custom_logo'] == 1 - && file_exists(Filesystem::getPathToPiwikRoot() . '/misc/user/logo.png') - ) { - $logo = 'misc/user/logo.png'; - } - if (!$pathOnly) { - return SettingsPiwik::getPiwikUrl() . $logo; - } - return Filesystem::getPathToPiwikRoot() . '/' . $logo; + $defaultLogo = 'plugins/Zeitgeist/images/logo.png'; + $themeLogo = 'plugins/%s/images/logo.png'; + $userLogo = 'misc/user/logo.png'; + return $this->getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $userLogo); } /** @@ -343,16 +337,10 @@ class API extends \Piwik\Plugin\API */ public function getHeaderLogoUrl($pathOnly = false) { - $logo = 'plugins/Zeitgeist/images/logo-header.png'; - if (Config::getInstance()->branding['use_custom_logo'] == 1 - && file_exists(Filesystem::getPathToPiwikRoot() . '/misc/user/logo-header.png') - ) { - $logo = 'misc/user/logo-header.png'; - } - if (!$pathOnly) { - return SettingsPiwik::getPiwikUrl() . $logo; - } - return Filesystem::getPathToPiwikRoot() . '/' . $logo; + $defaultLogo = 'plugins/Zeitgeist/images/logo-header.png'; + $themeLogo = 'plugins/%s/images/logo-header.png'; + $customLogo = 'misc/user/logo-header.png'; + return $this->getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo); } /** @@ -364,16 +352,35 @@ class API extends \Piwik\Plugin\API */ public function getSVGLogoUrl($pathOnly = false) { - $logo = 'plugins/Zeitgeist/images/logo.svg'; + $defaultLogo = 'plugins/Zeitgeist/images/logo.svg'; + $themeLogo = 'plugins/%s/images/logo.svg'; + $customLogo = 'misc/user/logo.svg'; + $svg = $this->getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo); + return $svg; + } + + protected function getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo) + { + $pathToPiwikRoot = Filesystem::getPathToPiwikRoot(); + + $logo = $defaultLogo; + + $themeName = \Piwik\Plugin\Manager::getInstance()->getThemeEnabled()->getPluginName(); + $themeLogo = sprintf($themeLogo, $themeName); + + if (file_exists($pathToPiwikRoot . '/' . $themeLogo)) { + $logo = $themeLogo; + } if (Config::getInstance()->branding['use_custom_logo'] == 1 - && file_exists(Filesystem::getPathToPiwikRoot() . '/misc/user/logo.svg') + && file_exists($pathToPiwikRoot . '/' . $customLogo) ) { - $logo = 'misc/user/logo.svg'; + $logo = $customLogo; } + if (!$pathOnly) { return SettingsPiwik::getPiwikUrl() . $logo; } - return Filesystem::getPathToPiwikRoot() . '/' . $logo; + return $pathToPiwikRoot . '/' . $logo; } /** @@ -386,7 +393,9 @@ class API extends \Piwik\Plugin\API if (Config::getInstance()->branding['use_custom_logo'] == 0) { /* We always have our application logo */ return true; - } else if (Config::getInstance()->branding['use_custom_logo'] == 1 + } + + if (Config::getInstance()->branding['use_custom_logo'] == 1 && file_exists(Filesystem::getPathToPiwikRoot() . '/misc/user/logo.svg') ) { return true; |