Prepare modulebuilder to work on core modules
This commit is contained in:
parent
d44be341a5
commit
7f007f4182
@ -1,5 +1,5 @@
|
|||||||
# Dolibarr language file - Source file is en_US - loan
|
# Dolibarr language file - Source file is en_US - loan
|
||||||
ModuleBuilderDesc=This tool must be used by only by experienced users or developers. It gives you utilities to build or edit your own module.<br>Documentation for alternative <a href="%s" target="_blank">manual development is here</a>.
|
ModuleBuilderDesc=This tool must be used only by experienced users or developers. It provides utilities to build or edit your own module.<br>Documentation for alternative <a href="%s" target="_blank">manual development is here</a>.
|
||||||
EnterNameOfModuleDesc=Enter name of the module/application to create with no spaces. Use uppercase to separate words (For example: MyModule, EcommerceForShop, SyncWithMySystem...)
|
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.
|
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.
|
||||||
ModuleBuilderDesc2=Path where modules are generated/edited (first directory for external modules defined into %s): <strong>%s</strong>
|
ModuleBuilderDesc2=Path where modules are generated/edited (first directory for external modules defined into %s): <strong>%s</strong>
|
||||||
|
|||||||
@ -22,6 +22,9 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/modulebuilder/index.php
|
* \file htdocs/modulebuilder/index.php
|
||||||
* \brief Home page for module builder module
|
* \brief Home page for module builder module
|
||||||
|
*
|
||||||
|
* You can add parameter dirins=/home/ldestailleur/git/dolibarr/htdocs/mymodule to force generation of module
|
||||||
|
* into the dirins directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test
|
if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION', '1'); // Do not check anti SQL+XSS injection attack test
|
||||||
@ -932,14 +935,13 @@ if ($dirins && $action == 'generatedoc')
|
|||||||
{
|
{
|
||||||
$FILENAMEDOC=strtolower($module).'.html';
|
$FILENAMEDOC=strtolower($module).'.html';
|
||||||
$dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
|
$dirofmodule = dol_buildpath(strtolower($module), 0).'/doc';
|
||||||
$outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC;
|
|
||||||
|
|
||||||
$util = new Utils($db);
|
$util = new Utils($db);
|
||||||
$result = $util->generateDoc($module);
|
$result = $util->generateDoc($module);
|
||||||
|
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
setEventMessages($langs->trans("DocFileGeneratedInto", $outputfiledoc), null);
|
setEventMessages($langs->trans("DocFileGeneratedInto", $dirofmodule), null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1066,11 +1068,17 @@ $text=$langs->trans("ModuleBuilder");
|
|||||||
|
|
||||||
print load_fiche_titre($text, '', 'title_setup');
|
print load_fiche_titre($text, '', 'title_setup');
|
||||||
|
|
||||||
|
print $langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'<br>';
|
||||||
|
|
||||||
|
$dirsrootforscan=array($dirread);
|
||||||
|
if ($dirread != DOL_DOCUMENT_ROOT && ! empty($conf->global->MAIN_FEATURES_LEVEL >=2)) { $dirsrootforscan[]=DOL_DOCUMENT_ROOT; }
|
||||||
|
|
||||||
// Search modules to edit
|
// Search modules to edit
|
||||||
$listofmodules=array();
|
$listofmodules=array();
|
||||||
|
foreach($dirsrootforscan as $dirread)
|
||||||
$dirsincustom=dol_dir_list($dirread, 'directories');
|
{
|
||||||
if (is_array($dirsincustom) && count($dirsincustom) > 0) {
|
$dirsincustom=dol_dir_list($dirread, 'directories');
|
||||||
|
if (is_array($dirsincustom) && count($dirsincustom) > 0) {
|
||||||
foreach ($dirsincustom as $dircustomcursor) {
|
foreach ($dirsincustom as $dircustomcursor) {
|
||||||
$fullname = $dircustomcursor['fullname'];
|
$fullname = $dircustomcursor['fullname'];
|
||||||
if (dol_is_file($fullname . '/' . $FILEFLAG))
|
if (dol_is_file($fullname . '/' . $FILEFLAG))
|
||||||
@ -1097,25 +1105,36 @@ if (is_array($dirsincustom) && count($dirsincustom) > 0) {
|
|||||||
}
|
}
|
||||||
if ($modulenamewithcase)
|
if ($modulenamewithcase)
|
||||||
{
|
{
|
||||||
$listofmodules[$dircustomcursor['name']] = array('modulenamewithcase'=>$modulenamewithcase, 'moduledescriptorrelpath'=> $moduledescriptorrelpath, 'moduledescriptorfullpath'=>$moduledescriptorfullpath);
|
$listofmodules[$dircustomcursor['name']] = array(
|
||||||
|
'modulenamewithcase'=>$modulenamewithcase,
|
||||||
|
'moduledescriptorrelpath'=> $moduledescriptorrelpath,
|
||||||
|
'moduledescriptorfullpath'=>$moduledescriptorfullpath,
|
||||||
|
'moduledescriptorrootpath'=>$dirread
|
||||||
|
);
|
||||||
}
|
}
|
||||||
//var_dump($listofmodules);
|
//var_dump($listofmodules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($forceddirread && empty($listofmodules))
|
|
||||||
{
|
|
||||||
$listofmodules[strtolower($module)] = array('modulenamewithcase'=>$module, 'moduledescriptorrelpath'=> 'notyetimplemented', 'moduledescriptorfullpath'=> 'notyetimplemented');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show description of content
|
if ($forceddirread && empty($listofmodules)) // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir
|
||||||
$newdircustom=$dirins;
|
{
|
||||||
if (empty($newdircustom)) $newdircustom=img_warning();
|
$listofmodules[strtolower($module)] = array(
|
||||||
print $langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'<br>';
|
'modulenamewithcase'=>$module,
|
||||||
print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'<br>';
|
'moduledescriptorrelpath'=> 'notyetimplemented',
|
||||||
// If dirread was forced to somewhere else, by using URL
|
'moduledescriptorfullpath'=> 'notyetimplemented',
|
||||||
// htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product
|
'moduledescriptorrootpath'=> 'notyetimplemented',
|
||||||
if ($forceddirread) print $langs->trans("DirScanned").' : <strong>'.$dirread.'</strong><br>';
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show description of content
|
||||||
|
$newdircustom=$dirins;
|
||||||
|
if (empty($newdircustom)) $newdircustom=img_warning();
|
||||||
|
// If dirread was forced to somewhere else, by using URL
|
||||||
|
// htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product
|
||||||
|
print $langs->trans("DirScanned").' : <strong>'.$dirread.'</strong><br>';
|
||||||
|
}
|
||||||
|
//var_dump($listofmodules);
|
||||||
|
|
||||||
$message='';
|
$message='';
|
||||||
if (! $dirins)
|
if (! $dirins)
|
||||||
@ -1190,7 +1209,7 @@ $head = array();
|
|||||||
$h=0;
|
$h=0;
|
||||||
|
|
||||||
$head[$h][0] = $_SERVER["PHP_SELF"].'?module=initmodule';
|
$head[$h][0] = $_SERVER["PHP_SELF"].'?module=initmodule';
|
||||||
$head[$h][1] = $langs->trans("NewModule");
|
$head[$h][1] = $langs->trans("NewModule").'<span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
|
||||||
$head[$h][2] = 'initmodule';
|
$head[$h][2] = 'initmodule';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
@ -1218,7 +1237,9 @@ if ($module == 'initmodule')
|
|||||||
print '<input type="hidden" name="action" value="initmodule">';
|
print '<input type="hidden" name="action" value="initmodule">';
|
||||||
print '<input type="hidden" name="module" value="initmodule">';
|
print '<input type="hidden" name="module" value="initmodule">';
|
||||||
|
|
||||||
print $langs->trans("EnterNameOfModuleDesc").'<br><br>';
|
print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'<br>';
|
||||||
|
print $langs->trans("EnterNameOfModuleDesc").'<br>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">';
|
print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).'" placeholder="'.dol_escape_htmltag($langs->trans("ModuleKey")).'">';
|
||||||
|
|
||||||
@ -1243,6 +1264,8 @@ elseif (! empty($module))
|
|||||||
// Tabs for module
|
// Tabs for module
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
$dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath'];
|
||||||
|
|
||||||
$head2 = array();
|
$head2 = array();
|
||||||
$h=0;
|
$h=0;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user