dolibarr 22.0.5
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 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22
29require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php'; // used for color functions
30require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
31
32
37{
41 public $primaryColorHex = '#263c5c';
42
46 public $primaryColorHsl = array(
47 'h' => 216, // Hue
48 'l' => 42, // lightness
49 's' => 25, // Saturation
50 'a' => 1 // Alfa
51 );
52
56 public $loginLogoUrl;
57
61 public $menuLogoUrl;
62
66 public $loginBackground;
67
71 public $bannerBackground;
72
76 public $bannerUseDarkTheme;
77
78
82 public function __construct()
83 {
84 global $db, $conf;
85
86 $mysoc = new Societe($db);
87 $mysoc->setMysoc($conf);
88
89 $this->loadPrimaryColor();
90
91 $urllogo = DOL_URL_ROOT.'/theme/common/login_logo.png';
92 if (!empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small)) {
93 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$mysoc->logo_small);
94 } elseif (!empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
95 $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$mysoc->logo);
96 } elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.svg')) {
97 $urllogo = DOL_URL_ROOT.'/theme/dolibarr_logo.svg';
98 }
99
100 $this->loginLogoUrl = getDolGlobalString('WEBPORTAL_LOGIN_LOGO_URL', $urllogo);
101 $this->menuLogoUrl = getDolGlobalString('WEBPORTAL_MENU_LOGO_URL', $this->loginLogoUrl);
102 $this->loginBackground = getDolGlobalString('WEBPORTAL_LOGIN_BACKGROUND');
103 $this->bannerBackground = getDolGlobalString('WEBPORTAL_BANNER_BACKGROUND');
104 $this->bannerUseDarkTheme = getDolGlobalInt('WEBPORTAL_BANNER_BACKGROUND_IS_DARK');
105 }
106
112 public function loadPrimaryColor()
113 {
114 $outColor = '';
115
116 if (getDolGlobalString('WEBPORTAL_PRIMARY_COLOR')) {
117 $outColor = getDolGlobalString('WEBPORTAL_PRIMARY_COLOR');
118 } elseif (getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')) {
119 $outColor = colorArrayToHex(colorStringToArray(getDolGlobalString('THEME_ELDY_TOPMENU_BACK1')));
120 }
121 if (strpos($outColor, '#') !== 0) {
122 $outColor = '#'.$outColor;
123 }
124
125 // If custom color is valid, w e use it
126 if (!empty($outColor) && colorValidateHex($outColor)) {
127 $this->primaryColorHex = $outColor;
128 $this->primaryColorHsl = colorHexToHsl($outColor, 1, true);
129 }
130 }
131}
Class to manage third parties objects (customers, suppliers, prospects...)
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79