mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Work on modulebuilder
This commit is contained in:
@@ -454,7 +454,9 @@ elseif (! empty($module))
|
||||
$head2 = array();
|
||||
$h=0;
|
||||
|
||||
$modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive");
|
||||
$modulelowercase=strtolower($module);
|
||||
|
||||
$modulestatusinfo=img_info('').' '.$langs->trans("ModuleIsNotActive");
|
||||
if (! empty($conf->$module->enabled))
|
||||
{
|
||||
$modulestatusinfo=img_warning().' '.$langs->trans("ModuleIsLive");
|
||||
@@ -513,7 +515,12 @@ elseif (! empty($module))
|
||||
|
||||
if ($tab == 'description')
|
||||
{
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
|
||||
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong><br>';
|
||||
print '<br>';
|
||||
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
@@ -579,12 +586,9 @@ elseif (! empty($module))
|
||||
|
||||
if ($tab == 'objects')
|
||||
{
|
||||
|
||||
$head3 = array();
|
||||
$h=0;
|
||||
|
||||
$modulelowercase=strtolower($module);
|
||||
|
||||
// Dir for module
|
||||
$dir = $dirins.'/'.$modulelowercase.'/class';
|
||||
|
||||
@@ -621,10 +625,92 @@ elseif (! empty($module))
|
||||
print '<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans("Create")).'"'.($dirins?'':' disabled="disabled"').'>';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
if ($tabobj == 'fields')
|
||||
else
|
||||
{
|
||||
print $langs->trans("FeatureNotYetAvailable").'<br><br>';
|
||||
try {
|
||||
$pathtoclass = strtolower($module).'/class/'.strtolower($tabobj).'.class.php';
|
||||
$pathtoapi = strtolower($module).'/class/api_'.strtolower($tabobj).'.class.php';
|
||||
$pathtolist = strtolower($module).'/'.strtolower($tabobj).'_list.class.php';
|
||||
$pathtocard = strtolower($module).'/'.strtolower($tabobj).'_card.class.php';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("ClassFile").' : <strong>'.$pathtoclass.'</strong><br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("ApiClassFile").' : <strong>'.$pathtoapi.'</strong><br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForList").' : <strong>'.$pathtolist.'</strong><br>';
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("PageForCreateEditView").' : <strong>'.$pathtocard.'</strong><br>';
|
||||
|
||||
$result = dol_include_once($pathtoclass);
|
||||
$tmpobjet = new $tabobj($db);
|
||||
|
||||
$reflector = new ReflectionClass($tabobj);
|
||||
$properties = $reflector->getProperties();
|
||||
$propdefault = $reflector->getDefaultProperties();
|
||||
|
||||
print load_fiche_titre($langs->trans("Properties"), '', '');
|
||||
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="initobject">';
|
||||
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 '<table class="noborder">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Property").'</td>';
|
||||
print '<td>'.$langs->trans("Description").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td>'.$langs->trans("DefaultValue").'</td>';
|
||||
print '<td></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
print '<td><input class="text" name="propname" value=""></td>';
|
||||
print '<td><input class="text" name="propname" value=""></td>';
|
||||
print '<td><input class="text" name="propname" value=""></td>';
|
||||
print '<td><input class="text" name="propname" value=""></td>';
|
||||
print '<td align="center">';
|
||||
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>';
|
||||
foreach($properties as $propkey => $propval)
|
||||
{
|
||||
if ($propval->class == $tabobj)
|
||||
{
|
||||
$propname=$propval->getName();
|
||||
|
||||
// Discard generic properties
|
||||
if (in_array($propname, array('element', 'table_element', 'table_element_line', 'class_element_line', 'ismultientitymanaged'))) continue;
|
||||
|
||||
// Keep or not lines
|
||||
if (in_array($propname, array('fk_element', 'lines'))) continue;
|
||||
|
||||
|
||||
print '<tr class="oddeven"><td>';
|
||||
print $propname;
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
print $propdefault[$propname];
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
print $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -666,10 +752,9 @@ elseif (! empty($module))
|
||||
$var=True;
|
||||
foreach ($triggers as $trigger)
|
||||
{
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td valign="top" width="14" align="center">'.$trigger['picto'].'</td>';
|
||||
print '<td class="tdtop">'.$trigger['file'].'</td>';
|
||||
print '<td class="tdtop">'.$trigger['relpath'].'</td>';
|
||||
print '<td valign="top" align="center">'.$trigger['status'].'</td>';
|
||||
print '<td class="tdtop">';
|
||||
$text=$trigger['info'];
|
||||
@@ -698,11 +783,56 @@ elseif (! empty($module))
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
$modulelowercase=strtolower($module);
|
||||
|
||||
// Zip file to build
|
||||
$FILENAMEZIP='';
|
||||
|
||||
// Load module
|
||||
dol_include_once($modulelowercase.'/core/modules/mod'.$module.'.class.php');
|
||||
$class='mod'.$module;
|
||||
|
||||
if (class_exists($class))
|
||||
{
|
||||
try {
|
||||
$moduleobj = new $class($db);
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($e->getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$langs->load("errors");
|
||||
dol_print_error($langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module));
|
||||
exit;
|
||||
}
|
||||
|
||||
$arrayversion=explode('.',$moduleobj->version,3);
|
||||
if (count($arrayversion))
|
||||
{
|
||||
$FILENAMEZIP="module_".$modulelowercase.'-'.$arrayversion[0].'.'.$arrayversion[1].($arrayversion[2]?".".$arrayversion[2]:"").".zip";
|
||||
$outputfile = $conf->admin->dir_temp.'/'.$FILENAMEZIP;
|
||||
}
|
||||
|
||||
print '<span class="fa fa-file"></span> '. $langs->trans("PathToModulePackage") . ' : ';
|
||||
if (! dol_is_file($outputfile)) print '<strong>'.$langs->trans("PackageFileNotYetGenerated").'</strong>';
|
||||
else {
|
||||
print '<strong>'.$outputfile.'</strong>';
|
||||
print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')';
|
||||
}
|
||||
print '</strong><br>';
|
||||
|
||||
print '<br><br>';
|
||||
|
||||
print '<form name="generatepackage">';
|
||||
print '<input type="hidden" name="action" value="generatepackage">';
|
||||
print '<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).'">';
|
||||
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Generate").'">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("BuildPackage").'">';
|
||||
print '</form>';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user