diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 79d4f17d8ee..34070520aa5 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -397,7 +397,8 @@ class ModeleBoxes // Can't be abtract as it is instantiated to build "empty" box $orders = array(); $i = 0; - $dirwidget=array_merge(array('/core/boxes/')); + //$dirwidget=array_merge(array('/core/boxes/'), $conf->modules_parts['widgets']); + $dirwidget=array('/core/boxes/'); // $conf->modules_parts['widgets'] is not required if (is_array($forcedirwidget)) { $dirwidget=$forcedirwidget; diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index b67780da75a..4a9fd644ecf 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -443,6 +443,17 @@ function dol_is_dir($folder) else return false; } +/** + * Return if path is empty + * + * @param string $dir Path of Directory + * @return boolean True or false + */ +function dol_is_dir_empty($dir) { + if (!is_readable($dir)) return false; + return (count(scandir($dir)) == 2); +} + /** * Return if path is a file * @@ -2654,7 +2665,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, } if (! empty($conf->productbatch->enabled)) $original_file=$conf->productbatch->multidir_output[$entity].'/'.$original_file; } - + // Wrapping for stock movements elseif ($modulepart == 'movement' || $modulepart == 'mouvement') { diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 765edad6687..a8af38d5240 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -2,7 +2,7 @@ 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. 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 alternative directory defined into %s): %s +ModuleBuilderDesc2=Path where modules are generated/edited (first directory for external modules defined into %s): %s ModuleBuilderDesc3=Generated/editable modules found: %s ModuleBuilderDesc4=A module is detected as 'editable' when the file %s exists in root of module directory NewModule=New module @@ -100,4 +100,8 @@ UseAboutPage=Disable the about page UseDocFolder=Disable the documentation folder UseSpecificReadme=Use a specific ReadMe RealPathOfModule=Real path of module -ContentCantBeEmpty=Content of file can't be empty \ No newline at end of file +ContentCantBeEmpty=Content of file can't be empty +WidgetDesc=You can generate and edit here the widgets that will be embedded with your module. +CLIDesc=You can generate here some command line scripts you want to provide with your module. +CLIFile=CLI File +NoCLIFile=No CLI files \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index b74fb5e2a59..22c83222b8b 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -108,8 +108,8 @@ if ($dirins && $action == 'initmodule' && $modulename) $destdir = $dirins.'/'.strtolower($modulename); $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename ); $result = dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement); @@ -128,31 +128,45 @@ if ($dirins && $action == 'initmodule' && $modulename) } } - if (!empty($conf->global->MODULEBUILDER_USE_ABOUT)) + if (! empty($conf->global->MODULEBUILDER_USE_ABOUT)) { dol_delete_file($destdir.'/admin/about.php'); } - if (!empty($conf->global->MODULEBUILDER_USE_DOCFOLDER)) - { - dol_delete_dir($destdir.'/doc/'); - } - // Delete some files related to object (because to previous dolCopyDir has copied everything) + // Delete dir and files that can be generated in sub tabs later if we need them (we want a minimal module first) + dol_delete_dir_recursive($destdir.'/build/doxygen'); + dol_delete_dir_recursive($destdir.'/core/modules/mailings'); + dol_delete_dir_recursive($destdir.'/core/tpl'); + dol_delete_dir_recursive($destdir.'/core/triggers'); + dol_delete_dir_recursive($destdir.'/doc'); + dol_delete_dir_recursive($destdir.'/.tx'); + dol_delete_dir_recursive($destdir.'/core/boxes'); + + dol_delete_file($destdir.'/sql/data.sql'); + dol_delete_file($destdir.'/sql/update_x.x.x-y.y.y.sql'); + dol_delete_dir($destdir.'/sql'); + + dol_delete_file($destdir.'/class/actions_'.strtolower($modulename).'.class.php'); + dol_delete_file($destdir.'/class/api_'.strtolower($modulename).'.class.php'); + dol_delete_dir($destdir.'/class'); + + dol_delete_file($destdir.'/scripts/'.strtolower($modulename).'.php'); + dol_delete_dir($destdir.'/scripts'); + + + // Delete some files related to Object (because the dolCopyDir has copied everything) dol_delete_file($destdir.'/myobject_card.php'); dol_delete_file($destdir.'/myobject_note.php'); dol_delete_file($destdir.'/myobject_document.php'); dol_delete_file($destdir.'/myobject_agenda.php'); dol_delete_file($destdir.'/myobject_list.php'); - dol_delete_file($destdir.'/lib/mymodule_myobject.lib.php'); + dol_delete_file($destdir.'/lib/'.strtolower($modulename).'_myobject.lib.php'); dol_delete_file($destdir.'/test/phpunit/MyObjectTest.php'); - dol_delete_file($destdir.'/sql/llx_mymodule_myobject.sql'); - dol_delete_file($destdir.'/sql/llx_mymodule_myobject_extrafields.sql'); - dol_delete_file($destdir.'/sql/llx_mymodule_myobject.key.sql'); - dol_delete_file($destdir.'/scripts/myobject.php'); + dol_delete_file($destdir.'/sql/llx'.strtolower($modulename).'_myobject.sql'); + dol_delete_file($destdir.'/sql/llx_'.strtolower($modulename).'_myobject_extrafields.sql'); + dol_delete_file($destdir.'/sql/llx_'.strtolower($modulename).'_myobject.key.sql'); dol_delete_file($destdir.'/img/object_myobject.png'); dol_delete_file($destdir.'/class/myobject.class.php'); - dol_delete_file($destdir.'/class/api_mymodule.class.php'); - dol_delete_file($destdir.'/doc/*example*'); } // Edit PHP files @@ -163,18 +177,17 @@ if ($dirins && $action == 'initmodule' && $modulename) { //var_dump($phpfileval['fullname']); $arrayreplacement=array( - 'mymodule'=>strtolower($modulename), - 'MyModule'=>$modulename, - 'MYMODULE'=>strtoupper($modulename), - 'My module'=>$modulename, - 'my module'=>$modulename, - 'Mon module'=>$modulename, - 'mon module'=>$modulename, - 'htdocs/modulebuilder/template'=>strtolower($modulename), - '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') ); - $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); //var_dump($result); if ($result < 0) @@ -198,6 +211,132 @@ if ($dirins && $action == 'initmodule' && $modulename) } } +if ($dirins && $action == 'inithook' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/class'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/class/actions_mymodule.class.php'; + $destfile = $dirins.'/'.strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); +} +if ($dirins && $action == 'inittrigger' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/core/triggers'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php'; + $destfile = $dirins.'/'.strtolower($module).'/core/triggers/interface_99_mod'.$module.'_'.$module.'Triggers.class.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + } +} +if ($dirins && $action == 'initwidget' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/core/boxes'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/core/boxes/mymodulewidget1.php'; + $destfile = $dirins.'/'.strtolower($module).'/core/boxes/'.strtolower($module).'widget1.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + } +} +if ($dirins && $action == 'initcli' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/scripts'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/scripts/mymodule.php'; + $destfile = $dirins.'/'.strtolower($module).'/scripts/'.strtolower($module).'.php'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + } +} +if ($dirins && $action == 'initdoc' && !empty($module)) +{ + dol_mkdir($dirins.'/'.strtolower($module).'/doc'); + $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; + $srcfile = $srcdir.'/doc/Specifications.asciidoc'; + $destfile = $dirins.'/'.strtolower($module).'/doc/Specifications.asciidoc'; + //var_dump($srcfile);var_dump($destfile); + $result = dol_copy($srcfile, $destfile, 0, 0); + + if ($result > 0) + { + $modulename = ucfirst($module); // Force first letter in uppercase + + //var_dump($phpfileval['fullname']); + $arrayreplacement=array( + 'mymodule'=>strtolower($modulename), + 'MyModule'=>$modulename, + 'MYMODULE'=>strtoupper($modulename), + 'My module'=>$modulename, + 'my module'=>$modulename, + 'Mon module'=>$modulename, + 'mon module'=>$modulename, + 'htdocs/modulebuilder/template'=>strtolower($modulename), + '---Put here your own copyright and developer email---'=>dol_print_date($now, '%Y').' '.$user->getFullName($langs).($user->email?' <'.$user->email.'>':'') + ); + + dolReplaceInFile($destfile, $arrayreplacement); + } +} + if ($dirins && $action == 'addlanguage' && !empty($module)) { $newlangcode=GETPOST('newlangcode', 'aZ09'); @@ -206,6 +345,20 @@ if ($dirins && $action == 'addlanguage' && !empty($module)) $result = dolCopyDir($srcfile, $destfile, 0, 0); } +if ($dirins && $action == 'confirm_removefile' && !empty($module)) +{ + $relativefilename=dol_sanitizePathName(GETPOST('file', 'none')); + if ($relativefilename) + { + $dirnametodelete = dirname($relativefilename); + $filetodelete = $dirins.'/'.$relativefilename; + $dirtodelete = $dirins.'/'.$dirnametodelete; + + $result = dol_delete_file($filetodelete); + if (dol_is_dir_empty($dirtodelete)) dol_delete_dir($dirtodelete); + } +} + if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', 'alpha')) { $tablename = GETPOST('initfromtablename', 'alpha'); @@ -413,17 +566,17 @@ if ($dirins && $action == 'initobject' && $module && $objectname) //var_dump($phpfileval['fullname']); $arrayreplacement=array( - 'mymodule'=>strtolower($module), - 'MyModule'=>$module, - 'MYMODULE'=>strtoupper($module), - 'My module'=>$module, - 'my module'=>$module, - 'mon module'=>$module, - 'Mon module'=>$module, - 'htdocs/modulebuilder/template/'=>strtolower($modulename), - 'myobject'=>strtolower($objectname), - 'MyObject'=>$objectname, - 'MYOBJECT'=>strtoupper($objectname) + 'mymodule'=>strtolower($module), + 'MyModule'=>$module, + 'MYMODULE'=>strtoupper($module), + 'My module'=>$module, + 'my module'=>$module, + 'mon module'=>$module, + 'Mon module'=>$module, + 'htdocs/modulebuilder/template/'=>strtolower($modulename), + 'myobject'=>strtolower($objectname), + 'MyObject'=>$objectname, + 'MYOBJECT'=>strtoupper($objectname) ); $result=dolReplaceInFile($phpfileval['fullname'], $arrayreplacement); @@ -1067,6 +1220,7 @@ if ($module == 'initmodule') print $langs->trans("EnterNameOfModuleDesc").'

