Complete module template
This commit is contained in:
parent
c29d78bd0e
commit
99a27162fb
@ -40,6 +40,7 @@ PathToModuleDocumentation=Path to file of module/application documentation
|
||||
SpaceOrSpecialCharAreNotAllowed=Spaces or special characters are not allowed.
|
||||
FileNotYetGenerated=File not yet generated
|
||||
SpecificationFile=File with business rules
|
||||
LanguageFile=File for language
|
||||
ConfirmDeleteProperty=Are you sure you want to delete the property <strong>%s</strong> ? This will change code in PHP class but also remove column from table definition of object.
|
||||
NotNull=Not NULL
|
||||
SearchAll=Used for 'search all'
|
||||
|
||||
@ -146,7 +146,10 @@ if ($dirins && $action == 'initmodule' && $modulename)
|
||||
'MyModule'=>$modulename,
|
||||
'MYMODULE'=>strtoupper($modulename),
|
||||
'My module'=>$modulename,
|
||||
'htdocs/modulebuilder/template/'=>strtolower($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.'>':'')
|
||||
);
|
||||
|
||||
@ -293,7 +296,10 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
|
||||
'MyModule'=>$module,
|
||||
'MYMODULE'=>strtoupper($module),
|
||||
'My module'=>$module,
|
||||
'htdocs/modulebuilder/template/'=>strtolower($modulename),
|
||||
'my module'=>$module,
|
||||
'mon module'=>$module,
|
||||
'Mon module'=>$module,
|
||||
'htdocs/modulebuilder/template/'=>strtolower($modulename),
|
||||
'myobject'=>strtolower($objectname),
|
||||
'MyObject'=>$objectname
|
||||
);
|
||||
@ -908,6 +914,11 @@ elseif (! empty($module))
|
||||
$head2[$h][2] = 'specifications';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=languages&module='.$module.($forceddirread?'@'.$dirread:'');
|
||||
$head2[$h][1] = $langs->trans("Languages");
|
||||
$head2[$h][2] = 'languages';
|
||||
$h++;
|
||||
|
||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=objects&module='.$module.($forceddirread?'@'.$dirread:'');
|
||||
$head2[$h][1] = $langs->trans("Objects");
|
||||
$head2[$h][2] = 'objects';
|
||||
@ -1151,6 +1162,51 @@ elseif (! empty($module))
|
||||
}
|
||||
}
|
||||
|
||||
if ($tab == 'languages')
|
||||
{
|
||||
if ($action != 'editfile' || empty($file))
|
||||
{
|
||||
$langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$');
|
||||
|
||||
foreach ($langfiles as $langfile)
|
||||
{
|
||||
$pathtofile = $modulelowercase.'/langs/'.$langfile['relativename'];
|
||||
print '<span class="fa fa-file"></span> '.$langs->trans("LanguageFile").' '.basename(dirname($pathtofile)).' : <strong>'.$pathtofile.'</strong>';
|
||||
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format='.$format.'&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||
print '<br>';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Edit text language file
|
||||
|
||||
//print $langs->trans("UseAsciiDocFormat").'<br>';
|
||||
|
||||
$fullpathoffile=dol_buildpath($file, 0);
|
||||
|
||||
$content = file_get_contents($fullpathoffile);
|
||||
|
||||
// New module
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="savefile">';
|
||||
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
|
||||
print '<input type="hidden" name="tab" value="'.$tab.'">';
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
|
||||
$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'):'text'));
|
||||
print '<br>';
|
||||
print '<center>';
|
||||
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||
print '</center>';
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($tab == 'objects')
|
||||
{
|
||||
$head3 = array();
|
||||
|
||||
@ -78,13 +78,9 @@ class ActionsMyModule
|
||||
|
||||
$error = 0; // Error counter
|
||||
|
||||
/*
|
||||
print_r($parameters);
|
||||
print_r($object);
|
||||
echo "action: " . $action;
|
||||
*/
|
||||
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@ -115,14 +111,9 @@ class ActionsMyModule
|
||||
|
||||
$error = 0; // Error counter
|
||||
|
||||
/*
|
||||
print_r($parameters);
|
||||
print_r($object);
|
||||
echo "action: " . $action;
|
||||
*/
|
||||
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) { // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
|
||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
{
|
||||
foreach($parameters['toselect'] as $objectid)
|
||||
{
|
||||
// Do action on each object id
|
||||
@ -156,7 +147,8 @@ class ActionsMyModule
|
||||
|
||||
$error = 0; // Error counter
|
||||
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext'
|
||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
{
|
||||
$this->resprints = '<option value="0"'.($disabled?' disabled="disabled"':'').'>'.$langs->trans("MyModuleMassAction").'</option>';
|
||||
}
|
||||
@ -171,4 +163,64 @@ class ActionsMyModule
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Execute action
|
||||
*
|
||||
* @param array $parameters Array of parameters
|
||||
* @param Object $object Object output on PDF
|
||||
* @param string $action 'add', 'update', 'view'
|
||||
* @return int <0 if KO,
|
||||
* =0 if OK but we want to process standard actions too,
|
||||
* >0 if OK and we want to replace standard actions.
|
||||
*/
|
||||
function beforePDFCreation($parameters, &$object, &$action)
|
||||
{
|
||||
global $langs,$conf;
|
||||
global $hookmanager;
|
||||
|
||||
$outputlangs=$langs;
|
||||
|
||||
$ret=0; $deltemp=array();
|
||||
dol_syslog(get_class($this).'::executeHooks action='.$action);
|
||||
|
||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute action
|
||||
*
|
||||
* @param array $parameters Array of parameters
|
||||
* @param Object $pdfhandler PDF builder handler
|
||||
* @param string $action 'add', 'update', 'view'
|
||||
* @return int <0 if KO,
|
||||
* =0 if OK but we want to process standard actions too,
|
||||
* >0 if OK and we want to replace standard actions.
|
||||
*/
|
||||
function afterPDFCreation($parameters, &$pdfhandler, &$action)
|
||||
{
|
||||
global $langs,$conf;
|
||||
global $hookmanager;
|
||||
|
||||
$outputlangs=$langs;
|
||||
|
||||
$ret=0; $deltemp=array();
|
||||
dol_syslog(get_class($this).'::executeHooks action='.$action);
|
||||
|
||||
/* print_r($parameters); print_r($object); echo "action: " . $action; */
|
||||
if (in_array($parameters['currentcontext'], array('somecontext1','somecontext2'))) // do something only for the context 'somecontext1' or 'somecontext2'
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/* Add here any other hooked methods... */
|
||||
|
||||
}
|
||||
|
||||
1
htdocs/modulebuilder/template/core/boxes/README.md
Normal file
1
htdocs/modulebuilder/template/core/boxes/README.md
Normal file
@ -0,0 +1 @@
|
||||
Directory where widgets files are stored.
|
||||
@ -95,7 +95,7 @@ class modMyModule extends DolibarrModules
|
||||
'models' => 0, // Set this to 1 if module has its own models directory (core/modules/xxx)
|
||||
'css' => array('/mymodule/css/mymodule.css.php'), // Set this to relative path of css file if module has its own css file
|
||||
'js' => array('/mymodule/js/mymodule.js.php'), // Set this to relative path of js file if module must load a js on all pages
|
||||
'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module. You can also set hook context 'all'
|
||||
'hooks' => array('hookcontext1','hookcontext2') // Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context 'all'
|
||||
);
|
||||
|
||||
// Data directories to create when module is enabled.
|
||||
@ -305,15 +305,18 @@ class modMyModule extends DolibarrModules
|
||||
*/
|
||||
public function init($options='')
|
||||
{
|
||||
$sql = array();
|
||||
|
||||
$this->_load_tables('/mymodule/sql/');
|
||||
|
||||
// Create extrafields
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields = new ExtraFields($this->db);
|
||||
|
||||
//$result1=$extrafields->addExtraField('myattr1', "New Attr 1 label", 'boolean', 1, 3, 'thirdparty');
|
||||
//$result2=$extrafields->addExtraField('myattr2', "New Attr 2 label", 'string', 1, 10, 'project');
|
||||
//$param=array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3'));
|
||||
//$result3=$extrafields->addExtraField('myattr3', "New Attr 3 label", 'select', 1, 3, 'thirdparty', 0, 1, '', $param, 1);
|
||||
|
||||
$sql = array();
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
|
||||
1
htdocs/modulebuilder/template/core/triggers/README.md
Normal file
1
htdocs/modulebuilder/template/core/triggers/README.md
Normal file
@ -0,0 +1 @@
|
||||
Directory where triggers files are stored.
|
||||
Loading…
Reference in New Issue
Block a user