Merge pull request #20612 from vold-lu/add_tabs_in_module_builder
NEW: ModuileBuilder - Add tabs view in module builder
This commit is contained in:
commit
aee0c8afc6
@ -147,3 +147,6 @@ ImportExportProfiles=Import and export profiles
|
|||||||
ValidateModBuilderDesc=Set this to 1 if you want to have the method $this->validateField() of object being called to validate the content of the field during insert or upadate. Set 0 if there is no validation required.
|
ValidateModBuilderDesc=Set this to 1 if you want to have the method $this->validateField() of object being called to validate the content of the field during insert or upadate. Set 0 if there is no validation required.
|
||||||
WarningDatabaseIsNotUpdated=Warning: The database is not updated automatically, you must destroy tables and disable-enable the module to have tables recreated
|
WarningDatabaseIsNotUpdated=Warning: The database is not updated automatically, you must destroy tables and disable-enable the module to have tables recreated
|
||||||
LinkToParentMenu=Parent menu (fk_xxxxmenu)
|
LinkToParentMenu=Parent menu (fk_xxxxmenu)
|
||||||
|
ListOfTabsEntries=List of tab entries
|
||||||
|
TabsDefDesc=Define here the tabs provided by your module
|
||||||
|
TabsDefDescTooltip=The tabs provided by your module/application are defined into the array <strong>$this->tabs</strong> into the module descriptor file. You can edit manually this file or use the embedded editor.
|
||||||
|
|||||||
@ -2015,6 +2015,11 @@ if ($module == 'initmodule') {
|
|||||||
$head2[$h][2] = 'permissions';
|
$head2[$h][2] = 'permissions';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
|
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=tabs&module='.$module.($forceddirread ? '@'.$dirread : '');
|
||||||
|
$head2[$h][1] = $langs->trans("Tabs");
|
||||||
|
$head2[$h][2] = 'tabs';
|
||||||
|
$h++;
|
||||||
|
|
||||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : '');
|
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread ? '@'.$dirread : '');
|
||||||
$head2[$h][1] = $langs->trans("Menus");
|
$head2[$h][1] = $langs->trans("Menus");
|
||||||
$head2[$h][2] = 'menus';
|
$head2[$h][2] = 'menus';
|
||||||
@ -4032,6 +4037,129 @@ if ($module == 'initmodule') {
|
|||||||
print '</form>';
|
print '</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($tab == 'tabs') {
|
||||||
|
$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
|
||||||
|
|
||||||
|
$tabs = $moduleobj->tabs;
|
||||||
|
|
||||||
|
if ($action != 'editfile' || empty($file)) {
|
||||||
|
print '<span class="opacitymedium">';
|
||||||
|
$htmlhelp = $langs->trans("TabsDefDescTooltip", '{s1}');
|
||||||
|
$htmlhelp = str_replace('{s1}', '<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.'/admin/menus/index.php">'.$langs->trans('Setup').' - '.$langs->trans('Tabs').'</a>', $htmlhelp);
|
||||||
|
print $form->textwithpicto($langs->trans("TabsDefDesc"), $htmlhelp, 1, 'help', '', 0, 2, 'helpondesc').'<br>';
|
||||||
|
print '</span>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
print '<span class="fa fa-file-o"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>';
|
||||||
|
print ' <a class="editfielda paddingleft paddingright" href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.($forceddirread ? '@'.$dirread : '').'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print load_fiche_titre($langs->trans("ListOfTabsEntries"), '', '');
|
||||||
|
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
print '<input type="hidden" name="action" value="addproperty">';
|
||||||
|
print '<input type="hidden" name="tab" value="objects">';
|
||||||
|
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
|
||||||
|
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="noborder small">';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print_liste_field_titre("ObjectType", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("Tab", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("Title", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("LangFile", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("Condition", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder);
|
||||||
|
print_liste_field_titre("Path", $_SERVER["PHP_SELF"], '', "", $param, '', $sortfield, $sortorder);
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
if (count($tabs)) {
|
||||||
|
foreach ($tabs as $tab) {
|
||||||
|
$parts = explode(':', $tab['data']);
|
||||||
|
|
||||||
|
$objectType = $parts[0];
|
||||||
|
$tabName = $parts[1];
|
||||||
|
$tabTitle = isset($parts[2]) ? $parts[2] : '';
|
||||||
|
$langFile = isset($parts[3]) ? $parts[3] : '';
|
||||||
|
$condition = isset($parts[4]) ? $parts[4] : '';
|
||||||
|
$path = isset($parts[5]) ? $parts[5] : '';
|
||||||
|
|
||||||
|
// If we want to remove the tab, then the format is 'objecttype:tabname:optionalcondition'
|
||||||
|
// See: https://wiki.dolibarr.org/index.php?title=Tabs_system#To_remove_an_existing_tab
|
||||||
|
if ($tabName[0] === '-') {
|
||||||
|
$tabTitle = '';
|
||||||
|
$condition = isset($parts[2]) ? $parts[2] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print dol_escape_htmltag($parts[0]);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
if ($tabName[0] === "+") {
|
||||||
|
print '<span class="badge badge-status4 badge-status">' . dol_escape_htmltag($tabName) . '</span>';
|
||||||
|
} else {
|
||||||
|
print '<span class="badge badge-status8 badge-status">' . dol_escape_htmltag($tabName) . '</span>';
|
||||||
|
}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print dol_escape_htmltag($tabTitle);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print dol_escape_htmltag($langFile);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print dol_escape_htmltag($condition);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print dol_escape_htmltag($path);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
print '<tr><td class="opacitymedium" colspan="5">'.$langs->trans("None").'</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
} else {
|
||||||
|
$fullpathoffile = dol_buildpath($file, 0);
|
||||||
|
|
||||||
|
$content = file_get_contents($fullpathoffile);
|
||||||
|
|
||||||
|
// New module
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
|
print '<input type="hidden" name="action" value="savefile">';
|
||||||
|
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
|
||||||
|
print '<input type="hidden" name="tab" value="'.$tab.'">';
|
||||||
|
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||||
|
|
||||||
|
$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 '<br>';
|
||||||
|
print '<center>';
|
||||||
|
print '<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||||
|
print '</center>';
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($tab != 'description') {
|
if ($tab != 'description') {
|
||||||
print dol_get_fiche_end();
|
print dol_get_fiche_end();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user