'; print ''; + print ''; print ''; } @@ -1162,6 +1316,11 @@ elseif (! empty($module)) $head2[$h][2] = 'widgets'; $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cli&module='.$module.($forceddirread?'@'.$dirread:''); + $head2[$h][1] = $langs->trans("CLI"); + $head2[$h][2] = 'cli'; + $h++; + $head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module.($forceddirread?'@'.$dirread:''); $head2[$h][1] = $langs->trans("CronList"); $head2[$h][2] = 'cron'; @@ -1198,21 +1357,24 @@ elseif (! empty($module)) { dol_fiche_head($head2, $tab, '', -1, ''); // Description - level 2 - print $langs->trans("ModuleBuilderDesc".$tab).'

'; + print ''.$langs->trans("ModuleBuilderDesc".$tab).'

'; + print ''; + + print ''; - print ' '.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ''; - print ' '.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ''; - print '
'; + print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'.img_picto($langs->trans("Edit"), 'edit').''; + print '
'.$langs->trans("ReadmeFile").' : '.$pathtofilereadme.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print '
'.$langs->trans("ChangeLog").' : '.$pathtochangelog.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; print '
'; print load_fiche_titre($langs->trans("DescriptorFile")); @@ -1344,62 +1506,11 @@ elseif (! empty($module)) dol_fiche_head($head2, $tab, '', -1, ''); // Level 2 } - - if ($tab == 'specifications') - { - if ($action != 'editfile' || empty($file)) - { - print $langs->trans("SpecDefDesc").'
'; - print '
'; - - $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); - - foreach ($specs as $spec) - { - $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; - $format='asciidoc'; - if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; - print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; - } - } - else - { - // Use MD or asciidoc - - //print $langs->trans("UseAsciiDocFormat").'
'; - - $fullpathoffile=dol_buildpath($file, 0); - - $content = file_get_contents($fullpathoffile); - - // New module - print '
'; - print ''; - print ''; - print ''; - print ''; - print ''; - - $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); - print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); - print '
'; - print '
'; - print ''; - print '   '; - print ''; - print '
'; - - print '
'; - } - } - if ($tab == 'languages') { if ($action != 'editfile' || empty($file)) { - print $langs->trans("LanguageDefDesc").'
'; + print ''.$langs->trans("LanguageDefDesc").'
'; print '
'; @@ -1418,13 +1529,16 @@ elseif (! empty($module)) $langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$'); + print ''; foreach ($langfiles as $langfile) { $pathtofile = $modulelowercase.'/langs/'.$langfile['relativename']; - print ' '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ''; } + print '
'.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : '.$pathtofile.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print ''.img_picto($langs->trans("Delete"), 'delete').''; + print '
'; } else { @@ -1516,7 +1630,7 @@ elseif (! empty($module)) print ''; print ''; - print $langs->trans("EnterNameOfObjectDesc").'

