mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Work on modulebuilder
This commit is contained in:
parent
a6b4b15e07
commit
69b26dcb4e
|
|
@ -17,7 +17,7 @@ ModuleBuilderDescpermissions=This tab is dedicated to define the new permissions
|
|||
ModuleBuilderDesctriggers=This is the view of triggers provided by your module. To include code executed when a triggered business event is launched, just edit this file with your IDE.
|
||||
ModuleBuilderDeschooks=This tab is dedicated to hooks.
|
||||
ModuleBuilderDescwidgets=This tab is dedicated to manage/build widgets.
|
||||
ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to get your module package file.
|
||||
ModuleBuilderDescbuildpackage=You can generate here a "ready to distribute" package file (a normalized .zip file) of your module. Just click on button to build the module package file.
|
||||
ModuleBuilderDescdangerzone=You can delete your module. WARNING: All files of module will be definetly lost !
|
||||
DangerZone=Danger zone
|
||||
BuildPackage=Build package
|
||||
|
|
@ -25,4 +25,10 @@ ModuleIsNotActive=This module was not activated yet (go into Home-Setup-Module t
|
|||
ModuleIsLive=This module has been activated. Any change on it may break a current active feature.
|
||||
DescriptionLong=Long description
|
||||
EditorName=Name of editor
|
||||
EditorUrl=URL of editor
|
||||
EditorUrl=URL of editor
|
||||
DescriptorFile=Descriptor file of module
|
||||
ClassFile=File for PHP class
|
||||
ApiClassFile=File for PHP API class
|
||||
PageForList=PHP page for list of record
|
||||
PageForCreateEditView=PHP page to create/edit/view a record
|
||||
PathToModulePackage=Path to zip of module/application package
|
||||
|
|
@ -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>';
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
/**
|
||||
* \file htdocs/modulebuilder/template/class/myobject.class.php
|
||||
* \ingroup mymodule othermodule1 othermodule2
|
||||
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
|
||||
* \ingroup mymodule
|
||||
* \brief This file is a CRUD class file for MyObject (Create/Read/Update/Delete)
|
||||
*/
|
||||
|
||||
// Put here all includes required by your class file
|
||||
|
|
@ -31,24 +31,22 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
|
|||
//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
|
||||
|
||||
/**
|
||||
* Class MyObject
|
||||
*
|
||||
* Put here description of your class.
|
||||
* Class for MyObject
|
||||
*/
|
||||
class MyObject extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string Id to identify managed object
|
||||
*/
|
||||
public $element = 'mymoduleobject';
|
||||
public $element = 'myobject';
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'mymoduleobject';
|
||||
public $table_element = 'myobject';
|
||||
/**
|
||||
* @var array Array with all fields and their property
|
||||
*/
|
||||
public $picto = 'generic';
|
||||
public $picto = 'myobject';
|
||||
/**
|
||||
* @var array Array with all fields and their property
|
||||
*/
|
||||
|
|
@ -67,12 +65,12 @@ class MyObject extends CommonObject
|
|||
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
public $table_element_line = 'mymoduleobjectdet';
|
||||
public $class_element_line = 'MyModuleObjectline';
|
||||
public $fk_element = 'fk_mymoduleobject';
|
||||
public $table_element_line = 'myobjectdet';
|
||||
public $class_element_line = 'MyObjectline';
|
||||
public $fk_element = 'fk_myobject';
|
||||
|
||||
/**
|
||||
* @var MyModuleObjectLine[] Lines
|
||||
* @var MyObjectLine[] Lines
|
||||
*/
|
||||
public $lines = array();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user