diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 329c4921ca3..a43234e82db 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -1,5 +1,5 @@ # 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.
Documentation for alternative manual development is here. +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. ModuleBuilderDesc2=Path where modules are generated/edited (first directory for external modules defined into %s): %s diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b5559534a3b..414ba60679e 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -22,6 +22,9 @@ /** * \file htdocs/modulebuilder/index.php * \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 @@ -932,14 +935,13 @@ if ($dirins && $action == 'generatedoc') { $FILENAMEDOC=strtolower($module).'.html'; $dirofmodule = dol_buildpath(strtolower($module), 0).'/doc'; - $outputfiledoc = $dirofmodule.'/'.$FILENAMEDOC; $util = new Utils($db); $result = $util->generateDoc($module); if ($result > 0) { - setEventMessages($langs->trans("DocFileGeneratedInto", $outputfiledoc), null); + setEventMessages($langs->trans("DocFileGeneratedInto", $dirofmodule), null); } else { @@ -1066,56 +1068,73 @@ $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').'
'; + +$dirsrootforscan=array($dirread); +if ($dirread != DOL_DOCUMENT_ROOT && ! empty($conf->global->MAIN_FEATURES_LEVEL >=2)) { $dirsrootforscan[]=DOL_DOCUMENT_ROOT; } + // Search modules to edit $listofmodules=array(); - -$dirsincustom=dol_dir_list($dirread, 'directories'); -if (is_array($dirsincustom) && count($dirsincustom) > 0) { - foreach ($dirsincustom as $dircustomcursor) { - $fullname = $dircustomcursor['fullname']; - if (dol_is_file($fullname . '/' . $FILEFLAG)) - { - // Get real name of module (MyModule instead of mymodule) - $dirtoscanrel = basename($fullname).'/core/modules/'; - - $descriptorfiles = dol_dir_list(dirname($fullname).'/'.$dirtoscanrel, 'files', 0, 'mod.*\.class\.php$'); - if (empty($descriptorfiles)) // If descriptor not found into module dir, we look into main module dir. - { - $dirtoscanrel = 'core/modules/'; - $descriptorfiles = dol_dir_list($fullname.'/../'.$dirtoscanrel, 'files', 0, 'mod'.strtoupper(basename($fullname)).'\.class\.php$'); - } - $modulenamewithcase = ''; - $moduledescriptorrelpath = ''; - $moduledescriptorfullpath = ''; - - foreach ($descriptorfiles as $descriptorcursor) { - $modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']); - $modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase); - $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor['name']; - $moduledescriptorfullpath = $descriptorcursor['fullname']; - //var_dump($descriptorcursor); - } - if ($modulenamewithcase) - { - $listofmodules[$dircustomcursor['name']] = array('modulenamewithcase'=>$modulenamewithcase, 'moduledescriptorrelpath'=> $moduledescriptorrelpath, 'moduledescriptorfullpath'=>$moduledescriptorfullpath); - } - //var_dump($listofmodules); - } - } -} -if ($forceddirread && empty($listofmodules)) +foreach($dirsrootforscan as $dirread) { - $listofmodules[strtolower($module)] = array('modulenamewithcase'=>$module, 'moduledescriptorrelpath'=> 'notyetimplemented', 'moduledescriptorfullpath'=> 'notyetimplemented'); -} + $dirsincustom=dol_dir_list($dirread, 'directories'); + if (is_array($dirsincustom) && count($dirsincustom) > 0) { + foreach ($dirsincustom as $dircustomcursor) { + $fullname = $dircustomcursor['fullname']; + if (dol_is_file($fullname . '/' . $FILEFLAG)) + { + // Get real name of module (MyModule instead of mymodule) + $dirtoscanrel = basename($fullname).'/core/modules/'; -// Show description of content -$newdircustom=$dirins; -if (empty($newdircustom)) $newdircustom=img_warning(); -print $langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
'; -print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'
'; -// If dirread was forced to somewhere else, by using URL -// htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product -if ($forceddirread) print $langs->trans("DirScanned").' : '.$dirread.'
'; + $descriptorfiles = dol_dir_list(dirname($fullname).'/'.$dirtoscanrel, 'files', 0, 'mod.*\.class\.php$'); + if (empty($descriptorfiles)) // If descriptor not found into module dir, we look into main module dir. + { + $dirtoscanrel = 'core/modules/'; + $descriptorfiles = dol_dir_list($fullname.'/../'.$dirtoscanrel, 'files', 0, 'mod'.strtoupper(basename($fullname)).'\.class\.php$'); + } + $modulenamewithcase = ''; + $moduledescriptorrelpath = ''; + $moduledescriptorfullpath = ''; + + foreach ($descriptorfiles as $descriptorcursor) { + $modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']); + $modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase); + $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor['name']; + $moduledescriptorfullpath = $descriptorcursor['fullname']; + //var_dump($descriptorcursor); + } + if ($modulenamewithcase) + { + $listofmodules[$dircustomcursor['name']] = array( + 'modulenamewithcase'=>$modulenamewithcase, + 'moduledescriptorrelpath'=> $moduledescriptorrelpath, + 'moduledescriptorfullpath'=>$moduledescriptorfullpath, + 'moduledescriptorrootpath'=>$dirread + ); + } + //var_dump($listofmodules); + } + } + } + + if ($forceddirread && empty($listofmodules)) // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir + { + $listofmodules[strtolower($module)] = array( + 'modulenamewithcase'=>$module, + 'moduledescriptorrelpath'=> 'notyetimplemented', + 'moduledescriptorfullpath'=> 'notyetimplemented', + 'moduledescriptorrootpath'=> 'notyetimplemented', + ); + } + + // 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").' : '.$dirread.'
'; +} +//var_dump($listofmodules); $message=''; if (! $dirins) @@ -1190,7 +1209,7 @@ $head = array(); $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].'?module=initmodule'; -$head[$h][1] = $langs->trans("NewModule"); +$head[$h][1] = $langs->trans("NewModule").''; $head[$h][2] = 'initmodule'; $h++; @@ -1218,7 +1237,9 @@ if ($module == 'initmodule') print ''; print ''; - print $langs->trans("EnterNameOfModuleDesc").'

'; + print $langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'
'; + print $langs->trans("EnterNameOfModuleDesc").'
'; + print '
'; print ''; @@ -1243,6 +1264,8 @@ elseif (! empty($module)) // Tabs for module if (! $error) { + $dirread = $listofmodules[strtolower($module)]['moduledescriptorrootpath']; + $head2 = array(); $h=0;