diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index b8300182b05..8d9a31cfdf7 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 0f60d76ca4f..d9ae491b654 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -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 '
'; + $pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.'| '.$trigger['picto'].' | '; - print ''.$trigger['file'].' | '; + print ''.$trigger['relpath'].' | '; print ''.$trigger['status'].' | '; print '';
$text=$trigger['info'];
@@ -698,11 +783,56 @@ elseif (! empty($module))
print ' '; } + $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 ' '. $langs->trans("PathToModulePackage") . ' : '; + if (! dol_is_file($outputfile)) print ''.$langs->trans("PackageFileNotYetGenerated").''; + else { + print ''.$outputfile.''; + print ' ('.$langs->trans("GeneratedOn").' '.dol_print_date(dol_filemtime($outputfile), 'dayhour').')'; + } + print ' '; + + print ' '; + print ''; } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 9e66b9410f6..4993f60f83c 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -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(); |