From 70530b558de3ee64b872ed0524e8b70c5e6b4422 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2019 03:10:48 +0100 Subject: [PATCH 1/2] Enable / Disable js css in modulebuilder --- htdocs/modulebuilder/index.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0bb48af3b46..3c9b23c7638 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -480,10 +480,15 @@ if ($dirins && $action == 'initcss' && !empty($module)) 'Mon module'=>$modulename, 'mon module'=>$modulename, 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':''), ); dolReplaceInFile($destfile, $arrayreplacement); + + // Update descriptor file to uncomment file + $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $arrayreplacement = array('/\/\/\s*\''.preg_quote('/'.strtolower($module).'/css/'.strtolower($module).'.css.php', '/').'\'/' => '\'/'.strtolower($module).'/css/'.strtolower($module).'.css.php\''); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } else { @@ -518,6 +523,11 @@ if ($dirins && $action == 'initjs' && !empty($module)) ); dolReplaceInFile($destfile, $arrayreplacement); + + // Update descriptor file to uncomment file + $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $arrayreplacement = array('/\/\/\s*\''.preg_quote('/'.strtolower($module).'/js/'.strtolower($module).'.js.php', '/').'\'/' => '\'/'.strtolower($module).'/js/'.strtolower($module).'.js.php\''); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); } else { @@ -635,6 +645,14 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) $result = dol_delete_file($filetodelete); if (dol_is_dir_empty($dirtodelete)) dol_delete_dir($dirtodelete); + + // Update descriptor file to comment file + if (in_array($tab, array('css', 'js'))) + { + $srcfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $arrayreplacement = array('/^\s*\''.preg_quote('/'.$relativefilename, '/').'\',*/m'=>' // \'/'.$relativefilename.'\','); + dolReplaceInFile($srcfile, $arrayreplacement, '', 0, 0, 1); + } } } @@ -1967,7 +1985,10 @@ elseif (! empty($module)) print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("LanguageFile").' : '.$dicts['langs'].'
'; + print ' '.$langs->trans("LanguageFile").' : '; + if (! is_array($dicts) || empty($dicts)) print ''.$langs->trans("NoDictionaries").''; + else print ''.$dicts['langs'].''; + print '
'; print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); From 5b5a2e98048892919937019660027488f0cac1c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 1 Nov 2019 03:25:09 +0100 Subject: [PATCH 2/2] Clean code --- htdocs/core/lib/functions.lib.php | 2 +- htdocs/modulebuilder/index.php | 8 ++++---- htdocs/theme/eldy/global.inc.php | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 4d4a20f3a5c..943afe69a1a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2997,7 +2997,7 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF * @param int $notitle 1=Disable tag title. Use it if you add js tooltip, to avoid duplicate tooltip. * @param string $alt Force alt for bind people * @param string $morecss Add more class css on img tag (For example 'myclascss'). Work only if $moreatt is empty. - * @param string $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left maring on picto, 0 = No margin left. Works for fontawesome picto only. + * @param string $marginleftonlyshort 1 = Add a short left margin on picto, 2 = Add a larger left margin on picto, 0 = No margin left. Works for fontawesome picto only. * @return string Return img tag * @see img_object(), img_picto_common() */ diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 3c9b23c7638..234746a0d83 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1641,14 +1641,14 @@ elseif (! empty($module)) $linktoenabledisable=''; if (! empty($conf->global->$const_name)) // If module is already activated { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on'); + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Activated"), 'switch_on', '', false, 0, 0, '', '', 1); $linktoenabledisable.=''; } else { - $linktoenabledisable.=''; - $linktoenabledisable.=img_picto($langs->trans("Disabled"), 'switch_off'); + $linktoenabledisable.=''; + $linktoenabledisable.=img_picto($langs->trans("Disabled"), 'switch_off', '', false, 0, 0, '', '', 1); $linktoenabledisable.="\n"; } if (! empty($conf->$modulelowercase->enabled)) diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index c3bbc92af9c..cf5c4f9703a 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -521,7 +521,8 @@ body[class*="colorblind-"] .text-success{ } .fa-toggle-on, .fa-toggle-off { font-size: 2em; } -.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; } +.websiteselectionsection .fa-toggle-on, .websiteselectionsection .fa-toggle-off, +.asetresetmodule .fa-toggle-on, .asetresetmodule .fa-toggle-off { font-size: 1.5em; vertical-align: text-bottom; } /* Themes for badges */