Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N°3777 - favicon: change easily favicon #619

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 61 additions & 2 deletions application/themehandler.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,42 @@ public static function GetCurrentThemeId()
*/
public static function GetApplicationThemeId(): string
{
$sThemeId = null;
try {
$sThemeId = utils::GetConfig()->Get('backoffice_default_theme');
//environment type from config.php
$sEnvType = MetaModel::GetConfig()->Get('local_branding');
//environment type from config.php
if (utils::IsNotNullOrEmptyString($sEnvType)) {
$sWorkingPath = APPROOT.'env-'.utils::GetCurrentEnvironment().'/';
$aThemeParameters = json_decode(@file_get_contents($sWorkingPath.'branding/themes.json'), true);
if ( isset($aThemeParameters[$sEnvType]) ) {
if (isset($aThemeParameters[$sEnvType]['allowed_theme'])) {
$aThemeId = $aThemeParameters[$sEnvType]['allowed_theme'];
if (in_array($sThemeId, $aThemeId) == false) {
$sThemeId = null;
}
}
if (is_null($sThemeId)) {
//environment type from config.php
if (isset($aThemeParameters[$sEnvType]['default_theme'])) {
$sThemeId = $aThemeParameters[$sEnvType]['default_theme'];
} else {
$aDefaultTheme = ThemeHandler::GetDefaultThemeInformation();
$sThemeId = $aDefaultTheme['name'];
}
}
}
}
if (is_null($sThemeId)) {
$sThemeId = utils::GetConfig()->Get('backoffice_default_theme');
}
}
catch (CoreException $oCompileException) {
// Fallback on our default theme in case the config. is not available yet
$aDefaultTheme = ThemeHandler::GetDefaultThemeInformation();
$sThemeId = $aDefaultTheme['name'];
}

IssueLog::Error("GetApplicationThemeId: ".$sThemeId);
return $sThemeId;
}

Expand All @@ -101,11 +128,24 @@ public static function GetCurrentUserThemeId(): string
catch (Exception $oException) {
// Do nothing, already handled by $sThemeId null by default
}
$sEnvType = MetaModel::GetConfig()->Get('local_branding');
//environment type from config.php
if (utils::IsNotNullOrEmptyString($sEnvType)) {
$sWorkingPath = APPROOT.'env-'.utils::GetCurrentEnvironment().'/';
$aThemeParameters = json_decode(@file_get_contents($sWorkingPath.'branding/themes.json'), true);
if (isset($aThemeParameters[$sEnvType]) && isset($aThemeParameters[$sEnvType]['allowed_theme'])) {
$aThemeId = $aThemeParameters[$sEnvType]['allowed_theme'];
if ( in_array($sThemeId,$aThemeId) == false) {
$sThemeId = null;
}
}
}

// Fallback on the app. theme
if (is_null($sThemeId)) {
$sThemeId = static::GetApplicationThemeId();
}
IssueLog::Error("GetCurrentUserThemeId: ".$sThemeId);

return $sThemeId;
}
Expand Down Expand Up @@ -142,6 +182,25 @@ public static function GetAvailableThemes(): array
}
asort($aThemes);

$sEnvType = MetaModel::GetConfig()->Get('local_branding');
if (!utils::IsNullOrEmptyString($sEnvType)) {
$sWorkingPath = APPROOT . 'env-' . utils::GetCurrentEnvironment() . '/';
$aThemeParameters = json_decode(@file_get_contents($sWorkingPath . 'branding/themes.json'), true);
//environment type from config.php
if (isset($aThemeParameters[$sEnvType])) {
$aThemeId = $aThemeParameters[$sEnvType]['allowed_theme'];
$aAvailableThemes = [];
foreach ($aThemeId as $sThemeId) {
if (isset($aThemes[$sThemeId])) {
$aAvailableThemes[$sThemeId] = $aThemes[$sThemeId];
}
}
if (count($aAvailableThemes) > 0) {
$aThemes = $aAvailableThemes;
}
}
}

return $aThemes;
}

