NEW Debug the custom CSS feature to avoid a directory search/scan at

each page load
This commit is contained in:
Laurent Destailleur 2023-02-17 15:43:50 +01:00
parent c40786df66
commit 57d26fc7da
3 changed files with 15 additions and 11 deletions

View File

@ -300,8 +300,9 @@ if ($action == 'update') {
} }
if ($mode == 'css') { if ($mode == 'css') {
$data = GETPOST('CUSTOM_CSS', 'none'); //file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data);
file_put_contents(DOL_DATA_ROOT.'/admin/customcss.css', $data); //dol_chmod(DOL_DATA_ROOT.'/admin/customcss.css');
dolibarr_set_const($db, "MAIN_IHM_CUSTOM_CSS", GETPOST('MAIN_IHM_CUSTOM_CSS', 'restricthtml'), 'chaine', 0, '', $conf->entity);
} }
$_SESSION["mainmenu"] = ""; // The menu manager may have changed $_SESSION["mainmenu"] = ""; // The menu manager may have changed
@ -310,7 +311,7 @@ if ($action == 'update') {
dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", ((int) $conf->global->MAIN_IHM_PARAMS_REV) + 1, 'chaine', 0, '', $conf->entity);
} }
header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".'&mode='.$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : '')); header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup&mode=".$mode.(GETPOSTISSET('page_y') ? '&page_y='.GETPOST('page_y', 'int') : ''));
exit; exit;
} }
@ -698,9 +699,10 @@ if ($mode == 'css') {
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td colspan="2">'; print '<td colspan="2">';
$customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css'); //$customcssValue = file_get_contents(DOL_DATA_ROOT.'/admin/customcss.css');
$customcssValue = getDolGlobalString('MAIN_IHM_CUSTOM_CSS');
$doleditor = new DolEditor('CUSTOM_CSS', $customcssValue, '', 400, 'Basic', 'In', false, true, 'ace', 80, 80, 0); $doleditor = new DolEditor('MAIN_IHM_CUSTOM_CSS', $customcssValue, '80%', 400, 'Basic', 'In', true, false, 'ace', 10, '90%');
$doleditor->Create(0, '', true, 'css', 'css'); $doleditor->Create(0, '', true, 'css', 'css');
print '</td></tr>'."\n"; print '</td></tr>'."\n";

View File

@ -1786,9 +1786,11 @@ function top_htmlhead($head, $title = '', $disablejs = 0, $disablehead = 0, $arr
} }
} }
//customcss // Custom CSS
if (getDolGlobalString('MAIN_IHM_CUSTOM_CSS')) {
// If a custom CSS was set, we add link to the custom css php file
print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/custom.css.php">'."\n"; print '<link rel="stylesheet" type="text/css" href="'.DOL_URL_ROOT.'/theme/custom.css.php">'."\n";
}
// Output standard javascript links // Output standard javascript links
if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) { if (!defined('DISABLE_JQUERY') && !$disablejs && !empty($conf->use_javascript_ajax)) {

View File

@ -30,6 +30,6 @@ if (empty($dolibarr_nocache)) {
header('Cache-Control: no-cache'); header('Cache-Control: no-cache');
} }
if (file_exists(DOL_DATA_ROOT.'/admin/customcss.css')) {
readfile(DOL_DATA_ROOT.'/admin/customcss.css'); print '// Here, the content of the common custom CSS defined into Home - Setup - Display - CSS'."\n";
} print getDolGlobalString('MAIN_IHM_CUSTOM_CSS');