'; + print ''.$langs->trans("EnterNameOfObjectDesc").'

'; print ''; print ''; @@ -1554,7 +1668,7 @@ elseif (! empty($module)) { // tabobj = module if ($action == 'deleteproperty') { - $formconfirm = $form->formconfirm( + $formconfirm = $form->formconfirm( $_SERVER["PHP_SELF"].'?propertykey='.urlencode(GETPOST('propertykey', 'alpha')).'&objectname='.urlencode($objectname).'&tab='.urlencode($tab).'&module='.urlencode($module).'&tabobj='.urlencode($tabobj), $langs->trans('Delete'), $langs->trans('ConfirmDeleteProperty', GETPOST('propertykey', 'alpha')), 'confirm_deleteproperty', '', 0, 1 ); @@ -1852,7 +1966,56 @@ elseif (! empty($module)) } else { - print ''.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').''; + if ($tab == 'specifications') + { + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("SpecDefDesc").'
'; + print '
'; + + $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); + + foreach ($specs as $spec) + { + $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; + $format='asciidoc'; + if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; + print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + } + } + else + { + // Use MD or asciidoc + + //print $langs->trans("UseAsciiDocFormat").'
'; + + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + print ''.$langs->trans('Property $field not found into the class. The class was probably not generated by modulebuilder.').''; } print ''; print ''; @@ -1915,7 +2078,7 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - print $langs->trans("MenusDefDesc", ''.$langs->trans('Menus').'').'
'; + print ''.$langs->trans("MenusDefDesc", ''.$langs->trans('Menus').'').'
'; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; @@ -2040,7 +2203,7 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - print $langs->trans("PermissionsDefDesc", ''.$langs->trans('DefaultPermissions').'').'
'; + print ''.$langs->trans("PermissionsDefDesc", ''.$langs->trans('DefaultPermissions').'').'
'; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; @@ -2161,18 +2324,32 @@ elseif (! empty($module)) { if ($action != 'editfile' || empty($file)) { - print $langs->trans("HooksDefDesc").'
'; + print ''.$langs->trans("HooksDefDesc").'
'; print '
'; + print ''; + print ''; + print ''; + } + else + { + print ''.$langs->trans("FileNotYetGenerated").''; + print ''; + } + print ''; } else { @@ -2210,24 +2387,31 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - print $langs->trans("TriggerDefDesc").'
'; + print ''.$langs->trans("TriggerDefDesc").'
'; print '
'; + print '
'; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; - print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print '
'; + print ''.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; $pathtohook = strtolower($module).'/class/actions_'.strtolower($module).'.class.php'; - print ' '.$langs->trans("HooksFile").' : '.$pathtohook.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print ' '.$langs->trans("HooksFile").' : '; + if (dol_is_file($dirins.'/'.$pathtohook)) + { + print ''.$pathtohook.''; + print '
'.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; if (! empty($triggers)) { foreach ($triggers as $trigger) { $pathtofile = $trigger['relpath']; + print ''; + print ''; + print ''; } } else { - print $langs->trans("NoTrigger"); + print ''; + print ''; } + print '
'; print ' '.$langs->trans("TriggersFile").' : '.$pathtofile.''; - print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; + print ' '.$langs->trans("NoTrigger"); + print '
'; } else { @@ -2264,21 +2448,30 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - if (! empty($widget)) + print ''.$langs->trans("WidgetDesc").'
'; + print '
'; + + print ''; + if (! empty($widgets)) { foreach ($widgets as $widget) { $pathtofile = $widget['relpath']; - print ' '.$langs->trans("WidgetFile").' : '.$pathtofile.''; + print ''; + print ''; + print ''; } } else { - print $langs->trans("NoWidget"); + print ''; } + print '
'.$langs->trans("WidgetFile").' : '.$pathtofile.''; print ' '.img_picto($langs->trans("Edit"), 'edit').''; - print '
'; + print '
'.img_picto($langs->trans("Delete"), 'delete').'
'.$langs->trans("NoWidget"); + print ''; + print '
'; } else { @@ -2307,6 +2500,92 @@ elseif (! empty($module)) } } + if ($tab == 'cli') + { + $clifiles = array(); + $i = 0; + + $dircli=array('/'.strtolower($module).'/scripts'); + + foreach($dircli as $reldir) + { + $dir=dol_buildpath($reldir, 0); + $newdir=dol_osencode($dir); + + // Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call) + if (! is_dir($newdir)) continue; + + $handle=opendir($newdir); + if (is_resource($handle)) + { + while (($tmpfile = readdir($handle))!==false) + { + if (is_readable($newdir.'/'.$file) && preg_match('/^(.+)\.php/', $tmpfile, $reg)) + { + if (preg_match('/\.back$/', $tmpfile)) continue; + + $clifiles[$i]['relpath'] = preg_replace('/^\//', '', $reldir).'/'.$tmpfile; + + $i++; + } + } + closedir($handle); + } + } + + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("CLIDesc").'
'; + print '
'; + + print ''; + if (! empty($clifiles)) + { + foreach ($clifiles as $clifile) + { + $pathtofile = $clifile['relpath']; + + print ''; + print ''; + print ''; + } + } + else + { + print ''; + } + print '
'.$langs->trans("CLIFile").' : '.$pathtofile.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'.$langs->trans("NoCLIFile"); + print ''; + print '
'; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab == 'cron') { $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; @@ -2315,7 +2594,7 @@ elseif (! empty($module)) if ($action != 'editfile' || empty($file)) { - print $langs->trans("CronJobDefDesc", ''.$langs->transnoentities('CronList').'').'
'; + print ''.$langs->trans("CronJobDefDesc", ''.$langs->transnoentities('CronList').'').'
'; print '
'; print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; @@ -2429,6 +2708,70 @@ elseif (! empty($module)) } } + if ($tab == 'specifications') + { + if ($action != 'editfile' || empty($file)) + { + print ''.$langs->trans("SpecDefDesc").'
'; + print '
'; + + $specs=dol_dir_list(dol_buildpath($modulelowercase.'/doc', 0), 'files', 1, '(\.md|\.asciidoc)$', array('\/temp\/')); + + print ''; + if (is_array($specs) && ! empty($specs)) + { + foreach ($specs as $spec) + { + $pathtofile = $modulelowercase.'/doc/'.$spec['relativename']; + $format='asciidoc'; + if (preg_match('/\.md$/i', $spec['name'])) $format='markdown'; + print ''; + print ''; + print ''; + } + } + else + { + print ''; + print ''; + } + print '
'; + print ' '.$langs->trans("SpecificationFile").' : '.$pathtofile.''; + print ''.img_picto($langs->trans("Edit"), 'edit').''.img_picto($langs->trans("Delete"), 'delete').'
'; + print ' '.$langs->trans("FileNotYetGenerated"); + print '
'; + } + else + { + // Use MD or asciidoc + + //print $langs->trans("UseAsciiDocFormat").'
'; + + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + $doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%'); + print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format', 'aZ09')?GETPOST('format', 'aZ09'):'html')); + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab == 'buildpackage') { if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP')) diff --git a/htdocs/modulebuilder/template/README.md b/htdocs/modulebuilder/template/README.md index 635e1eed5b0..f894c3ac6ae 100644 --- a/htdocs/modulebuilder/template/README.md +++ b/htdocs/modulebuilder/template/README.md @@ -87,14 +87,8 @@ Licenses ### Main code -![GPLv3 logo](img/gplv3.png) - -GPLv3 or (at your option) any later version. - -See file COPYING for more information. +GPLv3 or (at your option) any later version. See file COPYING for more information. #### Documentation -All texts and readmes. - -![GFDL logo](img/gfdl.png) +All texts and readmes are licensed under GFDL. diff --git a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php index 087f102daef..ed35331f8e3 100644 --- a/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php +++ b/htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php @@ -18,7 +18,7 @@ */ /** - * \file modulebuilder/template/core/boxes/mymodulewidget1.php + * \file htdocs/modulebuilder/template/core/boxes/mymodulewidget1.php * \ingroup mymodule * \brief Widget provided by MyModule * diff --git a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php index 0f350e83226..c58452bc0aa 100644 --- a/htdocs/modulebuilder/template/core/modules/modMyModule.class.php +++ b/htdocs/modulebuilder/template/core/modules/modMyModule.class.php @@ -91,14 +91,14 @@ class modMyModule extends DolibarrModules 'substitutions' => 1, // Set this to 1 if module has its own menus handler directory (core/menus) 'menus' => 0, - // Set this to 1 if module has its own theme directory (theme) - 'theme' => 0, // Set this to 1 if module overwrite template dir (core/tpl) 'tpl' => 0, // Set this to 1 if module has its own barcode directory (core/modules/barcode) 'barcode' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx) 'models' => 0, + // Set this to 1 if module has its own theme directory (theme) + 'theme' => 0, // Set this to relative path of css file if module has its own css file 'css' => array( '/mymodule/css/mymodule.css.php', diff --git a/htdocs/modulebuilder/template/doc/Specifications.asciidoc b/htdocs/modulebuilder/template/doc/Specifications.asciidoc index be8316c8cda..232ba7a705f 100644 --- a/htdocs/modulebuilder/template/doc/Specifications.asciidoc +++ b/htdocs/modulebuilder/template/doc/Specifications.asciidoc @@ -13,7 +13,7 @@ This document describe specifications of module MyModule [options="header",format="csv"] |=== Author, Date, Version ----Put here your own copyright and developer email---, Date YYY-MM-DD, Version 1.0 +---Put here your own copyright and developer email---, Date YYYY-MM-DD, Version 1.0 |=== diff --git a/htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc b/htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc index 72d1d5f4d82..6917d7cdd68 100644 --- a/htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc +++ b/htdocs/modulebuilder/template/doc/Specifications_full_en.example.asciidoc @@ -39,7 +39,7 @@ external documents stored in the *Appendices* directory accompanying this docume [options="header",format="csv"] |=== Author, Date, Version -John Doe, Date YYY-MM-DD, Version 1.0 +John Doe, Date YYYY-MM-DD, Version 1.0 |=== diff --git a/htdocs/modulebuilder/template/img/gfdl.png b/htdocs/modulebuilder/template/img/gfdl.png deleted file mode 100644 index f2bacfd179a..00000000000 Binary files a/htdocs/modulebuilder/template/img/gfdl.png and /dev/null differ diff --git a/htdocs/modulebuilder/template/img/gplv3.png b/htdocs/modulebuilder/template/img/gplv3.png deleted file mode 100644 index ba78d4c4941..00000000000 Binary files a/htdocs/modulebuilder/template/img/gplv3.png and /dev/null differ diff --git a/htdocs/modulebuilder/template/scripts/mymodule.php b/htdocs/modulebuilder/template/scripts/mymodule.php index f80a5f67b3e..765b1138f05 100644 --- a/htdocs/modulebuilder/template/scripts/mymodule.php +++ b/htdocs/modulebuilder/template/scripts/mymodule.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/modulebuilder/template/scripts/myobject.php + * \file htdocs/modulebuilder/template/scripts/mymodule.php * \ingroup mymodule - * \brief This file is an example for a command line script to work on MyObject + * \brief This file is an example for a command line script for module MyModule */ $sapi_type = php_sapi_name(); @@ -81,8 +81,8 @@ $db->begin(); // Examples for manipulating class MyObject -dol_include_once("/mymodule/class/myobject.class.php"); -$myobject=new MyObject($db); +//dol_include_once("/mymodule/class/myobject.class.php"); +//$myobject=new MyObject($db); // Example for inserting creating object in database /*