dolibarr 20.0.0
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
31// Translations
32$langs->loadLangs(array("admin", "webportal", "website"));
33
34// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
35$hookmanager->initHooks(array('webportalthemesetup', 'globalsetup'));
36
37// Parameters
38$action = GETPOST('action', 'aZ09');
39$backtopage = GETPOST('backtopage', 'alpha');
40$modulepart = GETPOST('modulepart', 'aZ09'); // Used by actions_setmoduleoptions.inc.php
41
42$value = GETPOST('value', 'alpha');
43$label = GETPOST('label', 'alpha');
44$scandir = GETPOST('scan_dir', 'alpha');
45
46// Access control
47if (!$user->admin) {
49}
50
51$error = 0;
52$setupnotempty = 0;
53
54// Set this to 1 to use the factory to manage constants. Warning, the generated module will be compatible with version v15+ only
55$useFormSetup = 1;
56
57if (!class_exists('FormSetup')) {
58 require_once DOL_DOCUMENT_ROOT . '/core/class/html.formsetup.class.php';
59}
60
61$formSetup = new FormSetup($db);
62
63require_once __DIR__ . '/../class/webPortalTheme.class.php';
64$webPortalTheme = new WebPortalTheme();
65
66// Setup conf for secondary color
67$item = $formSetup->newItem('WEBPORTAL_PRIMARY_COLOR');
68$item->setAsColor();
69$item->defaultFieldValue = $webPortalTheme->primaryColorHex;
70
71
72// Logo URL
73$item = $formSetup->newItem('WEBPORTAL_LOGIN_LOGO_URL');
74$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
75
76$item = $formSetup->newItem('WEBPORTAL_MENU_LOGO_URL');
77$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
78
79
80
81// Background URL
82$item = $formSetup->newItem('WEBPORTAL_LOGIN_BACKGROUND');
83$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
84
85$item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND');
86$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
87
88
89$item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND_IS_DARK')->setAsYesNo();
90
91$setupnotempty += count($formSetup->items);
92
93
94
95/*
96 * Actions
97 */
98
99include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';
100
101// Force always edit mode
102if (empty($action) || $action == 'update') {
103 $action = 'edit';
104}
105
106
107/*
108 * View
109 */
110
111$form = new Form($db);
112
113$help_url = '';
114$title = "WebPortalSetup";
115
116llxHeader('', $langs->trans($title), $help_url);
117
118// Subheader
119$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
120
121print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
122
123// Configuration header
125print dol_get_fiche_head($head, 'themesettings', $langs->trans($title), -1, "webportal");
126
127// Setup page goes here
128//print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp"));
129
130if ($action == 'edit') {
131 print $formSetup->generateOutput(true);
132 print '<br>';
133} elseif (!empty($formSetup->items)) {
134 print $formSetup->generateOutput();
135 print '<div class="tabsAction">';
136 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>';
137 print '</div>';
138} else {
139 print '<br>' . $langs->trans("NothingToSetup");
140}
141
142
143// Page end
144print dol_get_fiche_end();
145
146llxFooter();
147$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage generation of HTML components Only common components must be here.
This class help you create setup render.
Class WebPortalTheme.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.