dolibarr 24.0.0-beta
setup_theme.php
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) 2024 Frédéric France <frederic.france@free.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
26// Load Dolibarr environment
27require_once "../../main.inc.php";
28require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
29require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
30
39// Translations
40$langs->loadLangs(array("admin", "webportal", "website"));
41
42// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
43$hookmanager->initHooks(array('webportalthemesetup', 'globalsetup'));
44
45// Parameters
46$action = GETPOST('action', 'aZ09');
47$backtopage = GETPOST('backtopage', 'alpha');
48$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
49
50$value = GETPOST('value', 'alpha');
51$label = GETPOST('label', 'alpha');
52$scandir = GETPOST('scan_dir', 'alpha');
53
54// Access control
55if (!$user->admin) {
57}
58
59$error = 0;
60$setupnotempty = 0;
61
62// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
63$useFormSetup = 1;
64
65if (!class_exists('FormSetup')) {
66 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsetup.class.php';
67}
68
69$formSetup = new FormSetup($db);
70
71require_once __DIR__ . '/../class/webPortalTheme.class.php';
72$webPortalTheme = new WebPortalTheme();
73
74// Setup conf for secondary color
75$item = $formSetup->newItem('WEBPORTAL_PRIMARY_COLOR');
76$item->setAsColor();
77$item->defaultFieldValue = $webPortalTheme->primaryColorHex;
78
79// Login theme
80$options = [
81 'default' => [
82 'id' => 'default-login-theme',
83 'label' => '<img src="'. DOL_URL_ROOT . '/public/webportal/img/login-tpl/default.svg" alt="'.dolPrintHTMLForAttribute($langs->trans('UseDefaultLoginForm')).'" />',
84 'labelIsHtml' => true
85 ],
86 'right' => [
87 'id' => 'right-login-theme',
88 'label' => '<img src="'. DOL_URL_ROOT . '/public/webportal/img/login-tpl/right.svg" alt="'.dolPrintHTMLForAttribute($langs->trans('UseRightLoginForm')).'" />',
89 'labelIsHtml' => true
90 ],
91];
92$item = $formSetup->newItem('WEBPORTAL_LOGIN_FORM_THEME')->setAsRadio($options);
93$item->cssClass = 'integrated-radio';
94$item->defaultFieldValue = 'default';
95
96
97// Logo URL
98$item = $formSetup->newItem('WEBPORTAL_LOGIN_LOGO_URL');
99$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
100
101$item = $formSetup->newItem('WEBPORTAL_MENU_LOGO_URL');
102$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
103
104
105
106// Background URL
107$item = $formSetup->newItem('WEBPORTAL_LOGIN_BACKGROUND');
108$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
109
110$item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND');
111$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
112
113
114$item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND_IS_DARK')->setAsYesNo();
115
116$setupnotempty += count($formSetup->items);
117
118
119
120/*
121 * Actions
122 */
123
124include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';
125
126// Force always edit mode
127if (empty($action) || $action == 'update') {
128 $action = 'edit';
129}
130
131
132/*
133 * View
134 */
135
136$form = new Form($db);
137
138$help_url = '';
139$title = "WebPortalSetup";
140
141llxHeader('', $langs->trans($title), $help_url);
142
143// Subheader
144$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
145
146print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
147
148// Configuration header
150print dol_get_fiche_head($head, 'themesettings', $langs->trans($title), -1, "webportal");
151
152
153if ($action == 'edit') {
154 print $formSetup->generateOutput(true);
155 print '<br>';
156} elseif (!empty($formSetup->items)) {
157 print $formSetup->generateOutput();
158 print '<div class="tabsAction">';
159 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>';
160 print '</div>';
161} else {
162 print '<br>' . $langs->trans("NothingToSetup");
163}
164
165
166// Page end
167print dol_get_fiche_end();
168
169llxFooter();
170$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage generation of HTML components Only common components must be here.
This class help you create setup render.
Class WebPortalTheme.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
webportalAdminPrepareHead()
Prepare admin pages header.