* @package Combodo\iTop\Application * @since 3.0.0 */ class Branding { /** @var string Full main logo, used everywhere when there is no need for a special one */ public const ENUM_LOGO_TYPE_MAIN_LOGO_FULL = 'main_logo_full'; /** @var string Compact main logo, used in the collapsed menu of the backoffice */ public const ENUM_LOGO_TYPE_MAIN_LOGO_COMPACT = 'main_logo_compact'; /** @var string Logo used in the end-users portal */ 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 Default logo */ public const DEFAULT_LOGO_TYPE = self::ENUM_LOGO_TYPE_MAIN_LOGO_FULL; /** @var \string[][] Relative paths to the default/custom logos from the current environment folder */ public static $aLogoPaths = [ self::ENUM_LOGO_TYPE_MAIN_LOGO_FULL => [ 'default' => 'images/itop-logo.png', 'custom' => 'branding/main-logo-full.png', ], self::ENUM_LOGO_TYPE_MAIN_LOGO_COMPACT => [ 'default' => 'images/itop-logo-square.png', 'custom' => 'branding/main-logo-compact.png', ], self::ENUM_LOGO_TYPE_PORTAL_LOGO => [ 'default' => 'images/logo-itop-dark-bg.svg', 'custom' => 'branding/portal-logo.png', ], self::ENUM_LOGO_TYPE_LOGIN_LOGO => [ 'default' => 'images/itop-logo.png', 'custom' => 'branding/login-logo.png', ], ]; /** * Return the absolute URL for the full main logo * * @param string $sType Type of the logo to return * @see static::ENUM_LOGO_TYPE_XXX * * @return string * @throws \Exception */ public static function GetLogoAbsoluteUrl($sType = self::DEFAULT_LOGO_TYPE) { $sDefaultLogoPath = static::$aLogoPaths[$sType]['default']; $sCustomLogoPath = static::$aLogoPaths[$sType]['custom']; if (file_exists(MODULESROOT.$sCustomLogoPath)) { $sUrl = utils::GetAbsoluteUrlModulesRoot().$sCustomLogoPath; } else { $sUrl = utils::GetAbsoluteUrlAppRoot().$sDefaultLogoPath; } return $sUrl.'?t='.utils::GetCacheBusterTimestamp(); } /** * Return the absolute URL for the full main logo * * @return string * @throws \Exception */ public static function GetFullMainLogoAbsoluteUrl() { return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_MAIN_LOGO_FULL); } /** * Return the absolute URL for the compact main logo * * @return string * @throws \Exception */ public static function GetCompactMainLogoAbsoluteUrl() { return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_MAIN_LOGO_COMPACT); } /** * Return the absolute URL for the portal logo * * @return string * @throws \Exception */ public static function GetPortalLogoAbsoluteUrl() { return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_PORTAL_LOGO); } /** * Return the absolute URL for the login logo * * @return string * @throws \Exception */ public static function GetLoginLogoAbsoluteUrl() { return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_LOGIN_LOGO); } }