diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 06a9b4037d7..229db385916 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -13,6 +13,9 @@
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
';
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.'
';
$message='';
if (! $dirins)
@@ -770,9 +793,9 @@ if (! empty($module) && $module != 'initmodule' && $module != 'deletemodule')
}
else
{
- $error++;
+ if (empty($forceddirread)) $error++;
$langs->load("errors");
- print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module);
+ print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
';
}
}
@@ -833,7 +856,7 @@ elseif ($module == 'deletemodule')
}
elseif (! empty($module))
{
- // Tabs for module
+ // Tabs for module
if (! $error)
{
$head2 = array();
@@ -868,52 +891,52 @@ elseif (! empty($module))
$modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive");
}
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=description&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Description");
$head2[$h][2] = 'description';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=specifications&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Specifications");
$head2[$h][2] = 'specifications';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Objects");
$head2[$h][2] = 'objects';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=menus&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Menus");
$head2[$h][2] = 'menus';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=permissions&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Permissions");
$head2[$h][2] = 'permissions';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=hooks&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Hooks");
$head2[$h][2] = 'hooks';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=triggers&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Triggers");
$head2[$h][2] = 'triggers';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=widgets&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("Widgets");
$head2[$h][2] = 'widgets';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("CronList");
$head2[$h][2] = 'cron';
$h++;
- $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module;
+ $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module.($forceddirread?'@'.$dirread:'');
$head2[$h][1] = $langs->trans("BuildPackage");
$head2[$h][2] = 'buildpackage';
$h++;
@@ -1121,27 +1144,36 @@ elseif (! empty($module))
$h=0;
// Dir for module
- $dir = $dirins.'/'.$modulelowercase.'/class';
+ $dir = $dirread.'/'.$modulelowercase.'/class';
- $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=newobject';
+ $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj=newobject';
$head3[$h][1] = $langs->trans("NewObject");
$head3[$h][2] = 'newobject';
$h++;
- $listofobject = dol_dir_list($dir, 'files', 0, '\.txt$');
+ // Scan for object class files
+ $listofobject = dol_dir_list($dir, 'files', 0, '\.class\.php$');
+
$firstobjectname='';
foreach($listofobject as $fileobj)
{
- $objectname = preg_replace('/\.txt$/', '', $fileobj['name']);
- if (empty($firstobjectname)) $firstobjectname = $objectname;
+ if (preg_match('/^api_/',$fileobj['name'])) continue;
- $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj='.$objectname;
+ $tmpcontent=file_get_contents($fileobj['fullname']);
+ if (preg_match('/class\s+([^\s]*)\s+extends\s+CommonObject/ims',$tmpcontent,$reg))
+ {
+ //$objectname = preg_replace('/\.txt$/', '', $fileobj['name']);
+ $objectname = $reg[1];
+ if (empty($firstobjectname)) $firstobjectname = $objectname;
+ }
+
+ $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'').'&tabobj='.$objectname;
$head3[$h][1] = $objectname;
$head3[$h][2] = $objectname;
$h++;
}
- $head3[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.'&tabobj=deleteobject';
+ $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++;
@@ -1157,7 +1189,7 @@ elseif (! empty($module))
if ($tabobj == 'newobject')
{
- // New module
+ // New object tab
print '