diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 5347eebd392..7102217cb8e 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -6,6 +6,7 @@ * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2021 Anthony Berton + * Copyright (C) 2023 Eric Seigne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -298,6 +299,11 @@ if ($action == 'update') { } } + if ($mode == 'css') { + $data = GETPOST('CUSTOM_CSS','none'); + file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css',$data); + } + $_SESSION["mainmenu"] = ""; // The menu manager may have changed if (GETPOST('dol_resetcache')) { @@ -314,7 +320,13 @@ if ($action == 'update') { */ $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; -llxHeader('', $langs->trans("Setup"), $wikihelp); + +llxHeader('', $langs->trans("Setup"), $wikihelp, '', 0, 0, + array( + '/includes/ace/src/ace.js', + '/includes/ace/src/ext-statusbar.js', + '/includes/ace/src/ext-language_tools.js', + ), array()); $form = new Form($db); $formother = new FormOther($db); @@ -679,8 +691,27 @@ if ($mode == 'login') { print ''; } +if ($mode == 'css') { + print '
'; + print ''; + + print ''; + print ''."\n"; + + print '
'; + + $customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css'); + + $doleditor = new DolEditor('CUSTOM_CSS', $customcssValue, '', 400, 'Basic', 'In', false, true, 'ace',80,80,0); + $doleditor->Create(0,'',true,'css','css'); + print '
'."\n"; + print '
'; + +} + + print '
'; -print ''; +print ''; print ''; print '
'; diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 23c38a6b157..04a04ee8cac 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2016 Regis Houssin * Copyright (C) 2012 J. Fernando Lagrange * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2023 Eric Seigne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -772,6 +773,11 @@ function ihm_prepare_head() $head[$h][2] = 'login'; $h++; + $head[$h][0] = DOL_URL_ROOT."/admin/ihm.php?mode=css"; + $head[$h][1] = $langs->trans("CSSPage"); + $head[$h][2] = 'css'; + $h++; + complete_head_from_modules($conf, $langs, null, $head, $h, 'ihm_admin'); complete_head_from_modules($conf, $langs, null, $head, $h, 'ihm_admin', 'remove'); diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 082bfc101e0..9f370340a01 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2372,4 +2372,6 @@ WarningModuleHasChangedLastVersionCheckParameter=Warning: the module %s has set WarningModuleHasChangedSecurityCsrfParameter=Warning: the module %s has disabled the CSRF security of your instance. This action is suspect and your installation may no more be secured. Please contact the author of the module for explanation. EMailsInGoingDesc=Incoming emails are managed by the module %s. You must enable and configure it if you need to support ingoing emails. MAIN_IMAP_USE_PHPIMAP=Use the PHP-IMAP library for IMAP instead of native PHP IMAP. This also allows the use of an OAuth2 connection for IMAP (module OAuth must also be activated). -MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) \ No newline at end of file +MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default) + +CSSPage=CSS Style diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 889a1900139..3a28077277e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -16,6 +16,7 @@ * Copyright (C) 2021 Frédéric France * Copyright (C) 2021 Alexandre Spangaro * Copyright (C) 2023 Joachim Küter + * Copyright (C) 2023 Eric Seigne * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1785,6 +1786,10 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr } } + //customcss + print ''."\n"; + + // Output standard javascript links if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { // JQuery. Must be before other includes diff --git a/htdocs/theme/custom.css.php b/htdocs/theme/custom.css.php new file mode 100644 index 00000000000..d3502782749 --- /dev/null +++ b/htdocs/theme/custom.css.php @@ -0,0 +1,35 @@ + + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +require_once __DIR__.'/../main.inc.php'; // __DIR__ allow this script to be included in custom themes +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + +// Define css type +top_httphead('text/css'); +// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access. +if (empty($dolibarr_nocache)) { + header('Cache-Control: max-age=10800, public, must-revalidate'); +} else { + header('Cache-Control: no-cache'); +} + +if(file_exists(DOL_DATA_ROOT.'/admin/customcss.css')) { + readfile(DOL_DATA_ROOT.'/admin/customcss.css'); +}