dolibarr 24.0.0-beta
configcss.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 Patrice Andreani <pandreani@easya.solutions>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require_once "../../main.inc.php";
36require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
37require_once DOL_DOCUMENT_ROOT . "/webportal/lib/webportal.lib.php";
38
39// Translations
40$langs->loadLangs(array("admin", "hrm", "other", "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('webportalsetup', 'globalsetup'));
44
45// Parameters
46$action = GETPOST('action', 'aZ09');
47$backtopage = GETPOST('backtopage', 'alpha');
48
49if (empty($action)) {
50 $action = 'edit';
51}
52
53// Access control
54if (!$user->admin) {
56}
57
58$object = new stdClass();
59
60
61/*
62 * Actions
63 */
64
65$parameters = array();
66$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
67if ($reshook < 0) {
68 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
69}
70
71// Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff)
72$regs = array();
73if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) {
74 if ($regs[1] == 'set') {
75 dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity);
76 } else {
77 dolibarr_del_const($db, $regs[2], $conf->entity);
78 }
79}
80
81if ($action == 'updatecss') {
82 $csscontent = GETPOST('WEBPORTAL_CUSTOM_CSS', 'restricthtml'); // Will return a sanitized HTML content (so with double spaes that may be replaced with one, ...
83 $csscontent = dol_string_nohtmltag($csscontent, 2, 'UTF-8', 0, 0);
84
85 dolibarr_set_const($db, "WEBPORTAL_CUSTOM_CSS", $csscontent, 'chaine', 0, '', $conf->entity);
86
87 setEventMessages($langs->trans("RecordSaved"), null);
88
89 if (GETPOST('dol_resetcache')) {
90 dolibarr_set_const($db, "WEBPORTAL_PARAMS_REV", getDolGlobalInt('WEBPORTAL_PARAMS_REV') + 1, 'chaine', 0, '', $conf->entity);
91 }
92}
93
94
95/*
96 * View
97 */
98
99$title = "WebPortalSetup";
100
101$wikihelp = 'EN:First_setup|FR:Premiers_param&eacute;trages|ES:Primeras_configuraciones';
102
104 '',
105 $langs->trans($title),
106 $wikihelp,
107 '',
108 0,
109 0,
110 array(
111 '/includes/ace/src/ace.js',
112 '/includes/ace/src/ext-statusbar.js',
113 '/includes/ace/src/ext-language_tools.js',
114 ),
115 array()
116);
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, 'css', $langs->trans($title), -1, "webportal");
126
127// Setup page goes here
128echo '<span class="opacitymedium">' . $langs->trans("WebPortalCSS") . '</span><br><br>';
129
130//WYSIWYG Editor
131require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
132
133print '<form enctype="multipart/form-data" method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
134
135print '<input type="hidden" name="token" value="' . newToken() . '">';
136print '<input type="hidden" name="action" value="updatecss">';
137
138clearstatcache();
139
140// editeur CSS
141print '<div class="div-table-responsive-no-min">';
142print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
143
144print '<tr class="liste_titre">';
145print '<td colspan="2">';
146
147$customcssValue = getDolGlobalString('WEBPORTAL_CUSTOM_CSS');
148
149$doleditor = new DolEditor('WEBPORTAL_CUSTOM_CSS', $customcssValue, '80%', 400, 'Basic', 'In', true, false, 'ace', 10, '90%');
150$doleditor->Create(0, '', true, 'css', 'css');
151print '</td></tr>' . "\n";
152
153print '</table>' . "\n";
154print '</div>';
155
156print '<div class="center">';
157print '<input class="button button-save reposition buttonforacesave" type="submit" name="submit" value="' . $langs->trans("Save") . '">';
158//print '<input class="button button-cancel reposition" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
159print '</div>';
160
161print '</form>';
162
163// Page end
164print dol_get_fiche_end();
165
166// End of page
167llxFooter();
168$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
dolibarr_del_const($db, $name, $entity=1)
Delete a constant.
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 a WYSIWYG editor.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.