NEW: add customize CSS in admin/ihm settings

This commit is contained in:
Eric Seigne 2023-02-17 00:29:14 +01:00
parent 43bcc72dcd
commit 3581f14b40
5 changed files with 82 additions and 3 deletions

View File

@ -6,6 +6,7 @@
* Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2021 Anthony Berton <bertonanthony@gmail.com>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
*
* 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&eacute;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 '</div>';
}
if ($mode == 'css') {
print '<div class="div-table-responsive-no-min">';
print '<table summary="edit" class="noborder centpercent editmode tableforfield">';
print '<tr class="liste_titre">';
print '<td colspan="2">';
$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 '</td></tr>'."\n";
print '</table>'."\n";
print '</div>';
}
print '<div class="center">';
print '<input class="button button-save reposition" type="submit" name="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button button-save reposition buttonforacesave" type="submit" name="submit" value="' . $langs->trans("Save") . '">';
print '<input class="button button-cancel reposition" type="submit" name="cancel" value="' . $langs->trans("Cancel") . '">';
print '</div>';

View File

@ -3,6 +3,7 @@
* Copyright (C) 2005-2016 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 J. Fernando Lagrange <fernando@demo-tic.org>
* Copyright (C) 2015 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
*
* 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');

View File

@ -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)
MAIN_CHECKBOX_LEFT_COLUMN=Show the column for field and line selection on the left (on the right by default)
CSSPage=CSS Style

View File

@ -16,6 +16,7 @@
* Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2021 Alexandre Spangaro <aspangaro@open-dsi.fr>
* Copyright (C) 2023 Joachim Küter <git-jk@bloxera.com>
* Copyright (C) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
*
* 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 '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/custom.css.php">'."\n";
// Output standard javascript links
if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) {
// JQuery. Must be before other includes

View File

@ -0,0 +1,35 @@
<?php
/**
* custom.css.php
*
* Copyright (c) 2023 Eric Seigne <eric.seigne@cap-rel.fr>
*
* 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 <https://www.gnu.org/licenses/>.
*/
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');
}