dolibarr 21.0.0-alpha
webPortalTheme.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2023-2024 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2023-2024 Lionel Vessiller <lvessiller@easya.solutions>
4 * Copyright (C) 2023-2024 John Botella <john.botella@atm-consulting.fr>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
21
28require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; // used for color functions
29
34{
38 public $primaryColorHex = '#263c5c';
39
43 public $primaryColorHsl = array(
44 'h' => 216, // Hue
45 'l' => 42, // lightness
46 's' => 25, // Saturation
47 'a' => 1 // Alfa
48 );
49
53 public $loginLogoUrl;
54
58 public $menuLogoUrl;
59
63 public $loginBackground;
64
68 public $bannerBackground;
69
73 public $bannerUseDarkTheme;
74
75
79 public function __construct()
80 {
81 global $mysoc, $conf;
82
83 $this->loadPrimaryColor();
84
85 $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
86 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
87 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
88 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
89 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$mysoc->logo);
90 } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
91 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
92 }
93
94 $this->loginLogoUrl = getDolGlobalString('WEBPORTAL_LOGIN_LOGO_URL', $urllogo);
95 $this->menuLogoUrl = getDolGlobalString('WEBPORTAL_MENU_LOGO_URL', $this->loginLogoUrl);
96 $this->loginBackground = getDolGlobalString('WEBPORTAL_LOGIN_BACKGROUND');
97 $this->bannerBackground = getDolGlobalString('WEBPORTAL_BANNER_BACKGROUND');
98 $this->bannerUseDarkTheme = getDolGlobalInt('WEBPORTAL_BANNER_BACKGROUND_IS_DARK');
99 }
100
106 public function loadPrimaryColor()
107 {
108 $outColor = '';
109
110 if (getDolGlobalString('WEBPORTAL_PRIMARY_COLOR')) {
111 $outColor = getDolGlobalString('WEBPORTAL_PRIMARY_COLOR');
112 } elseif (getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')) {
113 $outColor = colorArrayToHex(colorStringToArray(getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')));
114 }
115 if (strpos($outColor, '#') !== 0) {
116 $outColor = '#'.$outColor;
117 }
118
119 // If custom color is valid, w e use it
120 if (!empty($outColor) && colorValidateHex($outColor)) {
121 $this->primaryColorHex = $outColor;
122 $this->primaryColorHsl = colorHexToHsl($outColor, true, true);
123 }
124 }
125}
Class WebPortalTheme.
loadPrimaryColor()
Load hex of primary theme color.
__construct()
Constructor.
colorArrayToHex($arraycolor, $colorifnotfound='888888')
Convert an array with RGB value into hex RGB value.
colorStringToArray($stringcolor, $colorifnotfound=array(88, 88, 88))
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,...
colorHexToHsl($hex, $alpha=false, $returnArray=false)
Color Hex to Hsl (used for style)
colorValidateHex($color, $allow_white=true)
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.