Work on module builder
This commit is contained in:
parent
1371af5f66
commit
c26d24e97d
24
.tx/config
24
.tx/config
@ -224,6 +224,18 @@ source_file = htdocs/langs/en_US/members.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.members]
|
||||
file_filter = htdocs/langs/<lang>/modulebuilder.lang
|
||||
source_file = htdocs/langs/en_US/modulebuilder.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.members]
|
||||
file_filter = htdocs/langs/<lang>/multicurrency.lang
|
||||
source_file = htdocs/langs/en_US/multicurrency.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.oauth]
|
||||
file_filter = htdocs/langs/<lang>/oauth.lang
|
||||
source_file = htdocs/langs/en_US/oauth.lang
|
||||
@ -350,18 +362,18 @@ source_file = htdocs/langs/en_US/users.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.withdrawals]
|
||||
file_filter = htdocs/langs/<lang>/withdrawals.lang
|
||||
source_file = htdocs/langs/en_US/withdrawals.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.website]
|
||||
file_filter = htdocs/langs/<lang>/website.lang
|
||||
source_file = htdocs/langs/en_US/website.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.withdrawals]
|
||||
file_filter = htdocs/langs/<lang>/withdrawals.lang
|
||||
source_file = htdocs/langs/en_US/withdrawals.lang
|
||||
source_lang = en_US
|
||||
type = MOZILLAPROPERTIES
|
||||
|
||||
[dolibarr.workflow]
|
||||
file_filter = htdocs/langs/<lang>/workflow.lang
|
||||
source_file = htdocs/langs/en_US/workflow.lang
|
||||
|
||||
@ -165,6 +165,7 @@ ErrorGlobalVariableUpdater5=No global variable selected
|
||||
ErrorFieldMustBeANumeric=Field <b>%s</b> must be a numeric value
|
||||
ErrorMandatoryParametersNotProvided=Mandatory parameter(s) not provided
|
||||
ErrorOppStatusRequiredIfAmount=You set an estimated amount for this opportunity/lead. So you must also enter its status
|
||||
ErrorFailedToLoadModuleDescriptorForXXX=Failed to load module descriptor class for %s
|
||||
ErrorBadDefinitionOfMenuArrayInModuleDescriptor=Bad Definition Of Menu Array In Module Descriptor (bad value for key fk_menu)
|
||||
ErrorSavingChanges=An error has ocurred when saving the changes
|
||||
ErrorWarehouseRequiredIntoShipmentLine=Warehouse is required on the line to ship
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
# Dolibarr language file - Source file is en_US - loan
|
||||
ModuleBuilderDesc=This tools give you utilites to build your own module.
|
||||
ModuleBuilderDesc2=Path were modules are generated (first alternative directory defined into %s): <strong>%s</strong>.
|
||||
They are detected when the file %s exists in root of module directory.
|
||||
ModuleBuilderDesc=This tools give you utilites to build or edit your own module.
|
||||
ModuleBuilderDesc2=Path were modules are generated/edited (first alternative directory defined into %s): <strong>%s</strong>.
|
||||
ModuleBuilderDesc3=Modules found: <strong>%s</strong> (they are detected as editable when the file <strong>%s</strong> exists in root of module directory).
|
||||
NewModule=New module
|
||||
ModuleKey=Key for new module
|
||||
|
||||
|
||||
|
||||
@ -31,6 +31,11 @@ $langs->load("other");
|
||||
|
||||
$action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$module=GETPOST('module');
|
||||
$tab=GETPOST('tab');
|
||||
if (empty($module)) $module='initmodule';
|
||||
if (empty($tab)) $tab='description';
|
||||
|
||||
|
||||
// Security check
|
||||
if (! $user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE)) accessforbidden('ModuleBuilderNotAllowed');
|
||||
@ -41,6 +46,7 @@ $modulename=dol_sanitizeFileName(GETPOST('modulename','alpha'));
|
||||
$tmp=explode(',', $dolibarr_main_document_root_alt);
|
||||
$dircustom = $tmp[0];
|
||||
|
||||
$FILEFLAG='modulebuilder.txt';
|
||||
|
||||
|
||||
/*
|
||||
@ -54,8 +60,6 @@ if ($dircustom && $action == 'initmodule' && $modulename)
|
||||
$result = dolCopyDir($srcfile, $destfile, 0, 0);
|
||||
//dol_mkdir($destfile);
|
||||
|
||||
fopen($destfile, $mode)
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
setEventMessages('ModuleInitialized', null);
|
||||
@ -71,9 +75,6 @@ if ($dircustom && $action == 'initmodule' && $modulename)
|
||||
* View
|
||||
*/
|
||||
|
||||
$socstatic=new Societe($db);
|
||||
|
||||
|
||||
llxHeader("",$langs->trans("ModuleBuilder"),"");
|
||||
|
||||
|
||||
@ -81,23 +82,6 @@ $text=$langs->trans("ModuleBuilder");
|
||||
|
||||
print load_fiche_titre($text, '', 'title_setup');
|
||||
|
||||
// Show description of content
|
||||
print $langs->trans("ModuleBuilderDesc").'<br>';
|
||||
print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $dircustom).'<br>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
// New module
|
||||
print '<div class="modulebuilderbox">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="initmodule">';
|
||||
print '<input type="text" name="modulename" value="" placeholder="'.dol_escape_htmltag($langs->trans("ModuleName")).'">';
|
||||
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("CreateNewModule")).'">';
|
||||
print '</form>';
|
||||
print '<div>';
|
||||
|
||||
|
||||
$listofmodules=array();
|
||||
/*
|
||||
if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder
|
||||
@ -107,16 +91,16 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En
|
||||
{
|
||||
foreach ($dolibarr_main_document_root_alt as $diralt)
|
||||
{*/
|
||||
$dirsincustom=dol_dir_list($dircustom);
|
||||
$dirsincustom=dol_dir_list($dircustom, 'directories');
|
||||
|
||||
if (is_array($dirsincustom) && count($dirsincustom) > 0)
|
||||
{
|
||||
foreach ($dirsincustom as $dircustom)
|
||||
foreach ($dirsincustom as $dircustomcursor)
|
||||
{
|
||||
$fullname = $dircustom['fullname'];
|
||||
if (dol_is_file($fullname.'/modulebuilder.txt'))
|
||||
$fullname = $dircustomcursor['fullname'];
|
||||
if (dol_is_file($fullname.'/'.$FILEFLAG))
|
||||
{
|
||||
$listofmodules[$module]=$fullname;
|
||||
$listofmodules[$dircustomcursor['name']]=$fullname;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,11 +111,124 @@ if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // En
|
||||
$newmenu->add('', 'NoGeneratedModuleFound', 0, 0);
|
||||
}*/
|
||||
|
||||
foreach($listofmodules as $modules => $fullname)
|
||||
{
|
||||
print '<div class="modulebuilderbox>'.$module.'</div>';
|
||||
}
|
||||
|
||||
// Show description of content
|
||||
print $langs->trans("ModuleBuilderDesc").'<br>';
|
||||
print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $dircustom).'<br>';
|
||||
print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<br>';
|
||||
|
||||
$head = array();
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = $_SERVER["PHP_SELF"].'?module=initmodule';
|
||||
$head[$h][1] = $langs->trans("NewModule");
|
||||
$head[$h][2] = 'initmodule';
|
||||
$h++;
|
||||
|
||||
foreach($listofmodules as $tmpmodule => $fullname)
|
||||
{
|
||||
$head[$h][0] = $_SERVER["PHP_SELF"].'?module='.$tmpmodule;
|
||||
$head[$h][1] = $tmpmodule;
|
||||
$head[$h][2] = $tmpmodule;
|
||||
$h++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
dol_fiche_head($head, $module, $langs->trans("Modules"), -1, 'generic');
|
||||
|
||||
if ($module == 'initmodule')
|
||||
{
|
||||
// New module
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="initmodule">';
|
||||
print '<input type="hidden" name="module" value="initmodule">';
|
||||
print '<input type="text" name="modulename" value="" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">';
|
||||
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'">';
|
||||
print '</form>';
|
||||
}
|
||||
elseif (! empty($module))
|
||||
{
|
||||
$error=0;
|
||||
|
||||
// Load module
|
||||
dol_include_once($module.'/core/modules/mod'.ucfirst($module).'.class.php');
|
||||
$class='mod'.ucfirst($module);
|
||||
if (class_exists($class))
|
||||
{
|
||||
try {
|
||||
$moduleobj = new $class($db);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$error++;
|
||||
print $e->getMessage();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module);
|
||||
}
|
||||
|
||||
// Button to delete module
|
||||
|
||||
|
||||
// Tabs for module
|
||||
if (! $error)
|
||||
{
|
||||
$head2 = array();
|
||||
$h=0;
|
||||
|
||||
foreach($listofmodules as $tmpmodule => $fullname)
|
||||
{
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description';
|
||||
$head2[$h][1] = $langs->trans("Description");
|
||||
$head2[$h][2] = 'description';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects';
|
||||
$head2[$h][1] = $langs->trans("Objects");
|
||||
$head2[$h][2] = 'objects';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab='.$tmpmodule;
|
||||
$head2[$h][1] = $langs->trans("Menus");
|
||||
$head2[$h][2] = 'menus';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab='.$tmpmodule;
|
||||
$head2[$h][1] = $langs->trans("Permissions");
|
||||
$head2[$h][2] = 'permissions';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab='.$tmpmodule;
|
||||
$head2[$h][1] = $langs->trans("Triggers");
|
||||
$head2[$h][2] = 'triggers';
|
||||
$h++;
|
||||
}
|
||||
|
||||
dol_fiche_head($head2, $tab, '', -1, '');
|
||||
|
||||
print $moduleobj->getDescLong();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dol_fiche_end();
|
||||
}
|
||||
}
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user