30 if (!defined(
'NOSCANPOSTFORINJECTION')) define(
'NOSCANPOSTFORINJECTION',
'1');
32 require
'../main.inc.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/modulebuilder.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/class/utils.class.php';
41 $langs->loadLangs(array(
"admin",
"modulebuilder",
"other",
"cron",
"errors"));
43 $action =
GETPOST(
'action',
'aZ09');
44 $confirm =
GETPOST(
'confirm',
'alpha');
45 $cancel =
GETPOST(
'cancel',
'alpha');
47 $module =
GETPOST(
'module',
'alpha');
49 $tabobj =
GETPOST(
'tabobj',
'alpha');
50 $propertykey =
GETPOST(
'propertykey',
'alpha');
51 if (empty($module)) $module =
'initmodule';
52 if (empty($tab)) $tab =
'description';
53 if (empty($tabobj)) $tabobj =
'newobjectifnoobj';
54 $file =
GETPOST(
'file',
'alpha');
61 if (!$user->admin && empty($conf->global->MODULEBUILDER_FOREVERYONE))
accessforbidden($langs->trans(
'ModuleBuilderNotAllowed'));
65 $tmp = explode(
',', $dolibarr_main_document_root_alt);
70 $tmpdir = explode(
'@', $module);
71 if (!empty($tmpdir[1]))
74 $dirread = $tmpdir[1];
79 $dirread = $dirins =
GETPOST(
'dirins',
'alpha');
83 $FILEFLAG =
'modulebuilder.txt';
87 if (empty($newmask) && !empty($conf->global->MAIN_UMASK)) $newmask = $conf->global->MAIN_UMASK;
97 $form =
new Form($db);
100 $dirsrootforscan = array($dirread);
102 if ($dirread != DOL_DOCUMENT_ROOT && ($conf->global->MAIN_FEATURES_LEVEL >= 2 || !empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT))) { $dirsrootforscan[] = DOL_DOCUMENT_ROOT; }
105 $textforlistofdirs =
'<!-- Directory scanned -->'.
"\n";
106 $listofmodules = array();
108 foreach ($dirsrootforscan as $dirread)
110 $moduletype =
'external';
111 if ($dirread == DOL_DOCUMENT_ROOT) {
112 $moduletype =
'internal';
116 if (is_array($dirsincustom) && count($dirsincustom) > 0) {
117 foreach ($dirsincustom as $dircustomcursor) {
118 $fullname = $dircustomcursor[
'fullname'];
122 $dirtoscanrel = basename($fullname).
'/core/modules/';
124 $descriptorfiles =
dol_dir_list(dirname($fullname).
'/'.$dirtoscanrel,
'files', 0,
'mod.*\.class\.php$');
125 if (empty($descriptorfiles))
127 $dirtoscanrel =
'core/modules/';
128 $descriptorfiles =
dol_dir_list($fullname.
'/../'.$dirtoscanrel,
'files', 0,
'mod'.strtoupper(basename($fullname)).
'\.class\.php$');
130 $modulenamewithcase =
'';
131 $moduledescriptorrelpath =
'';
132 $moduledescriptorfullpath =
'';
134 foreach ($descriptorfiles as $descriptorcursor) {
135 $modulenamewithcase = preg_replace(
'/^mod/',
'', $descriptorcursor[
'name']);
136 $modulenamewithcase = preg_replace(
'/\.class\.php$/',
'', $modulenamewithcase);
137 $moduledescriptorrelpath = $dirtoscanrel.$descriptorcursor[
'name'];
138 $moduledescriptorfullpath = $descriptorcursor[
'fullname'];
141 if ($modulenamewithcase)
143 $listofmodules[$dircustomcursor[
'name']] = array(
144 'modulenamewithcase'=>$modulenamewithcase,
145 'moduledescriptorrelpath'=> $moduledescriptorrelpath,
146 'moduledescriptorfullpath'=>$moduledescriptorfullpath,
147 'moduledescriptorrootpath'=>$dirread,
148 'moduletype'=>$moduletype
156 if ($forceddirread && empty($listofmodules))
158 $listofmodules[strtolower($module)] = array(
159 'modulenamewithcase'=>$module,
160 'moduledescriptorrelpath'=>
'notyetimplemented',
161 'moduledescriptorfullpath'=>
'notyetimplemented',
162 'moduledescriptorrootpath'=>
'notyetimplemented',
167 $newdircustom = $dirins;
168 if (empty($newdircustom)) $newdircustom =
img_warning();
171 if (empty($i)) $textforlistofdirs .= $langs->trans(
"DirScanned").
' : ';
172 else $textforlistofdirs .=
', ';
173 $textforlistofdirs .=
'<strong class="wordbreakimp">'.$dirread.
'</strong>';
174 if ($dirread == DOL_DOCUMENT_ROOT) {
175 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MAIN_FEATURES_LEVEL"));
176 if (!empty($conf->global->MODULEBUILDER_ADD_DOCUMENT_ROOT)) $textforlistofdirs .= $form->textwithpicto(
'', $langs->trans(
"ConstantIsOn",
"MODULEBUILDER_ADD_DOCUMENT_ROOT"));
186 if ($dirins && $action ==
'initmodule' && $modulename)
188 $modulename = ucfirst($modulename);
190 if (preg_match(
'/[^a-z0-9_]/i', $modulename))
193 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"), null,
'errors');
198 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
199 $destdir = $dirins.
'/'.strtolower($modulename);
201 $arrayreplacement = array(
202 'mymodule'=>strtolower($modulename),
203 'MyModule'=>$modulename
206 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement);
213 $langs->load(
"errors");
214 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir), null,
'errors');
217 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir), null,
'warnings');
221 if (!empty($conf->global->MODULEBUILDER_USE_ABOUT))
241 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
242 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
258 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
260 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
261 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
262 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
263 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
279 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
280 foreach ($listofphpfilestoedit as $phpfileval)
283 $arrayreplacement = array(
284 'mymodule'=>strtolower($modulename),
285 'MyModule'=>$modulename,
286 'MYMODULE'=>strtoupper($modulename),
287 'My module'=>$modulename,
288 'my module'=>$modulename,
289 'Mon module'=>$modulename,
290 'mon module'=>$modulename,
291 'htdocs/modulebuilder/template'=>strtolower($modulename),
292 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
295 if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
296 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME)) $arrayreplacement[
'Editor name'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_NAME;
297 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL)) $arrayreplacement[
'https://www.example.com'] = $conf->global->MODULEBUILDER_SPECIFIC_EDITOR_URL;
298 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_AUTHOR)) $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' '.$conf->global->MODULEBUILDER_SPECIFIC_AUTHOR;
299 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_VERSION)) $arrayreplacement[
'1.0'] = $conf->global->MODULEBUILDER_SPECIFIC_VERSION;
300 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_FAMILY)) $arrayreplacement[
'other'] = $conf->global->MODULEBUILDER_SPECIFIC_FAMILY;
307 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']), null,
'errors');
311 if (!empty($conf->global->MODULEBUILDER_SPECIFIC_README))
313 setEventMessages($langs->trans(
"ContentOfREADMECustomized"), null,
'warnings');
315 file_put_contents($destdir.
'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README);
322 $module = $modulename;
327 if ($dirins && $action ==
'initapi' && !empty($module))
329 $modulename = ucfirst($module);
330 $objectname = $tabobj;
332 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
333 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
334 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
335 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
337 $result =
dol_copy($srcfile, $destfile, 0, 0);
342 $arrayreplacement = array(
343 'mymodule'=>strtolower($modulename),
344 'MyModule'=>$modulename,
345 'MYMODULE'=>strtoupper($modulename),
346 'My module'=>$modulename,
347 'my module'=>$modulename,
348 'Mon module'=>$modulename,
349 'mon module'=>$modulename,
350 'htdocs/modulebuilder/template'=>strtolower($modulename),
351 'myobject'=>strtolower($objectname),
352 'MyObject'=>$objectname,
353 'MYOBJECT'=>strtoupper($objectname),
354 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
359 $langs->load(
"errors");
360 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
363 if ($dirins && $action ==
'initphpunit' && !empty($module))
365 $modulename = ucfirst($module);
366 $objectname = $tabobj;
368 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
369 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
370 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
371 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
372 $result =
dol_copy($srcfile, $destfile, 0, 0);
377 $arrayreplacement = array(
378 'mymodule'=>strtolower($modulename),
379 'MyModule'=>$modulename,
380 'MYMODULE'=>strtoupper($modulename),
381 'My module'=>$modulename,
382 'my module'=>$modulename,
383 'Mon module'=>$modulename,
384 'mon module'=>$modulename,
385 'htdocs/modulebuilder/template'=>strtolower($modulename),
386 'myobject'=>strtolower($objectname),
387 'MyObject'=>$objectname,
388 'MYOBJECT'=>strtoupper($objectname),
389 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
394 $langs->load(
"errors");
395 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
398 if ($dirins && $action ==
'initsqlextrafields' && !empty($module)) {
399 $modulename = ucfirst($module);
400 $objectname = $tabobj;
402 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
403 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
404 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
405 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
407 $result1 =
dol_copy($srcfile1, $destfile1, 0, 0);
408 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
409 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
411 $result2 =
dol_copy($srcfile2, $destfile2, 0, 0);
413 if ($result1 > 0 && $result2 > 0)
415 $modulename = ucfirst($module);
418 $arrayreplacement = array(
419 'mymodule'=>strtolower($modulename),
420 'MyModule'=>$modulename,
421 'MYMODULE'=>strtoupper($modulename),
422 'My module'=>$modulename,
423 'my module'=>$modulename,
424 'Mon module'=>$modulename,
425 'mon module'=>$modulename,
426 'htdocs/modulebuilder/template'=>strtolower($modulename),
427 'My Object'=>$objectname,
428 'MyObject'=>$objectname,
429 'my object'=>strtolower($objectname),
430 'myobject'=>strtolower($objectname),
431 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
437 $langs->load(
"errors");
438 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
''), null,
'errors');
442 if ($dirins && $action ==
'inithook' && !empty($module))
444 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
445 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
446 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
447 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
449 $result =
dol_copy($srcfile, $destfile, 0, 0);
453 $modulename = ucfirst($module);
456 $arrayreplacement = array(
457 'mymodule'=>strtolower($modulename),
458 'MyModule'=>$modulename,
459 'MYMODULE'=>strtoupper($modulename),
460 'My module'=>$modulename,
461 'my module'=>$modulename,
462 'Mon module'=>$modulename,
463 'mon module'=>$modulename,
464 'htdocs/modulebuilder/template'=>strtolower($modulename),
465 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
470 $langs->load(
"errors");
471 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
474 if ($dirins && $action ==
'inittrigger' && !empty($module))
476 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
477 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
478 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
479 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
481 $result =
dol_copy($srcfile, $destfile, 0, 0);
485 $modulename = ucfirst($module);
488 $arrayreplacement = array(
489 'mymodule'=>strtolower($modulename),
490 'MyModule'=>$modulename,
491 'MYMODULE'=>strtoupper($modulename),
492 'My module'=>$modulename,
493 'my module'=>$modulename,
494 'Mon module'=>$modulename,
495 'mon module'=>$modulename,
496 'htdocs/modulebuilder/template'=>strtolower($modulename),
497 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
502 $langs->load(
"errors");
503 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
506 if ($dirins && $action ==
'initwidget' && !empty($module))
508 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
509 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
510 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
511 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
513 $result =
dol_copy($srcfile, $destfile, 0, 0);
516 $modulename = ucfirst($module);
519 $arrayreplacement = array(
520 'mymodule'=>strtolower($modulename),
521 'MyModule'=>$modulename,
522 'MYMODULE'=>strtoupper($modulename),
523 'My module'=>$modulename,
524 'my module'=>$modulename,
525 'Mon module'=>$modulename,
526 'mon module'=>$modulename,
527 'htdocs/modulebuilder/template'=>strtolower($modulename),
528 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
533 $langs->load(
"errors");
534 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
537 if ($dirins && $action ==
'initcss' && !empty($module))
539 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
540 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
541 $srcfile = $srcdir.
'/css/mymodule.css.php';
542 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
544 $result =
dol_copy($srcfile, $destfile, 0, 0);
548 $modulename = ucfirst($module);
551 $arrayreplacement = array(
552 'mymodule'=>strtolower($modulename),
553 'MyModule'=>$modulename,
554 'MYMODULE'=>strtoupper($modulename),
555 'My module'=>$modulename,
556 'my module'=>$modulename,
557 'Mon module'=>$modulename,
558 'mon module'=>$modulename,
559 'htdocs/modulebuilder/template'=>strtolower($modulename),
560 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
566 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
567 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
570 $langs->load(
"errors");
571 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
575 if ($dirins && $action ==
'initjs' && !empty($module))
577 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
578 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
579 $srcfile = $srcdir.
'/js/mymodule.js.php';
580 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
582 $result =
dol_copy($srcfile, $destfile, 0, 0);
586 $modulename = ucfirst($module);
589 $arrayreplacement = array(
590 'mymodule'=>strtolower($modulename),
591 'MyModule'=>$modulename,
592 'MYMODULE'=>strtoupper($modulename),
593 'My module'=>$modulename,
594 'my module'=>$modulename,
595 'Mon module'=>$modulename,
596 'mon module'=>$modulename,
597 'htdocs/modulebuilder/template'=>strtolower($modulename),
598 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
604 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
605 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
608 $langs->load(
"errors");
609 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
612 if ($dirins && $action ==
'initcli' && !empty($module))
614 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
615 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
616 $srcfile = $srcdir.
'/scripts/mymodule.php';
617 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
619 $result =
dol_copy($srcfile, $destfile, 0, 0);
623 $modulename = ucfirst($module);
626 $arrayreplacement = array(
627 'mymodule'=>strtolower($modulename),
628 'MyModule'=>$modulename,
629 'MYMODULE'=>strtoupper($modulename),
630 'My module'=>$modulename,
631 'my module'=>$modulename,
632 'Mon module'=>$modulename,
633 'mon module'=>$modulename,
634 'htdocs/modulebuilder/template'=>strtolower($modulename),
635 '__MYCOMPANY_NAME__'=>$mysoc->name,
636 '__KEYWORDS__'=>$modulename,
637 '__USER_FULLNAME__'=>$user->getFullName($langs),
638 '__USER_EMAIL__'=>$user->email,
640 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
645 $langs->load(
"errors");
646 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
649 if ($dirins && $action ==
'initdoc' && !empty($module)) {
650 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
651 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
652 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
653 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
655 $result =
dol_copy($srcfile, $destfile, 0, 0);
658 $modulename = ucfirst($module);
659 $modulelowercase = strtolower($module);
662 $arrayreplacement = array(
663 'mymodule'=>strtolower($modulename),
664 'MyModule'=>$modulename,
665 'MYMODULE'=>strtoupper($modulename),
666 'My module'=>$modulename,
667 'my module'=>$modulename,
668 'Mon module'=>$modulename,
669 'mon module'=>$modulename,
670 'htdocs/modulebuilder/template'=>strtolower($modulename),
671 '__MYCOMPANY_NAME__'=>$mysoc->name,
672 '__KEYWORDS__'=>$modulename,
673 '__USER_FULLNAME__'=>$user->getFullName($langs),
674 '__USER_EMAIL__'=>$user->email,
676 '---Put here your own copyright and developer email---'=>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
682 $FILENAMEDOC = $modulelowercase.
'.html';
683 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
684 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
685 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
686 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
687 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
692 $langs->load(
"errors");
693 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile), null,
'errors');
697 if ($dirins && $action ==
'addlanguage' && !empty($module))
699 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
700 $srcfile = $dirins.
'/'.strtolower($module).
'/langs/en_US';
701 $destfile = $dirins.
'/'.strtolower($module).
'/langs/'.$newlangcode;
702 $result =
dolCopyDir($srcfile, $destfile, 0, 0);
705 if ($dirins && $action ==
'confirm_removefile' && !empty($module))
708 if ($relativefilename)
710 $dirnametodelete = dirname($relativefilename);
711 $filetodelete = $dirins.
'/'.$relativefilename;
712 $dirtodelete = $dirins.
'/'.$dirnametodelete;
716 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)), null,
'errors');
721 if (in_array($tab, array(
'css',
'js')))
723 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
724 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
'=>'
732 if ($dirins && $action ==
'initobject' && $module &&
GETPOST(
'createtablearray',
'alpha'))
734 $tablename =
GETPOST(
'initfromtablename',
'alpha');
735 $_results = $db->DDLDescTable($tablename);
736 if (empty($_results))
738 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename), null,
'errors');
780 $string =
'public $fields=array('.
"\n";
783 while ($obj = $db->fetch_object($_results))
786 $fieldname = $obj->Field;
789 if ($type ==
'int(11)') $type =
'integer';
790 if ($type ==
'float') $type =
'real';
791 if (strstr($type,
'tinyint')) $type =
'integer';
792 if ($obj->Field ==
'fk_soc') $type =
'integer:Societe:societe/class/societe.class.php';
793 if (preg_match(
'/^fk_proj/', $obj->Field)) $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
794 if (preg_match(
'/^fk_prod/', $obj->Field)) $type =
'integer:Product:product/class/product.class.php:1';
795 if ($obj->Field ==
'fk_warehouse') $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
796 if (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) $type =
'integer:User:user/class/user.class.php';
799 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
800 if ($fieldname ==
'fk_user_modif') $notnull = -1;
802 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
803 if ($fieldname ==
'rowid') $label =
'TechnicalID';
804 if ($fieldname ==
'import_key') $label =
'ImportId';
805 if ($fieldname ==
'fk_soc') $label =
'ThirdParty';
806 if ($fieldname ==
'tms') $label =
'DateModification';
807 if ($fieldname ==
'datec') $label =
'DateCreation';
808 if ($fieldname ==
'date_valid') $label =
'DateValidation';
809 if ($fieldname ==
'datev') $label =
'DateValidation';
810 if ($fieldname ==
'note_private') $label =
'NotePublic';
811 if ($fieldname ==
'note_public') $label =
'NotePrivate';
812 if ($fieldname ==
'fk_user_creat') $label =
'UserAuthor';
813 if ($fieldname ==
'fk_user_modif') $label =
'UserModif';
814 if ($fieldname ==
'fk_user_valid') $label =
'UserValidation';
817 if ($fieldname ==
'entity') $visible = -2;
818 if ($fieldname ==
'import_key') $visible = -2;
819 if ($fieldname ==
'fk_user_creat') $visible = -2;
820 if ($fieldname ==
'fk_user_modif') $visible = -2;
821 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) $visible = 0;
826 if ($fieldname ==
'entity') $default = 1;
829 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) $position = 500;
830 if ($fieldname ==
'import_key') $position = 900;
833 if ($fieldname ==
'entity') $index = 1;
835 $string .=
"'".$obj->Field.
"' =>array('type'=>'".$type.
"', 'label'=>'".$label.
"',";
836 if ($default !=
'') $string .=
" 'default'=>".$default.
",";
837 $string .=
" 'enabled'=>".$enabled.
",";
838 $string .=
" 'visible'=>".$visible;
839 if ($notnull) $string .=
", 'notnull'=>".$notnull;
840 if ($fieldname ==
'ref') $string .=
", 'showoncombobox'=>1";
841 $string .=
", 'position'=>".$position;
842 if ($index) $string .=
", 'index'=>".$index;
847 $string .=
');'.
"\n";
854 if ($dirins && $action ==
'initobject' && $module && $objectname)
856 $objectname = ucfirst($objectname);
858 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
859 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
861 if (preg_match(
'/[^a-z0-9_]/i', $objectname))
864 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"), null,
'errors');
865 $tabobj =
'newobject';
867 if (class_exists($objectname)) {
870 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"), null,
'errors');
871 $tabobj =
'newobject';
874 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
875 $destdir = $dirins.
'/'.strtolower($module);
887 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
888 $alreadyfound =
false;
889 foreach ($dirlist as $key => $val)
891 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
892 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound)
894 $alreadyfound =
true;
896 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"), null,
'errors');
905 $filetogenerate = array(
906 'myobject_card.php'=>strtolower($objectname).
'_card.php',
907 'myobject_note.php'=>strtolower($objectname).
'_note.php',
908 'myobject_contact.php'=>strtolower($objectname).
'_contact.php',
909 'myobject_document.php'=>strtolower($objectname).
'_document.php',
910 'myobject_agenda.php'=>strtolower($objectname).
'_agenda.php',
911 'myobject_list.php'=>strtolower($objectname).
'_list.php',
912 'admin/myobject_extrafields.php'=>
'admin/'.strtolower($objectname).
'_extrafields.php',
913 'lib/mymodule_myobject.lib.php'=>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
915 'sql/llx_mymodule_myobject.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
916 'sql/llx_mymodule_myobject.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
917 'sql/llx_mymodule_myobject_extrafields.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
918 'sql/llx_mymodule_myobject_extrafields.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
920 'img/object_myobject.png'=>
'img/object_'.strtolower($objectname).
'.png',
921 'class/myobject.class.php'=>
'class/'.strtolower($objectname).
'.class.php',
925 if (
GETPOST(
'includerefgeneration',
'aZ09'))
927 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
929 $filetogenerate += array(
930 'core/modules/mymodule/mod_myobject_advanced.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
931 'core/modules/mymodule/mod_myobject_standard.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
932 'core/modules/mymodule/modules_myobject.php'=>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
935 if (
GETPOST(
'includedocgeneration',
'aZ09'))
937 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
938 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
940 $filetogenerate += array(
941 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
942 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
946 foreach ($filetogenerate as $srcfile => $destfile)
948 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
954 $langs->load(
"errors");
955 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile), null,
'errors');
958 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile), null,
'warnings');
964 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
966 $arrayreplacement = array(
967 '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' =>
"'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'"
971 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
973 $arrayreplacement = array(
974 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
976 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
980 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
982 $arrayreplacement = array(
983 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
985 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
986 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'', 0, 0, 1);
988 $arrayreplacement = array(
989 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
992 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
999 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1001 $firstobjectname =
'';
1002 foreach ($listofobject as $fileobj)
1004 if (preg_match(
'/^api_/', $fileobj[
'name']))
continue;
1005 if (preg_match(
'/^actions_/', $fileobj[
'name']))
continue;
1007 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1009 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg))
1011 $objectnameloop = $reg[1];
1012 if (empty($firstobjectname)) $firstobjectname = $objectnameloop;
1017 \$this->menu[\$r++]=array(
1018 // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
1019 'fk_menu'=>'fk_mainmenu=mymodule',
1020 // This is a Left menu entry
1022 'titre'=>'List MyObject',
1023 'mainmenu'=>'mymodule',
1024 'leftmenu'=>'mymodule_myobject',
1025 'url'=>'/mymodule/myobject_list.php',
1026 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
1027 'langs'=>'mymodule@mymodule',
1028 'position'=>1100+\$r,
1029 // Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected.
1030 'enabled'=>'\$conf->mymodule->enabled',
1031 // Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
1034 // 0=Menu for internal users, 1=external users, 2=both
1037 \$this->menu[\$r++]=array(
1038 // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
1039 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=mymodule_myobject',
1040 // This is a Left menu entry
1042 'titre'=>'New MyObject',
1043 'mainmenu'=>'mymodule',
1044 'leftmenu'=>'mymodule_myobject',
1045 'url'=>'/mymodule/myobject_card.php?action=create',
1046 // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
1047 'langs'=>'mymodule@mymodule',
1048 'position'=>1100+\$r,
1049 // Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected.
1050 'enabled'=>'\$conf->mymodule->enabled',
1051 // Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
1054 // 0=Menu for internal users, 1=external users, 2=both
1057 $stringtoadd = preg_replace(
'/MyObject/', $objectnameloop, $stringtoadd);
1058 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1059 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectnameloop), $stringtoadd);
1061 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1066 dolReplaceInFile($moduledescriptorfile, array(
'END MODULEBUILDER LEFTMENU MYOBJECT */' =>
'*/'.
"\n".$stringtoadd.
"\n\t\t/* END MODULEBUILDER LEFTMENU MYOBJECT */"));
1069 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1076 foreach ($filetogenerate as $destfile)
1078 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1081 $arrayreplacement = array(
1082 'mymodule'=>strtolower($module),
1083 'MyModule'=>$module,
1084 'MYMODULE'=>strtoupper($module),
1085 'My module'=>$module,
1086 'my module'=>$module,
1087 'mon module'=>$module,
1088 'Mon module'=>$module,
1089 'htdocs/modulebuilder/template/'=>strtolower($modulename),
1090 'myobject'=>strtolower($objectname),
1091 'MyObject'=>$objectname,
1092 'MYOBJECT'=>strtoupper($objectname)
1099 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']), null,
'errors');
1107 $object = rebuildObjectClass($destdir, $module, $objectname, $newmask);
1108 if (is_numeric($object) && $object < 0) $error++;
1113 $result = rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1114 if ($result < 0) $error++;
1119 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname), null);
1120 $tabobj = $objectname;
1124 if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj))
1126 $objectname = $tabobj;
1128 $arrayoftables = array();
1129 if ($action ==
'droptable') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1130 if ($action ==
'droptableextrafields') $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1132 foreach ($arrayoftables as $tabletodrop)
1135 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1136 $resql = $db->query($sql);
1139 $obj = $db->fetch_object(
$resql);
1145 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE')
1147 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop), null,
'warnings');
1154 $resql = $db->DDLDropTable($tabletodrop);
1156 setEventMessages($langs->trans(
"TableDropped", $tabletodrop), null,
'mesgs');
1159 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop), null,
'warnings');
1164 if ($dirins && $action ==
'addproperty' && !empty($module) && !empty($tabobj))
1168 $objectname = $tabobj;
1170 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1171 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1173 $srcdir = $dirread.
'/'.strtolower($module);
1174 $destdir = $dirins.
'/'.strtolower($module);
1178 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing'))
1180 if (!
GETPOST(
'propname',
'aZ09'))
1183 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")), null,
'errors');
1185 if (!
GETPOST(
'proplabel',
'alpha'))
1188 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")), null,
'errors');
1190 if (!
GETPOST(
'proptype',
'alpha'))
1193 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")), null,
'errors');
1198 $addfieldentry = array(
1199 'name'=>
GETPOST(
'propname',
'aZ09'),
'label'=>
GETPOST(
'proplabel',
'alpha'),
'type'=>
GETPOST(
'proptype',
'alpha'),
1200 'arrayofkeyval'=>
GETPOST(
'proparrayofkeyval',
'restricthtml'),
1201 'visible'=>
GETPOST(
'propvisible',
'int'),
'enabled'=>
GETPOST(
'propenabled',
'int'),
1202 'position'=>
GETPOST(
'propposition',
'int'),
'notnull'=>
GETPOST(
'propnotnull',
'int'),
'index'=>
GETPOST(
'propindex',
'int'),
'searchall'=>
GETPOST(
'propsearchall',
'int'),
1203 'isameasure'=>
GETPOST(
'propisameasure',
'int'),
'comment'=>
GETPOST(
'propcomment',
'alpha'),
'help'=>
GETPOST(
'prophelp',
'alpha')
1206 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval']))
1208 $addfieldentry[
'arrayofkeyval'] = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1222 $moduletype =
'external';
1224 $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, $addfieldentry, $moduletype);
1225 if (is_numeric($object) && $object <= 0)
1234 $moduletype =
'external';
1236 $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1245 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname), null);
1247 clearstatcache(
true);
1250 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1256 if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey)
1258 $objectname = $tabobj;
1260 $srcdir = $dirread.
'/'.strtolower($module);
1261 $destdir = $dirins.
'/'.strtolower($module);
1267 $object = rebuildObjectClass($destdir, $module, $objectname, $newmask, $srcdir, array(), $propertykey);
1268 if (is_numeric($object) && $object <= 0) $error++;
1274 $result = rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1275 if ($result <= 0) $error++;
1280 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname), null);
1282 clearstatcache(
true);
1285 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1291 if ($dirins && $action ==
'confirm_deletemodule')
1293 if (preg_match(
'/[^a-z0-9_]/i', $module))
1296 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"), null,
'errors');
1301 $modulelowercase = strtolower($module);
1304 $dir = $dirins.
'/'.$modulelowercase;
1317 $module =
'deletemodule';
1320 if ($dirins && $action ==
'confirm_deleteobject' && $objectname)
1322 if (preg_match(
'/[^a-z0-9_]/i', $objectname))
1325 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"), null,
'errors');
1330 $modulelowercase = strtolower($module);
1331 $objectlowercase = strtolower($objectname);
1334 $dir = $dirins.
'/'.$modulelowercase;
1337 $filetodelete = array(
1338 'myobject_card.php'=>strtolower($objectname).
'_card.php',
1339 'myobject_note.php'=>strtolower($objectname).
'_note.php',
1340 'myobject_contact.php'=>strtolower($objectname).
'_contact.php',
1341 'myobject_document.php'=>strtolower($objectname).
'_document.php',
1342 'myobject_agenda.php'=>strtolower($objectname).
'_agenda.php',
1343 'myobject_list.php'=>strtolower($objectname).
'_list.php',
1344 'admin/myobject_extrafields.php'=>
'admin/'.strtolower($objectname).
'_extrafields.php',
1345 'lib/mymodule_myobject.lib.php'=>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1346 'test/phpunit/MyObjectTest.php'=>
'test/phpunit/'.strtolower($objectname).
'Test.php',
1347 'sql/llx_mymodule_myobject.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1348 'sql/llx_mymodule_myobject_extrafields.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1349 'sql/llx_mymodule_myobject.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1350 'sql/llx_mymodule_myobject_extrafields.key.sql'=>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1351 'scripts/myobject.php'=>
'scripts/'.strtolower($objectname).
'.php',
1352 'img/object_myobject.png'=>
'img/object_'.strtolower($objectname).
'.png',
1353 'class/myobject.class.php'=>
'class/'.strtolower($objectname).
'.class.php',
1354 'class/api_myobject.class.php'=>
'class/api_'.strtolower($module).
'.class.php',
1355 'core/modules/mymodule/mod_myobject_advanced.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1356 'core/modules/mymodule/mod_myobject_standard.php'=>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1357 'core/modules/mymodule/modules_myobject.php'=>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1358 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1359 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php'=>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1363 foreach ($filetodelete as $filetodelete)
1366 $resulttmp =
dol_delete_file($dir.
'/'.$filetodelete.
'.back', 0, 0, 1);
1367 if (!$resulttmp) $resultko++;
1374 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"), null,
'warnings');
1379 $tabobj =
'deleteobject';
1383 if ($dirins && $action ==
'generatepackage')
1385 $modulelowercase = strtolower($module);
1388 $dir = $dirins.
'/'.$modulelowercase;
1393 dol_include_once($modulelowercase.
'/core/modules/mod'.$module.
'.class.php');
1394 $class =
'mod'.$module;
1396 if (class_exists($class))
1399 $moduleobj =
new $class($db);
1407 $langs->load(
"errors");
1408 dol_print_error($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1412 $arrayversion = explode(
'.', $moduleobj->version, 3);
1413 if (count($arrayversion))
1415 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].
'.'.$arrayversion[1].($arrayversion[2] ?
".".$arrayversion[2] :
"").
".zip";
1418 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
1422 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'', $modulelowercase);
1429 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip), null);
1432 $langs->load(
"errors");
1433 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip), null,
'errors');
1437 $langs->load(
"errors");
1438 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"), null,
'errors');
1442 if ($dirins && $action ==
'generatedoc')
1444 $FILENAMEDOC = strtolower($module).
'.html';
1445 $dirofmodule =
dol_buildpath(strtolower($module), 0).
'/doc';
1447 $util =
new Utils($db);
1448 $result = $util->generateDoc($module);
1452 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule), null);
1460 if ($action ==
'savefile' && empty($cancel))
1462 $relofcustom = basename($dirins);
1467 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) $file = $relofcustom.
'/'.$file;
1475 dol_copy($pathoffile, $pathoffilebackup, 0, 1);
1478 $check =
'restricthtml';
1480 if ($srclang ==
'md') $check =
'restricthtml';
1481 if ($srclang ==
'lang') $check =
'restricthtml';
1482 if ($srclang ==
'php') $check =
'none';
1484 $content =
GETPOST(
'editfilecontent', $check);
1490 $result = file_put_contents($pathoffile, $content);
1493 @chmod($pathoffile, octdec($newmask));
1508 if ($action ==
'set' && $user->admin)
1511 if ($module) $param .=
'&module='.urlencode($module);
1512 if ($tab) $param .=
'&tab='.urlencode($tab);
1513 if ($tabobj) $param .=
'&tabobj='.urlencode($tabobj);
1515 $value =
GETPOST(
'value',
'alpha');
1517 if (!empty($resarray[
'errors']))
setEventMessages(
'', $resarray[
'errors'],
'errors');
1520 if ($resarray[
'nbperms'] > 0)
1522 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
1523 $resqltmp = $db->query($tmpsql);
1526 $obj = $db->fetch_object($resqltmp);
1528 if ($obj && $obj->nb > 1)
1530 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
1536 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?".$param);
1541 if ($action ==
'reset' && $user->admin)
1544 if ($module) $param .=
'&module='.urlencode($module);
1545 if ($tab) $param .=
'&tab='.urlencode($tab);
1546 if ($tabobj) $param .=
'&tabobj='.urlencode($tabobj);
1548 $value =
GETPOST(
'value',
'alpha');
1551 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?".$param);
1561 $form =
new Form($db);
1571 llxHeader(
'', $langs->trans(
"ModuleBuilder"),
'',
'', 0, 0,
1573 '/includes/ace/src/ace.js',
1574 '/includes/ace/src/ext-statusbar.js',
1575 '/includes/ace/src/ext-language_tools.js',
1577 ), array(),
'',
'classforhorizontalscrolloftabs');
1580 $text = $langs->trans(
"ModuleBuilder");
1584 print '<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span><br>';
1586 print $textforlistofdirs;
1594 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
1601 $langs->load(
"errors");
1602 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
1606 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
1616 $infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'</span>', $langs->trans(
"ModuleBuilderDesc4", $FILEFLAG)).
'</div>';
1624 if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule')
1626 $modulelowercase = strtolower($module);
1627 $loadclasserrormessage =
'';
1631 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1636 $class =
'mod'.$module;
1637 }
catch (Throwable $e) {
1638 $loadclasserrormessage = $e->getMessage().
"<br>\n";
1639 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
1640 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
1643 if (class_exists($class))
1646 $moduleobj =
new $class($db);
1649 print $e->getMessage();
1652 if (empty($forceddirread)) $error++;
1653 $langs->load(
"errors");
1654 print img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
1655 print $loadclasserrormessage;
1666 $head[$h][0] =
$_SERVER[
"PHP_SELF"].
'?module=initmodule';
1667 $head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
1668 $head[$h][2] =
'initmodule';
1671 $linktoenabledisable =
'';
1672 $modulestatusinfo =
'';
1674 if (is_array($listofmodules) && count($listofmodules) > 0) {
1676 $modulelowercase = strtolower($module);
1677 $const_name =
'MAIN_MODULE_'.strtoupper($module);
1680 if ($tab) $param .=
'&tab='.urlencode($tab);
1681 if ($module) $param .=
'&module='.urlencode($module);
1682 if ($tabobj) $param .=
'&tabobj='.urlencode($tabobj);
1684 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
1685 if (!empty($conf->global->$const_name))
1687 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=reset&value=mod'.$module.$param.
'">';
1688 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'',
false, 0, 0,
'',
'', 1);
1689 $linktoenabledisable .=
'</a>';
1691 $objMod = $moduleobj;
1692 $backtourlparam =
'';
1693 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
1694 if ($tab) $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
1695 $backtourl =
$_SERVER[
"PHP_SELF"].$backtourlparam;
1698 if (is_array($objMod->config_page_url))
1701 foreach ($objMod->config_page_url as $page)
1706 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
1709 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs))
1711 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
1712 $linktoenabledisable .=
' <a href="'.$urltouse.(preg_match(
'/\?/', $urltouse) ?
'&' :
'?').
'save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 6px"').
'</a>';
1714 $urltouse = $urlpage;
1715 $linktoenabledisable .=
' <a href="'.$urltouse.(preg_match(
'/\?/', $urltouse) ?
'&' :
'?').
'save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 6px"').
'</a>';
1719 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
1720 $linktoenabledisable .=
' <a href="'.dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1).
'?save_lastsearch_values=1&backtopage='.urlencode($backtourl).
'" title="'.$langs->trans(
"Setup").
'">'.
img_picto($langs->trans(
"Setup"),
"setup",
'style="padding-right: 6px"').
'</a>';
1723 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
1724 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'',
false, 0, 0,
'',
'classfortooltip', 1);
1725 $linktoenabledisable .=
"</a>\n";
1728 if (!empty($conf->$modulelowercase->enabled))
1730 $modulestatusinfo = $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
1734 foreach ($listofmodules as $tmpmodule => $tmpmodulearray)
1736 $head[$h][0] =
$_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
1737 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
1738 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
1749 $head[$h][0] =
$_SERVER[
"PHP_SELF"].
'?module=deletemodule';
1750 $head[$h][1] = $langs->trans(
"DangerZone");
1751 $head[$h][2] =
'deletemodule';
1756 if ($module ==
'initmodule')
1759 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
1760 print '<input type="hidden" name="token" value="'.newToken().
'">';
1761 print '<input type="hidden" name="action" value="initmodule">';
1762 print '<input type="hidden" name="module" value="initmodule">';
1765 print $langs->trans(
"EnterNameOfModuleDesc").
'<br>';
1768 print '<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ModuleKey")).
'"><br>';
1770 print '<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
1772 } elseif ($module ==
'deletemodule') {
1773 print '<!-- Form to init a module -->'.
"\n";
1774 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
1775 print '<input type="hidden" name="token" value="'.newToken().
'">';
1776 print '<input type="hidden" name="action" value="confirm_deletemodule">';
1777 print '<input type="hidden" name="module" value="deletemodule">';
1779 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
1781 print '<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="">';
1782 print '<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
1784 } elseif (!empty($module)) {
1788 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1793 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1794 $head2[$h][1] = $langs->trans(
"Description");
1795 $head2[$h][2] =
'description';
1798 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1799 $head2[$h][1] = $langs->trans(
"Languages");
1800 $head2[$h][2] =
'languages';
1803 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1804 $head2[$h][1] = $langs->trans(
"Dictionaries");
1805 $head2[$h][2] =
'dictionaries';
1808 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1809 $head2[$h][1] = $langs->trans(
"Objects");
1810 $head2[$h][2] =
'objects';
1813 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1814 $head2[$h][1] = $langs->trans(
"Permissions");
1815 $head2[$h][2] =
'permissions';
1818 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1819 $head2[$h][1] = $langs->trans(
"Menus");
1820 $head2[$h][2] =
'menus';
1823 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1824 $head2[$h][1] = $langs->trans(
"Hooks");
1825 $head2[$h][2] =
'hooks';
1828 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1829 $head2[$h][1] = $langs->trans(
"Triggers");
1830 $head2[$h][2] =
'triggers';
1833 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1834 $head2[$h][1] = $langs->trans(
"Widgets");
1835 $head2[$h][2] =
'widgets';
1838 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1839 $head2[$h][1] = $langs->trans(
"CSS");
1840 $head2[$h][2] =
'css';
1843 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1844 $head2[$h][1] = $langs->trans(
"JS");
1845 $head2[$h][2] =
'js';
1848 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1849 $head2[$h][1] = $langs->trans(
"CLI");
1850 $head2[$h][2] =
'cli';
1853 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1854 $head2[$h][1] = $langs->trans(
"CronList");
1855 $head2[$h][2] =
'cron';
1858 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1859 $head2[$h][1] = $langs->trans(
"Documentation");
1860 $head2[$h][2] =
'specifications';
1863 $head2[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
1864 $head2[$h][1] = $langs->trans(
"BuildPackage");
1865 $head2[$h][2] =
'buildpackage';
1869 print '<div class="center">'.$modulestatusinfo;
1870 print ' '.$linktoenabledisable.
'</div>';
1876 if ($tab ==
'description')
1878 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1879 $pathtofilereadme = $modulelowercase.
'/README.md';
1880 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
1882 if ($action !=
'editfile' || empty($file))
1886 print '<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
1887 $infoonmodulepath =
'';
1888 if (realpath($dirread.
'/'.$modulelowercase) != $dirread.
'/'.$modulelowercase)
1890 $infoonmodulepath =
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong>'.realpath($dirread.
'/'.$modulelowercase).
'</strong><br>';
1891 print ' '.$infoonmodulepath;
1898 print '<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
1899 print '</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
1902 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ReadmeFile").
' : <strong>'.$pathtofilereadme.
'</strong>';
1903 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=markdown&file='.urlencode($pathtofilereadme).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
1906 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ChangeLog").
' : <strong>'.$pathtochangelog.
'</strong>';
1907 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=markdown&file='.urlencode($pathtochangelog).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
1915 if (!empty($moduleobj))
1917 print
'<div class="underbanner clearboth"></div>';
1918 print
'<div class="fichecenter">';
1920 print
'<table class="border centpercent">';
1921 print
'<tr class="liste_titre"><td class="titlefield">';
1922 print $langs->trans(
"Parameter");
1924 print $langs->trans(
"Value");
1928 print $langs->trans(
"Numero");
1930 print $moduleobj->numero;
1931 print
' (<a href="'.DOL_URL_ROOT.
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info" target="_blank">'.$langs->trans(
"SeeIDsInUse").
'</a>';
1932 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
1936 print $langs->trans(
"Name");
1938 print $moduleobj->getName();
1942 print $langs->trans(
"Version");
1944 print $moduleobj->getVersion();
1948 print $langs->trans(
"Family");
1951 print $moduleobj->family;
1955 print $langs->trans(
"EditorName");
1957 print $moduleobj->editor_name;
1961 print $langs->trans(
"EditorUrl");
1963 print $moduleobj->editor_url;
1967 print $langs->trans(
"Description");
1969 print $moduleobj->getDesc();
1974 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
1977 if (!empty($moduleobj))
1984 print
'<!-- readme file -->';
1985 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
1986 else print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
1993 print
'<!-- changelog file -->';
1994 if (
dol_is_file($dirread.
'/'.$pathtochangelog)) print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
1995 else print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
2002 if ($fullpathoffile)
2004 $content = file_get_contents($fullpathoffile);
2008 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2009 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2010 print
'<input type="hidden" name="action" value="savefile">';
2011 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2012 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2013 print
'<input type="hidden" name="module" value="'.$module.
'">';
2017 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%',
'');
2018 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
2023 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2025 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2034 if ($tab ==
'languages')
2036 if ($action !=
'editfile' || empty($file))
2038 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
2042 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2043 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2044 print
'<input type="hidden" name="action" value="addlanguage">';
2045 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2046 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2047 print
'<input type="hidden" name="module" value="'.$module.
'">';
2048 print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT,
'newlangcode', 0, 0, 1, 0, 0,
'minwidth300', 1);
2049 print
'<input type="submit" name="addlanguage" class="button" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
2057 print
'<table class="none">';
2058 foreach ($langfiles as $langfile)
2060 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
2061 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong>'.$pathtofile.
'</strong>';
2062 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=txt&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2063 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2074 $content = file_get_contents($fullpathoffile);
2077 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2078 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2079 print
'<input type="hidden" name="action" value="savefile">';
2080 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2081 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2082 print
'<input type="hidden" name="module" value="'.$module.
'">';
2084 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
2085 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
2088 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2090 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2097 if ($tab ==
'dictionaries')
2099 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2101 $dicts = $moduleobj->dictionaries;
2103 if ($action !=
'editfile' || empty($file))
2105 print
'<span class="opacitymedium">';
2106 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'<a href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>');
2107 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
2111 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
2112 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2114 if (is_array($dicts) && !empty($dicts)) {
2115 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
2116 print
'<strong>'.$dicts[
'langs'].
'</strong>';
2120 print
load_fiche_titre($langs->trans(
"ListOfDictionariesEntries"),
'',
'');
2122 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2123 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2124 print
'<input type="hidden" name="action" value="addproperty">';
2125 print
'<input type="hidden" name="tab" value="objects">';
2126 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
2127 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
2129 print
'<div class="div-table-responsive">';
2130 print
'<table class="noborder">';
2132 print
'<tr class="liste_titre">';
2145 if (is_array($dicts) && is_array($dicts[
'tabname']))
2148 $maxi = count($dicts[
'tabname']);
2151 print
'<tr class="oddeven">';
2158 print $dicts[
'tabname'][$i];
2162 print $dicts[
'tablib'][$i];
2166 print $dicts[
'tabsql'][$i];
2170 print $dicts[
'tabsqlsort'][$i];
2174 print $dicts[
'tabfield'][$i];
2178 print $dicts[
'tabfieldvalue'][$i];
2182 print $dicts[
'tabfieldinsert'][$i];
2185 print
'<td class="right">';
2186 print $dicts[
'tabrowid'][$i];
2189 print
'<td class="right">';
2190 print $dicts[
'tabcond'][$i];
2197 print
'<tr><td class="opacitymedium" colspan="5">'.$langs->trans(
"None").
'</td></tr>';
2207 $content = file_get_contents($fullpathoffile);
2210 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2211 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2212 print
'<input type="hidden" name="action" value="savefile">';
2213 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2214 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2215 print
'<input type="hidden" name="module" value="'.$module.
'">';
2217 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
2218 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
2221 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2223 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2230 if ($tab ==
'objects')
2236 $dir = $dirread.
'/'.$modulelowercase.
'/class';
2238 $head3[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
2239 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
2240 $head3[$h][2] =
'newobject';
2244 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
2246 $firstobjectname =
'';
2247 foreach ($listofobject as $fileobj)
2249 if (preg_match(
'/^api_/', $fileobj[
'name']))
continue;
2250 if (preg_match(
'/^actions_/', $fileobj[
'name']))
continue;
2252 $tmpcontent = file_get_contents($fileobj[
'fullname']);
2253 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg))
2256 $objectname = $reg[1];
2257 if (empty($firstobjectname)) $firstobjectname = $objectname;
2259 $head3[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
2260 $head3[$h][1] = $objectname;
2261 $head3[$h][2] = $objectname;
2266 $head3[$h][0] =
$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
2267 $head3[$h][1] = $langs->trans(
"DangerZone");
2268 $head3[$h][2] =
'deleteobject';
2272 if ($tabobj ==
'newobjectifnoobj')
2274 if ($firstobjectname) $tabobj = $firstobjectname;
2275 else $tabobj =
'newobject';
2280 if ($tabobj ==
'newobject')
2283 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2284 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2285 print
'<input type="hidden" name="action" value="initobject">';
2286 print
'<input type="hidden" name="tab" value="objects">';
2287 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
2289 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
2291 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(
GETPOST(
'objectname',
'alpha') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ObjectKey")).
'"><br>';
2292 print
'<input type="checkbox" name="includerefgeneration" value="includerefgeneration"> '.$form->textwithpicto($langs->trans(
"IncludeRefGeneration"), $langs->trans(
"IncludeRefGenerationHelp")).
'<br>';
2293 print
'<input type="checkbox" name="includedocgeneration" value="includedocgeneration"> '.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'<br>';
2294 print
'<input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Generate")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
2298 print $langs->trans(
"or");
2302 print $langs->trans(
"InitStructureFromExistingTable");
2303 print
'<input type="text" name="initfromtablename" value="" placeholder="'.$langs->trans(
"TableName").
'">';
2304 print
'<input type="submit" class="button" name="createtablearray" value="'.dol_escape_htmltag($langs->trans(
"Generate")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
2308 } elseif ($tabobj ==
'deleteobject') {
2310 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2311 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2312 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
2313 print
'<input type="hidden" name="tab" value="objects">';
2314 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
2316 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
2318 print
'<input type="text" name="objectname" value="'.dol_escape_htmltag($modulename).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"ObjectKey")).
'">';
2319 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
2323 if ($action ==
'deleteproperty')
2325 $formconfirm = $form->formconfirm(
2326 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
2327 $langs->trans(
'Delete'), $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
'confirm_deleteproperty',
'', 0, 1
2334 if ($action !=
'editfile' || empty($file))
2339 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
2340 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
2341 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
2342 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
2343 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
2344 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
2345 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
2346 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
2347 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
2348 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
2349 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
2350 $pathtosqlkey = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.key.sql';
2351 $pathtosqlextrakey = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.key.sql';
2352 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
2353 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
2354 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
2355 $pathtoscript = strtolower($module).
'/scripts/'.strtolower($tabobj).
'.php';
2358 $realpathtoclass = $dirread.
'/'.$pathtoclass;
2359 $realpathtoapi = $dirread.
'/'.$pathtoapi;
2360 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
2361 $realpathtocard = $dirread.
'/'.$pathtocard;
2362 $realpathtodocument = $dirread.
'/'.$pathtodocument;
2363 $realpathtolist = $dirread.
'/'.$pathtolist;
2364 $realpathtonote = $dirread.
'/'.$pathtonote;
2365 $realpathtocontact = $dirread.
'/'.$pathtocontact;
2366 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
2367 $realpathtosql = $dirread.
'/'.$pathtosql;
2368 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
2369 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
2370 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
2371 $realpathtolib = $dirread.
'/'.$pathtolib;
2372 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
2373 $realpathtopicto = $dirread.
'/'.$pathtopicto;
2374 $realpathtoscript = $dirread.
'/'.$pathtoscript;
2376 if (empty($realpathtoapi))
2378 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
2379 $realpathtoapi = $dirread.
'/'.$pathtoapi;
2381 $urloflist = $dirread.
'/'.$pathtolist;
2382 $urlofcard = $dirread.
'/'.$pathtocard;
2384 print
'<div class="fichehalfleft">';
2385 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"ClassFile").
' : <strong>'.($realpathtoclass ?
'' :
'<strike>').$pathtoclass.($realpathtoclass ?
'' :
'</strike>').
'</strong>';
2386 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtoclass).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2388 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"ApiClassFile").
' : <strong>'.($realpathtoapi ?
'' :
'<strike>').$pathtoapi.($realpathtoapi ?
'' :
'</strike>').
'</strong>';
2390 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2392 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2394 if (empty($conf->global->$const_name))
2396 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"GoToApiExplorer").
'</strike></a>';
2398 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"GoToApiExplorer").
'</a>';
2402 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initapi&format=php&file='.urlencode($pathtoapi).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a>';
2406 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TestClassFile").
' : <strong>'.($realpathtophpunit ?
'' :
'<strike>').$pathtophpunit.($realpathtophpunit ?
'' :
'</strike>').
'</strong>';
2408 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtophpunit).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2410 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtophpunit).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2413 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initphpunit&format=php&file='.urlencode($pathtophpunit).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a>';
2419 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForLib").
' : <strong>'.($realpathtolib ?
'' :
'<strike>').$pathtolib.($realpathtolib ?
'' :
'</strike>').
'</strong>';
2420 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtolib).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2422 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForObjLib").
' : <strong>'.($realpathtoobjlib ?
'' :
'<strike>').$pathtoobjlib.($realpathtoobjlib ?
'' :
'</strike>').
'</strong>';
2423 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtoobjlib).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2425 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : <strong>'.($realpathtopicto ?
'' :
'<strike>').$pathtopicto.($realpathtopicto ?
'' :
'</strike>').
'</strong>';
2430 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFile").
' : <strong>'.($realpathtosql ?
'' :
'<strike>').$pathtosql.($realpathtosql ?
'' :
'</strike>').
'</strong>';
2431 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=sql&file='.urlencode($pathtosql).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2432 print
' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=droptable">'.$langs->trans(
"DropTableIfEmpty").
'</a>';
2435 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileKey").
' : <strong>'.($realpathtosqlkey ?
'' :
'<strike>').$pathtosqlkey.($realpathtosqlkey ?
'' :
'</strike>').
'</strong>';
2436 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=sql&file='.urlencode($pathtosqlkey).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2439 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileExtraFields").
' : <strong>'.($realpathtosqlextra ?
'' :
'<strike>').$pathtosqlextra.($realpathtosqlextra ?
'' :
'</strike>').
'</strong>';
2441 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2443 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2445 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=droptableextrafields">'.$langs->trans(
"DropTableIfEmpty").
'</a>';
2447 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initsqlextrafields&format=sql&file='.urlencode($pathtosqlextra).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a>';
2451 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileKeyExtraFields").
' : <strong>'.($realpathtosqlextrakey ?
'' :
'<strike>').$pathtosqlextrakey.($realpathtosqlextrakey ?
'' :
'</strike>').
'</strong>';
2453 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=sql&file='.urlencode($pathtosqlextrakey).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2455 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtosqlextrakey).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2457 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initsqlextrafields&format=sql&file='.urlencode($pathtosqlextra).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a>';
2465 print
'<div class="fichehalfleft">';
2466 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForList").
' : <strong><a href="'.$urloflist.
'" target="_test">'.($realpathtolist ?
'' :
'<strike>').$pathtolist.($realpathtolist ?
'' :
'</strike>').
'</a></strong>';
2467 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtolist).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2469 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForCreateEditView").
' : <strong><a href="'.$urlofcard.
'?action=create" target="_test">'.($realpathtocard ?
'' :
'<strike>').$pathtocard.($realpathtocard ?
'' :
'</strike>').
'?action=create</a></strong>';
2470 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtocard).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2472 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForContactTab").
' : <strong>'.($realpathtocontact ?
'' :
'<strike>').$pathtocontact.($realpathtocontact ?
'' :
'</strike>').
'</strong>';
2473 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2476 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtocontact).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2479 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForDocumentTab").
' : <strong>'.($realpathtodocument ?
'' :
'<strike>').$pathtodocument.($realpathtodocument ?
'' :
'</strike>').
'</strong>';
2480 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtodocument).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2483 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtodocument).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2486 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForNoteTab").
' : <strong>'.($realpathtonote ?
'' :
'<strike>').$pathtonote.($realpathtonote ?
'' :
'</strike>').
'</strong>';
2487 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2490 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2493 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForAgendaTab").
' : <strong>'.($realpathtoagenda ?
'' :
'<strike>').$pathtoagenda.($realpathtoagenda ?
'' :
'</strike>').
'</strong>';
2494 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtoagenda).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2497 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&file='.urlencode($pathtoagenda).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
2511 print
'<br><br><br>';
2513 if (function_exists(
'opcache_invalidate')) opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
2515 if (empty($forceddirread) && empty($dirread))
2519 $result = @include_once $dirread.
'/'.$pathtoclass;
2521 if (class_exists($tabobj))
2524 $tmpobjet = @
new $tabobj($db);
2527 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
2531 if (!empty($tmpobjet))
2533 $reflector =
new ReflectionClass($tabobj);
2534 $reflectorproperties = $reflector->getProperties();
2535 $reflectorpropdefault = $reflector->getDefaultProperties();
2539 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2540 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2541 print
'<input type="hidden" name="action" value="addproperty">';
2542 print
'<input type="hidden" name="tab" value="objects">';
2543 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
2544 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
2546 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
2551 print
'<!-- Table with properties of object -->'.
"\n";
2552 print
'<div class="div-table-responsive">';
2553 print
'<table class="noborder">';
2554 print
'<tr class="liste_titre">';
2555 print
'<th>'.$langs->trans(
"Property");
2556 print
' (<a class="" href="https://wiki.dolibarr.org/index.php/Language_and_development_rules#Table_and_fields_structures" target="_blank">'.$langs->trans(
"SeeExamples").
'</a>)';
2559 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
2561 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelp")).
'</th>';
2562 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
2563 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
2564 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
2565 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
2566 print
'<th class="center">'.$langs->trans(
"ForeignKey").
'</th>';
2567 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
2568 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc")).
'</th>';
2569 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visible"), $langs->trans(
"VisibleDesc")).
'</th>';
2570 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
2571 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
2572 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
2573 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
2574 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
2575 print
'<th class="center">'.$langs->trans(
"KeyForTooltip").
'</th>';
2576 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
2578 print
'<th>'.$langs->trans(
"Comment").
'</th>';
2585 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
2587 if (!empty($properties))
2591 print
'<td><input class="text maxwidth75" name="propname" value="'.dol_escape_htmltag(
GETPOST(
'propname',
'alpha')).
'"></td>';
2592 print
'<td><input class="text maxwidth75" name="proplabel" value="'.dol_escape_htmltag(
GETPOST(
'proplabel',
'alpha')).
'"></td>';
2593 print
'<td><input class="text maxwidth75" name="proptype" value="'.dol_escape_htmltag(
GETPOST(
'proptype',
'alpha')).
'"></td>';
2594 print
'<td><input class="text maxwidth75" name="proparrayofkeyval" value="'.dol_escape_htmltag(
GETPOST(
'proparrayofkeyval',
'restricthtml')).
'"></td>';
2595 print
'<td class="center"><input class="text" size="2" name="propnotnull" value="'.dol_escape_htmltag(
GETPOST(
'propnotnull',
'alpha')).
'"></td>';
2596 print
'<td><input class="text maxwidth50" name="propdefault" value="'.dol_escape_htmltag(
GETPOST(
'propdefault',
'alpha')).
'"></td>';
2597 print
'<td class="center"><input class="text" size="2" name="propindex" value="'.dol_escape_htmltag(
GETPOST(
'propindex',
'alpha')).
'"></td>';
2598 print
'<td class="center"><input class="text" size="2" name="propforeignkey" value="'.dol_escape_htmltag(
GETPOST(
'propforeignkey',
'alpha')).
'"></td>';
2599 print
'<td class="right"><input class="text right" size="2" name="propposition" value="'.dol_escape_htmltag(
GETPOST(
'propposition',
'alpha')).
'"></td>';
2600 print
'<td class="center"><input class="text" size="2" name="propenabled" value="'.dol_escape_htmltag(
GETPOST(
'propenabled',
'alpha')).
'"></td>';
2601 print
'<td class="center"><input class="text" size="2" name="propvisible" value="'.dol_escape_htmltag(
GETPOST(
'propvisible',
'alpha')).
'"></td>';
2602 print
'<td class="center"><input class="text" size="2" name="propnoteditable" value="'.dol_escape_htmltag(
GETPOST(
'propnoteditable',
'alpha')).
'"></td>';
2603 print
'<td class="center"><input class="text" size="2" name="propsearchall" value="'.dol_escape_htmltag(
GETPOST(
'propsearchall',
'alpha')).
'"></td>';
2604 print
'<td class="center"><input class="text" size="2" name="propisameasure" value="'.dol_escape_htmltag(
GETPOST(
'propisameasure',
'alpha')).
'"></td>';
2605 print
'<td class="center"><input class="text" size="2" name="propcss" value="'.dol_escape_htmltag(
GETPOST(
'propcss',
'alpha')).
'"></td>';
2606 print
'<td class="center"><input class="text" size="2" name="propcssview" value="'.dol_escape_htmltag(
GETPOST(
'propcssview',
'alpha')).
'"></td>';
2607 print
'<td class="center"><input class="text" size="2" name="prophelp" value="'.dol_escape_htmltag(
GETPOST(
'prophelp',
'alpha')).
'"></td>';
2608 print
'<td class="center"><input class="text" size="2" name="propshowoncombobox" value="'.dol_escape_htmltag(
GETPOST(
'propshowoncombobox',
'alpha')).
'"></td>';
2610 print
'<td><input class="text maxwidth100" name="propcomment" value="'.dol_escape_htmltag(
GETPOST(
'propcomment',
'alpha')).
'"></td>';
2611 print
'<td class="center">';
2612 print
'<input class="button" type="submit" name="add" value="'.$langs->trans(
"Add").
'">';
2616 foreach ($properties as $propkey => $propval)
2632 $propname = $propkey;
2633 $proplabel = $propval[
'label'];
2634 $proptype = $propval[
'type'];
2635 $proparrayofkeyval = $propval[
'arrayofkeyval'];
2636 $propnotnull = $propval[
'notnull'];
2637 $propdefault = $propval[
'default'];
2638 $propindex = $propval[
'index'];
2639 $propforeignkey = $propval[
'foreignkey'];
2640 $propposition = $propval[
'position'];
2641 $propenabled = $propval[
'enabled'];
2642 $propvisible = $propval[
'visible'];
2643 $propnoteditable = $propval[
'noteditable'];
2644 $propsearchall = $propval[
'searchall'];
2645 $propisameasure = $propval[
'isameasure'];
2646 $propcss = $propval[
'css'];
2647 $propcssview = $propval[
'cssview'];
2648 $prophelp = $propval[
'help'];
2649 $propshowoncombobox = $propval[
'showoncombobox'];
2651 $propcomment = $propval[
'comment'];
2653 print
'<tr class="oddeven">';
2661 print
'<td class="tdoverflowmax200">';
2662 print
'<span title="'.dol_escape_htmltag($proptype).
'">'.
dol_escape_htmltag($proptype).
'</span>';
2664 print
'<td class="tdoverflowmax200">';
2665 if ($proparrayofkeyval) {
2666 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval)).
'">';
2671 print
'<td class="center">';
2677 print
'<td class="center">';
2678 print $propindex ?
'1' :
'';
2680 print
'<td class="center">';
2683 print
'<td class="right">';
2686 print
'<td class="center">';
2689 print
'<td class="center">';
2692 print
'<td class="center">';
2695 print
'<td class="center">';
2696 print $propsearchall ?
'1' :
'';
2698 print
'<td class="center">';
2701 print
'<td class="center">';
2704 print
'<td class="center">';
2707 print
'<td class="tdoverflowmax200">';
2710 print
'<td class="center">';
2716 print
'<td class="tdoverflowmax200">';
2717 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
2721 print
'<td class="center">';
2722 if ($propname !=
'rowid')
2724 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteproperty&token='.
newToken().
'&propertykey='.urlencode($propname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_delete().
'</a>';
2731 if ($tab ==
'specifications')
2733 if ($action !=
'editfile' || empty($file))
2735 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
2740 foreach ($specs as $spec)
2742 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
2743 $format =
'asciidoc';
2744 if (preg_match(
'/\.md$/i', $spec[
'name'])) $format =
'markdown';
2745 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong>'.$pathtofile.
'</strong>';
2746 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2756 $content = file_get_contents($fullpathoffile);
2759 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2760 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2761 print
'<input type="hidden" name="action" value="savefile">';
2762 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2763 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2764 print
'<input type="hidden" name="module" value="'.$module.
'">';
2766 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
2767 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
2770 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2772 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2778 print
'<tr><td><span class="warning">'.$langs->trans(
'Property $field not found into the class. The class was probably not generated by modulebuilder.').
'</warning></td></tr>';
2785 print
'<tr><td><span class="warning">'.$langs->trans(
'Failed to init the object with the new.').
'</warning></td></tr>';
2789 print $e->getMessage();
2792 if (empty($forceddirread))
2796 $fullpathoffile = $dirread.
'/'.$file;
2799 $content = file_get_contents($fullpathoffile);
2802 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2803 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2804 print
'<input type="hidden" name="action" value="savefile">';
2805 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2806 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2807 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
2808 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
2810 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
2811 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
2814 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2816 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2826 if ($tab ==
'menus')
2828 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2830 $menus = $moduleobj->menu;
2832 if ($action !=
'editfile' || empty($file))
2834 print
'<span class="opacitymedium">';
2835 $htmlhelp = $langs->trans(
"MenusDefDescTooltip",
'<a href="'.DOL_URL_ROOT.
'/admin/menus/index.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Menus').
'</a>');
2836 print $form->textwithpicto($langs->trans(
"MenusDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
2840 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
2841 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2847 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2848 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2849 print
'<input type="hidden" name="action" value="addproperty">';
2850 print
'<input type="hidden" name="tab" value="objects">';
2851 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
2852 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
2854 print
'<div class="div-table-responsive">';
2855 print
'<table class="noborder">';
2857 print
'<tr class="liste_titre">';
2874 foreach ($menus as $menu)
2876 print
'<tr class="oddeven">';
2879 print $menu[
'type'];
2883 print $menu[
'fk_menu'];
2887 print $menu[
'titre'];
2891 print $menu[
'mainmenu'];
2895 print $menu[
'leftmenu'];
2903 print $menu[
'langs'];
2907 print $menu[
'position'];
2911 print $menu[
'enabled'];
2915 print $menu[
'perms'];
2919 print $menu[
'target'];
2922 print
'<td class="right">';
2923 print $menu[
'user'];
2929 print
'<tr><td class="opacitymedium" colspan="5">'.$langs->trans(
"None").
'</td></tr>';
2939 $content = file_get_contents($fullpathoffile);
2942 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2943 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2944 print
'<input type="hidden" name="action" value="savefile">';
2945 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
2946 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
2947 print
'<input type="hidden" name="module" value="'.$module.
'">';
2949 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
2950 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
2953 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
2955 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
2962 if ($tab ==
'permissions')
2964 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2966 $perms = $moduleobj->rights;
2968 if ($action !=
'editfile' || empty($file))
2970 print
'<span class="opacitymedium">';
2971 $htmlhelp = $langs->trans(
"PermissionsDefDescTooltip",
'<a href="'.DOL_URL_ROOT.
'/admin/perms.php">'.$langs->trans(
'DefaultPermissions').
'</a>');
2972 print $form->textwithpicto($langs->trans(
"PermissionsDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
2976 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
2977 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
2983 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
2984 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2985 print
'<input type="hidden" name="action" value="addproperty">';
2986 print
'<input type="hidden" name="tab" value="objects">';
2987 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
2988 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
2990 print
'<div class="div-table-responsive">';
2991 print
'<table class="noborder">';
2993 print
'<tr class="liste_titre">';
3002 foreach ($perms as $perm)
3004 print
'<tr class="oddeven">';
3025 print
'<tr><td class="opacitymedium" colspan="4">'.$langs->trans(
"None").
'</td></tr>';
3035 $content = file_get_contents($fullpathoffile);
3038 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3039 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3040 print
'<input type="hidden" name="action" value="savefile">';
3041 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3042 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3043 print
'<input type="hidden" name="module" value="'.$module.
'">';
3045 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3046 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3049 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3051 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3058 if ($tab ==
'hooks')
3060 if ($action !=
'editfile' || empty($file))
3062 print
'<span class="opacitymedium">'.$langs->trans(
"HooksDefDesc").
'</span><br>';
3067 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3069 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="">'.$pathtofile.
'</strong>';
3071 print
'<a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3075 $pathtohook = strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
3076 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"HooksFile").
' : ';
3079 print
'<strong>'.$pathtohook.
'</strong>';
3081 print
'<td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a> ';
3082 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3084 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
3085 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inithook&format=php&file='.urlencode($pathtohook).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a></td>';
3092 $content = file_get_contents($fullpathoffile);
3095 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3096 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3097 print
'<input type="hidden" name="action" value="savefile">';
3098 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3099 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3100 print
'<input type="hidden" name="module" value="'.$module.
'">';
3102 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3103 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3106 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3108 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3115 if ($tab ==
'triggers')
3117 require_once DOL_DOCUMENT_ROOT.
'/core/class/interfaces.class.php';
3120 $triggers = $interfaces->getTriggersList(array(
'/'.strtolower($module).
'/core/triggers'));
3122 if ($action !=
'editfile' || empty($file))
3124 print
'<span class="opacitymedium">'.$langs->trans(
"TriggerDefDesc").
'</span><br>';
3129 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3131 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="">'.$pathtofile.
'</strong>';
3133 print
'<a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3136 if (!empty($triggers))
3138 foreach ($triggers as $trigger)
3140 $pathtofile = $trigger[
'relpath'];
3143 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TriggersFile").
' : <strong>'.$pathtofile.
'</strong>';
3144 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
3145 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3150 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"NoTrigger");
3151 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=inittrigger&format=php"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a></td>';
3160 $content = file_get_contents($fullpathoffile);
3163 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3164 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3165 print
'<input type="hidden" name="action" value="savefile">';
3166 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3167 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3168 print
'<input type="hidden" name="module" value="'.$module.
'">';
3170 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3171 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3174 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3176 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3185 if ($action !=
'editfile' || empty($file))
3187 print
'<span class="opacitymedium">'.$langs->trans(
"CSSDesc").
'</span><br>';
3193 $pathtohook = strtolower($module).
'/css/'.strtolower($module).
'.css.php';
3194 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"CSSFile").
' : ';
3197 print
'<strong>'.$pathtohook.
'</strong>';
3198 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
3199 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3201 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
3202 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcss&format=php&file='.urlencode($pathtohook).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a></td>';
3208 $content = file_get_contents($fullpathoffile);
3211 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3212 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3213 print
'<input type="hidden" name="action" value="savefile">';
3214 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3215 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3216 print
'<input type="hidden" name="module" value="'.$module.
'">';
3218 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3219 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3222 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3224 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3233 if ($action !=
'editfile' || empty($file))
3235 print
'<span class="opacitymedium">'.$langs->trans(
"JSDesc").
'</span><br>';
3241 $pathtohook = strtolower($module).
'/js/'.strtolower($module).
'.js.php';
3242 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"JSFile").
' : ';
3245 print
'<strong>'.$pathtohook.
'</strong>';
3246 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
3247 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtohook).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3249 print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
3250 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initjs&format=php&file='.urlencode($pathtohook).
'"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a></td>';
3256 $content = file_get_contents($fullpathoffile);
3259 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3260 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3261 print
'<input type="hidden" name="action" value="savefile">';
3262 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3263 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3264 print
'<input type="hidden" name="module" value="'.$module.
'">';
3266 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3267 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3270 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3272 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3279 if ($tab ==
'widgets')
3281 require_once DOL_DOCUMENT_ROOT.
'/core/boxes/modules_boxes.php';
3285 if ($action !=
'editfile' || empty($file))
3287 print
'<span class="opacitymedium">'.$langs->trans(
"WidgetDesc").
'</span><br>';
3291 if (!empty($widgets))
3293 foreach ($widgets as $widget)
3295 $pathtofile = $widget[
'relpath'];
3297 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"WidgetFile").
' : <strong>'.$pathtofile.
'</strong>';
3298 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3299 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3303 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"NoWidget");
3304 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initwidget&format=php"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a>';
3311 $content = file_get_contents($fullpathoffile);
3314 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3315 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3316 print
'<input type="hidden" name="action" value="savefile">';
3317 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3318 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3319 print
'<input type="hidden" name="module" value="'.$module.
'">';
3321 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3322 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3325 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3327 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3336 $clifiles = array();
3339 $dircli = array(
'/'.strtolower($module).
'/scripts');
3341 foreach ($dircli as $reldir)
3347 if (!is_dir($newdir))
continue;
3349 $handle = opendir($newdir);
3350 if (is_resource($handle))
3352 while (($tmpfile = readdir($handle)) !==
false)
3354 if (is_readable($newdir.
'/'.$file) && preg_match(
'/^(.+)\.php/', $tmpfile, $reg))
3356 if (preg_match(
'/\.back$/', $tmpfile))
continue;
3358 $clifiles[$i][
'relpath'] = preg_replace(
'/^\//',
'', $reldir).
'/'.$tmpfile;
3367 if ($action !=
'editfile' || empty($file))
3369 print
'<span class="opacitymedium">'.$langs->trans(
"CLIDesc").
'</span><br>';
3373 if (!empty($clifiles))
3375 foreach ($clifiles as $clifile)
3377 $pathtofile = $clifile[
'relpath'];
3379 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"CLIFile").
' : <strong>'.$pathtofile.
'</strong>';
3380 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
3381 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3385 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"NoCLIFile");
3386 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initcli&format=php"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a>';
3393 $content = file_get_contents($fullpathoffile);
3396 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3397 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3398 print
'<input type="hidden" name="action" value="savefile">';
3399 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3400 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3401 print
'<input type="hidden" name="module" value="'.$module.
'">';
3403 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3404 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3407 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3409 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3418 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3420 $cronjobs = $moduleobj->cronjobs;
3422 if ($action !=
'editfile' || empty($file))
3424 print
'<span class="opacitymedium">'.str_replace(
'{s1}',
'<a href="'.DOL_URL_ROOT.
'/cron/list.php">'.$langs->transnoentities(
'CronList').
'</a>', $langs->trans(
"CronJobDefDesc",
'{s1}')).
'</span><br>';
3427 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong>'.$pathtofile.
'</strong>';
3428 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3434 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3435 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3436 print
'<input type="hidden" name="action" value="addproperty">';
3437 print
'<input type="hidden" name="tab" value="objects">';
3438 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3439 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
3441 print
'<div class="div-table-responsive">';
3442 print
'<table class="noborder">';
3444 print
'<tr class="liste_titre">';
3452 if (count($cronjobs))
3454 foreach ($cronjobs as $cron)
3456 print
'<tr class="oddeven">';
3459 print $cron[
'label'];
3463 if ($cron[
'jobtype'] ==
'method')
3465 $text = $langs->trans(
"CronClass");
3466 $texttoshow = $langs->trans(
'CronModule').
': '.$module.
'<br>';
3467 $texttoshow .= $langs->trans(
'CronClass').
': '.$cron[
'class'].
'<br>';
3468 $texttoshow .= $langs->trans(
'CronObject').
': '.$cron[
'objectname'].
'<br>';
3469 $texttoshow .= $langs->trans(
'CronMethod').
': '.$cron[
'method'];
3470 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
3471 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
3472 } elseif ($cron[
'jobtype'] ==
'command')
3474 $text = $langs->trans(
'CronCommand');
3475 $texttoshow = $langs->trans(
'CronCommand').
': '.
dol_trunc($cron[
'command']);
3476 $texttoshow .=
'<br>'.$langs->trans(
'CronArgs').
': '.$cron[
'parameters'];
3477 $texttoshow .=
'<br>'.$langs->trans(
'Comment').
': '.$langs->trans($cron[
'comment']);
3479 print $form->textwithpicto($text, $texttoshow, 1);
3483 if ($cron[
'unitfrequency'] ==
"60") print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Minutes');
3484 if ($cron[
'unitfrequency'] ==
"3600") print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Hours');
3485 if ($cron[
'unitfrequency'] ==
"86400") print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Days');
3486 if ($cron[
'unitfrequency'] ==
"604800") print $langs->trans(
'CronEach').
" ".($cron[
'frequency']).
" ".$langs->trans(
'Weeks');
3490 print $cron[
'status'];
3494 if (!empty($cron[
'comment'])) {print $cron[
'comment']; }
3500 print
'<tr><td class="opacitymedium" colspan="5">'.$langs->trans(
"None").
'</td></tr>';
3510 $content = file_get_contents($fullpathoffile);
3513 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3514 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3515 print
'<input type="hidden" name="action" value="savefile">';
3516 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3517 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3518 print
'<input type="hidden" name="module" value="'.$module.
'">';
3520 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3521 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3524 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3526 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3533 if ($tab ==
'specifications')
3537 if ($action !=
'editfile' || empty($file))
3539 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
3543 if (is_array($specs) && !empty($specs))
3545 foreach ($specs as $spec)
3547 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
3548 $format =
'asciidoc';
3549 if (preg_match(
'/\.md$/i', $spec[
'name'])) $format =
'markdown';
3551 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong>'.$pathtofile.
'</strong>';
3552 print
'</td><td><a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a></td>';
3553 print
'<td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a></td>';
3558 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"FileNotYetGenerated");
3559 print
'</td><td><a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.$tab.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initdoc&format=php"><input type="button" class="button smallpaddingimp" value="'.$langs->trans(
"Generate").
'"></a></td>';
3570 $content = file_get_contents($fullpathoffile);
3573 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3574 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3575 print
'<input type="hidden" name="action" value="savefile">';
3576 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3577 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3578 print
'<input type="hidden" name="module" value="'.$module.
'">';
3580 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3581 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3584 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3586 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3592 print
'<br><br><br>';
3594 $FILENAMEDOC = $modulelowercase.
'.html';
3595 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
3596 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
3597 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
3598 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
3599 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
3602 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModuleDocumentation",
"HTML").
' : ';
3603 if (!
dol_is_file($outputfiledoc)) print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
3606 print
'<a href="'.$outputfiledocurl.
'" target="_blank">';
3607 print $outputfiledoc;
3612 print
'</strong><br>';
3615 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModuleDocumentation",
"PDF").
' : ';
3616 if (!
dol_is_file($outputfiledocpdf)) print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
3619 print
'<a href="'.$outputfiledocurlpdf.
'" target="_blank">';
3620 print $outputfiledocpdf;
3625 print
'</strong><br>';
3629 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatedoc">';
3630 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3631 print
'<input type="hidden" name="action" value="generatedoc">';
3632 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3633 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3634 print
'<input type="submit" class="button" name="generatedoc" value="'.$langs->trans(
"BuildDocumentation").
'"';
3635 if (!is_array($specs) || empty($specs)) print
' disabled="disabled"';
3640 if ($tab ==
'buildpackage')
3642 print
'<span class="opacitymedium">'.$langs->trans(
"BuildPackageDesc").
'</span>';
3645 if (!class_exists(
'ZipArchive') && !defined(
'ODTPHP_PATHTOPCLZIP'))
3647 print
img_warning().
' '.$langs->trans(
"ErrNoZipEngine");
3651 $modulelowercase = strtolower($module);
3657 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3659 $class =
'mod'.$module;
3661 if (class_exists($class))
3664 $moduleobj =
new $class($db);
3671 $langs->load(
"errors");
3672 dol_print_error($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
3676 $arrayversion = explode(
'.', $moduleobj->version, 3);
3677 if (count($arrayversion))
3679 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].
'.'.$arrayversion[1].($arrayversion[2] ?
".".$arrayversion[2] :
"").
".zip";
3680 $outputfilezip =
dol_buildpath($modulelowercase, 0).
'/bin/'.$FILENAMEZIP;
3685 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PathToModulePackage").
' : ';
3686 if (!
dol_is_file($outputfilezip)) print
'<span class="opacitymedium">'.$langs->trans(
"FileNotYetGenerated").
'</span>';
3688 $relativepath = $modulelowercase.
'/bin/'.$FILENAMEZIP;
3689 print
'<strong><a href="'.DOL_URL_ROOT.
'/document.php?modulepart=packages&file='.urlencode($relativepath).
'">'.$outputfilezip.
'</a></strong>';
3692 print
'</strong><br>';
3696 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="generatepackage">';
3697 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3698 print
'<input type="hidden" name="action" value="generatepackage">';
3699 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3700 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3701 print
'<input type="submit" class="button" name="generatepackage" value="'.$langs->trans(
"BuildPackage").
'">';
3705 if ($tab !=
'description')
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage utility methods.
dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
Copy a file to another file.
dolCopyDir($srcfile, $destfile, $newmask, $overwriteifexists, $arrayreplacement=null, $excludesubdir=0)
Copy a dir to another dir.
dol_sanitizePathName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a path name.
unActivateModule($value, $requiredby=1)
Disable a module.
dol_now($mode= 'auto')
Return date for now.
static getWidgetsList($forcedirwidget=null)
Return list of widget.
dol_is_dir($folder)
Test if filename is a directory.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
dol_mimetype($file, $default= 'application/octet-stream', $mode=0)
Return mime type of a file.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
dol_delete_dir_recursive($dir, $count=0, $nophperrors=0, $onlysub=0, &$countdeleted=0)
Remove a directory $dir and its subdirectories (or only files and subdirectories) ...
dol_delete_file($file, $disableglob=0, $nophperrors=0, $nohook=0, $object=null, $allowdotdot=false, $indexdatabase=1)
Remove a file or several files with a mask.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
dol_is_file($pathoffile)
Return if path is a file.
print $_SERVER["PHP_SELF"]
Edit parameters.
dolReplaceInFile($srcfile, $arrayreplacement, $destfile= '', $newmask=0, $indexdatabase=0, $arrayreplacementisregex=0)
Make replacement of strings into a file.
dol_sort_array(&$array, $index, $order= 'asc', $natsort=0, $case_sensitive=0, $keepindex=0)
Advanced sort array by second index function, which produces ascending (default) or descending output...
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_filemtime($pathoffile)
Return time of a file.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
activateModule($value, $withdeps=1)
Enable a module.
Class to manage a WYSIWYG editor.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
dol_delete_dir($dir, $nophperrors=0)
Remove a directory (not recursive, so content must be empty).
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
Class to manage triggers.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
dol_is_dir_empty($dir)
Return if path is empty.