Expand Down
75 changes: 42 additions & 33 deletions core/config.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,90 +185,98 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'temporary_object.garbage_interval' => [
'temporary_object.garbage_interval' => [
'type' => 'integer',
'description' => 'Seconds between garbage collections',
'default' => 60,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'app_env_label' => [
'app_env_label' => [
'type' => 'string',
'description' => 'Label displayed to describe the current application environment, defaults to the environment name (e.g. "production")',
'default' => '',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'app_root_url' => [
'app_root_url' => [
'type' => 'string',
'description' => 'Root URL used for navigating within the application, or from an email to the application (you can put $SERVER_NAME$ as a placeholder for the server\'s name)',
'default' => '',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'app_icon_url' => [
'local_branding' => [
'type' => 'string',
'description' => 'type of branding. useful for put different logo depending environment',
'default' => null,
'value' => null,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'app_icon_url' => [
'type' => 'string',
'description' => 'Hyperlink to redirect the user when clicking on the application icon (in the main window, or login/logoff pages)',
'default' => 'http://www.combodo.com/itop',
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'db_host' => [
'db_host' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'db_user' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'db_user' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'db_pwd' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'db_pwd' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'db_name' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'db_name' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'db_subname' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'db_subname' => [
'type' => 'string',
'default' => null,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'db_tls.enabled' => [
'type' => 'bool',
'description' => 'If true then the connection to the DB will be encrypted',
'default' => false,
'value' => false,
'source_of_value' => '',
'db_tls.enabled' => [
'type' => 'bool',
'description' => 'If true then the connection to the DB will be encrypted',
'default' => false,
'value' => false,
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'db_tls.ca' => [
'db_tls.ca' => [
'type' => 'string',
'description' => 'Path to certificate authority file for SSL',
'default' => null,
'value' => '',
'source_of_value' => '',
'show_in_conf_sample' => false,
],
'db_core_transactions_enabled' => [
'db_core_transactions_enabled' => [
'type' => 'bool',
'description' => 'If true, CRUD transactions in iTop core will be enabled',
'default' => true,
Expand Down Expand Up @@ -1888,6 +1896,7 @@ public function Set($sPropCode, $value, $sSourceDesc = 'unknown', $bCanOverride
*/
public function Get($sPropCode)
{

return $this->m_aSettings[$sPropCode]['value'];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public function Process(Container $oContainer)
*/
private function GetInitialPortalConf()
{

$aPortalConf = array(
'properties' => array(
'id' => $_ENV['PORTAL_ID'],
Expand All @@ -81,15 +82,15 @@ private function GetInitialPortalConf()
'favicon' => Branding::GetPortalFavIconAbsoluteUrl(),
'themes' => array(
'bootstrap' => 'itop-portal-base/portal/public/css/bootstrap-theme-combodo.scss',
'portal' => 'itop-portal-base/portal/public/css/portal.scss',
'others' => array(),
'portal' => 'itop-portal-base/portal/public/css/portal.scss',
'others' => array(),
),
'templates' => array(
'templates' => array(
'layout' => 'itop-portal-base/portal/templates/layout.html.twig',
'home' => 'itop-portal-base/portal/templates/home/layout.html.twig',
'home' => 'itop-portal-base/portal/templates/home/layout.html.twig',
),
'urlmaker_class' => null,
'triggers_query' => null,
'urlmaker_class' => null,
'triggers_query' => null,
'attachments' => array(
'allow_delete' => true,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{% block pPageExtraMetas %}
{% endblock %}
<title>{% block pPageTitle %}{% if sPageTitle is defined and sPageTitle is not null %}{{ sPageTitle }} - {{ constant('ITOP_APPLICATION_SHORT') }}{% else %}{{ 'Page:DefaultTitle'|dict_format(constant('ITOP_APPLICATION_SHORT')) }}{% endif %}{% endblock %}</title>
<link rel="shortcut icon" href="{{ app['combodo.portal.instance.conf'].properties.favicon|add_itop_version }}"/>
<link rel="shortcut icon" href="{{ app['combodo.portal.instance.conf'].properties.favicon|add_itop_version }}"/>

{% block pPageStylesheets %}
{# First bootstrap core, lib themes, then bootstrap theme, portal adjustements #}
Expand Down Expand Up @@ -251,7 +251,7 @@
</nav>
{% endblock %}

{# Sidebar navigation menu for normal screens #}
{# Sidebar navigation menu for normal screens #}
{% block pNavigationSideMenuWrapper %}
<nav class="navbar-default hidden-xs col-sm-3 col-md-2" id="sidebar" role="navigation">
<div class="user_card bg-primary">
Expand Down
Loading