225 $error = error_get_last();
226 if ($error && ($error[
'type'] & (E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR))) {
228 echo
"Fatal error occurred: {$error['message']} in {$error['file']} on line {$error['line']}";
230 if (headers_sent()) {
235register_shutdown_function(
"moduleBuilderShutdownFunction");
242if ($dirins && $action ==
'initmodule' && $modulename) {
243 $modulename = ucfirst($modulename);
245 if (preg_match(
'/[^a-z0-9_]/i', $modulename)) {
247 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
251 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
252 $destdir = $dirins.
'/'.strtolower($modulename);
254 $arrayreplacement = array(
255 'mymodule' => strtolower($modulename),
256 'MyModule' => $modulename
258 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayreplacement);
263 $langs->load(
"errors");
264 setEventMessages($langs->trans(
"ErrorFailToCopyDir", $srcdir, $destdir),
null,
'errors');
267 setEventMessages($langs->trans(
"AllFilesDidAlreadyExist", $srcdir, $destdir),
null,
'warnings');
273 $tryToCopyFromSetupClass =
true;
274 $backportDest = $destdir .
'/backport/v16/core/class';
275 $backportFileSrc = DOL_DOCUMENT_ROOT.
'/core/class/html.formsetup.class.php';
276 $backportFileDest = $backportDest.
'/html.formsetup.class.php';
281 $langs->load(
"errors");
282 setEventMessages($langs->trans(
"ErrorFailToCreateDir", $backportDest),
null,
'errors');
283 $tryToCopyFromSetupClass =
false;
286 if ($tryToCopyFromSetupClass) {
287 $result =
dol_copy($backportFileSrc, $backportFileDest);
291 $langs->load(
"errors");
292 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $backportFileSrc, $backportFileDest),
null,
'errors');
294 setEventMessages($langs->trans(
"FileDidAlreadyExist", $backportFileDest),
null,
'warnings');
317 dol_delete_file($destdir.
'/class/actions_'.strtolower($modulename).
'.class.php');
318 dol_delete_file($destdir.
'/class/api_'.strtolower($modulename).
'.class.php');
336 dol_delete_file($destdir.
'/lib/'.strtolower($modulename).
'_myobject.lib.php');
337 dol_delete_file($destdir.
'/test/phpunit/functional/'.$modulename.
'FunctionalTest.php');
339 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.sql');
340 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.sql');
341 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject.key.sql');
342 dol_delete_file($destdir.
'/sql/llx_'.strtolower($modulename).
'_myobject_extrafields.key.sql');
357 $listofphpfilestoedit =
dol_dir_list($destdir,
'files', 1,
'\.(php|MD|js|sql|txt|xml|lang)$',
'',
'fullname', SORT_ASC, 0, 1);
358 foreach ($listofphpfilestoedit as $phpfileval) {
360 $arrayreplacement = array(
361 'mymodule' => strtolower($modulename),
362 'MyModule' => $modulename,
363 'MYMODULE' => strtoupper($modulename),
364 'My module' => $modulename,
365 'my module' => $modulename,
366 'Mon module' => $modulename,
367 'mon module' => $modulename,
368 'htdocs/modulebuilder/template' => strtolower($modulename),
369 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
370 'Editor name' => $editorname,
371 'https://www.example.com' => $editorurl,
372 '$this->version = \'1.0\'' =>
'$this->version = \''.$version.
'\'',
373 '$this->picto = \'generic\';' => (empty($picto)) ?
'$this->picto = \'generic\'' :
'$this->picto = \''.$picto.
'\';',
374 "modulefamily" => $family,
375 '500000' => $idmodule
379 $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
386 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
391 setEventMessages($langs->trans(
"ContentOfREADMECustomized"),
null,
'warnings');
393 file_put_contents($destdir.
'/README.md', $conf->global->MODULEBUILDER_SPECIFIC_README);
404 $module = $modulename;
406 clearstatcache(
true);
407 if (function_exists(
'opcache_invalidate')) {
411 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module='.$modulename);
418if ($dirins && in_array($action, array(
'initapi',
'initphpunit',
'initpagecontact',
'initpagedocument',
'initpagenote',
'initpageagenda')) && !empty($module)) {
419 $modulename = ucfirst($module);
420 $objectname = $tabobj;
421 $varnametoupdate =
'';
422 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
423 $destdir = $dirins.
'/'.strtolower($module);
429 if ($action ==
'initapi') {
430 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
431 $result =
dol_copy(DOL_DOCUMENT_ROOT.
'/modulebuilder/template/class/api_mymodule.class.php', $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php', 0, 1);
433 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
434 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
435 $srcfile = $srcdir.
'/class/api_mymodule.class.php';
436 $destfile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
437 } elseif ($action ==
'initphpunit') {
438 dol_mkdir($dirins.
'/'.strtolower($module).
'/test/phpunit');
439 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
440 $srcfile = $srcdir.
'/test/phpunit/MyObjectTest.php';
441 $destfile = $dirins.
'/'.strtolower($module).
'/test/phpunit/'.strtolower($objectname).
'Test.php';
442 } elseif ($action ==
'initpagecontact') {
443 dol_mkdir($dirins.
'/'.strtolower($module));
444 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
445 $srcfile = $srcdir.
'/myobject_contact.php';
446 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_contact.php';
447 $varnametoupdate =
'showtabofpagecontact';
448 } elseif ($action ==
'initpagedocument') {
449 dol_mkdir($dirins.
'/'.strtolower($module));
450 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
451 $srcfile = $srcdir.
'/myobject_document.php';
452 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_document.php';
453 $varnametoupdate =
'showtabofpagedocument';
454 } elseif ($action ==
'initpagenote') {
455 dol_mkdir($dirins.
'/'.strtolower($module));
456 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
457 $srcfile = $srcdir.
'/myobject_note.php';
458 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_note.php';
459 $varnametoupdate =
'showtabofpagenote';
460 } elseif ($action ==
'initpageagenda') {
461 dol_mkdir($dirins.
'/'.strtolower($module));
462 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
463 $srcfile = $srcdir.
'/myobject_agenda.php';
464 $destfile = $dirins.
'/'.strtolower($module).
'/'.strtolower($objectname).
'_agenda.php';
465 $varnametoupdate =
'showtabofpageagenda';
470 if (!file_exists($destfile)) {
471 $result =
dol_copy($srcfile, $destfile, 0, 0);
476 $arrayreplacement = array(
477 'mymodule' => strtolower($modulename),
478 'MyModule' => $modulename,
479 'MYMODULE' => strtoupper($modulename),
480 'My module' => $modulename,
481 'my module' => $modulename,
482 'Mon module' => $modulename,
483 'mon module' => $modulename,
484 'htdocs/modulebuilder/template' => strtolower($modulename),
485 'myobject' => strtolower($objectname),
486 'MyObject' => $objectname,
487 'MYOBJECT' => strtoupper($objectname),
488 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
491 if ($action ==
'initapi') {
492 if (count($objects) >= 1) {
500 if ($varnametoupdate) {
502 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
503 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 0;/' =>
'$'.$varnametoupdate.
' = 1;');
508 $langs->load(
"errors");
509 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
515if ($dirins && $action ==
'initsqlextrafields' && !empty($module)) {
516 $modulename = ucfirst($module);
517 $objectname = $tabobj;
519 dol_mkdir($dirins.
'/'.strtolower($module).
'/sql');
520 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
521 $srcfile1 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.sql';
522 $destfile1 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql';
525 $result1 =
dol_copy($srcfile1, $destfile1, 0, 0);
526 $srcfile2 = $srcdir.
'/sql/llx_mymodule_myobject_extrafields.key.sql';
527 $destfile2 = $dirins.
'/'.strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql';
530 $result2 =
dol_copy($srcfile2, $destfile2, 0, 0);
532 if ($result1 > 0 && $result2 > 0) {
533 $modulename = ucfirst($module);
536 $arrayreplacement = array(
537 'mymodule' => strtolower($modulename),
538 'MyModule' => $modulename,
539 'MYMODULE' => strtoupper($modulename),
540 'My module' => $modulename,
541 'my module' => $modulename,
542 'Mon module' => $modulename,
543 'mon module' => $modulename,
544 'htdocs/modulebuilder/template' => strtolower($modulename),
545 'My Object' => $objectname,
546 'MyObject' => $objectname,
547 'my object' => strtolower($objectname),
548 'myobject' => strtolower($objectname),
549 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
555 $langs->load(
"errors");
557 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile1),
null,
'errors');
560 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile2),
null,
'errors');
565 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
566 $arrayreplacement = array(
'/\$this->isextrafieldmanaged = 0;/' =>
'$this->isextrafieldmanaged = 1;');
572if ($dirins && $action ==
'inithook' && !empty($module)) {
573 dol_mkdir($dirins.
'/'.strtolower($module).
'/class');
574 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
575 $srcfile = $srcdir.
'/class/actions_mymodule.class.php';
576 $destfile = $dirins.
'/'.strtolower($module).
'/class/actions_'.strtolower($module).
'.class.php';
579 $result =
dol_copy($srcfile, $destfile, 0, 0);
582 $modulename = ucfirst($module);
585 $arrayreplacement = array(
586 'mymodule' => strtolower($modulename),
587 'MyModule' => $modulename,
588 'MYMODULE' => strtoupper($modulename),
589 'My module' => $modulename,
590 'my module' => $modulename,
591 'Mon module' => $modulename,
592 'mon module' => $modulename,
593 'htdocs/modulebuilder/template' => strtolower($modulename),
594 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
600 $langs->load(
"errors");
601 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
607if ($dirins && $action ==
'inittrigger' && !empty($module)) {
608 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/triggers');
609 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
610 $srcfile = $srcdir.
'/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php';
611 $destfile = $dirins.
'/'.strtolower($module).
'/core/triggers/interface_99_mod'.$module.
'_'.$module.
'Triggers.class.php';
614 $result =
dol_copy($srcfile, $destfile, 0, 0);
617 $modulename = ucfirst($module);
620 $arrayreplacement = array(
621 'mymodule' => strtolower($modulename),
622 'MyModule' => $modulename,
623 'MYMODULE' => strtoupper($modulename),
624 'My module' => $modulename,
625 'my module' => $modulename,
626 'Mon module' => $modulename,
627 'mon module' => $modulename,
628 'htdocs/modulebuilder/template' => strtolower($modulename),
629 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
635 $langs->load(
"errors");
636 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
642if ($dirins && $action ==
'initwidget' && !empty($module)) {
643 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/boxes');
644 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
645 $srcfile = $srcdir.
'/core/boxes/mymodulewidget1.php';
646 $destfile = $dirins.
'/'.strtolower($module).
'/core/boxes/'.strtolower($module).
'widget1.php';
649 $result =
dol_copy($srcfile, $destfile, 0, 0);
652 $modulename = ucfirst($module);
655 $arrayreplacement = array(
656 'mymodule' => strtolower($modulename),
657 'MyModule' => $modulename,
658 'MYMODULE' => strtoupper($modulename),
659 'My module' => $modulename,
660 'my module' => $modulename,
661 'Mon module' => $modulename,
662 'mon module' => $modulename,
663 'htdocs/modulebuilder/template' => strtolower($modulename),
664 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
670 $langs->load(
"errors");
671 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
677if ($dirins && $action ==
'initemailing' && !empty($module)) {
678 dol_mkdir($dirins.
'/'.strtolower($module).
'/core/modules/mailings');
679 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
680 $srcfile = $srcdir.
'/core/modules/mailings/mailing_mymodule_selector1.modules.php';
681 $destfile = $dirins.
'/'.strtolower($module).
'/core/modules/mailings/mailing_'.strtolower($module).
'_selector1.modules.php';
684 $result =
dol_copy($srcfile, $destfile, 0, 0);
687 $modulename = ucfirst($module);
690 $arrayreplacement = array(
691 'mymodule' => strtolower($modulename),
692 'MyModule' => $modulename,
693 'MYMODULE' => strtoupper($modulename),
694 'My module' => $modulename,
695 'my module' => $modulename,
696 'Mon module' => $modulename,
697 'mon module' => $modulename,
698 'htdocs/modulebuilder/template' => strtolower($modulename),
699 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
705 $langs->load(
"errors");
706 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
712if ($dirins && $action ==
'initcss' && !empty($module)) {
713 dol_mkdir($dirins.
'/'.strtolower($module).
'/css');
714 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
715 $srcfile = $srcdir.
'/css/mymodule.css.php';
716 $destfile = $dirins.
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php';
719 $result =
dol_copy($srcfile, $destfile, 0, 0);
722 $modulename = ucfirst($module);
725 $arrayreplacement = array(
726 'mymodule' => strtolower($modulename),
727 'MyModule' => $modulename,
728 'MYMODULE' => strtoupper($modulename),
729 'My module' => $modulename,
730 'my module' => $modulename,
731 'Mon module' => $modulename,
732 'mon module' => $modulename,
733 'htdocs/modulebuilder/template' => strtolower($modulename),
734 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
''),
741 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
742 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/css/'.strtolower($module).
'.css.php\'');
745 $langs->load(
"errors");
746 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
752if ($dirins && $action ==
'initjs' && !empty($module)) {
753 dol_mkdir($dirins.
'/'.strtolower($module).
'/js');
754 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
755 $srcfile = $srcdir.
'/js/mymodule.js.php';
756 $destfile = $dirins.
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php';
759 $result =
dol_copy($srcfile, $destfile, 0, 0);
762 $modulename = ucfirst($module);
765 $arrayreplacement = array(
766 'mymodule' => strtolower($modulename),
767 'MyModule' => $modulename,
768 'MYMODULE' => strtoupper($modulename),
769 'My module' => $modulename,
770 'my module' => $modulename,
771 'Mon module' => $modulename,
772 'mon module' => $modulename,
773 'htdocs/modulebuilder/template' => strtolower($modulename),
774 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
781 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
782 $arrayreplacement = array(
'/\/\/\s*\''.preg_quote(
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php',
'/').
'\'/
' => '\
'/'.strtolower($module).
'/js/'.strtolower($module).
'.js.php\'');
785 $langs->load(
"errors");
786 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
792if ($dirins && $action ==
'initcli' && !empty($module)) {
793 dol_mkdir($dirins.
'/'.strtolower($module).
'/scripts');
794 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
795 $srcfile = $srcdir.
'/scripts/mymodule.php';
796 $destfile = $dirins.
'/'.strtolower($module).
'/scripts/'.strtolower($module).
'.php';
799 $result =
dol_copy($srcfile, $destfile, 0, 0);
802 $modulename = ucfirst($module);
805 $arrayreplacement = array(
806 'mymodule' => strtolower($modulename),
807 'MyModule' => $modulename,
808 'MYMODULE' => strtoupper($modulename),
809 'My module' => $modulename,
810 'my module' => $modulename,
811 'Mon module' => $modulename,
812 'mon module' => $modulename,
813 'htdocs/modulebuilder/template' => strtolower($modulename),
814 '__MYCOMPANY_NAME__' => $mysoc->name,
815 '__KEYWORDS__' => $modulename,
816 '__USER_FULLNAME__' => $user->getFullName($langs),
817 '__USER_EMAIL__' => $user->email,
819 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
825 $langs->load(
"errors");
826 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
832if ($dirins && $action ==
'initdoc' && !empty($module)) {
833 dol_mkdir($dirins.
'/'.strtolower($module).
'/doc');
834 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
835 $srcfile = $srcdir.
'/doc/Documentation.asciidoc';
836 $destfile = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
839 $result =
dol_copy($srcfile, $destfile, 0, 0);
842 $modulename = ucfirst($module);
843 $modulelowercase = strtolower($module);
846 $arrayreplacement = array(
847 'mymodule' => strtolower($modulename),
848 'MyModule' => $modulename,
849 'MYMODULE' => strtoupper($modulename),
850 'My module' => $modulename,
851 'my module' => $modulename,
852 'Mon module' => $modulename,
853 'mon module' => $modulename,
854 'htdocs/modulebuilder/template' => strtolower($modulename),
855 '__MYCOMPANY_NAME__' => $mysoc->name,
856 '__KEYWORDS__' => $modulename,
857 '__USER_FULLNAME__' => $user->getFullName($langs),
858 '__USER_EMAIL__' => $user->email,
860 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'dayrfc').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
867 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
868 $destdir = $dirins.
'/'.strtolower($module);
870 foreach ($objects as $path => $obj) {
875 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
879 if (file_exists($dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php')) {
880 $apiFile = $dirins.
'/'.strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
885 if (file_exists($dirins.
'/'.strtolower($module).
'/ChangeLog.md')) {
886 $changeLog = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
887 $string = file_get_contents($changeLog);
889 $replace = explode(
"\n", $string);
890 $strreplace = array();
891 foreach ($replace as $line) {
895 if (strpos($line,
'##') !==
false) {
896 $strreplace[$line] = str_replace(
'##',
'', $line);
898 $strreplace[$line] = $line;
901 $stringLog = implode(
"\n", $strreplace);
903 dolReplaceInFile($destfile, array(
'//include::ChangeLog.md[]' =>
'',
'__CHANGELOG__' => $stringLog));
907 $FILENAMEDOC = $modulelowercase.
'.html';
908 $FILENAMEDOCPDF = $modulelowercase.
'.pdf';
909 $outputfiledoc =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOC;
910 $outputfiledocurl =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOC;
911 $outputfiledocpdf =
dol_buildpath($modulelowercase, 0).
'/doc/'.$FILENAMEDOCPDF;
912 $outputfiledocurlpdf =
dol_buildpath($modulelowercase, 1).
'/doc/'.$FILENAMEDOCPDF;
917 $langs->load(
"errors");
918 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $destfile),
null,
'errors');
924if ($dirins && $action ==
'addlanguage' && !empty($module)) {
925 $newlangcode =
GETPOST(
'newlangcode',
'aZ09');
928 $modulelowercase = strtolower($module);
933 if ($diroflang == $dolibarr_main_document_root.
'/'.$modulelowercase) {
935 $diroflang = $dolibarr_main_document_root;
937 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
938 $destfile = $diroflang.
'/langs/'.$newlangcode.
'/'.$modulelowercase.
'.lang';
940 $result =
dol_copy($srcfile, $destfile, 0, 0);
942 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcfile, $destfile),
null,
'errors');
945 $srcdir = $diroflang.
'/langs/en_US';
946 $srcfile = $diroflang.
'/langs/en_US/'.$modulelowercase.
'.lang';
947 $destdir = $diroflang.
'/langs/'.$newlangcode;
949 $arrayofreplacement = array();
951 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template/langs/en_US';
952 $arrayofreplacement = array(
'mymodule' => $modulelowercase);
954 $result =
dolCopyDir($srcdir, $destdir, 0, 0, $arrayofreplacement);
957 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language")),
null,
'errors');
963if ($dirins && $action ==
'confirm_removefile' && !empty($module)) {
964 $objectname = $tabobj;
965 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
966 $destdir = $dirins.
'/'.strtolower($module);
971 if ($relativefilename) {
972 $dirnametodelete = dirname($relativefilename);
973 $filetodelete = $dirins.
'/'.$relativefilename;
974 $dirtodelete = $dirins.
'/'.$dirnametodelete;
979 $keyofobjecttodelete = array_search($objectname, $objects);
980 if ($keyofobjecttodelete !==
false) {
981 unset($objects[$keyofobjecttodelete]);
985 if (strpos($relativefilename,
'api') !==
false) {
986 $file_api = $destdir.
'/class/api_'.strtolower($module).
'.class.php';
990 if (count($objects) == 0) {
1002 setEventMessages($langs->trans(
"ErrorFailToDeleteFile", basename($filetodelete)),
null,
'errors');
1005 if (preg_match(
'/\.sql$/', $relativefilename)) {
1006 if (preg_match(
'/\.key\.sql$/', $relativefilename)) {
1007 $relativefilename = preg_replace(
'/\.key\.sql$/',
'.sql', $relativefilename);
1008 $filetodelete = $dirins.
'/'.$relativefilename;
1010 } elseif (preg_match(
'/\.sql$/', $relativefilename)) {
1011 $relativefilename = preg_replace(
'/\.sql$/',
'.key.sql', $relativefilename);
1012 $filetodelete = $dirins.
'/'.$relativefilename;
1022 if (in_array($tab, array(
'css',
'js'))) {
1023 $srcfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1024 $arrayreplacement = array(
'/^\s*\''.preg_quote(
'/'.$relativefilename,
'/').
'\',*/m
' => '
1028 if (preg_match(
'/_extrafields/', $relativefilename)) {
1030 $srcfile = $dirins.
'/'.strtolower($module).
'/class/'.strtolower($objectname).
'.class.php';
1031 $arrayreplacement = array(
'/\$isextrafieldmanaged = 1;/' =>
'$isextrafieldmanaged = 0;');
1036 $varnametoupdate =
'';
1038 if (preg_match(
'/_([a-z]+)\.php$/', $relativefilename, $reg)) {
1039 $varnametoupdate =
'showtabofpage'.$reg[1];
1041 if ($varnametoupdate) {
1042 $srcfile = $dirins.
'/'.strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php';
1043 $arrayreplacement = array(
'/\$'.preg_quote($varnametoupdate,
'/').
' = 1;/' =>
'$'.preg_quote($varnametoupdate,
'/').
' = 0;');
1051if ($dirins && $action ==
'initobject' && $module && $objectname) {
1054 $objectname = ucfirst($objectname);
1056 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1057 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1059 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1061 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1062 $tabobj =
'newobject';
1064 if (class_exists($objectname)) {
1067 setEventMessages($langs->trans(
"AnObjectWithThisClassNameAlreadyExists"),
null,
'errors');
1068 $tabobj =
'newobject';
1071 $srcdir = DOL_DOCUMENT_ROOT.
'/modulebuilder/template';
1072 $destdir = $dirins.
'/'.strtolower($module);
1083 $dirlist =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.txt$');
1084 $alreadyfound =
false;
1085 foreach ($dirlist as $key => $val) {
1086 $filefound = preg_replace(
'/\.txt$/',
'', $val[
'name']);
1087 if (strtolower($objectname) == strtolower($filefound) && $objectname != $filefound) {
1088 $alreadyfound =
true;
1090 setEventMessages($langs->trans(
"AnObjectAlreadyExistWithThisNameAndDiffCase"),
null,
'errors');
1097 $stringforproperties =
'';
1098 $tablename =
GETPOST(
'initfromtablename',
'alpha');
1100 $_results = $db->DDLDescTable($tablename);
1101 if (empty($_results)) {
1103 $langs->load(
"errors");
1104 setEventMessages($langs->trans(
"ErrorTableNotFound", $tablename),
null,
'errors');
1153 $stringforproperties =
'// BEGIN MODULEBUILDER PROPERTIES'.
"\n";
1154 $stringforproperties .=
'public $fields=array('.
"\n";
1156 while ($obj = $db->fetch_object($_results)) {
1158 $fieldname = $obj->Field;
1161 if ($type ==
'int(11)') {
1164 if ($type ==
'float') {
1167 if (strstr($type,
'tinyint')) {
1170 if ($obj->Field ==
'fk_soc') {
1171 $type =
'integer:Societe:societe/class/societe.class.php';
1173 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1174 $type =
'integer:Project:projet/class/project.class.php:1:fk_statut=1';
1176 if (preg_match(
'/^fk_prod/', $obj->Field)) {
1177 $type =
'integer:Product:product/class/product.class.php:1';
1179 if ($obj->Field ==
'fk_warehouse') {
1180 $type =
'integer:Entrepot:product/stock/class/entrepot.class.php';
1182 if (preg_match(
'/^(fk_user|fk_commercial)/', $obj->Field)) {
1183 $type =
'integer:User:user/class/user.class.php';
1187 $notnull = ($obj->Null ==
'YES' ? 0 : 1);
1188 if ($fieldname ==
'fk_user_modif') {
1192 $label = preg_replace(
'/_/',
'', ucfirst($fieldname));
1193 if ($fieldname ==
'rowid') {
1194 $label =
'TechnicalID';
1196 if ($fieldname ==
'import_key') {
1197 $label =
'ImportId';
1199 if ($fieldname ==
'fk_soc') {
1200 $label =
'ThirdParty';
1202 if ($fieldname ==
'tms') {
1203 $label =
'DateModification';
1205 if ($fieldname ==
'datec') {
1206 $label =
'DateCreation';
1208 if ($fieldname ==
'date_valid') {
1209 $label =
'DateValidation';
1211 if ($fieldname ==
'datev') {
1212 $label =
'DateValidation';
1214 if ($fieldname ==
'note_private') {
1215 $label =
'NotePublic';
1217 if ($fieldname ==
'note_public') {
1218 $label =
'NotePrivate';
1220 if ($fieldname ==
'fk_user_creat') {
1221 $label =
'UserAuthor';
1223 if ($fieldname ==
'fk_user_modif') {
1224 $label =
'UserModif';
1226 if ($fieldname ==
'fk_user_valid') {
1227 $label =
'UserValidation';
1231 if ($fieldname ==
'entity') {
1234 if ($fieldname ==
'import_key') {
1237 if ($fieldname ==
'fk_user_creat') {
1240 if ($fieldname ==
'fk_user_modif') {
1243 if (in_array($fieldname, array(
'ref_ext',
'model_pdf',
'note_public',
'note_private'))) {
1250 if ($fieldname ==
'entity') {
1255 if (in_array($fieldname, array(
'status',
'statut',
'fk_status',
'fk_statut'))) {
1258 if ($fieldname ==
'import_key') {
1262 if ($fieldname ==
'label') {
1263 $alwayseditable = 1;
1267 if ($fieldname ==
'entity') {
1274 if (preg_match(
'/^fk_/', $fieldname)) {
1275 $css =
'maxwidth500 widthcentpercentminusxx';
1277 if ($fieldname ==
'label') {
1278 $css =
'minwidth300';
1279 $cssview =
'wordbreak';
1281 if (in_array($fieldname, array(
'note_public',
'note_private'))) {
1282 $cssview =
'wordbreak';
1284 if (in_array($fieldname, array(
'ref',
'label')) || preg_match(
'/integer:/', $type)) {
1285 $csslist =
'tdoverflowmax150';
1289 $picto = $obj->Picto;
1290 if ($obj->Field ==
'fk_soc') {
1293 if (preg_match(
'/^fk_proj/', $obj->Field)) {
1298 $stringforproperties .=
"'".$obj->Field.
"'=>array('type'=>'".$type.
"', 'label'=>'".$label.
"',";
1299 if ($default !=
'') {
1300 $stringforproperties .=
" 'default'=>".$default.
",";
1302 $stringforproperties .=
" 'enabled'=>".$enabled.
",";
1303 $stringforproperties .=
" 'visible'=>".$visible;
1305 $stringforproperties .=
", 'notnull'=>".$notnull;
1307 if ($alwayseditable) {
1308 $stringforproperties .=
", 'alwayseditable'=>1";
1310 if ($fieldname ==
'ref' || $fieldname ==
'code') {
1311 $stringforproperties .=
", 'showoncombobox'=>1";
1313 $stringforproperties .=
", 'position'=>".$position;
1315 $stringforproperties .=
", 'index'=>".$index;
1318 $stringforproperties .=
", 'picto'=>'".$picto.
"'";
1321 $stringforproperties .=
", 'css'=>'".$css.
"'";
1324 $stringforproperties .=
", 'cssview'=>'".$cssview.
"'";
1327 $stringforproperties .=
", 'csslist'=>'".$csslist.
"'";
1329 $stringforproperties .=
"),\n";
1332 $stringforproperties .=
');'.
"\n";
1333 $stringforproperties .=
'// END MODULEBUILDER PROPERTIES'.
"\n";
1339 $filetogenerate = array(
1340 'myobject_card.php' => strtolower($objectname).
'_card.php',
1341 'myobject_note.php' => strtolower($objectname).
'_note.php',
1342 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1343 'myobject_document.php' => strtolower($objectname).
'_document.php',
1344 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1345 'myobject_list.php' => strtolower($objectname).
'_list.php',
1346 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1347 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1349 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1350 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1351 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1352 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1354 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1358 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1359 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1361 $filetogenerate += array(
1362 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1363 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1364 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
1367 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1368 dol_mkdir($destdir.
'/core/modules/'.strtolower($module));
1369 dol_mkdir($destdir.
'/core/modules/'.strtolower($module).
'/doc');
1371 $filetogenerate += array(
1372 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
1373 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
1376 if (
GETPOST(
'generatepermissions',
'aZ09')) {
1377 $firstobjectname =
'myobject';
1378 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1380 $class =
'mod'.$module;
1381 if (class_exists($class)) {
1383 $moduleobj =
new $class($db);
1389 $rights = $moduleobj->rights;
1390 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1392 if ($checkComment < 0) {
1393 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
1395 $generatePerms =
reWriteAllPermissions($moduledescriptorfile, $rights,
null,
null, $objectname, $module, -2);
1396 if ($generatePerms < 0) {
1397 setEventMessages($langs->trans(
"WarningPermissionAlreadyExist", $langs->transnoentities($objectname)),
null,
'warnings');
1403 foreach ($filetogenerate as $srcfile => $destfile) {
1404 $result =
dol_copy($srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile, $newmask, 0);
1408 $langs->load(
"errors");
1409 setEventMessages($langs->trans(
"ErrorFailToCopyFile", $srcdir.
'/'.$srcfile, $destdir.
'/'.$destfile),
null,
'errors');
1412 setEventMessages($langs->trans(
"FileAlreadyExists", $destfile),
null,
'warnings');
1415 $arrayreplacement = array(
1416 '/myobject\.class\.php/' => strtolower($objectname).
'.class.php',
1417 '/myobject\.lib\.php/' => strtolower($objectname).
'.lib.php',
1425 if (!$error && $stringforproperties) {
1427 $arrayreplacement = array(
1428 '/\/\/ BEGIN MODULEBUILDER PROPERTIES.*\/\/ END MODULEBUILDER PROPERTIES/ims' => $stringforproperties
1431 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1435 if (
GETPOST(
'includerefgeneration',
'aZ09')) {
1437 $arrayreplacement = array(
1438 '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' =>
"'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)'"
1442 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1444 $arrayreplacement = array(
1445 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1447 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1451 if (
GETPOST(
'includedocgeneration',
'aZ09')) {
1453 $arrayreplacement = array(
1454 '/\$includedocgeneration = 0;/' =>
'$includedocgeneration = 1;'
1456 dolReplaceInFile($destdir.
'/class/'.strtolower($objectname).
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1457 dolReplaceInFile($destdir.
'/'.strtolower($objectname).
'_card.php', $arrayreplacement,
'', 0, 0, 1);
1459 $arrayreplacement = array(
1460 '/\'models\' => 0,/' =>
'\'models\
' => 1,'
1463 dolReplaceInFile($destdir.
'/core/modules/mod'.$module.
'.class.php', $arrayreplacement,
'', 0, 0, 1);
1470 $listofobject =
dol_dir_list($destdir.
'/class',
'files', 0,
'\.class\.php$');
1472 $firstobjectname =
'';
1473 foreach ($listofobject as $fileobj) {
1474 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
1477 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
1481 $tmpcontent = file_get_contents($fileobj[
'fullname']);
1483 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
1484 $objectnameloop = $reg[1];
1485 if (empty($firstobjectname)) {
1486 $firstobjectname = $objectnameloop;
1492 \$this->menu[\$r++]=array(
1493 'fk_menu'=>'fk_mainmenu=mymodule',
1495 'titre'=>'MyObject',
1496 'prefix' => img_picto('', \$this->picto, 'class=\"paddingright pictofixedwidth valignmiddle\"'),
1497 'mainmenu'=>'mymodule',
1498 'leftmenu'=>'myobject',
1499 'url'=>'/mymodule/myobject_list.php',
1500 'langs'=>'mymodule@mymodule',
1501 'position'=>1000+\$r,
1502 'enabled'=>'isModEnabled(\"mymodule\")',
1503 'perms'=>'".(GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1506 'object'=>'MyObject'
1508 \$this->menu[\$r++]=array(
1509 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1511 'titre'=>'List MyObject',
1512 'mainmenu'=>'mymodule',
1513 'leftmenu'=>'mymodule_myobject_list',
1514 'url'=>'/mymodule/myobject_list.php',
1515 'langs'=>'mymodule@mymodule',
1516 'position'=>1000+\$r,
1517 'enabled'=>'isModEnabled(\"mymodule\")',
1518 'perms'=>'".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "read")' :
'1').
"',
1521 'object'=>'MyObject'
1523 \$this->menu[\$r++]=array(
1524 'fk_menu'=>'fk_mainmenu=mymodule,fk_leftmenu=myobject',
1526 'titre'=>'New MyObject',
1527 'mainmenu'=>'mymodule',
1528 'leftmenu'=>'mymodule_myobject_new',
1529 'url'=>'/mymodule/myobject_card.php?action=create',
1530 'langs'=>'mymodule@mymodule',
1531 'position'=>1000+\$r,
1532 'enabled'=>'isModEnabled(\"mymodule\")',
1533 'perms'=>'".(
GETPOST(
'generatepermissions') ?
'$user->hasRight("mymodule", "myobject", "write")' :
'1').
"',
1536 'object'=>'MyObject'
1538 $stringtoadd = preg_replace(
'/MyObject/', $objectname, $stringtoadd);
1539 $stringtoadd = preg_replace(
'/mymodule/', strtolower($module), $stringtoadd);
1540 $stringtoadd = preg_replace(
'/myobject/', strtolower($objectname), $stringtoadd);
1542 $moduledescriptorfile = $destdir.
'/core/modules/mod'.$module.
'.class.php';
1548 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1550 $class =
'mod'.$module;
1551 if (class_exists($class)) {
1553 $moduleobj =
new $class($db);
1559 $menus = $moduleobj->menu;
1561 foreach ($menus as $menu) {
1562 if ($menu[
'leftmenu'] == strtolower($objectname)) {
1568 if ($checkComment < 0) {
1570 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"), basename($moduledescriptorfile)),
null,
'warnings');
1572 $arrayofreplacement = array(
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */' =>
'/* BEGIN MODULEBUILDER LEFTMENU '.strtoupper($objectname).
' */'.$stringtoadd.
"\n\t\t".
'/* END MODULEBUILDER LEFTMENU '.strtoupper($objectname).
' */'.
"\n\t\t".
'/* BEGIN MODULEBUILDER LEFTMENU MYOBJECT */');
1577 $filetogenerate[] =
'core/modules/mod'.$module.
'.class.php';
1582 foreach ($filetogenerate as $destfile) {
1583 $phpfileval[
'fullname'] = $destdir.
'/'.$destfile;
1586 $arrayreplacement = array(
1587 'mymodule' => strtolower($module),
1588 'MyModule' => $module,
1589 'MYMODULE' => strtoupper($module),
1590 'My module' => $module,
1591 'my module' => $module,
1592 'mon module' => $module,
1593 'Mon module' => $module,
1594 'htdocs/modulebuilder/template/' => strtolower($modulename),
1595 'myobject' => strtolower($objectname),
1596 'MyObject' => $objectname,
1598 '---Put here your own copyright and developer email---' =>
dol_print_date($now,
'%Y').
' '.$user->getFullName($langs).($user->email ?
' <'.$user->email.
'>' :
'')
1602 $arrayreplacement[
'---Put here your own copyright and developer email---'] =
dol_print_date($now,
'%Y').
' ' .
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_AUTHOR');
1608 setEventMessages($langs->trans(
"ErrorFailToMakeReplacementInto", $phpfileval[
'fullname']),
null,
'errors');
1617 if (is_numeric($object) && $object <= 0) {
1618 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1619 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1623 $file = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1624 $destfile = $destdir.
'/doc/Documentation.asciidoc';
1626 if (file_exists($destfile)) {
1632 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask,
'', $object);
1641 setEventMessages($langs->trans(
'FilesForObjectInitialized', $objectname),
null);
1642 $tabobj = $objectname;
1644 $tabobj =
'newobject';
1648 if (isModEnabled(strtolower($module))) {
1654 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
1655 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module);
1661if ($dirins && $action ==
'initdic' && $module && empty($cancel)) {
1662 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1663 $destdir = $dirins.
'/'.strtolower($module);
1664 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
1668 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Table")),
null,
'errors');
1672 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1675 $newdicname = $dicname;
1676 if (!preg_match(
'/^c_/', $newdicname)) {
1677 $newdicname =
'c_'.$dicname;
1680 $class =
'mod'.$module;
1682 if (class_exists($class)) {
1684 $moduleobj =
new $class($db);
1691 $langs->load(
"errors");
1692 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
1695 $dictionaries = $moduleobj->dictionaries;
1697 if ($checkComment < 0) {
1698 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
1701 if (function_exists(
'opcache_invalidate')) {
1704 clearstatcache(
true);
1705 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
1712if ($dirins && ($action ==
'droptable' || $action ==
'droptableextrafields') && !empty($module) && !empty($tabobj)) {
1713 $objectname = $tabobj;
1715 $arrayoftables = array();
1716 if ($action ==
'droptable') {
1717 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj);
1719 if ($action ==
'droptableextrafields') {
1720 $arrayoftables[] = MAIN_DB_PREFIX.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields';
1723 foreach ($arrayoftables as $tabletodrop) {
1725 $sql =
"SELECT COUNT(*) as nb FROM ".$tabletodrop;
1726 $resql = $db->query($sql);
1728 $obj = $db->fetch_object($resql);
1733 if ($db->lasterrno() ==
'DB_ERROR_NOSUCHTABLE') {
1734 setEventMessages($langs->trans(
"TableDoesNotExists", $tabletodrop),
null,
'warnings');
1740 $resql = $db->DDLDropTable($tabletodrop);
1742 setEventMessages($langs->trans(
"TableDropped", $tabletodrop),
null,
'mesgs');
1743 } elseif ($nb > 0) {
1744 setEventMessages($langs->trans(
"TableNotEmptyDropCanceled", $tabletodrop),
null,
'warnings');
1749if ($dirins && $action ==
'addproperty' && empty($cancel) && !empty($module) && (!empty($tabobj) || !empty(
GETPOST(
'obj')))) {
1754 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1755 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1757 $srcdir = $dirread.
'/'.strtolower($module);
1758 $destdir = $dirins.
'/'.strtolower($module);
1762 if (!in_array($objectname, array_values($objects))) {
1764 setEventMessages($langs->trans(
"ErrorObjectNotFound", $langs->transnoentities($objectname)),
null,
'errors');
1767 if (!
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1768 if (!
GETPOST(
'propname',
'aZ09')) {
1770 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Name")),
null,
'errors');
1772 if (!
GETPOST(
'proplabel',
'alpha')) {
1774 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
1776 if (!
GETPOST(
'proptype',
'alpha')) {
1778 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
1781 if (!$error && !
GETPOST(
'regenerateclasssql') && !
GETPOST(
'regeneratemissing')) {
1782 $addfieldentry = array(
1783 'name' =>
GETPOST(
'propname',
'aZ09'),
1784 'label' =>
GETPOST(
'proplabel',
'alpha'),
1785 'type' => strtolower(
GETPOST(
'proptype',
'alpha')),
1786 'arrayofkeyval' =>
GETPOST(
'proparrayofkeyval',
'alphawithlgt'),
1787 'visible' =>
GETPOST(
'propvisible',
'alphanohtml'),
1788 'enabled' =>
GETPOST(
'propenabled',
'alphanohtml'),
1792 'foreignkey' =>
GETPOST(
'propforeignkey',
'alpha'),
1794 'isameasure' =>
GETPOSTINT(
'propisameasure'),
1795 'comment' =>
GETPOST(
'propcomment',
'alpha'),
1796 'help' =>
GETPOST(
'prophelp',
'alpha'),
1797 'css' =>
GETPOST(
'propcss',
'alpha'),
1798 'cssview' =>
GETPOST(
'propcssview',
'alpha'),
1799 'csslist' =>
GETPOST(
'propcsslist',
'alpha'),
1800 'default' =>
GETPOST(
'propdefault',
'restricthtml'),
1801 'noteditable' => intval(
GETPOSTINT(
'propnoteditable')),
1806 if (!empty($addfieldentry[
'arrayofkeyval']) && !is_array($addfieldentry[
'arrayofkeyval'])) {
1807 $tmpdecode = json_decode($addfieldentry[
'arrayofkeyval'],
true);
1809 $addfieldentry[
'arrayofkeyval'] = $tmpdecode;
1812 $addfieldentry[
'arrayofkeyval'] = $tmparray;
1817 $addfieldentry = array();
1826 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1832 if (is_numeric($object) && $object <= 0) {
1833 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1834 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1841 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object, $moduletype);
1844 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1850 clearstatcache(
true);
1852 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1857 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname.
'&nocache='.time());
1862if ($dirins && $action ==
'confirm_deleteproperty' && $propertykey) {
1863 $objectname = $tabobj;
1865 $dirins = $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
1866 $moduletype = $listofmodules[strtolower($module)][
'moduletype'];
1868 $srcdir = $dirread.
'/'.strtolower($module);
1869 $destdir = $dirins.
'/'.strtolower($module);
1876 if (is_numeric($object) && $object <= 0) {
1877 $pathoffiletoeditsrc = $destdir.
'/class/'.strtolower($objectname).
'.class.php';
1878 setEventMessages($langs->trans(
'ErrorFailToCreateFile', $pathoffiletoeditsrc),
null,
'errors');
1885 $result =
rebuildObjectSql($destdir, $module, $objectname, $newmask, $srcdir, $object);
1888 setEventMessages($langs->trans(
'ErrorFailToCreateFile',
'.sql'),
null,
'errors');
1894 setEventMessages($langs->trans(
'FilesForObjectUpdated', $objectname),
null);
1896 clearstatcache(
true);
1899 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname);
1904if ($dirins && $action ==
'confirm_deletemodule') {
1905 if (preg_match(
'/[^a-z0-9_]/i', $module)) {
1907 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1911 $modulelowercase = strtolower($module);
1914 $dir = $dirins.
'/'.$modulelowercase;
1916 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
1926 $class =
'mod'.$module;
1928 if (class_exists($class)) {
1930 $moduleobj =
new $class($db);
1937 $langs->load(
"errors");
1938 setEventMessages($langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module),
null,
'warnings');
1942 $moduleobj->remove();
1950 clearstatcache(
true);
1951 if (function_exists(
'opcache_invalidate')) {
1955 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?module=deletemodule');
1963 $module =
'deletemodule';
1966if ($dirins && $action ==
'confirm_deleteobject' && $objectname) {
1967 if (preg_match(
'/[^a-z0-9_]/i', $objectname)) {
1969 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
1973 $modulelowercase = strtolower($module);
1974 $objectlowercase = strtolower($objectname);
1977 $dir = $dirins.
'/'.$modulelowercase;
1980 $filetodelete = array(
1981 'myobject_card.php' => strtolower($objectname).
'_card.php',
1982 'myobject_note.php' => strtolower($objectname).
'_note.php',
1983 'myobject_contact.php' => strtolower($objectname).
'_contact.php',
1984 'myobject_document.php' => strtolower($objectname).
'_document.php',
1985 'myobject_agenda.php' => strtolower($objectname).
'_agenda.php',
1986 'myobject_list.php' => strtolower($objectname).
'_list.php',
1987 'admin/myobject_extrafields.php' =>
'admin/'.strtolower($objectname).
'_extrafields.php',
1988 'lib/mymodule_myobject.lib.php' =>
'lib/'.strtolower($module).
'_'.strtolower($objectname).
'.lib.php',
1989 'test/phpunit/MyObjectTest.php' =>
'test/phpunit/'.strtolower($objectname).
'Test.php',
1990 'sql/llx_mymodule_myobject.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.sql',
1991 'sql/llx_mymodule_myobject_extrafields.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.sql',
1992 'sql/llx_mymodule_myobject.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'.key.sql',
1993 'sql/llx_mymodule_myobject_extrafields.key.sql' =>
'sql/llx_'.strtolower($module).
'_'.strtolower($objectname).
'_extrafields.key.sql',
1994 'scripts/myobject.php' =>
'scripts/'.strtolower($objectname).
'.php',
1995 'class/myobject.class.php' =>
'class/'.strtolower($objectname).
'.class.php',
1996 'class/api_myobject.class.php' =>
'class/api_'.strtolower($module).
'.class.php',
1997 'core/modules/mymodule/mod_myobject_advanced.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_advanced.php',
1998 'core/modules/mymodule/mod_myobject_standard.php' =>
'core/modules/'.strtolower($module).
'/mod_'.strtolower($objectname).
'_standard.php',
1999 'core/modules/mymodule/modules_myobject.php' =>
'core/modules/'.strtolower($module).
'/modules_'.strtolower($objectname).
'.php',
2000 'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/doc_generic_'.strtolower($objectname).
'_odt.modules.php',
2001 'core/modules/mymodule/doc/pdf_standard_myobject.modules.php' =>
'core/modules/'.strtolower($module).
'/doc/pdf_standard_'.strtolower($objectname).
'.modules.php'
2006 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2008 $class =
'mod'.$module;
2009 if (class_exists($class)) {
2011 $moduleobj =
new $class($db);
2017 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2020 $menus = $moduleobj->menu;
2023 if ($rewriteMenu < 0) {
2024 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2026 reWriteAllMenus($moduledescriptorfile, $menus, $objectname,
null, -1);
2030 $permissions = $moduleobj->rights;
2032 if ($rewritePerms < 0) {
2033 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2037 if ($rewritePerms && $rewriteMenu) {
2039 $file_doc = $dirins.
'/'.strtolower($module).
'/doc/Documentation.asciidoc';
2042 clearstatcache(
true);
2043 if (function_exists(
'opcache_invalidate')) {
2047 foreach ($filetodelete as $tmpfiletodelete) {
2049 $resulttmp =
dol_delete_file($dir.
'/'.$tmpfiletodelete.
'.back', 0, 0, 1);
2055 if ($resultko == 0) {
2058 setEventMessages($langs->trans(
"ErrorSomeFilesCouldNotBeDeleted"),
null,
'warnings');
2065 $tabobj =
'newobject';
2067 $tabobj =
'deleteobject';
2071 if (isModEnabled(strtolower($module))) {
2073 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2077 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2078 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&tabobj=deleteobject&module='.urlencode($module));
2083if (($dirins && $action ==
'confirm_deletedictionary' && $dicname) || ($dirins && $action ==
'confirm_deletedictionary' &&
GETPOST(
'dictionnarykey'))) {
2084 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2085 $destdir = $dirins.
'/'.strtolower($module);
2086 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2088 if (preg_match(
'/[^a-z0-9_]/i', $dicname)) {
2090 setEventMessages($langs->trans(
"SpaceOrSpecialCharAreNotAllowed"),
null,
'errors');
2093 if (!empty($dicname)) {
2094 $newdicname = $dicname;
2095 if (!preg_match(
'/^c_/', $newdicname)) {
2096 $newdicname =
'c_'.strtolower($dicname);
2101 $class =
'mod'.$module;
2103 if (class_exists($class)) {
2105 $moduleobj =
new $class($db);
2112 $langs->load(
"errors");
2113 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2117 $dicts = $moduleobj->dictionaries;
2119 if ($checkComment < 0) {
2121 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2124 if (!empty(
GETPOST(
'dictionnarykey'))) {
2125 $newdicname = $dicts[
'tabname'][
GETPOST(
'dictionnarykey') - 1];
2129 $checkTable = $db->DDLDescTable(MAIN_DB_PREFIX.strtolower($newdicname));
2130 if ($checkTable && $db->num_rows($checkTable) <= 0) {
2135 $keyToDelete =
null;
2136 foreach ($dicts[
'tabname'] as $key => $table) {
2138 if (strtolower($table) === $newdicname) {
2139 $keyToDelete = $key;
2144 if ($keyToDelete !==
null) {
2145 $keysToDelete = [
'tabname',
'tablib',
'tabsql',
'tabsqlsort',
'tabfield',
'tabfieldvalue',
'tabfieldinsert',
'tabrowid',
'tabcond',
'tabhelp'];
2146 foreach ($keysToDelete as $key) {
2147 unset($dicts[$key][$keyToDelete]);
2151 setEventMessages($langs->trans(
"ErrorDictionaryNotFound", ucfirst($dicname)),
null,
'errors');
2155 $_results = $db->DDLDropTable(MAIN_DB_PREFIX.strtolower($newdicname));
2156 if ($_results < 0) {
2158 $langs->load(
"errors");
2159 setEventMessages($langs->trans(
"ErrorTableNotFound", $newdicname),
null,
'errors');
2164 setEventMessages($langs->trans(
"DictionaryDeleted", ucfirst(substr($newdicname, 2))),
null);
2166 if (function_exists(
'opcache_invalidate')) {
2169 clearstatcache(
true);
2170 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2174if ($dirins && $action ==
'updatedictionary' &&
GETPOST(
'dictionnarykey')) {
2175 $keydict =
GETPOST(
'dictionnarykey') - 1 ;
2177 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2178 $destdir = $dirins.
'/'.strtolower($module);
2179 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2181 $class =
'mod'.$module;
2183 if (class_exists($class)) {
2185 $moduleobj =
new $class($db);
2192 $langs->load(
"errors");
2193 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2197 $dicts = $moduleobj->dictionaries;
2198 if (!empty(
GETPOST(
'tablib')) &&
GETPOST(
'tablib') !== $dicts[
'tablib'][$keydict]) {
2199 $dicts[
'tablib'][$keydict] = ucfirst(strtolower(
GETPOST(
'tablib')));
2201 if ($checkComment < 0) {
2202 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Dictionaries"),
"mod".$module.
"class.php"),
null,
'warnings');
2205 if ($updateDict > 0) {
2208 if (function_exists(
'opcache_invalidate')) {
2211 clearstatcache(
true);
2212 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
''));
2218if ($dirins && $action ==
'generatedoc') {
2219 $modulelowercase = strtolower($module);
2224 $FILENAMEDOC = strtolower($module).
'.html';
2226 $util =
new Utils($db);
2227 $result = $util->generateDoc($module);
2230 setEventMessages($langs->trans(
"DocFileGeneratedInto", $dirofmodule),
null);
2236if ($dirins && $action ==
'generatepackage') {
2237 $modulelowercase = strtolower($module);
2239 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2249 $class =
'mod'.$module;
2251 if (class_exists($class)) {
2253 $moduleobj =
new $class($db);
2260 $langs->load(
"errors");
2261 dol_print_error($db, $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module));
2265 $arrayversion = explode(
'.', $moduleobj->version, 3);
2266 if (count($arrayversion)) {
2267 $FILENAMEZIP =
"module_".$modulelowercase.
'-'.$arrayversion[0].(empty($arrayversion[1]) ?
'.0' :
'.'.$arrayversion[1]).(empty($arrayversion[2]) ?
'' :
'.'.$arrayversion[2]).
'.zip';
2270 $outputfilezip = $dirofmodule.
'/'.$FILENAMEZIP;
2276 $result = dol_compress_dir($dir, $outputfilezip,
'zip',
'/\/bin\/|\.git|\.old|\.back|\.ssh/', $modulelowercase);
2282 setEventMessages($langs->trans(
"ZipFileGeneratedInto", $outputfilezip),
null);
2285 $langs->load(
"errors");
2286 setEventMessages($langs->trans(
"ErrorFailToGenerateFile", $outputfilezip),
null,
'errors');
2290 $langs->load(
"errors");
2291 setEventMessages($langs->trans(
"ErrorCheckVersionIsDefined"),
null,
'errors');
2296if ($dirins && $action ==
'addright' && !empty($module) && empty($cancel)) {
2300 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2302 $class =
'mod'.$module;
2303 if (class_exists($class)) {
2305 $moduleobj =
new $class($db);
2313 if (!
GETPOST(
'label',
'alpha')) {
2315 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2317 if (!
GETPOST(
'permissionObj',
'alpha')) {
2319 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2323 $label =
GETPOST(
'label',
'alpha');
2324 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2325 $crud =
GETPOST(
'crud',
'alpha');
2329 $permsForObject = array();
2330 $permissions = $moduleobj->rights;
2331 $allObject = array();
2333 $countPerms = count($permissions);
2335 for ($i = 0; $i < $countPerms; $i++) {
2336 if ($permissions[$i][4] == $objectForPerms) {
2338 if (count($permsForObject) < 3) {
2339 $permsForObject[] = $permissions[$i];
2342 $allObject[] = $permissions[$i][4];
2346 $countPermsObj = count($permsForObject);
2347 for ($j = 0; $j < $countPermsObj; $j++) {
2348 if (in_array($crud, $permsForObject[$j])) {
2350 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($crud), $langs->transnoentities($objectForPerms)),
null,
'errors');
2355 $key = $countPerms + 1;
2360 4 => $objectForPerms,
2364 if (isModEnabled(strtolower($module))) {
2366 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2370 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2373 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2377 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2382 clearstatcache(
true);
2383 if (function_exists(
'opcache_invalidate')) {
2386 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2393if ($dirins &&
GETPOST(
'action') ==
'update_right' &&
GETPOST(
'modifyright') && empty($cancel)) {
2396 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2398 $class =
'mod'.$module;
2399 if (class_exists($class)) {
2401 $moduleobj =
new $class($db);
2408 if (!
GETPOST(
'label',
'alpha')) {
2410 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Label")),
null,
'errors');
2412 if (!
GETPOST(
'permissionObj',
'alpha')) {
2414 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Rights")),
null,
'errors');
2417 $label =
GETPOST(
'label',
'alpha');
2418 $objectForPerms = strtolower(
GETPOST(
'permissionObj',
'alpha'));
2419 $crud =
GETPOST(
'crud',
'alpha');
2422 if ($label ==
"Read objects of $module" && $crud !=
"read") {
2426 if ($label ==
"Create/Update objects of $module" && $crud !=
"write") {
2430 if ($label ==
"Delete objects of $module" && $crud !=
"delete") {
2435 $permissions = $moduleobj->rights;
2436 $key = (int)
GETPOST(
'counter') - 1;
2438 $x1 = $permissions[$key][1];
2439 $x2 = $permissions[$key][4];
2440 $x3 = $permissions[$key][5];
2443 $permsForObject = array();
2444 $permissions = $moduleobj->rights;
2447 $allObject = array();
2449 $countPerms = count($permissions);
2450 for ($i = 0; $i < $countPerms; $i++) {
2451 if ($permissions[$i][4] == $objectForPerms) {
2453 if (count($permsForObject) < 3) {
2454 $permsForObject[] = $permissions[$i];
2457 $allObject[] = $permissions[$i][4];
2460 if ($label != $x1 && $crud != $x3) {
2461 $countPermsObj = count($permsForObject);
2462 for ($j = 0; $j < $countPermsObj; $j++) {
2463 if (in_array($label, $permsForObject[$j])) {
2465 setEventMessages($langs->trans(
"ErrorExistingPermission", $langs->transnoentities($label), $langs->transnoentities($objectForPerms)),
null,
'errors');
2471 if (isModEnabled(strtolower($module))) {
2473 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2477 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2480 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2484 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2488 clearstatcache(
true);
2489 if (function_exists(
'opcache_invalidate')) {
2492 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2498if ($dirins && $action ==
'confirm_deleteright' && !empty($module) &&
GETPOSTINT(
'permskey')) {
2501 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2503 $class =
'mod'.$module;
2504 if (class_exists($class)) {
2506 $moduleobj =
new $class($db);
2513 $permissions = $moduleobj->rights;
2518 if (isModEnabled(strtolower($module))) {
2520 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2524 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2525 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2530 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2533 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Permissions"),
"mod".$module.
"class.php"),
null,
'warnings');
2538 clearstatcache(
true);
2539 if (function_exists(
'opcache_invalidate')) {
2543 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=permissions&module='.$module);
2549if ($action ==
'savefile' && empty($cancel)) {
2550 $relofcustom = basename($dirins);
2554 if (!preg_match(
'/^'.$relofcustom.
'/', $file)) {
2555 $file = $relofcustom.
'/'.$file;
2563 dol_copy($pathoffile, $pathoffilebackup, 0, 1);
2566 $check =
'restricthtml';
2568 if ($srclang ==
'md') {
2569 $check =
'restricthtml';
2571 if ($srclang ==
'lang') {
2572 $check =
'restricthtml';
2574 if ($srclang ==
'php') {
2578 $content =
GETPOST(
'editfilecontent', $check);
2583 $result = file_put_contents($pathoffile, $content);
2600if ($action ==
'set' && $user->admin) {
2603 $param .=
'&module='.urlencode($module);
2606 $param .=
'&tab='.urlencode($tab);
2609 $param .=
'&tabobj='.urlencode($tabobj);
2612 $value =
GETPOST(
'value',
'alpha');
2614 if (!empty($resarray[
'errors'])) {
2618 if ($resarray[
'nbperms'] > 0) {
2619 $tmpsql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"user WHERE admin <> 1";
2620 $resqltmp = $db->query($tmpsql);
2622 $obj = $db->fetch_object($resqltmp);
2624 if ($obj && $obj->nb > 1) {
2625 $msg = $langs->trans(
'ModuleEnabledAdminMustCheckRights');
2633 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2638if ($action ==
'reset' && $user->admin) {
2641 $param .=
'&module='.urlencode($module);
2644 $param .=
'&tab='.urlencode($tab);
2647 $param .=
'&tabobj='.urlencode($tabobj);
2650 $value =
GETPOST(
'value',
'alpha');
2655 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?".$param);
2660if ($dirins && $action ==
'confirm_deletemenu' &&
GETPOSTINT(
'menukey')) {
2662 if (isModEnabled(strtolower($module))) {
2664 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2668 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2669 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2673 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2675 $class =
'mod'.$module;
2676 if (class_exists($class)) {
2678 $moduleobj =
new $class($db);
2685 $dir = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2686 $destdir = $dir.
'/'.strtolower($module);
2688 $result = array_map(
'strtolower', $objects);
2690 $menus = $moduleobj->menu;
2692 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2695 if ($checkcomment < 0) {
2696 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2698 if ($menus[$key][
'fk_menu'] ===
'fk_mainmenu='.strtolower($module)) {
2699 if (in_array(strtolower($menus[$key][
'leftmenu']), $result)) {
2700 reWriteAllMenus($moduledescriptorfile, $menus, $menus[$key][
'leftmenu'], $key, -1);
2708 clearstatcache(
true);
2709 if (function_exists(
'opcache_invalidate')) {
2714 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2720if ($dirins && $action ==
'addmenu' && empty($cancel)) {
2722 if (isModEnabled(strtolower($module))) {
2724 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2728 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2729 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2735 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2737 $class =
'mod'.$module;
2738 if (class_exists($class)) {
2740 $moduleobj =
new $class($db);
2747 $menus = $moduleobj->menu;
2750 if (!
GETPOST(
'type',
'alpha')) {
2752 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Type")),
null,
'errors');
2754 if (!
GETPOST(
'titre',
'alpha')) {
2756 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Title")),
null,
'errors');
2758 if (!
GETPOST(
'user',
'alpha')) {
2760 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"DetailUser")),
null,
'errors');
2762 if (!
GETPOST(
'url',
'alpha')) {
2764 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentities(
"Url")),
null,
'errors');
2766 if (!empty(
GETPOST(
'target'))) {
2767 $targets = array(
'_blank',
'_self',
'_parent',
'_top',
'');
2768 if (!in_array(
GETPOST(
'target'), $targets)) {
2770 setEventMessages($langs->trans(
"ErrorFieldValue", $langs->transnoentities(
"target")),
null,
'errors');
2777 foreach ($menus as $menu) {
2780 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"url")),
null,
'errors');
2783 if (strtolower(
GETPOST(
'titre')) == strtolower($menu[
'titre'])) {
2785 setEventMessages($langs->trans(
"ErrorFieldExist", $langs->transnoentities(
"titre")),
null,
'errors');
2790 if (
GETPOST(
'type',
'alpha') ==
'left' && !empty(
GETPOST(
'lefmenu',
'alpha'))) {
2791 if (!str_contains(
GETPOST(
'leftmenu'), strtolower($module))) {
2793 setEventMessages($langs->trans(
"WarningFieldsMustContains", $langs->transnoentities(
"LeftmenuId")),
null,
'errors');
2796 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2797 $destdir = $dirins.
'/'.strtolower($module);
2800 if (
GETPOST(
'type',
'alpha') ==
'left') {
2801 if (empty(
GETPOST(
'leftmenu')) && count($objects) > 0) {
2803 setEventMessages($langs->trans(
"ErrorCoherenceMenu", $langs->transnoentities(
"LeftmenuId"), $langs->transnoentities(
"type")),
null,
'errors');
2806 if (
GETPOST(
'type',
'alpha') ==
'top') {
2808 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2811 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2815 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2816 'type' =>
GETPOST(
'type',
'alpha'),
2817 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2819 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2820 'leftmenu' =>
GETPOST(
'leftmenu',
'alpha'),
2821 'url' =>
GETPOST(
'url',
'alpha'),
2822 'langs' => strtolower($module).
"@".strtolower($module),
2824 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2825 'perms' =>
'$user->hasRight("'.strtolower($module).
'", "'.
GETPOST(
'objects',
'alpha').
'", "'.
GETPOST(
'perms',
'alpha').
'")',
2826 'target' =>
GETPOST(
'target',
'alpha'),
2827 'user' =>
GETPOST(
'user',
'alpha'),
2830 if (
GETPOST(
'type') ==
'left') {
2831 unset($menuToAdd[
'prefix']);
2832 if (empty(
GETPOST(
'fk_menu'))) {
2833 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha');
2835 $menuToAdd[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu',
'alpha').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2838 if (
GETPOST(
'enabled') ==
'1') {
2839 $menuToAdd[
'enabled'] =
'isModEnabled("'.strtolower($module).
'")';
2841 $menuToAdd[
'enabled'] =
"0";
2843 if (empty(
GETPOST(
'objects'))) {
2844 $menuToAdd[
'perms'] =
'1';
2848 if ($checkcomment < 0) {
2849 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2852 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuToAdd,
null, 1);
2854 clearstatcache(
true);
2855 if (function_exists(
'opcache_invalidate')) {
2864 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2872if ($dirins && $action ==
"update_menu" &&
GETPOSTINT(
'menukey') &&
GETPOST(
'tabobj')) {
2873 $objectname =
GETPOST(
'tabobj');
2874 $dirins = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
2875 $destdir = $dirins.
'/'.strtolower($module);
2878 if (empty($cancel)) {
2879 if (isModEnabled(strtolower($module))) {
2881 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2885 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2886 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2891 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2893 $class =
'mod'.$module;
2894 if (class_exists($class)) {
2896 $moduleobj =
new $class($db);
2902 $menus = $moduleobj->menu;
2905 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2907 $menuModify = array(
2908 'fk_menu' =>
GETPOST(
'fk_menu',
'alpha'),
2909 'type' =>
GETPOST(
'type',
'alpha'),
2910 'titre' => ucfirst(
GETPOST(
'titre',
'alpha')),
2911 'mainmenu' =>
GETPOST(
'mainmenu',
'alpha'),
2912 'leftmenu' => $menus[$key][
'leftmenu'],
2913 'url' =>
GETPOST(
'url',
'alpha'),
2914 'langs' => strtolower($module).
"@".strtolower($module),
2916 'enabled' =>
GETPOST(
'enabled',
'alpha'),
2917 'perms' =>
GETPOST(
'perms',
'alpha'),
2918 'target' =>
GETPOST(
'target',
'alpha'),
2919 'user' =>
GETPOST(
'user',
'alpha'),
2921 if (!empty(
GETPOST(
'fk_menu')) &&
GETPOST(
'fk_menu') != $menus[$key][
'fk_menu']) {
2922 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu').
',fk_leftmenu='.
GETPOST(
'fk_menu');
2923 } elseif (
GETPOST(
'fk_menu') == $menus[$key][
'fk_menu']) {
2924 $menuModify[
'fk_menu'] = $menus[$key][
'fk_menu'];
2926 $menuModify[
'fk_menu'] =
'fk_mainmenu='.GETPOST(
'mainmenu');
2928 if ($menuModify[
'enabled'] ===
'') {
2929 $menuModify[
'enabled'] =
'1';
2931 if ($menuModify[
'perms'] ===
'') {
2932 $menuModify[
'perms'] =
'1';
2935 if (
GETPOST(
'type',
'alpha') ==
'top') {
2937 setEventMessages($langs->trans(
"ErrorTypeMenu", $langs->transnoentities(
"type")),
null,
'errors');
2944 if ($checkComment < 0) {
2945 setEventMessages($langs->trans(
"WarningCommentNotFound", $langs->trans(
"Menus"),
"mod".$module.
"class.php"),
null,
'warnings');
2948 $result =
reWriteAllMenus($moduledescriptorfile, $menus, $menuModify, $key, 2);
2950 clearstatcache(
true);
2951 if (function_exists(
'opcache_invalidate')) {
2958 header(
"Location: ".$_SERVER[
"PHP_SELF"].
'?action=editmenu&token='.
newToken().
'&menukey='.urlencode((
string) ($key + 1)).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)).
'&tabobj='.($key + 1));
2963 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2968 $_POST[
'type'] =
'';
2969 $_POST[
'titre'] =
'';
2970 $_POST[
'fk_menu'] =
'';
2971 $_POST[
'leftmenu'] =
'';
2977if ($dirins && $action ==
"update_props_module" && !empty(
GETPOST(
'keydescription',
'alpha')) && empty($cancel)) {
2978 if (isModEnabled(strtolower($module))) {
2980 dolibarr_set_const($db,
"MAIN_IHM_PARAMS_REV", (
int) $conf->global->MAIN_IHM_PARAMS_REV + 1,
'chaine', 0,
'', $conf->entity);
2984 setEventMessages($langs->trans(
'WarningModuleNeedRefresh', $langs->transnoentities($module)),
null,
'warnings');
2985 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=menus&module='.$module);
2988 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
2989 $moduledescriptorfile = $dirins.
'/'.strtolower($module).
'/core/modules/mod'.$module.
'.class.php';
2990 $modulelogfile = $dirins.
'/'.strtolower($module).
'/ChangeLog.md';
2994 $class =
'mod'.$module;
2995 if (class_exists($class)) {
2997 $moduleobj =
new $class($db);
3004 $keydescription =
GETPOST(
'keydescription',
'alpha');
3005 switch ($keydescription) {
3007 $propertyToUpdate =
'description';
3014 $propertyToUpdate = $keydescription;
3017 $error =
GETPOST(
'keydescription');
3021 if (isset($propertyToUpdate) && !empty(
GETPOST(
'propsmodule'))) {
3022 $newValue =
GETPOST(
'propsmodule');
3023 $lineToReplace =
"\t\t\$this->$propertyToUpdate = ";
3024 $newLine =
"\t\t\$this->$propertyToUpdate = '$newValue';\n";
3027 if ($propertyToUpdate ===
'version') {
3028 dolReplaceInFile($modulelogfile, array(
"## ".$moduleobj->$propertyToUpdate => $newValue));
3031 $fileLines = file($moduledescriptorfile);
3032 foreach ($fileLines as &$line) {
3033 if (strpos($line, $lineToReplace) === 0) {
3039 clearstatcache(
true);
3040 if (function_exists(
'opcache_invalidate')) {
3043 setEventMessages($langs->trans(
'PropertyModuleUpdated', $propertyToUpdate),
null);
3044 header(
"Location: ".DOL_URL_ROOT.
'/modulebuilder/index.php?tab=description&module='.$module);
3054$form =
new Form($db);
3065 '/includes/ace/src/ace.js',
3066 '/includes/ace/src/ext-statusbar.js',
3067 '/includes/ace/src/ext-language_tools.js',
3072llxHeader(
'', $langs->trans(
"ModuleBuilder"), $help_url,
'', 0, 0, $morejs, $morecss,
'',
'classforhorizontalscrolloftabs');
3075$text = $langs->trans(
"ModuleBuilder");
3079print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ModuleBuilderDesc",
'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').
'</span>';
3080print
'<br class="hideonsmartphone">';
3089 $message =
info_admin($langs->trans(
"ConfFileMustContainCustom", DOL_DOCUMENT_ROOT.
'/custom', DOL_DOCUMENT_ROOT));
3094 $langs->load(
"errors");
3095 $message =
info_admin($langs->trans(
"ErrorFailedToWriteInDir", $dirins));
3099 $message =
info_admin($langs->trans(
"NotExistsDirect", $dirins).$langs->trans(
"InfDirAlt").$langs->trans(
"InfDirExample"));
3108$infomodulesfound =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'', $langs->trans(
"ModuleBuilderDesc3", count($listofmodules)).
'<br><br>'.$langs->trans(
"ModuleBuilderDesc4", $FILEFLAG).
'<br>'.$textforlistofdirs).
'</div>';
3112$dolibarrdataroot = preg_replace(
'/([\\/]+)$/i',
'', DOL_DATA_ROOT);
3113$allowonlineinstall =
true;
3114if (
dol_is_file($dolibarrdataroot.
'/installmodules.lock')) {
3115 $allowonlineinstall =
false;
3117if (empty($allowonlineinstall)) {
3120 $message =
info_admin($langs->trans(
'InstallModuleFromWebHasBeenDisabledContactUs'));
3123 $message =
info_admin($langs->trans(
"InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.
'/installmodules.lock'), 0, 0, 1,
'warning');
3138if (!empty($module) && $module !=
'initmodule' && $module !=
'deletemodule') {
3139 $modulelowercase = strtolower($module);
3140 $loadclasserrormessage =
'';
3144 $fullpathdirtodescriptor = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3149 $class =
'mod'.$module;
3150 }
catch (Throwable $e) {
3151 $loadclasserrormessage = $e->getMessage().
"<br>\n";
3152 $loadclasserrormessage .=
'File: '.$e->getFile().
"<br>\n";
3153 $loadclasserrormessage .=
'Line: '.$e->getLine().
"<br>\n";
3156 if (class_exists($class)) {
3158 $moduleobj =
new $class($db);
3161 print $e->getMessage();
3164 if (empty($forceddirread)) {
3167 $langs->load(
"errors");
3168 print
'<!-- ErrorFailedToLoadModuleDescriptorForXXX -->';
3169 print
img_warning(
'').
' '.$langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3170 print $loadclasserrormessage;
3181$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=initmodule';
3182$head[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewModule").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3183$head[$h][2] =
'initmodule';
3186$linktoenabledisable =
'';
3188if (is_array($listofmodules) && count($listofmodules) > 0) {
3190 $modulelowercase = strtolower($module);
3194 $param .=
'&tab='.urlencode($tab);
3197 $param .=
'&module='.urlencode($module);
3200 $param .=
'&tabobj='.urlencode($tabobj);
3203 $urltomodulesetup =
'<a href="'.DOL_URL_ROOT.
'/admin/modules.php?search_keyword='.urlencode($module).
'">'.$langs->trans(
'Home').
'-'.$langs->trans(
"Setup").
'-'.$langs->trans(
"Modules").
'</a>';
3206 if (isModEnabled($modulelowercase)) {
3207 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=reset&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3208 $linktoenabledisable .=
img_picto($langs->trans(
"Activated"),
'switch_on',
'',
false, 0, 0,
'',
'', 1);
3209 $linktoenabledisable .=
'</a>';
3211 $linktoenabledisable .= $form->textwithpicto(
'', $langs->trans(
"Warning").
' : '.$langs->trans(
"ModuleIsLive"), -1,
'warning');
3213 $objMod = $moduleobj;
3214 $backtourlparam =
'';
3215 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'module='.$module;
3217 $backtourlparam .= ($backtourlparam ?
'&' :
'?').
'tab='.$tab;
3219 $backtourl = $_SERVER[
"PHP_SELF"].$backtourlparam;
3222 if (is_array($objMod->config_page_url)) {
3224 foreach ($objMod->config_page_url as $page) {
3227 $linktoenabledisable .=
' <a href="'.$urlpage.
'" title="'.$langs->trans($page).
'">'.
img_picto(ucfirst($page),
"setup").
'</a>';
3230 if (preg_match(
'/^([^@]+)@([^@]+)$/i', $urlpage, $regs)) {
3231 $urltouse =
dol_buildpath(
'/'.$regs[2].
'/admin/'.$regs[1], 1);
3232 $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: 8px"').
'</a>';
3236 $urltouse = DOL_URL_ROOT.
'/admin/'.$urlpage;
3237 $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: 8px"').
'</a>';
3241 } elseif (preg_match(
'/^([^@]+)@([^@]+)$/i', $objMod->config_page_url, $regs)) {
3242 $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: 8px"').
'</a>';
3245 if (!empty($moduleobj)) {
3246 $linktoenabledisable .=
'<a class="reposition asetresetmodule valignmiddle" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$moduleobj->numero.
'&action=set&token='.
newToken().
'&value=mod'.$module.$param.
'">';
3247 $linktoenabledisable .=
img_picto($langs->trans(
"ModuleIsNotActive", $urltomodulesetup),
'switch_off',
'style="padding-right: 8px"',
false, 0, 0,
'',
'classfortooltip', 1);
3248 $linktoenabledisable .=
"</a>\n";
3253 foreach ($listofmodules as $tmpmodule => $tmpmodulearray) {
3254 $head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module='.$tmpmodulearray[
'modulenamewithcase'].($forceddirread ?
'@'.$dirread :
'');
3255 $head[$h][1] = $tmpmodulearray[
'modulenamewithcase'];
3256 $head[$h][2] = $tmpmodulearray[
'modulenamewithcase'];
3258 if ($tmpmodulearray[
'modulenamewithcase'] == $module) {
3259 $head[$h][4] =
'<span class="inline-block">'.$linktoenabledisable.
'</span>';
3266$head[$h][0] = $_SERVER[
"PHP_SELF"].
'?module=deletemodule';
3267$head[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3268$head[$h][2] =
'deletemodule';
3274if ($module ==
'initmodule') {
3276 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3277 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3278 print
'<input type="hidden" name="action" value="initmodule">';
3279 print
'<input type="hidden" name="module" value="initmodule">';
3284 print
'<div class="tagtable">';
3286 print
'<div class="tagtr"><div class="tagtd paddingright">';
3287 print
'<span class="opacitymedium">'.$langs->trans(
"IdModule").
'</span>';
3288 print
'</div><div class="tagtd">';
3289 print
'<input type="text" name="idmodule" class="width75" value="500000" placeholder="'.dol_escape_htmltag($langs->trans(
"IdModule")).
'">';
3290 print
'<span class="opacitymedium">';
3292 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3294 print
'<a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>';
3297 print
'</div></div>';
3299 print
'<div class="tagtr"><div class="tagtd paddingright">';
3300 print
'<span class="opacitymedium fieldrequired">'.$langs->trans(
"ModuleName").
'</span>';
3301 print
'</div><div class="tagtd">';
3302 print
'<input type="text" name="modulename" value="'.dol_escape_htmltag($modulename).
'" autofocus>';
3303 print
' '.$form->textwithpicto(
'', $langs->trans(
"EnterNameOfModuleDesc"));
3304 print
'</div></div>';
3306 print
'<div class="tagtr"><div class="tagtd paddingright">';
3307 print
'<span class="opacitymedium">'.$langs->trans(
"Description").
'</span>';
3308 print
'</div><div class="tagtd">';
3309 print
'<input type="text" name="description" value="" class="minwidth500"><br>';
3310 print
'</div></div>';
3312 print
'<div class="tagtr"><div class="tagtd paddingright">';
3313 print
'<span class="opacitymedium">'.$langs->trans(
"Version").
'</span>';
3314 print
'</div><div class="tagtd">';
3315 print
'<input type="text" name="version" class="width75" value="'.(GETPOSTISSET(
'version') ?
GETPOST(
'version') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_VERSION',
'1.0')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Version")).
'">';
3316 print
'</div></div>';
3318 print
'<div class="tagtr"><div class="tagtd paddingright">';
3319 print
'<span class="opacitymedium">'.$langs->trans(
"Family").
'</span>';
3320 print
'</div><div class="tagtd">';
3321 print
'<select name="family" id="family" class="minwidth400">';
3322 $arrayoffamilies = array(
3323 'hr' =>
"ModuleFamilyHr",
3324 'crm' =>
"ModuleFamilyCrm",
3325 'srm' =>
"ModuleFamilySrm",
3326 'financial' =>
'ModuleFamilyFinancial',
3327 'products' =>
'ModuleFamilyProducts',
3328 'projects' =>
'ModuleFamilyProjects',
3329 'ecm' =>
'ModuleFamilyECM',
3330 'technic' =>
'ModuleFamilyTechnic',
3331 'portal' =>
'ModuleFamilyPortal',
3332 'interface' =>
'ModuleFamilyInterface',
3333 'base' =>
'ModuleFamilyBase',
3334 'other' =>
'ModuleFamilyOther'
3336 foreach ($arrayoffamilies as $key => $value) {
3337 print
'<option value="hr"'.($key ==
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_FAMILY',
'other') ?
' selected="selected"' :
'').
' data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3341 print
'</div></div>';
3343 print
'<div class="tagtr"><div class="tagtd paddingright">';
3344 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span>';
3345 print
'</div><div class="tagtd">';
3346 print
'<input type="text" name="idpicto" value="'.(GETPOSTISSET(
'idpicto') ?
GETPOST(
'idpicto') :
getDolGlobalString(
'MODULEBUILDER_DEFAULTPICTO',
'fa-file-o')).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3347 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3348 print
'</div></div>';
3350 print
'<div class="tagtr"><div class="tagtd paddingright">';
3351 print
'<span class="opacitymedium">'.$langs->trans(
"EditorName").
'</span>';
3352 print
'</div><div class="tagtd">';
3353 print
'<input type="text" name="editorname" value="'.(GETPOSTISSET(
'editorname') ?
GETPOST(
'editorname') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_EDITOR_NAME', $mysoc->
name)).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"EditorName")).
'"><br>';
3354 print
'</div></div>';
3356 print
'<div class="tagtr"><div class="tagtd paddingright">';
3357 print
'<span class="opacitymedium">'.$langs->trans(
"EditorUrl").
'</span>';
3358 print
'</div><div class="tagtd">';
3359 print
'<input type="text" name="editorurl" value="'.(GETPOSTISSET(
'editorurl') ?
GETPOST(
'editorurl') :
getDolGlobalString(
'MODULEBUILDER_SPECIFIC_EDITOR_URL', $mysoc->url)).
'" placeholder="'.
dol_escape_htmltag($langs->trans(
"EditorUrl")).
'"><br>';
3360 print
'</div></div>';
3362 print
'<br><input type="submit" class="button" name="create" value="'.dol_escape_htmltag($langs->trans(
"Create")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3364} elseif ($module ==
'deletemodule') {
3365 print
'<!-- Form to init a module -->'.
"\n";
3366 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="delete">';
3367 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3368 print
'<input type="hidden" name="action" value="confirm_deletemodule">';
3369 print
'<input type="hidden" name="module" value="deletemodule">';
3371 print $langs->trans(
"EnterNameOfModuleToDeleteDesc").
'<br><br>';
3373 print
'<input type="text" name="module" placeholder="'.dol_escape_htmltag($langs->trans(
"ModuleKey")).
'" value="" autofocus>';
3374 print
'<input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Delete").
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3376} elseif (!empty($module)) {
3379 $dirread = $listofmodules[strtolower($module)][
'moduledescriptorrootpath'];
3380 $destdir = $dirread.
'/'.strtolower($module);
3384 $countDictionaries = (!empty($moduleobj->dictionaries) ? count($moduleobj->dictionaries[
'tabname']) : 0);
3385 $countRights = count($moduleobj->rights);
3386 $countMenus = count($moduleobj->menu);
3398 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=description&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3399 $head2[$h][1] = $langs->trans(
"Description");
3400 $head2[$h][2] =
'description';
3403 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3404 $head2[$h][1] = ((!is_array($objects) || count($objects) <= 0) ? $langs->trans(
"Objects") : $langs->trans(
"Objects").
'<span class="marginleftonlyshort badge">'.count($objects).
"</span>");
3405 $head2[$h][2] =
'objects';
3408 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=languages&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3409 $head2[$h][1] = ($countLangs <= 0 ? $langs->trans(
"Languages") : $langs->trans(
"Languages").
'<span class="marginleftonlyshort badge">'.$countLangs.
"</span>");
3410 $head2[$h][2] =
'languages';
3413 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3414 $head2[$h][1] = ($countDictionaries == 0 ? $langs->trans(
"Dictionaries") : $langs->trans(
'Dictionaries').
'<span class="marginleftonlyshort badge">'.$countDictionaries.
"</span>");
3415 $head2[$h][2] =
'dictionaries';
3418 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=permissions&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3419 $head2[$h][1] = ($countRights <= 0 ? $langs->trans(
"Permissions") : $langs->trans(
"Permissions").
'<span class="marginleftonlyshort badge">'.$countRights.
"</span>");
3420 $head2[$h][2] =
'permissions';
3423 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=tabs&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3424 $head2[$h][1] = $langs->trans(
"Tabs");
3425 $head2[$h][2] =
'tabs';
3428 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=menus&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3429 $head2[$h][1] = ($countMenus <= 0 ? $langs->trans(
"Menus") : $langs->trans(
"Menus").
'<span class="marginleftonlyshort badge">'.$countMenus.
"</span>");
3430 $head2[$h][2] =
'menus';
3433 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=hooks&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3434 $head2[$h][1] = $langs->trans(
"Hooks");
3435 $head2[$h][2] =
'hooks';
3438 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=triggers&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3439 $head2[$h][1] = ($countTriggers <= 0 ? $langs->trans(
"Triggers") : $langs->trans(
"Triggers").
'<span class="marginleftonlyshort badge">'.$countTriggers.
"</span>");
3440 $head2[$h][2] =
'triggers';
3443 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=widgets&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3444 $head2[$h][1] = ($countWidgets <= 0 ? $langs->trans(
"Widgets") : $langs->trans(
"Widgets").
'<span class="marginleftonlyshort badge">'.$countWidgets.
"</span>");
3445 $head2[$h][2] =
'widgets';
3448 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=emailings&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3449 $head2[$h][1] = ($countEmailingSelectors <= 0 ? $langs->trans(
"EmailingSelectors") : $langs->trans(
"EmailingSelectors").
'<span class="marginleftonlyshort badge">'.$countEmailingSelectors.
"</span>");
3450 $head2[$h][2] =
'emailings';
3453 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=exportimport&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3454 $head2[$h][1] = $langs->trans(
"Export").
'-'.$langs->trans(
"Import");
3455 $head2[$h][2] =
'exportimport';
3458 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=css&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3459 $head2[$h][1] = ($countCss <= 0 ? $langs->trans(
"CSS") : $langs->trans(
"CSS").
" (".$countCss.
")");
3460 $head2[$h][2] =
'css';
3463 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=js&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3464 $head2[$h][1] = ($countJs <= 0 ? $langs->trans(
"JS") : $langs->trans(
"JS").
'<span class="marginleftonlyshort badge">'.$countJs.
"</span>");
3465 $head2[$h][2] =
'js';
3468 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cli&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3469 $head2[$h][1] = ($countCLI <= 0 ? $langs->trans(
"CLI") : $langs->trans(
"CLI").
'<span class="marginleftonlyshort badge">'.$countCLI.
"</span>");
3470 $head2[$h][2] =
'cli';
3473 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=cron&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3474 $head2[$h][1] = $langs->trans(
"CronList");
3475 $head2[$h][2] =
'cron';
3478 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=specifications&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3479 $head2[$h][1] = ($hasDoc <= 0 ? $langs->trans(
"Documentation") : $langs->trans(
"Documentation").
'<span class="paddingleft badge">'.$hasDoc.
"</span>");
3480 $head2[$h][2] =
'specifications';
3483 $head2[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=buildpackage&module='.$module.($forceddirread ?
'@'.$dirread :
'');
3484 $head2[$h][1] = $langs->trans(
"BuildPackage");
3485 $head2[$h][2] =
'buildpackage';
3488 $MAXTABFOROBJECT = 15;
3490 print
'<!-- Section for a given module -->';
3494 if ($tab ==
'description') {
3495 print
'<!-- tab=description -->'.
"\n";
3496 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
3497 $pathtofilereadme = $modulelowercase.
'/README.md';
3498 $pathtochangelog = $modulelowercase.
'/ChangeLog.md';
3500 $realpathofmodule = realpath($dirread.
'/'.$modulelowercase);
3502 if ($action !=
'editfile' || empty($file)) {
3503 $morehtmlright =
'';
3504 if ($realpathofmodule != $dirread.
'/'.$modulelowercase) {
3505 $morehtmlright =
'<div style="padding: 12px 9px 12px">'.$form->textwithpicto(
'',
'<span class="opacitymedium">'.$langs->trans(
"RealPathOfModule").
' :</span> <strong class="wordbreak">'.$realpathofmodule.
'</strong>').
'</div>';
3508 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0, $morehtmlright,
'', $MAXTABFOROBJECT,
'formodulesuffix');
3510 print
'<span class="opacitymedium">'.$langs->trans(
"ModuleBuilderDesc".$tab).
'</span>';
3516 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3517 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=DESCRIPTION_FLAG">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3521 $listofsetuppages =
dol_dir_list($realpathofmodule.
'/admin',
'files', 0,
'\.php$');
3522 foreach ($listofsetuppages as $setuppage) {
3525 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SetupFile").
' : ';
3526 print
'<strong class="wordbreak bold"><a href="'.dol_buildpath($modulelowercase.
'/admin/'.$setuppage[
'relativename'], 1).
'" target="_test">'.$modulelowercase.
'/admin/'.$setuppage[
'relativename'].
'</a></strong>';
3527 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($modulelowercase.
'/admin/'.$setuppage[
'relativename']).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3531 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ReadmeFile").
' : <strong class="wordbreak">'.$pathtofilereadme.
'</strong>';
3532 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=markdown&file='.urlencode($pathtofilereadme).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3535 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"ChangeLog").
' : <strong class="wordbreak">'.$pathtochangelog.
'</strong>';
3536 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=markdown&file='.urlencode($pathtochangelog).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3542 print
load_fiche_titre($form->textwithpicto($langs->trans(
"DescriptorFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofile),
'',
'');
3544 if (!empty($moduleobj)) {
3545 print
'<div class="underbanner clearboth"></div>';
3546 print
'<div class="fichecenter">';
3547 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3548 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3549 print
'<input type="hidden" name="action" value="update_props_module">';
3550 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3551 print
'<input type="hidden" name="tab" value="'.dol_escape_htmltag($tab).
'">';
3552 print
'<input type="hidden" name="keydescription" value="'.dol_escape_htmltag(
GETPOST(
'keydescription',
'alpha')).
'">';
3553 print
'<table class="border centpercent">';
3554 print
'<tr class="liste_titre"><td class="titlefield">';
3555 print $langs->trans(
"Parameter");
3557 print $langs->trans(
"Value");
3561 print $langs->trans(
"IdModule");
3563 print $moduleobj->numero;
3564 print
'<span class="opacitymedium">';
3566 print
dolButtonToOpenUrlInDialogPopup(
'popup_modules_id', $langs->transnoentitiesnoconv(
"SeeIDsInUse"), $langs->transnoentitiesnoconv(
"SeeIDsInUse"),
'/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info',
'',
'');
3567 print
' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeReservedIDsRangeHere").
'</a>)';
3572 print $langs->trans(
"ModuleName");
3574 print $moduleobj->getName();
3578 print $langs->trans(
"Description");
3580 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'desc') {
3581 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag($moduleobj->description).
'">';
3582 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifydesc" value="'.$langs->trans(
"Modify").
'"/>';
3583 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3585 print $moduleobj->description;
3586 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=desc">'.
img_edit().
'</a>';
3588 $moduledescritpionautotrans = $moduleobj->getDesc();
3589 if ($moduledescritpionautotrans !=
"Module".$moduleobj->name.
"Desc") {
3591 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->name.
"Desc", $moduledescritpionautotrans));
3592 } elseif ($moduledescritpionautotrans !=
"Module".$moduleobj->numero.
"Desc") {
3594 print
' '.$form->textwithpicto(
'', $langs->trans(
"ModuleTranslatedIntoLangForKeyInto",
"Module".$moduleobj->numero.
"Desc", $moduledescritpionautotrans));
3600 print $langs->trans(
"Version");
3602 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'version') {
3603 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->getVersion()).
'">';
3604 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyversion" value="'.$langs->trans(
"Modify").
'"/>';
3605 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3607 print $moduleobj->getVersion();
3608 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=version">'.
img_edit().
'</a>';
3613 print $langs->trans(
"Family");
3616 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'family') {
3617 print
'<select name="propsmodule" id="family" class="minwidth400">';
3618 $arrayoffamilies = array(
3619 'hr' =>
"ModuleFamilyHr",
3620 'crm' =>
"ModuleFamilyCrm",
3621 'srm' =>
"ModuleFamilySrm",
3622 'financial' =>
'ModuleFamilyFinancial',
3623 'products' =>
'ModuleFamilyProducts',
3624 'projects' =>
'ModuleFamilyProjects',
3625 'ecm' =>
'ModuleFamilyECM',
3626 'technic' =>
'ModuleFamilyTechnic',
3627 'portal' =>
'ModuleFamilyPortal',
3628 'interface' =>
'ModuleFamilyInterface',
3629 'base' =>
'ModuleFamilyBase',
3630 'other' =>
'ModuleFamilyOther'
3632 print
'<option value="'.$moduleobj->family.
'" data-html="'.
dol_escape_htmltag($langs->trans($arrayoffamilies[$moduleobj->family]).
' <span class="opacitymedium">- '.$moduleobj->family.
'</span>').
'">'.$langs->trans($arrayoffamilies[$moduleobj->family]).
'</option>';
3633 foreach ($arrayoffamilies as $key => $value) {
3634 if ($key != $moduleobj->family) {
3635 print
'<option value="'.$key.
'" data-html="'.
dol_escape_htmltag($langs->trans($value).
' <span class="opacitymedium">- '.$key.
'</span>').
'">'.$langs->trans($value).
'</option>';
3639 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyfamily" value="'.$langs->trans(
"Modify").
'"/>';
3640 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3642 print $moduleobj->family;
3643 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=family">'.
img_edit().
'</a>';
3648 print $langs->trans(
"Picto");
3650 if ($action ==
'edit_modulepicto' &&
GETPOST(
'keydescription',
'alpha') ===
'picto') {
3651 print
'<input class="minwidth500" name="propsmodule" value="'.dol_escape_htmltag($moduleobj->picto).
'">';
3652 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifypicto" value="'.$langs->trans(
"Modify").
'"/>';
3653 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3655 print $moduleobj->picto;
3656 print
' '.img_picto(
'', $moduleobj->picto,
'class="valignmiddle pictomodule paddingrightonly"');
3657 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_modulepicto&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=picto">'.
img_edit().
'</a>';
3662 print $langs->trans(
"EditorName");
3664 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_name') {
3665 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->editor_name).
'">';
3666 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyname" value="'.$langs->trans(
"Modify").
'"/>';
3667 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3669 print $moduleobj->editor_name;
3670 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=editor_name">'.
img_edit().
'</a>';
3675 print $langs->trans(
"EditorUrl");
3677 if ($action ==
'edit_moduledescription' &&
GETPOST(
'keydescription',
'alpha') ===
'editor_url') {
3678 print
'<input name="propsmodule" value="'.dol_escape_htmltag($moduleobj->editor_url).
'">';
3679 print
'<input class="reposition button smallpaddingimp" type="submit" name="modifyeditorurl" value="'.$langs->trans(
"Modify").
'"/>';
3680 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'"/>';
3682 if (!empty($moduleobj->editor_url)) {
3683 print
'<a href="'.$moduleobj->editor_url.
'" target="_blank" rel="noopener">'.$moduleobj->editor_url.
' '.
img_picto(
'',
'globe').
'</a>';
3685 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit_moduledescription&token='.
newToken().
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&keydescription=editor_url">'.
img_edit().
'</a>';
3692 print $langs->trans(
"ErrorFailedToLoadModuleDescriptorForXXX", $module).
'<br>';
3695 if (!empty($moduleobj)) {
3699 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ReadmeFile"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtofilereadme),
'',
'');
3701 print
'<!-- readme file -->';
3702 if (
dol_is_file($dirread.
'/'.$pathtofilereadme)) {
3703 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getDescLong().
'</div>';
3705 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtofilereadme).
'</span>';
3711 print
load_fiche_titre($form->textwithpicto($langs->trans(
"ChangeLog"), $langs->transnoentitiesnoconv(
"File").
' '.$pathtochangelog),
'',
'');
3713 print
'<!-- changelog file -->';
3715 print
'<div class="underbanner clearboth"></div><div class="fichecenter">'.$moduleobj->getChangeLog().
'</div>';
3717 print
'<span class="opacitymedium">'.$langs->trans(
"ErrorFileNotFound", $pathtochangelog).
'</span>';
3725 if ($fullpathoffile) {
3726 $content = file_get_contents($fullpathoffile);
3730 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3731 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3732 print
'<input type="hidden" name="action" value="savefile">';
3733 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3734 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3735 print
'<input type="hidden" name="module" value="'.$module.
'">';
3739 $posCursor = (empty($find)) ? array() : array(
'find'=>$find);
3740 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%', 0, $posCursor);
3741 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
3746 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3748 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3754 print
dol_get_fiche_head($head2, $tab,
'', -1,
'', 0,
'',
'', $MAXTABFOROBJECT,
'formodulesuffix');
3757 if ($tab ==
'languages') {
3758 print
'<!-- tab=languages -->'.
"\n";
3759 if ($action !=
'editfile' || empty($file)) {
3760 print
'<span class="opacitymedium">'.$langs->trans(
"LanguageDefDesc").
'</span><br>';
3764 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3765 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3766 print
'<input type="hidden" name="action" value="addlanguage">';
3767 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3768 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3769 print
'<input type="hidden" name="module" value="'.$module.
'">';
3770 print $formadmin->select_language(
getDolGlobalString(
'MAIN_LANG_DEFAULT'),
'newlangcode', 0, 0, 1, 0, 0,
'minwidth300', 1);
3771 print
'<input type="submit" name="addlanguage" class="button smallpaddingimp" value="'.dol_escape_htmltag($langs->trans(
"AddLanguageFile")).
'"><br>';
3777 $modulelowercase = strtolower($module);
3781 $diroflang .=
'/langs';
3782 $langfiles =
dol_dir_list($diroflang,
'files', 1,
'\.lang$');
3784 if (!preg_match(
'/custom/', $dirread)) {
3786 $diroflang = $dirread;
3787 $diroflang .=
'/langs';
3788 $langfiles =
dol_dir_list($diroflang,
'files', 1, $modulelowercase.
'\.lang$');
3791 print
'<table class="none">';
3792 foreach ($langfiles as $langfile) {
3793 $pathtofile = $modulelowercase.
'/langs/'.$langfile[
'relativename'];
3794 if (!preg_match(
'/custom/', $dirread)) {
3795 $pathtofile =
'langs/'.$langfile[
'relativename'];
3797 print
'<tr><td><span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' '.basename(dirname($pathtofile)).
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
3798 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=ini&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
3799 print
'</td><td><a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
3810 $content = file_get_contents($fullpathoffile);
3813 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3814 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3815 print
'<input type="hidden" name="action" value="savefile">';
3816 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
3817 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
3818 print
'<input type="hidden" name="module" value="'.$module.
'">';
3820 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
3821 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'text'));
3824 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
3826 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
3833 if ($tab ==
'objects') {
3834 print
'<!-- tab=objects -->'.
"\n";
3839 $dir = $dirread.
'/'.$modulelowercase.
'/class';
3841 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=newobject';
3842 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewObjectInModulebuilder").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
3843 $head3[$h][2] =
'newobject';
3847 $listofobject =
dol_dir_list($dir,
'files', 0,
'\.class\.php$');
3849 $firstobjectname =
'';
3850 foreach ($listofobject as $fileobj) {
3851 if (preg_match(
'/^api_/', $fileobj[
'name'])) {
3854 if (preg_match(
'/^actions_/', $fileobj[
'name'])) {
3858 $tmpcontent = file_get_contents($fileobj[
'fullname']);
3859 if (preg_match(
'/class\s+([^\s]*)\s+extends\s+CommonObject/ims', $tmpcontent, $reg)) {
3861 $objectname = $reg[1];
3862 if (empty($firstobjectname)) {
3863 $firstobjectname = $objectname;
3865 $pictoname =
'generic';
3866 if (preg_match(
'/\$picto\s*=\s*["\']([^"\']+)["\']/', $tmpcontent, $reg)) {
3867 $pictoname = $reg[1];
3870 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj='.$objectname;
3871 $head3[$h][1] =
img_picto(
'', $pictoname,
'class="pictofixedwidth valignmiddle"').$objectname;
3872 $head3[$h][2] = $objectname;
3878 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=objects&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabobj=deleteobject';
3879 $head3[$h][1] =
img_picto(
'',
'delete',
'class="pictofixedwidth"').$langs->trans(
"DangerZone");
3880 $head3[$h][2] =
'deleteobject';
3885 if ($tabobj ==
'newobjectifnoobj') {
3886 if ($firstobjectname) {
3887 $tabobj = $firstobjectname;
3889 $tabobj =
'newobject';
3893 print
dol_get_fiche_head($head3, $tabobj,
'', -1,
'', 0,
'',
'', 0,
'forobjectsuffix');
3896 if ($tabobj ==
'newobject') {
3898 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
3899 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3900 print
'<input type="hidden" name="action" value="initobject">';
3901 print
'<input type="hidden" name="tab" value="objects">';
3902 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3904 print
'<span class="opacitymedium">'.$langs->trans(
"EnterNameOfObjectDesc").
'</span><br><br>';
3906 print
'<div class="tagtable">';
3908 print
'<div class="tagtr"><div class="tagtd">';
3909 print
'<span class="opacitymedium">'.$langs->trans(
"ObjectKey").
'</span> ';
3910 print
'</div><div class="tagtd">';
3911 print
'<input type="text" name="objectname" maxlength="64" value="'.dol_escape_htmltag(GETPOSTISSET(
'objectname') ?
GETPOST(
'objectname',
'alpha') : $modulename).
'" autofocus>';
3912 print $form->textwithpicto(
'', $langs->trans(
"Example").
': MyObject, ACamelCaseName, ...');
3913 print
'</div></div>';
3915 print
'<div class="tagtr"><div class="tagtd">';
3916 print
'<span class="opacitymedium">'.$langs->trans(
"Picto").
'</span> ';
3917 print
'</div><div class="tagtd">';
3918 print
'<input type="text" name="idpicto" value="fa-file-o" placeholder="'.dol_escape_htmltag($langs->trans(
"Picto")).
'">';
3919 print $form->textwithpicto(
'', $langs->trans(
"Example").
': fa-file-o, fa-globe, ... any font awesome code.<br>Advanced syntax is fa-fakey[_faprefix[_facolor[_fasize]]]');
3920 print
'</div></div>';
3922 print
'<div class="tagtr"><div class="tagtd">';
3923 print
'<span class="opacitymedium">'.$langs->trans(
"DefinePropertiesFromExistingTable").
'</span> ';
3924 print
'</div><div class="tagtd">';
3925 print
'<input type="text" name="initfromtablename" value="'.GETPOST(
'initfromtablename').
'" placeholder="'.$langs->trans(
"TableName").
'">';
3926 print $form->textwithpicto(
'', $langs->trans(
"DefinePropertiesFromExistingTableDesc").
'<br>'.$langs->trans(
"DefinePropertiesFromExistingTableDesc2"));
3927 print
'</div></div>';
3932 print
'<input type="checkbox" name="includerefgeneration" id="includerefgeneration" value="includerefgeneration"> <label class="margintoponly" for="includerefgeneration">'.$form->textwithpicto($langs->trans(
"IncludeRefGeneration"), $langs->trans(
"IncludeRefGenerationHelp")).
'</label><br>';
3933 print
'<input type="checkbox" name="includedocgeneration" id="includedocgeneration" value="includedocgeneration"> <label for="includedocgeneration">'.$form->textwithpicto($langs->trans(
"IncludeDocGeneration"), $langs->trans(
"IncludeDocGenerationHelp")).
'</label><br>';
3934 print
'<input type="checkbox" name="generatepermissions" id="generatepermissions" value="generatepermissions"> <label for="generatepermissions">'.$form->textwithpicto($langs->trans(
"GeneratePermissions"), $langs->trans(
"GeneratePermissionsHelp")).
'</label><br>';
3936 print
'<input type="submit" class="button small" name="create" value="'.dol_escape_htmltag($langs->trans(
"GenerateCode")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
3952 } elseif ($tabobj ==
'createproperty') {
3953 $attributesUnique = array(
3954 'proplabel' => $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey")),
3955 'propname' => $form->textwithpicto($langs->trans(
"Code"), $langs->trans(
"PropertyDesc"), 1,
'help',
'extracss', 0, 3,
'propertyhelp'),
3956 'proptype' => $form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp'),
3957 'proparrayofkeyval' => $form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")),
3958 'propnotnull' => $form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")),
3959 'propdefault' => $langs->trans(
"DefaultValue"),
3960 'propindex' => $langs->trans(
"DatabaseIndex"),
3961 'propforeignkey' => $form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp'),
3962 'propposition' => $langs->trans(
"Position"),
3963 'propenabled' => $form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp'),
3964 'propvisible' => $form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp'),
3965 'propnoteditable' => $langs->trans(
"NotEditable"),
3967 'propsearchall' => $form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")),
3968 'propisameasure' => $form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")),
3969 'propcss' => $langs->trans(
"CSSClass"),
3970 'propcssview' => $langs->trans(
"CSSViewClass"),
3971 'propcsslist' => $langs->trans(
"CSSListClass"),
3972 'prophelp' => $langs->trans(
"KeyForTooltip"),
3973 'propshowoncombobox' => $langs->trans(
"ShowOnCombobox"),
3975 'propcomment' => $langs->trans(
"Comment"),
3977 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode(
GETPOST(
'obj')).
'" method="POST">';
3978 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3979 print
'<input type="hidden" name="action" value="addproperty">';
3980 print
'<input type="hidden" name="tab" value="objects">';
3981 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
3982 print
'<input type="hidden" name="obj" value="'.dol_escape_htmltag(
GETPOST(
'obj')).
'">';
3984 print
'<table class="border centpercent tableforfieldcreate">'.
"\n";
3986 foreach ($attributesUnique as $key => $attribute) {
3987 if ($counter % 2 === 0) {
3990 if ($key ==
'propname' || $key ==
'proplabel') {
3991 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50"><input class="maxwidth200" id="'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'"></td>';
3992 } elseif ($key ==
'proptype') {
3993 print
'<td class="titlefieldcreate fieldrequired">'.$attribute.
'</td><td class="valuefieldcreate maxwidth50">';
3994 print
'<input class="maxwidth200" id="'.$key.
'" list="datalist'.$key.
'" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(
GETPOST($key,
'alpha')).
'">';
3996 print
'<datalist id="datalist'.$key.
'">';
3997 print
'<option>varchar(128)</option>';
3998 print
'<option>email</option>';
3999 print
'<option>phone</option>';
4000 print
'<option>ip</option>';
4001 print
'<option>url</option>';
4002 print
'<option>password</option>';
4003 print
'<option>text</option>';
4004 print
'<option>html</option>';
4005 print
'<option>date</option>';
4006 print
'<option>datetime</option>';
4007 print
'<option>integer</option>';
4008 print
'<option>double(28,4)</option>';
4009 print
'<option>real</option>';
4010 print
'<option>integer:ClassName:RelativePath/To/ClassFile.class.php[:1[:FILTER]]</option>';
4019 print
'</datalist>';
4023 } elseif ($key ==
'propvisible') {
4024 print
'<td class="titlefieldcreate">'.$attribute.
'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') :
"1").
'"></td>';
4025 } elseif ($key ==
'propenabled') {
4028 print
'<td class="titlefieldcreate">'.$attribute.
'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') : $default).
'"></td>';
4029 } elseif ($key ==
'proparrayofkeyval') {
4030 print
'<td class="titlefieldcreate tdproparrayofkeyval">'.$attribute.
'</td><td class="valuefieldcreate"><textarea class="maxwidth200" name="'.$key.
'">'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') :
"").
'</textarea></td>';
4032 print
'<td class="titlefieldcreate">'.$attribute.
'</td><td class="valuefieldcreate"><input class="maxwidth200" type="text" name="'.$key.
'" value="'.
dol_escape_htmltag(GETPOSTISSET($key) ?
GETPOST($key,
'alpha') :
'').
'"></td>';
4035 if ($counter % 2 === 0) {
4039 if ($counter % 2 !== 0) {
4040 while ($counter % 2 !== 0) {
4046 print
'</table><br>'.
"\n";
4047 print
'<div class="center">';
4048 print
'<input type="submit" class="button button-save" name="add" value="' .
dol_escape_htmltag($langs->trans(
'Create')) .
'">';
4049 print
'<input type="button" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
'Cancel')) .
'" onclick="goBack()">';
4055 var url = "'.$_SERVER[
"PHP_SELF"].
'?tab=objects&module='.urlencode($module).
'";
4056 window.location.href = url;
4058 $(document).ready(function() {
4059 $("#proplabel").on("keyup", function() {
4060 console.log("key up on label");
4061 s = cleanString($("#proplabel").val());
4062 $("#propname").val(s);
4065 function cleanString( stringtoclean )
4067 // allow "a-z", "A-Z", "0-9" and "_"
4068 stringtoclean = stringtoclean.replace(/[^a-z0-9_]+/ig, "");
4069 stringtoclean = stringtoclean.toLowerCase();
4070 if (!isNaN(stringtoclean)) {
4073 while ( stringtoclean.length > 1 && !isNaN( stringtoclean.charAt(0)) ){
4074 stringtoclean = stringtoclean.substr(1)
4076 if (stringtoclean.length > 28) {
4077 stringtoclean = stringtoclean.substring(0, 27);
4079 return stringtoclean;
4084 } elseif ($tabobj ==
'deleteobject') {
4086 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4087 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4088 print
'<input type="hidden" name="action" value="confirm_deleteobject">';
4089 print
'<input type="hidden" name="tab" value="objects">';
4090 print
'<input type="hidden" name="tabobj" value="deleteobject">';
4091 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module).
'">';
4093 print $langs->trans(
"EnterNameOfObjectToDeleteDesc").
'<br><br>';
4095 print
'<input type="text" name="objectname" value="" placeholder="'.dol_escape_htmltag($langs->trans(
"ObjectKey")).
'" autofocus>';
4096 print
'<input type="submit" class="button smallpaddingimp" name="delete" value="'.dol_escape_htmltag($langs->trans(
"Delete")).
'"'.($dirins ?
'' :
' disabled="disabled"').
'>';
4100 if ($action ==
'deleteproperty') {
4101 $formconfirm = $form->formconfirm(
4102 $_SERVER[
"PHP_SELF"].
'?propertykey='.urlencode(
GETPOST(
'propertykey',
'alpha')).
'&objectname='.urlencode($objectname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj),
4103 $langs->trans(
'Delete'),
4104 $langs->trans(
'ConfirmDeleteProperty',
GETPOST(
'propertykey',
'alpha')),
4105 'confirm_deleteproperty',
4114 if ($action !=
'editfile' || empty($file)) {
4118 $pathtoclass = strtolower($module).
'/class/'.strtolower($tabobj).
'.class.php';
4119 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
'.class.php';
4120 $pathtoagenda = strtolower($module).
'/'.strtolower($tabobj).
'_agenda.php';
4121 $pathtocard = strtolower($module).
'/'.strtolower($tabobj).
'_card.php';
4122 $pathtodocument = strtolower($module).
'/'.strtolower($tabobj).
'_document.php';
4123 $pathtolist = strtolower($module).
'/'.strtolower($tabobj).
'_list.php';
4124 $pathtonote = strtolower($module).
'/'.strtolower($tabobj).
'_note.php';
4125 $pathtocontact = strtolower($module).
'/'.strtolower($tabobj).
'_contact.php';
4126 $pathtophpunit = strtolower($module).
'/test/phpunit/'.strtolower($tabobj).
'Test.php';
4129 clearstatcache(
true);
4130 if (function_exists(
'opcache_invalidate')) {
4131 opcache_invalidate($dirread.
'/'.$pathtoclass,
true);
4134 if (empty($forceddirread) && empty($dirread)) {
4136 $stringofinclude =
"dol_include_once(".$pathtoclass.
")";
4138 $result = include_once $dirread.
'/'.$pathtoclass;
4139 $stringofinclude =
"@include_once ".$dirread.
'/'.$pathtoclass;
4142 if (class_exists($tabobj)) {
4144 $tmpobject = @
new $tabobj($db);
4146 dol_syslog(
'Failed to load Constructor of class: '.$e->getMessage(), LOG_WARNING);
4149 print
'<span class="warning">'.$langs->trans(
'Failed to find the class '.$tabobj.
' despite the '.$stringofinclude).
'</span><br><br>';
4153 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4156 $pathtosql = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'.sql';
4159 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'-'.strtolower($module).
'.sql';
4162 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'-'.strtolower($module).
'.sql';
4165 $pathtosql =
'install/mysql/tables/llx_'.strtolower($module).
'.sql';
4166 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields.sql';
4169 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_extrafields-'.strtolower($module).
'.sql';
4172 $pathtosqlextra =
'install/mysql/tables/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4175 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields.sql';
4178 $pathtosqlextra = strtolower($module).
'/sql/llx_'.strtolower($module).
'_'.strtolower($tabobj).
'_extrafields-'.strtolower($module).
'.sql';
4180 $pathtosqlroot = preg_replace(
'/\/llx_.*$/',
'', $pathtosql);
4182 $pathtosqlkey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosql);
4183 $pathtosqlextrakey = preg_replace(
'/\.sql$/',
'.key.sql', $pathtosqlextra);
4185 $pathtolib = strtolower($module).
'/lib/'.strtolower($module).
'.lib.php';
4186 $pathtoobjlib = strtolower($module).
'/lib/'.strtolower($module).
'_'.strtolower($tabobj).
'.lib.php';
4188 $tmpobject = $tmpobject ??
null;
4189 if (is_object($tmpobject) && property_exists($tmpobject,
'picto')) {
4190 $pathtopicto = $tmpobject->picto;
4191 $realpathtopicto =
'';
4193 $pathtopicto = strtolower($module).
'/img/object_'.strtolower($tabobj).
'.png';
4194 $realpathtopicto = $dirread.
'/'.$pathtopicto;
4199 $realpathtoclass = $dirread.
'/'.$pathtoclass;
4200 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4201 $realpathtoagenda = $dirread.
'/'.$pathtoagenda;
4202 $realpathtocard = $dirread.
'/'.$pathtocard;
4203 $realpathtodocument = $dirread.
'/'.$pathtodocument;
4204 $realpathtolist = $dirread.
'/'.$pathtolist;
4205 $realpathtonote = $dirread.
'/'.$pathtonote;
4206 $realpathtocontact = $dirread.
'/'.$pathtocontact;
4207 $realpathtophpunit = $dirread.
'/'.$pathtophpunit;
4208 $realpathtosql = $dirread.
'/'.$pathtosql;
4209 $realpathtosqlextra = $dirread.
'/'.$pathtosqlextra;
4210 $realpathtosqlkey = $dirread.
'/'.$pathtosqlkey;
4211 $realpathtosqlextrakey = $dirread.
'/'.$pathtosqlextrakey;
4212 $realpathtolib = $dirread.
'/'.$pathtolib;
4213 $realpathtoobjlib = $dirread.
'/'.$pathtoobjlib;
4215 if (empty($realpathtoapi)) {
4216 $pathtoapi = strtolower($module).
'/class/api_'.strtolower($module).
's.class.php';
4217 $realpathtoapi = $dirread.
'/'.$pathtoapi;
4225 print
'<!-- section for object -->';
4226 print
'<div class="fichehalfleft smallxxx">';
4228 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"ClassFile").
' : <strong>'.(
dol_is_file($realpathtoclass) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoclass).(
dol_is_file($realpathtoclass) ?
'' :
'</strike>').
'</strong>';
4229 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtoclass).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4232 if ($realpathtopicto &&
dol_is_file($realpathtopicto)) {
4233 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : <strong>'.(
dol_is_file($realpathtopicto) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtopicto).(
dol_is_file($realpathtopicto) ?
'' :
'</strike>').
'</strong>';
4236 } elseif (!empty($tmpobject)) {
4237 print
'<span class="fa fa-file-image-o"></span> '.$langs->trans(
"Image").
' : '.
img_picto(
'', $tmpobject->picto,
'class="pictofixedwidth valignmiddle"').$tmpobject->picto;
4243 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"ApiClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoapi) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoapi).(
dol_is_file($realpathtoapi) ?
'' :
'</span></strike>').
'</strong>';
4245 $file = file_get_contents($realpathtoapi);
4246 if (preg_match(
'/var '.$tabobj.
'\s+([^\s]*)\s/ims', $file, $objs)) {
4247 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4249 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4250 print $form->textwithpicto(
'', $langs->trans(
"InfoForApiFile"), 1,
'warning');
4253 if ($modulelowercase !==
null && !isModEnabled($modulelowercase)) {
4254 print
'<a href="#" class="classfortooltip" target="apiexplorer" title="'.$langs->trans(
"ModuleMustBeEnabled", $module).
'"><strike>'.$langs->trans(
"ApiExplorer").
'</strike></a>';
4256 print
'<a href="'.DOL_URL_ROOT.
'/api/index.php/explorer/" target="apiexplorer">'.$langs->trans(
"ApiExplorer").
'</a>';
4259 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initapi&token='.
newToken().
'&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto($langs->trans(
'AddAPIsForThisObject'),
'generate',
'class="paddingleft"').
'</a>';
4262 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initapi&token='.
newToken().
'&format=php&file='.urlencode($pathtoapi).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4266 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"TestClassFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtophpunit) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtophpunit).(
dol_is_file($realpathtophpunit) ?
'' :
'</span></strike>').
'</strong>';
4268 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtophpunit).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4270 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtophpunit).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4272 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initphpunit&token='.
newToken().
'&format=php&file='.urlencode($pathtophpunit).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4278 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtolib) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtolib).(
dol_is_file($realpathtolib) ?
'' :
'</strike>').
'</strong>';
4279 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtolib).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4281 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForObjLib").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoobjlib) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoobjlib).(
dol_is_file($realpathtoobjlib) ?
'' :
'</strike>').
'</strong>';
4282 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtoobjlib).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4286 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFile").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosql) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosql).(
dol_is_file($realpathtosql) ?
'' :
'</strike>').
'</strong>';
4287 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=sql&file='.urlencode($pathtosql).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4288 print
' <a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=droptable&token='.
newToken().
'">'.$langs->trans(
"DropTableIfEmpty").
'</a>';
4291 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileKey").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlkey) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlkey).(
dol_is_file($realpathtosqlkey) ?
'' :
'</strike>').
'</strong>';
4292 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=sql&file='.urlencode($pathtosqlkey).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4295 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextra) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlextra).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
4297 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4299 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtosqlextra).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4301 print
'<a class="reposition editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=droptableextrafields&token='.
newToken().
'">'.$langs->trans(
"DropTableIfEmpty").
'</a>';
4303 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initsqlextrafields&token='.
newToken().
'&format=sql&file='.urlencode($pathtosqlextra).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4307 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SqlFileKeyExtraFields").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtosqlextrakey) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtosqlextrakey).(
dol_is_file($realpathtosqlextra) &&
dol_is_file($realpathtosqlextrakey) ?
'' :
'</span></strike>').
'</strong>';
4309 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=sql&file='.urlencode($pathtosqlextrakey).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4311 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtosqlextrakey).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4313 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initsqlextrafields&token='.
newToken().
'&format=sql&file='.urlencode($pathtosqlextra).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4318 print
'<div class="fichehalfleft smallxxxx">';
4319 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForList").
' : <strong class="wordbreak"><a href="'.$urloflist.
'" target="_test">'.(
dol_is_file($realpathtolist) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtolist).(
dol_is_file($realpathtolist) ?
'' :
'</span></strike>').
'</a></strong>';
4320 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtolist).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4322 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForCreateEditView").
' : <strong class="wordbreak"><a href="'.$urlofcard.
'?action=create" target="_test">'.(
dol_is_file($realpathtocard) ?
'' :
'<strike>').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtocard).(
dol_is_file($realpathtocard) ?
'' :
'</strike>').
'?action=create</a></strong>';
4323 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtocard).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4326 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForContactTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtocontact) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtocontact).(
dol_is_file($realpathtocontact) ?
'' :
'</span></strike>').
'</strong>';
4327 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4330 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtocontact).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4332 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpagecontact&token='.
newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4336 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForDocumentTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtodocument) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtodocument).(
dol_is_file($realpathtodocument) ?
'' :
'</span></strike>').
'</strong>';
4337 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtodocument).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4340 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtodocument).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4342 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpagedocument&token='.
newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4346 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForNoteTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtonote) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtonote).(
dol_is_file($realpathtonote) ?
'' :
'</span></strike>').
'</strong>';
4347 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4350 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtonote).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4352 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpagenote&token='.
newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4356 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"PageForAgendaTab").
' : <strong class="wordbreak">'.(
dol_is_file($realpathtoagenda) ?
'' :
'<strike><span class="opacitymedium">').preg_replace(
'/^'.strtolower($module).
'\//',
'', $pathtoagenda).(
dol_is_file($realpathtoagenda) ?
'' :
'</span></strike>').
'</strong>';
4357 print
' <a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&format=php&token='.
newToken().
'&file='.urlencode($pathtoagenda).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4360 print
'<a class="reposition editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=confirm_removefile&token='.
newToken().
'&file='.urlencode($pathtoagenda).
'">'.
img_picto($langs->trans(
"Delete"),
'delete').
'</a>';
4362 print
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&tabobj='.$tabobj.
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=initpageagenda&token='.
newToken().
'&format=php&file='.urlencode($pathtocontact).
'">'.
img_picto(
'Generate',
'generate',
'class="paddingleft"').
'</a>';
4369 print
'<br><br><br>';
4371 if (!empty($tmpobject)) {
4372 $reflector =
new ReflectionClass($tabobj);
4373 $reflectorproperties = $reflector->getProperties();
4374 $reflectorpropdefault = $reflector->getDefaultProperties();
4378 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4379 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4380 print
'<input type="hidden" name="action" value="addproperty">';
4381 print
'<input type="hidden" name="tab" value="objects">';
4382 print
'<input type="hidden" name="page_y" value="">';
4383 print
'<input type="hidden" name="module" value="'.dol_escape_htmltag($module.($forceddirread ?
'@'.$dirread :
'')).
'">';
4384 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4386 print
'<input class="button smallpaddingimp" type="submit" name="regenerateclasssql" value="'.$langs->trans(
"RegenerateClassAndSql").
'">';
4389 $mod = strtolower($module);
4390 $obj = strtolower($tabobj);
4391 $newproperty =
dolGetButtonTitle($langs->trans(
'NewProperty'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=objects&module='.urlencode($module).
'&tabobj=createproperty&obj='.urlencode($tabobj));
4392 $nbOfProperties = count($reflectorpropdefault[
'fields']);
4394 print_barre_liste($langs->trans(
"ObjectProperties"), 0, $_SERVER[
"PHP_SELF"],
'',
'',
'',
'',
'', $nbOfProperties,
'', 0, $newproperty,
'',
'', 0, 0, 1);
4397 print
'<!-- Table with properties of object -->'.
"\n";
4398 print
'<div class="div-table-responsive">';
4399 print
'<table class="noborder small">';
4400 print
'<tr class="liste_titre">';
4401 print
'<th class="tdsticky tdstickygray">';
4402 $htmltext = $langs->trans(
"PropertyDesc").
'<br><br><a class="" href="https://wiki.dolibarr.org/index.php/Language_and_development_rules#Table_and_fields_structures" target="_blank" rel="noopener noreferrer external">'.$langs->trans(
"SeeExamples").
'</a>';
4403 print $form->textwithpicto($langs->trans(
"Code"), $htmltext, 1,
'help',
'extracss', 0, 3,
'propertyhelp');
4406 print $form->textwithpicto($langs->trans(
"Label"), $langs->trans(
"YouCanUseTranslationKey"));
4408 print
'<th>'.$form->textwithpicto($langs->trans(
"Type"), $langs->trans(
"TypeOfFieldsHelpIntro").
'<br><br>'.$langs->trans(
"TypeOfFieldsHelp"), 1,
'help',
'extracss', 0, 3,
'typehelp').
'</th>';
4409 print
'<th>'.$form->textwithpicto($langs->trans(
"ArrayOfKeyValues"), $langs->trans(
"ArrayOfKeyValuesDesc")).
'</th>';
4410 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"NotNull"), $langs->trans(
"NotNullDesc")).
'</th>';
4411 print
'<th class="center">'.$langs->trans(
"DefaultValue").
'</th>';
4412 print
'<th class="center">'.$langs->trans(
"DatabaseIndex").
'</th>';
4413 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"ForeignKey"), $langs->trans(
"ForeignKeyDesc"), 1,
'help',
'extracss', 0, 3,
'foreignkeyhelp').
'</th>';
4414 print
'<th class="right">'.$langs->trans(
"Position").
'</th>';
4415 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Enabled"), $langs->trans(
"EnabledDesc"), 1,
'help',
'extracss', 0, 3,
'enabledhelp').
'</th>';
4416 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"Visibility"), $langs->trans(
"VisibleDesc").
'<br><br>'.$langs->trans(
"ItCanBeAnExpression"), 1,
'help',
'extracss', 0, 3,
'visiblehelp').
'</th>';
4417 print
'<th class="center">'.$langs->trans(
"NotEditable").
'</th>';
4419 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"SearchAll"), $langs->trans(
"SearchAllDesc")).
'</th>';
4420 print
'<th class="center">'.$form->textwithpicto($langs->trans(
"IsAMeasure"), $langs->trans(
"IsAMeasureDesc")).
'</th>';
4421 print
'<th class="center">'.$langs->trans(
"CSSClass").
'</th>';
4422 print
'<th class="center">'.$langs->trans(
"CSSViewClass").
'</th>';
4423 print
'<th class="center">'.$langs->trans(
"CSSListClass").
'</th>';
4424 print
'<th>'.$langs->trans(
"KeyForTooltip").
'</th>';
4425 print
'<th class="center">'.$langs->trans(
"ShowOnCombobox").
'</th>';
4427 print
'<th>'.$form->textwithpicto($langs->trans(
"Validate"), $langs->trans(
"ValidateModBuilderDesc")).
'</th>';
4428 print
'<th>'.$langs->trans(
"Comment").
'</th>';
4429 print
'<th class="tdstickyright tdstickyghostwhite"></th>';
4435 $properties =
dol_sort_array($reflectorpropdefault[
'fields'],
'position');
4436 if (!empty($properties)) {
4438 foreach ($properties as $propkey => $propval) {
4453 $propname = $propkey;
4454 $proplabel = $propval[
'label'];
4455 $proptype = $propval[
'type'];
4456 $proparrayofkeyval = !empty($propval[
'arrayofkeyval']) ? $propval[
'arrayofkeyval'] :
'';
4457 $propnotnull = !empty($propval[
'notnull']) ? $propval[
'notnull'] :
'0';
4458 $propdefault = !empty($propval[
'default']) ? $propval[
'default'] :
'';
4459 $propindex = !empty($propval[
'index']) ? $propval[
'index'] :
'';
4460 $propforeignkey = !empty($propval[
'foreignkey']) ? $propval[
'foreignkey'] :
'';
4461 $propposition = $propval[
'position'];
4462 $propenabled = $propval[
'enabled'];
4463 $propvisible = $propval[
'visible'];
4464 $propnoteditable = !empty($propval[
'noteditable']) ? $propval[
'noteditable'] : 0;
4466 $propsearchall = !empty($propval[
'searchall']) ? $propval[
'searchall'] : 0;
4467 $propisameasure = !empty($propval[
'isameasure']) ? $propval[
'isameasure'] : 0;
4468 $propcss = !empty($propval[
'css']) ? $propval[
'css'] :
'';
4469 $propcssview = !empty($propval[
'cssview']) ? $propval[
'cssview'] :
'';
4470 $propcsslist = !empty($propval[
'csslist']) ? $propval[
'csslist'] :
'';
4471 $prophelp = !empty($propval[
'help']) ? $propval[
'help'] :
'';
4472 $propshowoncombobox = !empty($propval[
'showoncombobox']) ? $propval[
'showoncombobox'] : 0;
4474 $propvalidate = !empty($propval[
'validate']) ? $propval[
'validate'] : 0;
4475 $propcomment = !empty($propval[
'comment']) ? $propval[
'comment'] :
'';
4477 print
'<!-- line for object property -->'.
"\n";
4478 print
'<tr class="oddeven">';
4480 print
'<td class="tdsticky tdstickygray">';
4483 if ($action ==
'editproperty' && $propname == $propertykey) {
4485 print
'<input type="hidden" name="propname" value="'.dol_escape_htmltag($propname).
'">';
4486 print
'<input name="proplabel" class="maxwidth125" value="'.dol_escape_htmltag($proplabel).
'">';
4488 print
'<td class="tdoverflowmax150">';
4489 print
'<input name="proptype" class="maxwidth125" value="'.dol_escape_htmltag($proptype).
'"></input>';
4491 print
'<td class="tdoverflowmax200">';
4492 print
'<textarea name="proparrayofkeyval">';
4493 if (isset($proparrayofkeyval)) {
4494 if (is_array($proparrayofkeyval) || $proparrayofkeyval !=
'') {
4498 print
'</textarea>';
4501 print
'<input class="center width50" name="propnotnull" value="'.dol_escape_htmltag($propnotnull).
'">';
4504 print
'<input class="maxwidth50" name="propdefault" value="'.dol_escape_htmltag($propdefault).
'">';
4506 print
'<td class="center">';
4507 print
'<input class="center maxwidth50" name="propindex" value="'.dol_escape_htmltag($propindex).
'">';
4510 print
'<input class="center maxwidth100" name="propforeignkey" value="'.dol_escape_htmltag($propforeignkey).
'">';
4513 print
'<input class="right width50" name="propposition" value="'.dol_escape_htmltag($propposition).
'">';
4516 print
'<input class="center width75" name="propenabled" value="'.dol_escape_htmltag($propenabled).
'">';
4519 print
'<input class="center width75" name="propvisible" value="'.dol_escape_htmltag($propvisible).
'">';
4522 print
'<input class="center width50" name="propnoteditable" size="2" value="'.dol_escape_htmltag($propnoteditable).
'">';
4528 print
'<input class="center width50" name="propsearchall" value="'.dol_escape_htmltag($propsearchall).
'">';
4531 print
'<input class="center width50" name="propisameasure" value="'.dol_escape_htmltag($propisameasure).
'">';
4534 print
'<input class="center maxwidth50" name="propcss" value="'.dol_escape_htmltag($propcss).
'">';
4537 print
'<input class="center maxwidth50" name="propcssview" value="'.dol_escape_htmltag($propcssview).
'">';
4540 print
'<input class="center maxwidth50" name="propcsslist" value="'.dol_escape_htmltag($propcsslist).
'">';
4543 print
'<input class="maxwidth100" name="prophelp" value="'.dol_escape_htmltag($prophelp).
'">';
4546 print
'<input class="center maxwidth50" name="propshowoncombobox" value="'.dol_escape_htmltag($propshowoncombobox).
'">';
4549 print
'<input type="number" step="1" min="0" max="1" class="text maxwidth100" name="propvalidate" value="'.dol_escape_htmltag($propvalidate).
'">';
4552 print
'<input class="maxwidth100" name="propcomment" value="'.dol_escape_htmltag($propcomment).
'">';
4554 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4555 print
'<input class="reposition button smallpaddingimp" type="submit" name="edit" value="'.$langs->trans(
"Save").
'">';
4556 print
'<input class="reposition button button-cancel smallpaddingimp" type="submit" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
4559 print
'<td class="tdoverflowmax200" title="'.dol_escape_htmltag($proplabel).
'">';
4562 print
'<td class="tdoverflowmax200">';
4565 if (preg_match(
'/^varchar/', $proptype, $matches)) {
4566 $pictoType =
'varchar';
4567 } elseif (preg_match(
'/^integer:/', $proptype, $matches)) {
4568 $pictoType =
'link';
4569 } elseif (strpos($proptype,
'integer') === 0) {
4570 $pictoType = substr($proptype, 0, 3);
4571 } elseif (strpos($proptype,
'timestamp') === 0) {
4572 $pictoType =
'datetime';
4573 } elseif (strpos($proptype,
'real') === 0) {
4574 $pictoType =
'double';
4578 print
'<td class="tdoverflowmax200">';
4579 if ($proparrayofkeyval) {
4580 print
'<span title="'.dol_escape_htmltag(json_encode($proparrayofkeyval, JSON_UNESCAPED_UNICODE)).
'">';
4585 print
'<td class="center">';
4591 print
'<td class="center">';
4592 print $propindex ?
'1' :
'';
4594 print
'<td class="center">';
4597 print
'<td class="right">';
4600 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4604 print
'<td class="center tdoverflowmax100" title="'.($propvisible ?
dol_escape_htmltag($propvisible) :
'0').
'">';
4608 print
'<td class="center tdoverflowmax100" title="'.($propnoteditable ?
dol_escape_htmltag($propnoteditable) :
'').
'">';
4614 print
'<td class="center">';
4615 print $propsearchall ?
'1' :
'';
4617 print
'<td class="center">';
4620 print
'<td class="center tdoverflowmax100" title="'.($propcss ?
dol_escape_htmltag($propcss) :
'').
'">';
4623 print
'<td class="center tdoverflowmax100" title="'.($propcssview ?
dol_escape_htmltag($propcssview) :
'').
'">';
4626 print
'<td class="center tdoverflowmax100" title="'.($propcsslist ?
dol_escape_htmltag($propcsslist) :
'').
'">';
4630 print
'<td class="tdoverflowmax150" title="'.($prophelp ?
dol_escape_htmltag($prophelp) :
'').
'">';
4633 print
'<td class="center">';
4639 print
'<td class="center">';
4642 print
'<td class="tdoverflowmax200">';
4643 print
'<span title="'.dol_escape_htmltag($propcomment).
'">';
4647 print
'<td class="center minwidth75 tdstickyright tdstickyghostwhite">';
4648 if ($propname !=
'rowid') {
4649 print
'<a class="editfielda reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=editproperty&token='.
newToken().
'&propertykey='.urlencode($propname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_edit().
'</a>';
4650 print
'<a class="reposition marginleftonly marginrighttonly paddingright paddingleft" href="'.$_SERVER[
"PHP_SELF"].
'?action=deleteproperty&token='.
newToken().
'&propertykey='.urlencode($propname).
'&tab='.urlencode($tab).
'&module='.urlencode($module).
'&tabobj='.urlencode($tabobj).
'">'.
img_delete().
'</a>';
4657 if ($tab ==
'specifications') {
4658 if ($action !=
'editfile' || empty($file)) {
4659 print
'<span class="opacitymedium">'.$langs->trans(
"SpecDefDesc").
'</span><br>';
4664 foreach ($specs as $spec) {
4665 $pathtofile = $modulelowercase.
'/doc/'.$spec[
'relativename'];
4666 $format =
'asciidoc';
4667 if (preg_match(
'/\.md$/i', $spec[
'name'])) {
4668 $format =
'markdown';
4670 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"SpecificationFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4671 print
' <a href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format='.$format.
'&file='.urlencode($pathtofile).
'">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4681 $content = file_get_contents($fullpathoffile);
4684 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4685 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4686 print
'<input type="hidden" name="action" value="savefile">';
4687 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4688 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4689 print
'<input type="hidden" name="module" value="'.$module.
'">';
4691 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4692 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4695 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4697 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4703 print
'<tr><td><span class="warning">'.$langs->trans(
'Property %s not found in the class. The class was probably not generated by modulebuilder.', $field).
'</warning></td></tr>';
4710 print
'<span class="warning">'.$langs->trans(
'Failed to init the object with the new %s (%s)', $tabobj, (
string) $db).
'</warning>';
4714 print $e->getMessage();
4718 if (empty($forceddirread)) {
4721 $fullpathoffile = $dirread.
'/'.$file;
4724 $content = file_get_contents($fullpathoffile);
4727 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
4728 print
'<input type="hidden" name="token" value="'.newToken().
'">';
4729 print
'<input type="hidden" name="action" value="savefile">';
4730 print
'<input type="hidden" name="file" value="'.dol_escape_htmltag($file).
'">';
4731 print
'<input type="hidden" name="tab" value="'.$tab.
'">';
4732 print
'<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).
'">';
4733 print
'<input type="hidden" name="module" value="'.$module.($forceddirread ?
'@'.$dirread :
'').
'">';
4735 $doleditor =
new DolEditor(
'editfilecontent', $content,
'',
'300',
'Full',
'In',
true,
false,
'ace', 0,
'99%');
4736 print $doleditor->Create(1,
'',
false, $langs->trans(
"File").
' : '.$file, (
GETPOST(
'format',
'aZ09') ?
GETPOST(
'format',
'aZ09') :
'html'));
4739 print
'<input type="submit" class="button buttonforacesave button-save" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans(
"Save")).
'">';
4741 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans(
"Cancel")).
'">';
4751 if ($tab ==
'dictionaries') {
4752 print
'<!-- tab=dictionaries -->'.
"\n";
4753 $pathtofile = $listofmodules[strtolower($module)][
'moduledescriptorrelpath'];
4755 $dicts = $moduleobj->dictionaries;
4757 if ($action ==
'deletedict') {
4758 $formconfirm = $form->formconfirm(
4759 $_SERVER[
"PHP_SELF"].
'?dictionnarykey='.urlencode((
string) (
GETPOSTINT(
'dictionnarykey'))).
'&tab='.urlencode((
string) ($tab)).
'&module='.urlencode((
string) ($module)),
4760 $langs->trans(
'Delete'),
4761 $langs->trans(
'Confirm Delete Dictionnary',
GETPOST(
'dictionnarykey',
'alpha')),
4762 'confirm_deletedictionary',
4770 if ($action !=
'editfile' || empty($file)) {
4771 print
'<span class="opacitymedium">';
4772 $htmlhelp = $langs->trans(
"DictionariesDefDescTooltip",
'{s1}');
4773 $htmlhelp = str_replace(
'{s1}',
'<a target="adminbis" class="nofocusvisible" href="'.DOL_URL_ROOT.
'/admin/dict.php">'.$langs->trans(
'Setup').
' - '.$langs->trans(
'Dictionaries').
'</a>', $htmlhelp);
4774 print $form->textwithpicto($langs->trans(
"DictionariesDefDesc"), $htmlhelp, 1,
'help',
'', 0, 2,
'helpondesc').
'<br>';
4778 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"DescriptorFile").
' : <strong class="wordbreak">'.$pathtofile.
'</strong>';
4779 print
' <a class="editfielda paddingleft paddingright" href="'.$_SERVER[
'PHP_SELF'].
'?tab='.urlencode($tab).
'&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&action=editfile&token='.
newToken().
'&format=php&file='.urlencode($pathtofile).
'&find=DICTIONARIES">'.
img_picto($langs->trans(
"Edit"),
'edit').
'</a>';
4781 if (is_array($dicts) && !empty($dicts)) {
4782 print
'<span class="fa fa-file-o"></span> '.$langs->trans(
"LanguageFile").
' :</span> ';
4783 print
'<strong class="wordbreak">'.$dicts[
'langs'].
'</strong>';
4793 $head3[$h][0] = $_SERVER[
"PHP_SELF"].
'?tab=dictionaries&module='.$module.($forceddirread ?
'@'.$dirread :
'').
'&tabdic=newdictionary';
4794 $head3[$h][1] =
'<span class="valignmiddle text-plus-circle">'.$langs->trans(
"NewDictionary").
'</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>';
4795 $head3[$h][2] =
'newdictionary';
4836 $newdict =
dolGetButtonTitle($langs->trans(
'NewDictionary'),
'',
'fa fa-plus-circle', DOL_URL_ROOT.
'/modulebuilder/index.php?tab=dictionaries&module='.