dolibarr 20.0.0
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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20
27require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; // used for color functions
28
33{
34 public $primaryColorHex = '#263c5c';
35 public $primaryColorHsl = array(
36 'h' => 216, // Hue
37 'l' => 42, // lightness
38 's' => 25, // Saturation
39 'a' => 1 // Alfa
40 );
41
42
43 public $loginLogoUrl;
44 public $menuLogoUrl;
45 public $loginBackground;
46
50 public $bannerBackground;
51
55 public $bannerUseDarkTheme;
56
57
61 public function __construct()
62 {
63 global $mysoc, $conf;
64
65 $this->loadPrimaryColor();
66
67 $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
68 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
69 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
70 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
71 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;entity='.$conf->entity.'&amp;file='.urlencode('logos/'.$mysoc->logo);
72 } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
73 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
74 }
75
76 $this->loginLogoUrl = getDolGlobalString('WEBPORTAL_LOGIN_LOGO_URL', $urllogo);
77 $this->menuLogoUrl = getDolGlobalString('WEBPORTAL_MENU_LOGO_URL', $this->loginLogoUrl);
78 $this->loginBackground = getDolGlobalString('WEBPORTAL_LOGIN_BACKGROUND');
79 $this->bannerBackground = getDolGlobalString('WEBPORTAL_BANNER_BACKGROUND');
80 $this->bannerUseDarkTheme = getDolGlobalInt('WEBPORTAL_BANNER_BACKGROUND_IS_DARK');
81 }
82
88 public function loadPrimaryColor()
89 {
90 $outColor = '';
91
92 if (getDolGlobalString('WEBPORTAL_PRIMARY_COLOR')) {
93 $outColor = getDolGlobalString('WEBPORTAL_PRIMARY_COLOR');
94 } elseif (getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')) {
95 $outColor = colorArrayToHex(colorStringToArray(getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')));
96 }
97 if (strpos($outColor, '#') !== 0) {
98 $outColor = '#'.$outColor;
99 }
100
101 // If custom color is valid, w e use it
102 if (!empty($outColor) && colorValidateHex($outColor)) {
103 $this->primaryColorHex = $outColor;
104 $this->primaryColorHsl = colorHexToHsl($outColor, true, true);
105 }
106 }
107}
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 dolibarr global constant string value.