From d1df3272842a50df1554460eec9cfeafc958f38d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 6 Apr 2021 18:51:43 +0200 Subject: [PATCH] Add tab for import/export profiles --- htdocs/core/lib/modulebuilder.lib.php | 9 ++++- htdocs/langs/fr_FR/modulebuilder.lang | 1 + htdocs/modulebuilder/index.php | 54 +++++++++++++++++++++++---- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 85a16ac47cf..27a4ea7a9ab 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -119,7 +119,8 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if (count($object->fields)) { foreach ($object->fields as $key => $val) { $i++; - $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."', 'label'=>'".$val['label']."',"; + $texttoinsert .= "\t\t'".$key."' => array('type'=>'".$val['type']."',"; + $texttoinsert .= " 'label'=>'".$val['label']."',"; $texttoinsert .= " 'enabled'=>'".($val['enabled'] !== '' ? $val['enabled'] : 1)."',"; $texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).","; $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).","; @@ -145,6 +146,12 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = if ($val['css']) { $texttoinsert .= " 'css'=>'".$val['css']."',"; } + if ($val['cssview']) { + $texttoinsert .= " 'cssview'=>'".$val['cssview']."',"; + } + if ($val['csslist']) { + $texttoinsert .= " 'csslist'=>'".$val['csslist']."',"; + } if ($val['help']) { $texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\","; } diff --git a/htdocs/langs/fr_FR/modulebuilder.lang b/htdocs/langs/fr_FR/modulebuilder.lang index 15d87656f4b..d2bce2082cb 100644 --- a/htdocs/langs/fr_FR/modulebuilder.lang +++ b/htdocs/langs/fr_FR/modulebuilder.lang @@ -92,6 +92,7 @@ SearchAllDesc=Le champ doit-il être utilisé pour effectuer une recherche à pa SpecDefDesc=Entrez ici toute la documentation que vous souhaitez joindre au module et qui n'a pas encore été définis dans d'autres onglets. Vous pouvez utiliser .md ou, mieux, la syntaxe enrichie .asciidoc. LanguageDefDesc=Entrez dans ces fichiers, toutes les clés et la traduction pour chaque fichier de langue. MenusDefDesc=Définissez ici les menus fournis par votre module +ImportExportProfiles=You will find here the Export or Import profiles provided by your module DictionariesDefDesc=Définissez ici les dictionnaires fournis par le module PermissionsDefDesc=Définissez ici les nouvelles permissions fournies par votre module MenusDefDescTooltip=Les menus fournis par votre module / application sont définis dans le tableau $this->menus dans le fichier descripteur de module. Vous pouvez modifier manuellement ce fichier ou utiliser l'éditeur intégré.

Remarque: une fois définis (et les modules réactivés), les menus sont également visibles dans l'éditeur de menus mis à la disposition des utilisateurs administrateurs sur %s. diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 65775a0bb36..682fa4bc330 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1245,7 +1245,8 @@ if ($dirins && $action == 'addproperty' && !empty($module) && !empty($tabobj)) { 'arrayofkeyval'=>GETPOST('proparrayofkeyval', 'restricthtml'), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}' 'visible'=>GETPOST('propvisible', 'int'), 'enabled'=>GETPOST('propenabled', 'int'), 'position'=>GETPOST('propposition', 'int'), 'notnull'=>GETPOST('propnotnull', 'int'), 'index'=>GETPOST('propindex', 'int'), 'searchall'=>GETPOST('propsearchall', 'int'), - 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha') + 'isameasure'=>GETPOST('propisameasure', 'int'), 'comment'=>GETPOST('propcomment', 'alpha'), 'help'=>GETPOST('prophelp', 'alpha'), + 'css'=>GETPOST('propcss', 'aZ09'), 'cssview'=>GETPOST('propcssview', 'aZ09'), 'csslist'=>GETPOST('propcsslist', 'aZ09') ); if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) { @@ -1827,11 +1828,6 @@ if ($module == 'initmodule') { $head2 = array(); $h = 0; - $head2[$h][0] = ''; - $head2[$h][1] = $morehtmlleft; - $head2[$h][2] = ''; - $h++; - $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("Description"); $head2[$h][2] = 'description'; @@ -1877,6 +1873,11 @@ if ($module == 'initmodule') { $head2[$h][2] = 'widgets'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=exportimport&module='.$module.($forceddirread ? '@'.$dirread : ''); + $head2[$h][1] = $langs->trans("Export").'-'.$langs->trans("Import"); + $head2[$h][2] = 'exportimport'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=css&module='.$module.($forceddirread ? '@'.$dirread : ''); $head2[$h][1] = $langs->trans("CSS"); $head2[$h][2] = 'css'; @@ -1907,7 +1908,7 @@ if ($module == 'initmodule') { $head2[$h][2] = 'buildpackage'; $h++; - print '
'; + print ''; // Note module is inside $dirread @@ -3340,6 +3341,45 @@ if ($module == 'initmodule') { } } + if ($tab == 'exportimport') { + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $exportlist = $moduleobj->export_label; + $importlist = $moduleobj->import_label; + + if ($action != 'editfile' || empty($file)) { + print ''.$langs->transnoentities('ImportExportProfiles').'
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + } else { + $fullpathoffile = dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor = new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09') ?GETPOST('format', 'aZ09') : 'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab == 'cli') { $clifiles = array(); $i = 0;