From 0d20a3b60697054df59df270da6a0d72476828bd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 May 2022 21:54:38 +0200 Subject: [PATCH] Prepare code for dic management --- htdocs/core/lib/functions.lib.php | 4 +- htdocs/langs/en_US/modulebuilder.lang | 7 +- htdocs/modulebuilder/index.php | 457 ++++++++++++++++---------- 3 files changed, 294 insertions(+), 174 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e6852cdde03..524a62306a1 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1772,7 +1772,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab $out .= '
'; if (!empty($links[$i][0])) { $titletoshow = preg_replace('/<.*$/', '', $links[$i][1]); - $out .= ''; + $out .= ''; } $out .= $links[$i][1]; if (!empty($links[$i][0])) { @@ -1820,7 +1820,7 @@ function dol_get_fiche_head($links = array(), $active = '', $title = '', $notab if (empty($tabsname)) { $tabsname = str_replace("@", "", $picto); } - $out .= '
'; + $out .= '
'; $out .= ''; // Do not use "reposition" class in the "More". $out .= '
'; $out .= $outmore; diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 416ff013219..b17ab4fdeb2 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,14 +1,17 @@ # Dolibarr language file - Source file is en_US - loan ModuleBuilderDesc=This tool must be used only by experienced users or developers. It provides utilities to build or edit your own module. Documentation for alternative manual development is here. -EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) -EnterNameOfObjectDesc=Enter name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...). The CRUD class file, but also API file, pages to list/add/edit/delete object and SQL files will be generated. +EnterNameOfModuleDesc=Enter the name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...) +EnterNameOfObjectDesc=Enter the name of the object to create with no spaces. Use uppercase to separate words (For example: MyObject, Student, Teacher...). The CRUD class file, but also API file, pages to list/add/edit/delete object and SQL files will be generated. +EnterNameOfDictionaryDesc=Enter the name of the dictionary to create with no spaces. Use uppercase to separate words (For example: MyDico...). The class file, but also the SQL file will be generated. ModuleBuilderDesc2=Path where modules are generated/edited (first directory for external modules defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s ModuleBuilderDesc4=A module is detected as 'editable' when the file %s exists in root of module directory NewModule=New module NewObjectInModulebuilder=New object +NewDictionary=New dictionary ModuleKey=Module key ObjectKey=Object key +DicKey=Dictionary key ModuleInitialized=Module initialized FilesForObjectInitialized=Files for new object '%s' initialized FilesForObjectUpdated=Files for object '%s' updated (.sql files and .class.php file) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 3feeed0afad..f4137b8b791 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -52,6 +52,7 @@ $sortorder=GETPOST('sortorder', 'alpha'); $module = GETPOST('module', 'alpha'); $tab = GETPOST('tab', 'aZ09'); $tabobj = GETPOST('tabobj', 'alpha'); +$tabdic = GETPOST('tabdic', 'alpha'); $propertykey = GETPOST('propertykey', 'alpha'); if (empty($module)) { $module = 'initmodule'; @@ -62,10 +63,14 @@ if (empty($tab)) { if (empty($tabobj)) { $tabobj = 'newobjectifnoobj'; } +if (empty($tabdic)) { + $tabdic = 'newdicifnodic'; +} $file = GETPOST('file', 'alpha'); $modulename = dol_sanitizeFileName(GETPOST('modulename', 'alpha')); $objectname = dol_sanitizeFileName(GETPOST('objectname', 'alpha')); +$dicname = dol_sanitizeFileName(GETPOST('dicname', 'alpha')); // Security check if (empty($conf->modulebuilder->enabled)) { @@ -1358,6 +1363,21 @@ if ($dirins && $action == 'initobject' && $module && $objectname) { } } +// Add a dictionary +if ($dirins && $action == 'initdic' && $module && $dicname) { + if (!$error) { + $newdicname = $dicname; + if (!preg_match('/^c_/, $newdicname')) { + $newdicname = 'c_'.$dicname; + } + + // TODO + + setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'errors'); + } +} + +// Delete a SQL table if ($dirins && ($action == 'droptable' || $action == 'droptableextrafields') && !empty($module) && !empty($tabobj)) { $objectname = $tabobj; @@ -1841,7 +1861,8 @@ $text = $langs->trans("ModuleBuilder"); print load_fiche_titre($text, '', 'title_setup'); -print ''.$langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
'; +print ''.$langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').''; +print '
'; //print $textforlistofdirs; //print '
'; @@ -1869,7 +1890,7 @@ if ($message) { } //print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
'; -$infomodulesfound = '
'.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG).'
'.$textforlistofdirs).'
'; +$infomodulesfound = '
'.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG).'
'.$textforlistofdirs).'
'; // Load module descriptor @@ -2152,7 +2173,7 @@ if ($module == 'initmodule') { print ''.$langs->trans("ModuleBuilderDesc".$tab).''; $infoonmodulepath = ''; if (realpath($dirread.'/'.$modulelowercase) != $dirread.'/'.$modulelowercase) { - $infoonmodulepath = ''.$langs->trans("RealPathOfModule").' : '.realpath($dirread.'/'.$modulelowercase).'
'; + $infoonmodulepath = ''.$langs->trans("RealPathOfModule").' : '.realpath($dirread.'/'.$modulelowercase).'
'; print ' '.$infoonmodulepath; } print '
'; @@ -2160,15 +2181,15 @@ if ($module == 'initmodule') { print ''; print ''; - print ''; - print ''; @@ -2341,7 +2362,7 @@ if ($module == 'initmodule') { if (!preg_match('/custom/', $dirread)) { // If this is not a module into custom $pathtofile = 'langs/'.$langfile['relativename']; } - print ''; @@ -2377,137 +2398,6 @@ if ($module == 'initmodule') { } } - if ($tab == 'dictionaries') { - print ''."\n"; - $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - - $dicts = $moduleobj->dictionaries; - - if ($action != 'editfile' || empty($file)) { - print ''; - $htmlhelp = $langs->trans("DictionariesDefDescTooltip", '{s1}'); - $htmlhelp = str_replace('{s1}', ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').'', $htmlhelp); - print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; - print '
'; - print '
'; - - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - if (is_array($dicts) && !empty($dicts)) { - print ' '.$langs->trans("LanguageFile").' : '; - print ''.$dicts['langs'].''; - print '
'; - } - - print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - print '
'; - print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; + print '
'.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; + print '
'.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; + print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print '
'; - - print ''; - print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'thsticky thstickygrey '); - print_liste_field_titre("Table", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("SQL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("SQLSort", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("FieldsView", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("FieldsEdit", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("FieldsInsert", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Rowid", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); - print "\n"; - - if (!empty($dicts) && is_array($dicts) && !empty($dicts['tabname']) && is_array($dicts['tabname'])) { - $i = 0; - $maxi = count($dicts['tabname']); - while ($i < $maxi) { - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - - print ''; - $i++; - } - } else { - print ''; - } - - print '
'; - print ($i + 1); - print ''; - print $dicts['tabname'][$i]; - print ''; - print $dicts['tablib'][$i]; - print ''; - print $dicts['tabsql'][$i]; - print ''; - print $dicts['tabsqlsort'][$i]; - print ''; - print $dicts['tabfield'][$i]; - print ''; - print $dicts['tabfieldvalue'][$i]; - print ''; - print $dicts['tabfieldinsert'][$i]; - print ''; - print $dicts['tabrowid'][$i]; - print ''; - print $dicts['tabcond'][$i]; - print '
'.$langs->trans("None").'
'; - print '
'; - - 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 == 'objects') { print ''."\n"; $head3 = array(); @@ -2548,10 +2438,12 @@ if ($module == 'initmodule') { } } - $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=deleteobject'; - $head3[$h][1] = $langs->trans("DangerZone"); - $head3[$h][2] = 'deleteobject'; - $h++; + if ($h > 1) { + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabobj=deleteobject'; + $head3[$h][1] = $langs->trans("DangerZone"); + $head3[$h][2] = 'deleteobject'; + $h++; + } // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. if ($tabobj == 'newobjectifnoobj') { @@ -2675,7 +2567,7 @@ if ($module == 'initmodule') { print ' '.img_picto($langs->trans("Edit"), 'edit').''; // API file print '
'; - print ' '.$langs->trans("ApiClassFile").' : '.(dol_is_file($realpathtoapi) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').''; + print ' '.$langs->trans("ApiClassFile").' : '.(dol_is_file($realpathtoapi) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').''; if (dol_is_file($realpathtoapi)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2691,7 +2583,7 @@ if ($module == 'initmodule') { } // PHPUnit print '
'; - print ' '.$langs->trans("TestClassFile").' : '.(dol_is_file($realpathtophpunit) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').''; + print ' '.$langs->trans("TestClassFile").' : '.(dol_is_file($realpathtophpunit) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').''; if (dol_is_file($realpathtophpunit)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2703,10 +2595,10 @@ if ($module == 'initmodule') { print '
'; - print ' '.$langs->trans("PageForLib").' : '.(dol_is_file($realpathtolib) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolib).(dol_is_file($realpathtolib) ? '' : '').''; + print ' '.$langs->trans("PageForLib").' : '.(dol_is_file($realpathtolib) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolib).(dol_is_file($realpathtolib) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForObjLib").' : '.(dol_is_file($realpathtoobjlib) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).(dol_is_file($realpathtoobjlib) ? '' : '').''; + print ' '.$langs->trans("PageForObjLib").' : '.(dol_is_file($realpathtoobjlib) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoobjlib).(dol_is_file($realpathtoobjlib) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; print ' '.$langs->trans("Image").' : '.(dol_is_file($realpathtopicto) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtopicto).(dol_is_file($realpathtopicto) ? '' : '').''; @@ -2714,16 +2606,16 @@ if ($module == 'initmodule') { print '
'; print '
'; - print ' '.$langs->trans("SqlFile").' : '.(dol_is_file($realpathtosql) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).(dol_is_file($realpathtosql) ? '' : '').''; + print ' '.$langs->trans("SqlFile").' : '.(dol_is_file($realpathtosql) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosql).(dol_is_file($realpathtosql) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '   '.$langs->trans("DropTableIfEmpty").''; //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKey").' : '.(dol_is_file($realpathtosqlkey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlkey).(dol_is_file($realpathtosqlkey) ? '' : '').''; + print ' '.$langs->trans("SqlFileKey").' : '.(dol_is_file($realpathtosqlkey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlkey).(dol_is_file($realpathtosqlkey) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileExtraFields").' : '.(dol_is_file($realpathtosqlextra) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').''; + print ' '.$langs->trans("SqlFileExtraFields").' : '.(dol_is_file($realpathtosqlextra) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').''; if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2735,7 +2627,7 @@ if ($module == 'initmodule') { } //print '   '.$langs->trans("RunSql").''; print '
'; - print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.(dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').''; + print ' '.$langs->trans("SqlFileKeyExtraFields").' : '.(dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').''; if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) { print ' '.img_picto($langs->trans("Edit"), 'edit').''; print ' '; @@ -2747,14 +2639,14 @@ if ($module == 'initmodule') { print '
'; print '
'; - print ' '.$langs->trans("PageForList").' : '.(dol_is_file($realpathtolist) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolist).(dol_is_file($realpathtolist) ? '' : '').''; + print ' '.$langs->trans("PageForList").' : '.(dol_is_file($realpathtolist) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtolist).(dol_is_file($realpathtolist) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; - print ' '.$langs->trans("PageForCreateEditView").' : '.(dol_is_file($realpathtocard) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocard).(dol_is_file($realpathtocard) ? '' : '').'?action=create'; + print ' '.$langs->trans("PageForCreateEditView").' : '.(dol_is_file($realpathtocard) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocard).(dol_is_file($realpathtocard) ? '' : '').'?action=create'; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; // Page contact - print ' '.$langs->trans("PageForContactTab").' : '.(dol_is_file($realpathtocontact) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocontact).(dol_is_file($realpathtocontact) ? '' : '').''; + print ' '.$langs->trans("PageForContactTab").' : '.(dol_is_file($realpathtocontact) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtocontact).(dol_is_file($realpathtocontact) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; if (dol_is_file($realpathtocontact)) { print ' '; @@ -2764,7 +2656,7 @@ if ($module == 'initmodule') { } print '
'; // Page document - print ' '.$langs->trans("PageForDocumentTab").' : '.(dol_is_file($realpathtodocument) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtodocument).(dol_is_file($realpathtodocument) ? '' : '').''; + print ' '.$langs->trans("PageForDocumentTab").' : '.(dol_is_file($realpathtodocument) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtodocument).(dol_is_file($realpathtodocument) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; if (dol_is_file($realpathtodocument)) { print ' '; @@ -2774,7 +2666,7 @@ if ($module == 'initmodule') { } print '
'; // Page notes - print ' '.$langs->trans("PageForNoteTab").' : '.(dol_is_file($realpathtonote) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtonote).(dol_is_file($realpathtonote) ? '' : '').''; + print ' '.$langs->trans("PageForNoteTab").' : '.(dol_is_file($realpathtonote) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtonote).(dol_is_file($realpathtonote) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; if (dol_is_file($realpathtonote)) { print ' '; @@ -2784,7 +2676,7 @@ if ($module == 'initmodule') { } print '
'; // Page agenda - print ' '.$langs->trans("PageForAgendaTab").' : '.(dol_is_file($realpathtoagenda) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoagenda).(dol_is_file($realpathtoagenda) ? '' : '').''; + print ' '.$langs->trans("PageForAgendaTab").' : '.(dol_is_file($realpathtoagenda) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoagenda).(dol_is_file($realpathtoagenda) ? '' : '').''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; if (dol_is_file($realpathtoagenda)) { print ' '; @@ -3109,7 +3001,7 @@ if ($module == 'initmodule') { if (preg_match('/\.md$/i', $spec['name'])) { $format = 'markdown'; } - print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; + print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; } @@ -3188,6 +3080,231 @@ if ($module == 'initmodule') { print dol_get_fiche_end(); // Level 3 } + if ($tab == 'dictionaries') { + print ''."\n"; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + + $dicts = $moduleobj->dictionaries; + + if ($action != 'editfile' || empty($file)) { + print ''; + $htmlhelp = $langs->trans("DictionariesDefDescTooltip", '{s1}'); + $htmlhelp = str_replace('{s1}', ''.$langs->trans('Setup').' - '.$langs->trans('Dictionaries').'', $htmlhelp); + print $form->textwithpicto($langs->trans("DictionariesDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'
'; + print '
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + if (is_array($dicts) && !empty($dicts)) { + print ' '.$langs->trans("LanguageFile").' : '; + print ''.$dicts['langs'].''; + print '
'; + } + + print ''."\n"; + $head3 = array(); + $h = 0; + + // Dir for module + //$dir = $dirread.'/'.$modulelowercase.'/class'; + + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabdic=newdictionary'; + $head3[$h][1] = ''.$langs->trans("NewDictionary").''; + $head3[$h][2] = 'newdictionary'; + $h++; + + // Scan for object class files + //$listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$'); + + $firstdicname = ''; + foreach ($dicts['tabname'] as $key => $dic) { + $dicname = $dic; + $diclabel = $dicts['tablib'][$key]; + + if (empty($firstdicname)) { + $firstdicname = $dicname; + } + + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabdic='.$dicname; + $head3[$h][1] = $diclabel; + $head3[$h][2] = $dicname; + $h++; + } + + if ($h > 1) { + $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '').'&tabdic=deletedictionary'; + $head3[$h][1] = $langs->trans("DangerZone"); + $head3[$h][2] = 'deletedictionary'; + $h++; + } + + // If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects. + if ($tabdic == 'newdicifnodic') { + if ($firstdicname) { + $tabdic = $firstdicname; + } else { + $tabdic = 'newdictionary'; + } + } + + print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + print ''; + print_liste_field_titre("#", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder, 'thsticky thstickygrey '); + print_liste_field_titre("Table", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("SQL", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("SQLSort", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsView", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsEdit", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("FieldsInsert", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Rowid", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder); + print "\n"; + + if (!empty($dicts) && is_array($dicts) && !empty($dicts['tabname']) && is_array($dicts['tabname'])) { + $i = 0; + $maxi = count($dicts['tabname']); + while ($i < $maxi) { + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } else { + print ''; + } + + print '
'; + print ($i + 1); + print ''; + print $dicts['tabname'][$i]; + print ''; + print $dicts['tablib'][$i]; + print ''; + print $dicts['tabsql'][$i]; + print ''; + print $dicts['tabsqlsort'][$i]; + print ''; + print $dicts['tabfield'][$i]; + print ''; + print $dicts['tabfieldvalue'][$i]; + print ''; + print $dicts['tabfieldinsert'][$i]; + print ''; + print $dicts['tabrowid'][$i]; + print ''; + print $dicts['tabcond'][$i]; + print '
'.$langs->trans("None").'
'; + print '
'; + + print '
'; + + print dol_get_fiche_head($head3, $tabdic, '', -1, ''); // Level 3 + + if ($tabdic == 'newdictionary') { + // New dic tab + print '
'; + print ''; + print ''; + print ''; + print ''; + + print ''.$langs->trans("EnterNameOfDictionaryDesc").'

'; + + print '
'; + //print '
'; + //print '
'; + print ''; + /*print '
'; + print '
'; + print '
'; + print ''.$langs->trans("or").''; + print '
'; + print '
'; + //print ' '; + print $langs->trans("InitStructureFromExistingTable"); + print ''; + print ''; + print '
'; + */ + print '
'; + } elseif ($tabdic == 'deletedictionary') { + // Delete dic tab + print '
'; + print ''; + print ''; + print ''; + print ''; + + print $langs->trans("EnterNameOfObjectToDeleteDesc").'

'; + + print ''; + print ''; + print '
'; + } else { + print $langs->trans("FeatureNotYetAvailable"); + } + + print dol_get_fiche_end(); + } 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 == 'menus') { print ''."\n"; $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; @@ -3202,7 +3319,7 @@ if ($module == 'initmodule') { print ''; print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -3344,7 +3461,7 @@ if ($module == 'initmodule') { print ''; print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -3434,7 +3551,7 @@ if ($module == 'initmodule') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; print ''; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; @@ -3443,7 +3560,7 @@ if ($module == 'initmodule') { $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; print ' '.$langs->trans("HooksFile").' : '; if (dol_is_file($dirins.'/'.$pathtohook)) { - print ''.$pathtohook.''; + print ''.$pathtohook.''; print ''; print ''.img_picto($langs->trans("Edit"), 'edit').' '; print ''.img_picto($langs->trans("Delete"), 'delete').''; @@ -3494,7 +3611,7 @@ if ($module == 'initmodule') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; print ''; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''; @@ -3504,7 +3621,7 @@ if ($module == 'initmodule') { $pathtofile = $trigger['relpath']; print ''; - print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; + print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; @@ -3557,7 +3674,7 @@ if ($module == 'initmodule') { $pathtohook = strtolower($module).'/css/'.strtolower($module).'.css.php'; print ' '.$langs->trans("CSSFile").' : '; if (dol_is_file($dirins.'/'.$pathtohook)) { - print ''.$pathtohook.''; + print ''.$pathtohook.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { @@ -3603,7 +3720,7 @@ if ($module == 'initmodule') { $pathtohook = strtolower($module).'/js/'.strtolower($module).'.js.php'; print ' '.$langs->trans("JSFile").' : '; if (dol_is_file($dirins.'/'.$pathtohook)) { - print ''.$pathtohook.''; + print ''.$pathtohook.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; } else { @@ -3652,7 +3769,7 @@ if ($module == 'initmodule') { foreach ($widgets as $widget) { $pathtofile = $widget['relpath']; - print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; + print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; @@ -3700,7 +3817,7 @@ if ($module == 'initmodule') { print ''.$langs->transnoentities('ImportExportProfiles').'
'; print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; } else { @@ -3771,7 +3888,7 @@ if ($module == 'initmodule') { foreach ($clifiles as $clifile) { $pathtofile = $clifile['relpath']; - print ' '.$langs->trans("CLIFile").' : '.$pathtofile.''; + print ' '.$langs->trans("CLIFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print ''; @@ -3818,7 +3935,7 @@ if ($module == 'initmodule') { print ''.str_replace('{s1}', ''.$langs->transnoentities('CronList').'', $langs->trans("CronJobDefDesc", '{s1}')).'
'; print '
'; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; print '
'; @@ -3947,7 +4064,7 @@ if ($module == 'initmodule') { $format = 'markdown'; } print ''; - print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; + print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; print ''.img_picto($langs->trans("Edit"), 'edit').''; print ''.img_picto($langs->trans("Delete"), 'delete').''; print '';