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:
authorKevin Subileau <github@kevinsubileau.fr>2016-04-12 00:09:28 +0300
committerThomas Steur <tsteur@users.noreply.github.com>2016-04-12 00:09:28 +0300
commit120a7f7d54a05e85f2a8b47f7a6fd6a85464139b (patch)
tree7c360bee89502e9bdf040c6bb9842f4e3cfb6a60 /plugins/CoreAdminHome/CustomLogo.php
parent91dd5169e3cf8394a0bd3b74ff8836d3af50dbd9 (diff)
Don't try to display a custom logo or favicon if they don't exist (#10000)
* fix #9966 Do not display a custom logo or favicon in admin if they don't exist Prevents 404 errors. * refs #9966 Fix the custom logo instant preview * refs #9966 Fix style [ci skip] * refs #9966 Introduce CustomLogo::logoExists() to remove duplicated code
Diffstat (limited to 'plugins/CoreAdminHome/CustomLogo.php')
-rw-r--r--plugins/CoreAdminHome/CustomLogo.php53
1 files changed, 36 insertions, 17 deletions
diff --git a/plugins/CoreAdminHome/CustomLogo.php b/plugins/CoreAdminHome/CustomLogo.php
index 32fa636dd3..75948fdc12 100644
--- a/plugins/CoreAdminHome/CustomLogo.php
+++ b/plugins/CoreAdminHome/CustomLogo.php
@@ -24,7 +24,7 @@ class CustomLogo
{
$defaultLogo = 'plugins/Morpheus/images/logo.png';
$themeLogo = 'plugins/%s/images/logo.png';
- $userLogo = CustomLogo::getPathUserLogo();
+ $userLogo = static::getPathUserLogo();
return $this->getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $userLogo);
}
@@ -32,7 +32,7 @@ class CustomLogo
{
$defaultLogo = 'plugins/Morpheus/images/logo-header.png';
$themeLogo = 'plugins/%s/images/logo-header.png';
- $customLogo = CustomLogo::getPathUserLogoSmall();
+ $customLogo = static::getPathUserLogoSmall();
return $this->getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo);
}
@@ -40,7 +40,7 @@ class CustomLogo
{
$defaultLogo = 'plugins/Morpheus/images/logo.svg';
$themeLogo = 'plugins/%s/images/logo.svg';
- $customLogo = CustomLogo::getPathUserSvgLogo();
+ $customLogo = static::getPathUserSvgLogo();
$svg = $this->getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo);
return $svg;
}
@@ -67,9 +67,7 @@ class CustomLogo
return true;
}
- if ($this->isEnabled()
- && file_exists(Filesystem::getPathToPiwikRoot() . '/' . CustomLogo::getPathUserSvgLogo())
- ) {
+ if ($this->isEnabled() && static::logoExists(static::getPathUserSvgLogo())) {
return true;
}
@@ -111,8 +109,6 @@ class CustomLogo
protected function getPathToLogo($pathOnly, $defaultLogo, $themeLogo, $customLogo)
{
- $pathToPiwikRoot = Filesystem::getPathToPiwikRoot();
-
$logo = $defaultLogo;
$theme = \Piwik\Plugin\Manager::getInstance()->getThemeEnabled();
@@ -123,39 +119,38 @@ class CustomLogo
}
$themeLogo = sprintf($themeLogo, $themeName);
- if (file_exists($pathToPiwikRoot . '/' . $themeLogo)) {
+ if (static::logoExists($themeLogo)) {
$logo = $themeLogo;
}
- if ($this->isEnabled()
- && file_exists($pathToPiwikRoot . '/' . $customLogo)
- ) {
+ if ($this->isEnabled() && static::logoExists($customLogo)) {
$logo = $customLogo;
}
if (!$pathOnly) {
return SettingsPiwik::getPiwikUrl() . $logo;
}
- return $pathToPiwikRoot . '/' . $logo;
+
+ return Filesystem::getPathToPiwikRoot() . '/' . $logo;
}
public static function getPathUserLogo()
{
- return self::rewritePath('misc/user/logo.png');
+ return static::rewritePath('misc/user/logo.png');
}
public static function getPathUserFavicon()
{
- return self::rewritePath('misc/user/favicon.png');
+ return static::rewritePath('misc/user/favicon.png');
}
public static function getPathUserSvgLogo()
{
- return self::rewritePath('misc/user/logo.svg');
+ return static::rewritePath('misc/user/logo.svg');
}
public static function getPathUserLogoSmall()
{
- return self::rewritePath('misc/user/logo-header.png');
+ return static::rewritePath('misc/user/logo-header.png');
}
protected static function rewritePath($path)
@@ -163,6 +158,22 @@ class CustomLogo
return SettingsPiwik::rewriteMiscUserPathWithInstanceId($path);
}
+ /**
+ * @return bool
+ */
+ public static function hasUserLogo()
+ {
+ return static::logoExists(static::getPathUserLogo());
+ }
+
+ /**
+ * @return bool
+ */
+ public static function hasUserFavicon()
+ {
+ return static::logoExists(static::getPathUserFavicon());
+ }
+
public function copyUploadedLogoToFilesystem()
{
$uploadFieldName = 'customLogo';
@@ -229,4 +240,12 @@ class CustomLogo
return true;
}
+ /**
+ * @return bool
+ */
+ private static function logoExists($relativePath)
+ {
+ return file_exists(Filesystem::getPathToPiwikRoot() . '/' . $relativePath);
+ }
+
}