dolibarr 21.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
80// Logo URL
81$item = $formSetup->newItem('WEBPORTAL_LOGIN_LOGO_URL');
82$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
83
84$item = $formSetup->newItem('WEBPORTAL_MENU_LOGO_URL');
85$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
86
87
88
89// Background URL
90$item = $formSetup->newItem('WEBPORTAL_LOGIN_BACKGROUND');
91$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
92
93$item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND');
94$item->fieldAttr = array('type'=>'url', 'size'=> 50, 'placeholder'=>'https://');
95
96
97$item = $formSetup->newItem('WEBPORTAL_BANNER_BACKGROUND_IS_DARK')->setAsYesNo();
98
99$setupnotempty += count($formSetup->items);
100
101
102
103/*
104 * Actions
105 */
106
107include DOL_DOCUMENT_ROOT . '/core/actions_setmoduleoptions.inc.php';
108
109// Force always edit mode
110if (empty($action) || $action == 'update') {
111 $action = 'edit';
112}
113
114
115/*
116 * View
117 */
118
119$form = new Form($db);
120
121$help_url = '';
122$title = "WebPortalSetup";
123
124llxHeader('', $langs->trans($title), $help_url);
125
126// Subheader
127$linkback = '<a href="' . ($backtopage ? $backtopage : DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans("BackToModuleList") . '</a>';
128
129print load_fiche_titre($langs->trans($title), $linkback, 'title_setup');
130
131// Configuration header
133print dol_get_fiche_head($head, 'themesettings', $langs->trans($title), -1, "webportal");
134
135// Setup page goes here
136//print info_admin($langs->trans("UserAccountForWebPortalAreInThirdPartyTabHelp"));
137
138if ($action == 'edit') {
139 print $formSetup->generateOutput(true);
140 print '<br>';
141} elseif (!empty($formSetup->items)) {
142 print $formSetup->generateOutput();
143 print '<div class="tabsAction">';
144 print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?action=edit&token=' . newToken() . '">' . $langs->trans("Modify") . '</a>';
145 print '</div>';
146} else {
147 print '<br>' . $langs->trans("NothingToSetup");
148}
149
150
151// Page end
152print dol_get_fiche_end();
153
154llxFooter();
155$db->close();
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:71
Class to manage generation of HTML components Only common components must be here.
This class help you create setup render.
Class WebPortalTheme.
llxFooter()
Footer empty.
Definition document.php:107
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.