mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
N°3185 - Datamodel: Add square logo in branding
This commit is contained in:
@@ -21,6 +21,7 @@ require_once(APPROOT."/application/nicewebpage.class.inc.php");
|
||||
require_once(APPROOT."/application/applicationcontext.class.inc.php");
|
||||
require_once(APPROOT."/application/user.preferences.class.inc.php");
|
||||
|
||||
use Combodo\iTop\Application\Branding;
|
||||
use Combodo\iTop\Application\TwigBase\Twig\TwigHelper;
|
||||
|
||||
/**
|
||||
@@ -28,13 +29,6 @@ use Combodo\iTop\Application\TwigBase\Twig\TwigHelper;
|
||||
*/
|
||||
class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
{
|
||||
/** @var string ENUM_APP_ICON_SHAPE_SQUARE */
|
||||
const ENUM_APP_ICON_SHAPE_SQUARE = 'square';
|
||||
/** @var string ENUM_APP_ICON_SHAPE_FULL */
|
||||
const ENUM_APP_ICON_SHAPE_FULL = 'full';
|
||||
/** @var string DEFAULT_APP_ICON_SHAPE */
|
||||
const DEFAULT_APP_ICON_SHAPE = self::ENUM_APP_ICON_SHAPE_FULL;
|
||||
|
||||
/** @var string ENUM_BREADCRUMB_ENTRY_ICON_TYPE_IMAGE */
|
||||
const ENUM_BREADCRUMB_ENTRY_ICON_TYPE_IMAGE = 'image';
|
||||
/** @var string ENUM_BREADCRUMB_ENTRY_ICON_TYPE_CSS_CLASSES */
|
||||
@@ -42,18 +36,6 @@ class iTopWebPage extends NiceWebPage implements iTabbedPage
|
||||
/** @var string DEFAULT_BREADCRUMB_ENTRY_ICON_TYPE */
|
||||
const DEFAULT_BREADCRUMB_ENTRY_ICON_TYPE = self::ENUM_BREADCRUMB_ENTRY_ICON_TYPE_IMAGE;
|
||||
|
||||
/** @var array Default and branding filenames for the app. icon in the backoffice */
|
||||
protected static $aAppIconFilenames = [
|
||||
self::ENUM_APP_ICON_SHAPE_SQUARE => [
|
||||
'default' => 'itop-logo-square.png',
|
||||
'branding' => 'backoffice-square-logo.png',
|
||||
],
|
||||
self::ENUM_APP_ICON_SHAPE_FULL => [
|
||||
'default' => 'itop-logo.png',
|
||||
'branding' => 'main-logo.png',
|
||||
],
|
||||
];
|
||||
|
||||
private $m_sMenu;
|
||||
// private $m_currentOrganization;
|
||||
private $m_aMessages;
|
||||
@@ -855,34 +837,6 @@ JS
|
||||
return $sRevisionNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the absolute URL to the application logo of $sShape
|
||||
*
|
||||
* @see static::ENUM_APP_ICON_SHAPE_SQUARE, static::ENUM_APP_ICON_SHAPE_FULL, ...
|
||||
*
|
||||
* @param string $sShape Shape of the icon to return
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
* @since 2.8.0
|
||||
*/
|
||||
protected function GetApplicationIconUrl($sShape = self::DEFAULT_APP_ICON_SHAPE)
|
||||
{
|
||||
$sIconDefaultFilename = static::$aAppIconFilenames[$sShape]['default'];
|
||||
$sIconBrandingFilename = static::$aAppIconFilenames[$sShape]['branding'];
|
||||
|
||||
$sIconAbsUrl = utils::GetAbsoluteUrlAppRoot().'images/'.$sIconDefaultFilename;
|
||||
// Check if icon is overloaded by the branding
|
||||
if (file_exists(MODULESROOT.'branding/'.$sIconBrandingFilename))
|
||||
{
|
||||
$sIconAbsUrl = utils::GetAbsoluteUrlModulesRoot().'branding/'.$sIconBrandingFilename;
|
||||
}
|
||||
|
||||
$sIconAbsUrl .= '?t='.utils::GetCacheBusterTimestamp();
|
||||
|
||||
return $sIconAbsUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the navigation menu data (id, menu groups, ...)
|
||||
*
|
||||
@@ -898,8 +852,8 @@ JS
|
||||
return [
|
||||
'sId' => 'ibo-navigation-menu',
|
||||
'sAppRevisionNumber' => $this->GetApplicationRevisionNumber(),
|
||||
'sAppSquareIconUrl' => $this->GetApplicationIconUrl(static::ENUM_APP_ICON_SHAPE_SQUARE),
|
||||
'sAppFullIconUrl' => $this->GetApplicationIconUrl(static::ENUM_APP_ICON_SHAPE_FULL),
|
||||
'sAppSquareIconUrl' => Branding::GetSquareMainLogoAbsoluteUrl(),
|
||||
'sAppFullIconUrl' => Branding::GetFullMainLogoAbsoluteUrl(),
|
||||
'sAppIconLink' => MetaModel::GetConfig()->Get('app_icon_url'),
|
||||
'aMenuGroups' => ApplicationMenu::GetMenuGroups($oAppContext->GetAsHash()),
|
||||
];
|
||||
@@ -1472,11 +1426,11 @@ EOF;
|
||||
$sOnlineHelpUrl = MetaModel::GetConfig()->Get('online_help');
|
||||
//$sLogOffMenu = "<span id=\"logOffBtn\" style=\"height:55px;padding:0;margin:0;\"><img src=\"../images/onOffBtn.png\"></span>";
|
||||
|
||||
$sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo.png?t='.utils::GetCacheBusterTimestamp();
|
||||
if (file_exists(MODULESROOT.'branding/main-logo.png'))
|
||||
{
|
||||
$sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/main-logo.png?t='.utils::GetCacheBusterTimestamp();
|
||||
}
|
||||
// $sDisplayIcon = utils::GetAbsoluteUrlAppRoot().'images/itop-logo.png?t='.utils::GetCacheBusterTimestamp();
|
||||
// if (file_exists(MODULESROOT.'branding/main-logo.png'))
|
||||
// {
|
||||
// $sDisplayIcon = utils::GetAbsoluteUrlModulesRoot().'branding/main-logo.png?t='.utils::GetCacheBusterTimestamp();
|
||||
// }
|
||||
|
||||
$sHtml .= $sNorthPane;
|
||||
$sHtml .= '<div id="left-pane" class="ui-layout-west">';
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
namespace Combodo\iTop\Portal\DependencyInjection\SilexCompatBootstrap\PortalXmlConfiguration;
|
||||
|
||||
use Combodo\iTop\Application\Branding;
|
||||
use Combodo\iTop\DesignElement;
|
||||
use Combodo\iTop\Portal\Helper\UIExtensionsHelper;
|
||||
use DOMFormatException;
|
||||
@@ -72,7 +73,7 @@ class Basic extends AbstractConfiguration
|
||||
'properties' => array(
|
||||
'id' => $_ENV['PORTAL_ID'],
|
||||
'name' => 'Page:DefaultTitle',
|
||||
'logo' => (file_exists(MODULESROOT.'branding/portal-logo.png')) ? utils::GetAbsoluteUrlModulesRoot().'branding/portal-logo.png' : '../images/logo-itop-dark-bg.svg',
|
||||
'logo' => Branding::GetPortalLogoAbsoluteUrl(),
|
||||
'themes' => array(
|
||||
'bootstrap' => 'itop-portal-base/portal/public/css/bootstrap-theme-combodo.scss',
|
||||
'portal' => 'itop-portal-base/portal/public/css/portal.scss',
|
||||
|
||||
@@ -137,6 +137,7 @@ return array(
|
||||
'CharConcatWSExpression' => $baseDir . '/core/oql/expression.class.inc.php',
|
||||
'CheckStopWatchThresholds' => $baseDir . '/core/ormstopwatch.class.inc.php',
|
||||
'CheckableExpression' => $baseDir . '/core/oql/oqlquery.class.inc.php',
|
||||
'Combodo\\iTop\\Application\\Branding' => $baseDir . '/sources/application/Branding.php',
|
||||
'Combodo\\iTop\\Application\\Search\\AjaxSearchException' => $baseDir . '/sources/application/search/ajaxsearchexception.class.inc.php',
|
||||
'Combodo\\iTop\\Application\\Search\\CriterionConversionAbstract' => $baseDir . '/sources/application/search/criterionconversionabstract.class.inc.php',
|
||||
'Combodo\\iTop\\Application\\Search\\CriterionConversion\\CriterionToOQL' => $baseDir . '/sources/application/search/criterionconversion/criteriontooql.class.inc.php',
|
||||
@@ -315,6 +316,7 @@ return array(
|
||||
'NewObjectMenuNode' => $baseDir . '/application/menunode.class.inc.php',
|
||||
'NewsroomProviderBase' => $baseDir . '/application/newsroomprovider.class.inc.php',
|
||||
'NiceWebPage' => $baseDir . '/application/nicewebpage.class.inc.php',
|
||||
'NotYetEvaluatedExpression' => $baseDir . '/core/oql/expression.class.inc.php',
|
||||
'OQLActualClassTreeResolver' => $baseDir . '/core/oqlactualclasstreeresolver.class.inc.php',
|
||||
'OQLClassNode' => $baseDir . '/core/oqlclassnode.class.inc.php',
|
||||
'OQLClassTreeBuilder' => $baseDir . '/core/oqlclasstreebuilder.class.inc.php',
|
||||
|
||||
@@ -13,9 +13,6 @@ class ComposerAutoloaderInit0018331147de7601e7552f7da8e3bb8b
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
|
||||
@@ -367,6 +367,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'CharConcatWSExpression' => __DIR__ . '/../..' . '/core/oql/expression.class.inc.php',
|
||||
'CheckStopWatchThresholds' => __DIR__ . '/../..' . '/core/ormstopwatch.class.inc.php',
|
||||
'CheckableExpression' => __DIR__ . '/../..' . '/core/oql/oqlquery.class.inc.php',
|
||||
'Combodo\\iTop\\Application\\Branding' => __DIR__ . '/../..' . '/sources/application/Branding.php',
|
||||
'Combodo\\iTop\\Application\\Search\\AjaxSearchException' => __DIR__ . '/../..' . '/sources/application/search/ajaxsearchexception.class.inc.php',
|
||||
'Combodo\\iTop\\Application\\Search\\CriterionConversionAbstract' => __DIR__ . '/../..' . '/sources/application/search/criterionconversionabstract.class.inc.php',
|
||||
'Combodo\\iTop\\Application\\Search\\CriterionConversion\\CriterionToOQL' => __DIR__ . '/../..' . '/sources/application/search/criterionconversion/criteriontooql.class.inc.php',
|
||||
@@ -545,6 +546,7 @@ class ComposerStaticInit0018331147de7601e7552f7da8e3bb8b
|
||||
'NewObjectMenuNode' => __DIR__ . '/../..' . '/application/menunode.class.inc.php',
|
||||
'NewsroomProviderBase' => __DIR__ . '/../..' . '/application/newsroomprovider.class.inc.php',
|
||||
'NiceWebPage' => __DIR__ . '/../..' . '/application/nicewebpage.class.inc.php',
|
||||
'NotYetEvaluatedExpression' => __DIR__ . '/../..' . '/core/oql/expression.class.inc.php',
|
||||
'OQLActualClassTreeResolver' => __DIR__ . '/../..' . '/core/oqlactualclasstreeresolver.class.inc.php',
|
||||
'OQLClassNode' => __DIR__ . '/../..' . '/core/oqlclassnode.class.inc.php',
|
||||
'OQLClassTreeBuilder' => __DIR__ . '/../..' . '/core/oqlclasstreebuilder.class.inc.php',
|
||||
|
||||
@@ -2745,8 +2745,9 @@ EOF;
|
||||
// Transform file refs into files in the images folder
|
||||
$this->CompileFiles($oBrandingNode, $sTempTargetDir.'/branding', $sFinalTargetDir.'/branding', 'branding');
|
||||
|
||||
$this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo', 'main-logo');
|
||||
$this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'login_logo', 'login-logo');
|
||||
$this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo', 'main-logo-full');
|
||||
$this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo_square', 'main-logo-square');
|
||||
$this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'portal_logo', 'portal-logo');
|
||||
|
||||
// Cleanup the images directory (eventually made by CompileFiles)
|
||||
|
||||
133
sources/application/Branding.php
Normal file
133
sources/application/Branding.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2013-2020 Combodo SARL
|
||||
*
|
||||
* This file is part of iTop.
|
||||
*
|
||||
* iTop is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* iTop is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Application;
|
||||
|
||||
use utils;
|
||||
|
||||
/**
|
||||
* Class Branding
|
||||
*
|
||||
* @author Guillaume Lajarige <guillaume.lajarige@combodo.com>
|
||||
* @package Combodo\iTop\Application
|
||||
* @since 2.8.0
|
||||
*/
|
||||
class Branding
|
||||
{
|
||||
/** @var string Full main logo, used everywhere when there is no need for a special one */
|
||||
const ENUM_LOGO_TYPE_MAIN_LOGO_FULL = 'main_logo_full';
|
||||
/** @var string Square main logo, used in the collapsed menu of the backoffice */
|
||||
const ENUM_LOGO_TYPE_MAIN_LOGO_SQUARE = 'main_logo_square';
|
||||
/** @var string Logo used in the end-users portal */
|
||||
const ENUM_LOGO_TYPE_PORTAL_LOGO = 'portal_logo';
|
||||
/** @var string Logo used in the login pages */
|
||||
const ENUM_LOGO_TYPE_LOGIN_LOGO = 'login_logo';
|
||||
/** @var string Default logo */
|
||||
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_SQUARE => [
|
||||
'default' => 'images/itop-logo-square.png',
|
||||
'custom' => 'branding/main-logo-square.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 square main logo
|
||||
*
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function GetSquareMainLogoAbsoluteUrl()
|
||||
{
|
||||
return static::GetLogoAbsoluteUrl(static::ENUM_LOGO_TYPE_MAIN_LOGO_SQUARE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user