N°3363 - Add favicon in branding (#522)

This commit is contained in:
Anne-Catherine
2024-02-28 09:59:11 +01:00
committed by GitHub
parent baa05ba8d4
commit 1394bc221d
13 changed files with 161 additions and 35 deletions

View File

@@ -19,6 +19,7 @@
namespace Combodo\iTop\Application;
use MetaModel;
use utils;
/**
@@ -38,27 +39,52 @@ class Branding
public const ENUM_LOGO_TYPE_PORTAL_LOGO = 'portal_logo';
/** @var string Logo used in the login pages */
public const ENUM_LOGO_TYPE_LOGIN_LOGO = 'login_logo';
/**
* @var string Logo used in most pages (backoffice, ...)
* @since 3.2.0 N°3363
*/
public const ENUM_LOGO_TYPE_MAIN_FAVICON = 'main_favicon';
/**
* @var string Logo used in the end-users portals
* @since 3.2.0 N°3363
*/
public const ENUM_LOGO_TYPE_PORTAL_FAVICON = 'portal_favicon';
/**
* @var string Logo used in the login page
* @since 3.2.0 N°3363
*/
public const ENUM_LOGO_TYPE_LOGIN_FAVICON = 'login_favicon';
/** @var string Default logo */
public const DEFAULT_LOGO_TYPE = self::ENUM_LOGO_TYPE_MAIN_LOGO_FULL;
/** @var \string[][] Relative paths to the logos from the current environment folder */
public static $aLogoPaths = [
self::ENUM_LOGO_TYPE_MAIN_LOGO_FULL => [
self::ENUM_LOGO_TYPE_MAIN_LOGO_FULL => [
'default' => 'images/itop-logo.png',
],
self::ENUM_LOGO_TYPE_MAIN_LOGO_COMPACT => [
'default' => 'images/itop-logo-square.png',
],
self::ENUM_LOGO_TYPE_PORTAL_LOGO => [
self::ENUM_LOGO_TYPE_PORTAL_LOGO => [
'default' => 'images/logo-itop-dark-bg.svg',
],
self::ENUM_LOGO_TYPE_LOGIN_LOGO => [
self::ENUM_LOGO_TYPE_LOGIN_LOGO => [
'default' => 'images/itop-logo-external.png',
],
self::ENUM_LOGO_TYPE_MAIN_FAVICON => [
'default' => 'images/favicon.ico',
],
self::ENUM_LOGO_TYPE_PORTAL_FAVICON => [
'default' => 'images/favicon.ico',
],
self::ENUM_LOGO_TYPE_LOGIN_FAVICON => [
'default' => 'images/favicon.ico',
],
];
/**
* Return url or path of logo defined by $sType
*
* @param string $sType
* @param string $sAppPath
* @param ?string $sModulePath
@@ -73,7 +99,7 @@ class Branding
if (isset($aThemeParameters[$sType])) {
$sCustomLogoPath = $aThemeParameters[$sType];
if (file_exists($sWorkingPath.$sCustomLogoPath)) {
return ($sModulePath??$sAppPath).$sCustomLogoPath;
return ($sModulePath ?? $sAppPath).$sCustomLogoPath;
}
}
@@ -154,4 +180,39 @@ class Branding
return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_LOGIN_LOGO);
}
/**
* Return the absolute URL for thefavicon
*
* @return string
* @throws \Exception
* @since 3.2.0 N°3363
*/
public static function GetMainFavIconAbsoluteUrl(): string
{
return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_MAIN_FAVICON);
}
/**
* Return the absolute URL for thefavicon
*
* @return string
* @throws \Exception
* @since 3.2.0 N°3363
*/
public static function GetPortalFavIconAbsoluteUrl(): string
{
return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_PORTAL_FAVICON);
}
/**
* Return the absolute URL for thefavicon
*
* @return string
* @throws \Exception
* @since 3.2.0 N°3363
*/
public static function GetLoginFavIconAbsoluteUrl(): string
{
return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_LOGIN_FAVICON);
}
}