2017-03-29 21:36:50 +02:00
< ? php
2019-11-01 15:53:57 +01:00
/* Copyright ( C ) 2004 - 2019 Laurent Destailleur < eldy @ users . sourceforge . net >
2019-03-28 23:57:17 +01:00
* Copyright ( C ) 2018 - 2019 Nicolas ZABOURI < info @ inovea - conseil . com >
2017-03-29 21:36:50 +02:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// www . gnu . org / licenses />.
2017-08-02 23:50:17 +02:00
*
* You can also make a direct call the page with parameter like this :
* htdocs / modulebuilder / index . php ? module = Inventory @/ pathtodolibarr / htdocs / product
2017-03-29 21:36:50 +02:00
*/
/**
* \file htdocs / modulebuilder / index . php
* \brief Home page for module builder module
2019-03-17 02:46:28 +01:00
*
* You can add parameter dirins =/ home / ldestailleur / git / dolibarr / htdocs / mymodule to force generation of module
* into the dirins directory .
2017-03-29 21:36:50 +02:00
*/
2019-11-13 19:37:08 +01:00
if ( ! defined ( 'NOSCANPOSTFORINJECTION' )) define ( 'NOSCANPOSTFORINJECTION' , '1' ); // Do not check anti SQL+XSS injection attack test
2017-07-08 16:52:10 +02:00
2017-03-29 21:36:50 +02:00
require '../main.inc.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2017-07-16 14:57:30 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php' ;
2017-10-05 09:54:48 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formadmin.class.php' ;
2017-07-12 01:55:07 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/modulebuilder.lib.php' ;
2017-07-08 15:43:36 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2017-12-11 13:50:26 +01:00
require_once DOL_DOCUMENT_ROOT . '/core/class/utils.class.php' ;
2017-03-29 21:36:50 +02:00
2018-05-26 17:57:30 +02:00
// Load translation files required by the page
2018-11-05 10:15:22 +01:00
$langs -> loadLangs ( array ( " admin " , " modulebuilder " , " other " , " cron " , " errors " ));
2017-03-29 21:36:50 +02:00
2019-11-13 19:37:08 +01:00
$action = GETPOST ( 'action' , 'aZ09' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$cancel = GETPOST ( 'cancel' , 'alpha' );
2017-07-08 15:43:36 +02:00
2019-11-13 19:37:08 +01:00
$module = GETPOST ( 'module' , 'alpha' );
$tab = GETPOST ( 'tab' , 'aZ09' );
$tabobj = GETPOST ( 'tabobj' , 'alpha' );
$propertykey = GETPOST ( 'propertykey' , 'alpha' );
if ( empty ( $module )) $module = 'initmodule' ;
if ( empty ( $tab )) $tab = 'description' ;
if ( empty ( $tabobj )) $tabobj = 'newobjectifnoobj' ;
$file = GETPOST ( 'file' , 'alpha' );
2017-05-08 23:55:46 +02:00
2019-11-13 19:37:08 +01:00
$modulename = dol_sanitizeFileName ( GETPOST ( 'modulename' , 'alpha' ));
$objectname = dol_sanitizeFileName ( GETPOST ( 'objectname' , 'alpha' ));
2017-05-08 21:00:23 +02:00
2017-03-29 21:36:50 +02:00
// Security check
2017-07-08 15:43:36 +02:00
if ( empty ( $conf -> modulebuilder -> enabled )) accessforbidden ( 'ModuleBuilderNotAllowed' );
2019-11-13 19:37:08 +01:00
if ( ! $user -> admin && empty ( $conf -> global -> MODULEBUILDER_FOREVERYONE )) accessforbidden ( 'ModuleBuilderNotAllowed' );
2017-03-29 21:36:50 +02:00
2017-05-08 21:00:23 +02:00
// Dir for custom dirs
2019-11-13 19:37:08 +01:00
$tmp = explode ( ',' , $dolibarr_main_document_root_alt );
2017-06-10 23:50:02 +02:00
$dirins = $tmp [ 0 ];
2017-08-02 23:50:17 +02:00
$dirread = $dirins ;
$forceddirread = 0 ;
$tmpdir = explode ( '@' , $module );
2019-11-13 19:37:08 +01:00
if ( ! empty ( $tmpdir [ 1 ]))
2017-08-02 23:50:17 +02:00
{
2019-11-13 19:37:08 +01:00
$module = $tmpdir [ 0 ];
$dirread = $tmpdir [ 1 ];
$forceddirread = 1 ;
2017-08-02 23:50:17 +02:00
}
2019-01-27 11:55:16 +01:00
if ( GETPOST ( 'dirins' , 'alpha' ))
2018-10-31 15:04:01 +01:00
{
2019-01-27 11:55:16 +01:00
$dirread = $dirins = GETPOST ( 'dirins' , 'alpha' );
2019-11-13 19:37:08 +01:00
$forceddirread = 1 ;
2018-10-31 15:04:01 +01:00
}
2017-05-08 21:00:23 +02:00
2019-11-13 19:37:08 +01:00
$FILEFLAG = 'modulebuilder.txt' ;
2017-05-08 21:00:23 +02:00
2019-11-13 19:37:08 +01:00
$now = dol_now ();
2017-07-12 01:55:07 +02:00
$newmask = 0 ;
2019-11-13 19:37:08 +01:00
if ( empty ( $newmask ) && ! empty ( $conf -> global -> MAIN_UMASK )) $newmask = $conf -> global -> MAIN_UMASK ;
2017-07-12 01:55:07 +02:00
if ( empty ( $newmask )) // This should no happen
{
2019-11-13 19:37:08 +01:00
$newmask = '0664' ;
2017-07-12 01:55:07 +02:00
}
2017-05-08 21:00:23 +02:00
2020-01-31 10:29:41 +01:00
$result = restrictedArea ( $user , 'modulebuilder' , null );
2017-07-11 20:47:49 +02:00
2017-05-08 21:00:23 +02:00
/*
* Actions
*/
2017-06-10 23:50:02 +02:00
if ( $dirins && $action == 'initmodule' && $modulename )
2017-05-08 21:00:23 +02:00
{
2019-11-13 19:37:08 +01:00
$modulename = ucfirst ( $modulename ); // Force first letter in uppercase
2019-02-09 13:40:22 +01:00
2017-10-11 19:41:19 +02:00
if ( preg_match ( '/[^a-z0-9_]/i' , $modulename ))
2017-10-06 02:42:32 +02:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " SpaceOrSpecialCharAreNotAllowed " ), null , 'errors' );
}
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$destdir = $dirins . '/' . strtolower ( $modulename );
2019-11-13 19:37:08 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename
2017-10-06 02:42:32 +02:00
);
$result = dolCopyDir ( $srcdir , $destdir , 0 , 0 , $arrayreplacement );
//dol_mkdir($destfile);
if ( $result <= 0 )
{
if ( $result < 0 )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFailToCopyDir " , $srcdir , $destdir ), null , 'errors' );
}
else // $result == 0
{
setEventMessages ( $langs -> trans ( " AllFilesDidAlreadyExist " , $srcdir , $destdir ), null , 'warnings' );
}
}
2018-06-30 14:35:33 +02:00
2019-11-13 19:37:08 +01:00
if ( ! empty ( $conf -> global -> MODULEBUILDER_USE_ABOUT ))
2018-08-28 02:35:45 +02:00
{
dol_delete_file ( $destdir . '/admin/about.php' );
}
2017-10-06 02:42:32 +02:00
2019-03-10 19:33:28 +01:00
// Delete dir and files that can be generated in sub tabs later if we need them (we want a minimal module first)
dol_delete_dir_recursive ( $destdir . '/build/doxygen' );
dol_delete_dir_recursive ( $destdir . '/core/modules/mailings' );
dol_delete_dir_recursive ( $destdir . '/core/tpl' );
dol_delete_dir_recursive ( $destdir . '/core/triggers' );
dol_delete_dir_recursive ( $destdir . '/doc' );
dol_delete_dir_recursive ( $destdir . '/.tx' );
dol_delete_dir_recursive ( $destdir . '/core/boxes' );
dol_delete_file ( $destdir . '/sql/data.sql' );
dol_delete_file ( $destdir . '/sql/update_x.x.x-y.y.y.sql' );
dol_delete_dir ( $destdir . '/sql' );
dol_delete_file ( $destdir . '/class/actions_' . strtolower ( $modulename ) . '.class.php' );
dol_delete_file ( $destdir . '/class/api_' . strtolower ( $modulename ) . '.class.php' );
dol_delete_dir ( $destdir . '/class' );
2019-10-24 11:41:36 +02:00
dol_delete_file ( $destdir . '/css/' . strtolower ( $modulename ) . '.css.php' );
dol_delete_dir ( $destdir . '/css' );
dol_delete_file ( $destdir . '/js/' . strtolower ( $modulename ) . '.js.php' );
dol_delete_dir ( $destdir . '/js' );
2019-03-10 19:33:28 +01:00
dol_delete_file ( $destdir . '/scripts/' . strtolower ( $modulename ) . '.php' );
dol_delete_dir ( $destdir . '/scripts' );
2019-05-02 12:03:14 +02:00
// Delete some files related to Object (because the previous dolCopyDir has copied everything)
2017-10-06 02:42:32 +02:00
dol_delete_file ( $destdir . '/myobject_card.php' );
dol_delete_file ( $destdir . '/myobject_note.php' );
dol_delete_file ( $destdir . '/myobject_document.php' );
dol_delete_file ( $destdir . '/myobject_agenda.php' );
dol_delete_file ( $destdir . '/myobject_list.php' );
2019-03-10 19:33:28 +01:00
dol_delete_file ( $destdir . '/lib/' . strtolower ( $modulename ) . '_myobject.lib.php' );
2019-10-24 11:43:59 +02:00
dol_delete_file ( $destdir . '/test/phpunit/MyModuleFunctionnalTest.php' );
2017-10-06 02:42:32 +02:00
dol_delete_file ( $destdir . '/test/phpunit/MyObjectTest.php' );
2019-05-19 16:21:11 +02:00
dol_delete_file ( $destdir . '/test/phpunit' );
dol_delete_file ( $destdir . '/test' );
2019-06-06 18:55:24 +02:00
dol_delete_file ( $destdir . '/sql/llx_' . strtolower ( $modulename ) . '_myobject.sql' );
2019-03-10 19:33:28 +01:00
dol_delete_file ( $destdir . '/sql/llx_' . strtolower ( $modulename ) . '_myobject_extrafields.sql' );
dol_delete_file ( $destdir . '/sql/llx_' . strtolower ( $modulename ) . '_myobject.key.sql' );
2017-10-06 02:42:32 +02:00
dol_delete_file ( $destdir . '/img/object_myobject.png' );
dol_delete_file ( $destdir . '/class/myobject.class.php' );
2019-06-06 18:55:24 +02:00
dol_delete_dir ( $destdir . '/sql' );
2017-10-06 02:42:32 +02:00
}
// Edit PHP files
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
$listofphpfilestoedit = dol_dir_list ( $destdir , 'files' , 1 , '\.(php|MD|js|sql|txt|xml|lang)$' , '' , 'fullname' , SORT_ASC , 0 , 1 );
2019-11-13 19:37:08 +01:00
foreach ( $listofphpfilestoedit as $phpfileval )
2017-10-06 02:42:32 +02:00
{
//var_dump($phpfileval['fullname']);
2019-11-13 19:37:08 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2017-10-06 02:42:32 +02:00
);
2020-01-30 01:48:28 +01:00
if ( $conf -> global -> MAIN_FEATURES_LEVEL >= 2 ) {
if ( ! empty ( $conf -> global -> MODULEBUILDER_SPECIFIC_EDITOR_NAME )) $arrayreplacement [ 'Editor name' ] = $conf -> global -> MODULEBUILDER_SPECIFIC_EDITOR_NAME ;
if ( ! empty ( $conf -> global -> MODULEBUILDER_SPECIFIC_EDITOR_URL )) $arrayreplacement [ 'https://www.example.com' ] = $conf -> global -> MODULEBUILDER_SPECIFIC_EDITOR_URL ;
if ( ! empty ( $conf -> global -> MODULEBUILDER_SPECIFIC_AUTHOR )) $arrayreplacement [ '---Put here your own copyright and developer email---' ] = dol_print_date ( $now , '%Y' ) . ' ' . $conf -> global -> MODULEBUILDER_SPECIFIC_AUTHOR ;
if ( ! empty ( $conf -> global -> MODULEBUILDER_SPECIFIC_VERSION )) $arrayreplacement [ '1.0' ] = $conf -> global -> MODULEBUILDER_SPECIFIC_VERSION ;
if ( ! empty ( $conf -> global -> MODULEBUILDER_SPECIFIC_FAMILY )) $arrayreplacement [ 'other' ] = $conf -> global -> MODULEBUILDER_SPECIFIC_FAMILY ;
2019-03-28 23:57:17 +01:00
}
2020-01-30 01:48:28 +01:00
$result = dolReplaceInFile ( $phpfileval [ 'fullname' ], $arrayreplacement );
2019-08-30 02:21:34 +02:00
2017-10-06 02:42:32 +02:00
//var_dump($result);
if ( $result < 0 )
{
setEventMessages ( $langs -> trans ( " ErrorFailToMakeReplacementInto " , $phpfileval [ 'fullname' ]), null , 'errors' );
}
}
2018-06-30 14:35:33 +02:00
2018-08-28 02:37:06 +02:00
if ( ! empty ( $conf -> global -> MODULEBUILDER_SPECIFIC_README ))
{
2019-08-30 02:21:34 +02:00
setEventMessages ( $langs -> trans ( " ContentOfREADMECustomized " ), null , 'warnings' );
2018-08-28 02:37:06 +02:00
dol_delete_file ( $destdir . '/README.md' );
file_put_contents ( $destdir . '/README.md' , $conf -> global -> MODULEBUILDER_SPECIFIC_README );
}
2017-10-06 02:42:32 +02:00
}
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
setEventMessages ( 'ModuleInitialized' , null );
2019-11-13 19:37:08 +01:00
$module = $modulename ;
2017-10-06 02:42:32 +02:00
$modulename = '' ;
}
2017-05-08 21:00:23 +02:00
}
2017-03-29 21:36:50 +02:00
2019-05-02 12:03:14 +02:00
if ( $dirins && $action == 'initapi' && ! empty ( $module ))
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-05-19 16:21:11 +02:00
$objectname = $tabobj ;
2019-05-02 12:03:14 +02:00
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/class' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/class/api_mymodule.class.php' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/class/api_' . strtolower ( $module ) . '.class.php' ;
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2019-05-19 16:21:11 +02:00
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-05-19 16:21:11 +02:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
'myobject' => strtolower ( $objectname ),
'MyObject' => $objectname ,
'MYOBJECT' => strtoupper ( $objectname ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-05-19 16:21:11 +02:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-05-19 16:21:11 +02:00
}
if ( $dirins && $action == 'initphpunit' && ! empty ( $module ))
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-05-19 16:21:11 +02:00
$objectname = $tabobj ;
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/class' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/test/phpunit/MyObjectTest.php' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/test/phpunit/' . strtolower ( $objectname ) . 'Test.php' ;
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
2019-10-24 14:08:26 +02:00
2019-05-19 16:21:11 +02:00
if ( $result > 0 )
{
2019-05-02 12:03:14 +02:00
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-05-02 12:03:14 +02:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
'myobject' => strtolower ( $objectname ),
'MyObject' => $objectname ,
'MYOBJECT' => strtoupper ( $objectname ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-05-02 12:03:14 +02:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
}
2019-05-19 16:21:11 +02:00
else
{
2019-10-24 14:08:26 +02:00
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
2019-05-19 16:21:11 +02:00
}
2019-05-02 12:03:14 +02:00
}
2019-08-28 13:04:22 +02:00
if ( $dirins && $action == 'initsqlextrafields' && ! empty ( $module ))
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-08-28 13:04:22 +02:00
$objectname = $tabobj ;
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/sql' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile1 = $srcdir . '/sql/llx_mymodule_myobject_extrafields.sql' ;
$destfile1 = $dirins . '/' . strtolower ( $module ) . '/sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '_extrafields.sql' ;
//var_dump($srcfile);var_dump($destfile);
$result1 = dol_copy ( $srcfile1 , $destfile1 , 0 , 0 );
$srcfile2 = $srcdir . '/sql/llx_mymodule_myobject_extrafields.key.sql' ;
$destfile2 = $dirins . '/' . strtolower ( $module ) . '/sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '_extrafields.key.sql' ;
//var_dump($srcfile);var_dump($destfile);
$result2 = dol_copy ( $srcfile2 , $destfile2 , 0 , 0 );
if ( $result1 > 0 && $result2 > 0 )
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-08-28 13:04:22 +02:00
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-08-28 13:04:22 +02:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2019-10-24 11:01:34 +02:00
'My Object' => $objectname ,
'MyObject' => $objectname ,
'my object' => strtolower ( $objectname ),
'myobject' => strtolower ( $objectname ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-08-28 13:04:22 +02:00
);
dolReplaceInFile ( $destfile1 , $arrayreplacement );
dolReplaceInFile ( $destfile2 , $arrayreplacement );
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , '' ), null , 'errors' );
}
2019-08-28 13:04:22 +02:00
// TODO Enable in class the property $isextrafieldmanaged = 1
}
2019-03-10 19:33:28 +01:00
if ( $dirins && $action == 'inithook' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/class' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/class/actions_mymodule.class.php' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/class/actions_' . strtolower ( $module ) . '.class.php' ;
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
2019-05-02 12:03:14 +02:00
if ( $result > 0 )
{
2019-11-13 19:37:08 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-05-02 12:03:14 +02:00
//var_dump($phpfileval['fullname']);
2019-11-13 19:37:08 +01:00
$arrayreplacement = array (
2019-05-02 12:03:14 +02:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2019-11-13 19:37:08 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-05-02 12:03:14 +02:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-03-10 19:33:28 +01:00
}
if ( $dirins && $action == 'inittrigger' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/core/triggers' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/core/triggers/interface_99_modMyModule_MyModuleTriggers.class.php' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/core/triggers/interface_99_mod' . $module . '_' . $module . 'Triggers.class.php' ;
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2019-11-13 19:37:08 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-03-10 19:33:28 +01:00
//var_dump($phpfileval['fullname']);
2019-11-13 19:37:08 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2019-11-13 19:37:08 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-03-10 19:33:28 +01:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-03-10 19:33:28 +01:00
}
if ( $dirins && $action == 'initwidget' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/core/boxes' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/core/boxes/mymodulewidget1.php' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/core/boxes/' . strtolower ( $module ) . 'widget1.php' ;
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2019-11-13 19:37:08 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-03-10 19:33:28 +01:00
//var_dump($phpfileval['fullname']);
2019-11-13 19:37:08 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-03-10 19:33:28 +01:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-03-10 19:33:28 +01:00
}
2019-10-24 11:41:36 +02:00
if ( $dirins && $action == 'initcss' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/css' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/css/mymodule.css.php' ;
2019-10-24 14:08:26 +02:00
$destfile = $dirins . '/' . strtolower ( $module ) . '/css/' . strtolower ( $module ) . '.css.php' ;
2019-10-24 11:41:36 +02:00
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-10-24 11:41:36 +02:00
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-10-24 11:41:36 +02:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' ),
2019-10-24 11:41:36 +02:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
2019-11-01 03:10:48 +01:00
// Update descriptor file to uncomment file
$srcfile = $dirins . '/' . strtolower ( $module ) . '/core/modules/mod' . $module . '.class.php' ;
$arrayreplacement = array ( '/\/\/\s*\'' . preg_quote ( '/' . strtolower ( $module ) . '/css/' . strtolower ( $module ) . '.css.php' , '/' ) . '\'/' => '\'/' . strtolower ( $module ) . '/css/' . strtolower ( $module ) . '.css.php\'' );
dolReplaceInFile ( $srcfile , $arrayreplacement , '' , 0 , 0 , 1 );
2019-10-24 11:41:36 +02:00
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-10-24 11:41:36 +02:00
}
if ( $dirins && $action == 'initjs' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/js' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/js/mymodule.js.php' ;
2019-10-24 14:08:26 +02:00
$destfile = $dirins . '/' . strtolower ( $module ) . '/js/' . strtolower ( $module ) . '.js.php' ;
2019-10-24 11:41:36 +02:00
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-10-24 11:41:36 +02:00
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-10-24 11:41:36 +02:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2020-01-30 01:48:28 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , '%Y' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-10-24 11:41:36 +02:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
2019-11-01 03:10:48 +01:00
// Update descriptor file to uncomment file
$srcfile = $dirins . '/' . strtolower ( $module ) . '/core/modules/mod' . $module . '.class.php' ;
$arrayreplacement = array ( '/\/\/\s*\'' . preg_quote ( '/' . strtolower ( $module ) . '/js/' . strtolower ( $module ) . '.js.php' , '/' ) . '\'/' => '\'/' . strtolower ( $module ) . '/js/' . strtolower ( $module ) . '.js.php\'' );
dolReplaceInFile ( $srcfile , $arrayreplacement , '' , 0 , 0 , 1 );
2019-10-24 11:41:36 +02:00
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-10-24 11:41:36 +02:00
}
2019-03-10 19:33:28 +01:00
if ( $dirins && $action == 'initcli' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/scripts' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$srcfile = $srcdir . '/scripts/mymodule.php' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/scripts/' . strtolower ( $module ) . '.php' ;
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2020-01-30 01:48:28 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-03-10 19:33:28 +01:00
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2019-03-17 15:45:50 +01:00
'__MYCOMPANY_NAME__' => $mysoc -> name ,
'__KEYWORDS__' => $modulename ,
'__USER_FULLNAME__' => $user -> getFullName ( $langs ),
'__USER_EMAIL__' => $user -> email ,
'__YYYY-MM-DD__' => dol_print_date ( $now , 'dayrfc' ),
2019-11-13 19:37:08 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , 'dayrfc' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-03-10 19:33:28 +01:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-03-10 19:33:28 +01:00
}
if ( $dirins && $action == 'initdoc' && ! empty ( $module ))
{
dol_mkdir ( $dirins . '/' . strtolower ( $module ) . '/doc' );
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
2019-03-17 15:45:50 +01:00
$srcfile = $srcdir . '/doc/Documentation.asciidoc' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/doc/Documentation.asciidoc' ;
2019-03-10 19:33:28 +01:00
//var_dump($srcfile);var_dump($destfile);
$result = dol_copy ( $srcfile , $destfile , 0 , 0 );
if ( $result > 0 )
{
2019-11-13 19:37:08 +01:00
$modulename = ucfirst ( $module ); // Force first letter in uppercase
2019-03-17 19:33:25 +01:00
$modulelowercase = strtolower ( $module );
2019-03-10 19:33:28 +01:00
//var_dump($phpfileval['fullname']);
2019-11-13 19:37:08 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $modulename ),
'MyModule' => $modulename ,
'MYMODULE' => strtoupper ( $modulename ),
'My module' => $modulename ,
'my module' => $modulename ,
'Mon module' => $modulename ,
'mon module' => $modulename ,
'htdocs/modulebuilder/template' => strtolower ( $modulename ),
2019-03-17 15:45:50 +01:00
'__MYCOMPANY_NAME__' => $mysoc -> name ,
'__KEYWORDS__' => $modulename ,
'__USER_FULLNAME__' => $user -> getFullName ( $langs ),
'__USER_EMAIL__' => $user -> email ,
'__YYYY-MM-DD__' => dol_print_date ( $now , 'dayrfc' ),
2019-11-13 19:37:08 +01:00
'---Put here your own copyright and developer email---' => dol_print_date ( $now , 'dayrfc' ) . ' ' . $user -> getFullName ( $langs ) . ( $user -> email ? ' <' . $user -> email . '>' : '' )
2019-03-10 19:33:28 +01:00
);
dolReplaceInFile ( $destfile , $arrayreplacement );
2019-03-17 19:33:25 +01:00
// Delete old documentation files
2019-11-13 19:37:08 +01:00
$FILENAMEDOC = $modulelowercase . '.html' ;
$FILENAMEDOCPDF = $modulelowercase . '.pdf' ;
2019-03-17 19:33:25 +01:00
$outputfiledoc = dol_buildpath ( $modulelowercase , 0 ) . '/doc/' . $FILENAMEDOC ;
$outputfiledocurl = dol_buildpath ( $modulelowercase , 1 ) . '/doc/' . $FILENAMEDOC ;
$outputfiledocpdf = dol_buildpath ( $modulelowercase , 0 ) . '/doc/' . $FILENAMEDOCPDF ;
$outputfiledocurlpdf = dol_buildpath ( $modulelowercase , 1 ) . '/doc/' . $FILENAMEDOCPDF ;
dol_delete_file ( $outputfiledoc , 0 , 0 , 0 , null , false , 0 );
dol_delete_file ( $outputfiledocpdf , 0 , 0 , 0 , null , false , 0 );
2019-03-10 19:33:28 +01:00
}
2019-10-24 14:08:26 +02:00
else
{
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( 'ErrorFailToCreateFile' , $destfile ), null , 'errors' );
}
2019-03-10 19:33:28 +01:00
}
2017-11-19 16:26:39 +01:00
if ( $dirins && $action == 'addlanguage' && ! empty ( $module ))
{
2019-11-13 19:37:08 +01:00
$newlangcode = GETPOST ( 'newlangcode' , 'aZ09' );
2017-11-19 16:26:39 +01:00
$srcfile = $dirins . '/' . strtolower ( $module ) . '/langs/en_US' ;
$destfile = $dirins . '/' . strtolower ( $module ) . '/langs/' . $newlangcode ;
$result = dolCopyDir ( $srcfile , $destfile , 0 , 0 );
}
2019-03-10 19:33:28 +01:00
if ( $dirins && $action == 'confirm_removefile' && ! empty ( $module ))
{
2019-11-13 19:37:08 +01:00
$relativefilename = dol_sanitizePathName ( GETPOST ( 'file' , 'none' ));
2019-03-10 19:33:28 +01:00
if ( $relativefilename )
{
$dirnametodelete = dirname ( $relativefilename );
$filetodelete = $dirins . '/' . $relativefilename ;
$dirtodelete = $dirins . '/' . $dirnametodelete ;
$result = dol_delete_file ( $filetodelete );
if ( dol_is_dir_empty ( $dirtodelete )) dol_delete_dir ( $dirtodelete );
2019-11-01 03:10:48 +01:00
// Update descriptor file to comment file
if ( in_array ( $tab , array ( 'css' , 'js' )))
{
$srcfile = $dirins . '/' . strtolower ( $module ) . '/core/modules/mod' . $module . '.class.php' ;
$arrayreplacement = array ( '/^\s*\'' . preg_quote ( '/' . $relativefilename , '/' ) . '\',*/m' => ' // \'/' . $relativefilename . '\',' );
dolReplaceInFile ( $srcfile , $arrayreplacement , '' , 0 , 0 , 1 );
}
2019-03-10 19:33:28 +01:00
}
}
2020-02-08 13:44:31 +01:00
// Build the $fields array from SQL table (initfromtablename)
2019-01-27 11:55:16 +01:00
if ( $dirins && $action == 'initobject' && $module && GETPOST ( 'createtablearray' , 'alpha' ))
2018-03-13 20:23:59 +01:00
{
2019-01-27 11:55:16 +01:00
$tablename = GETPOST ( 'initfromtablename' , 'alpha' );
2018-03-13 20:23:59 +01:00
$_results = $db -> DDLDescTable ( $tablename );
if ( empty ( $_results ))
{
setEventMessages ( $langs -> trans ( " ErrorTableNotFound " , $tablename ), null , 'errors' );
}
else
{
2019-10-16 11:23:06 +02:00
/**
* 'type' if the field format ( 'integer' , 'integer:Class:pathtoclass' , 'varchar(x)' , 'double(24,8)' , 'text' , 'html' , 'datetime' , 'timestamp' , 'float' )
* 'label' the translation key .
* 'enabled' is a condition when the field must be managed .
* 'visible' says if field is visible in list ( Examples : 0 = Not visible , 1 = Visible on list and create / update / view forms , 2 = Visible on list only , 3 = Visible on create / update / view form only ( not list ), 4 = Visible on list and update / view form only ( not create ) . Using a negative value means field is not shown by default on list but can be selected for viewing )
* 'noteditable' says if field is not editable ( 1 or 0 )
* 'notnull' is set to 1 if not null in database . Set to - 1 if we must set data to null if empty ( '' or 0 ) .
* 'default' is a default value for creation ( can still be replaced by the global setup of default values )
* 'index' if we want an index in database .
* 'foreignkey' => 'tablename.field' if the field is a foreign key ( it is recommanded to name the field fk_ ... ) .
* 'position' is the sort order of field .
* 'searchall' is 1 if we want to search in this field when making a search from the quick search button .
* 'isameasure' must be set to 1 if you want to have a total on list for this field . Field type must be summable like integer or double ( 24 , 8 ) .
* 'css' is the CSS style to use on field . For example : 'maxwidth200'
* 'help' is a string visible as a tooltip on field
* 'comment' is not used . You can store here any text of your choice . It is not used by application .
* 'showoncombobox' if value of the field must be visible into the label of the combobox that list record
* 'arraykeyval' to set list of value if type is a list of predefined values . For example : array ( " 0 " => " Draft " , " 1 " => " Active " , " -1 " => " Cancel " )
*/
2018-03-13 20:23:59 +01:00
/* public $fields = array (
'rowid' => array ( 'type' => 'integer' , 'label' => 'TechnicalID' , 'enabled' => 1 , 'visible' =>- 2 , 'notnull' => 1 , 'index' => 1 , 'position' => 1 , 'comment' => 'Id' ),
'ref' => array ( 'type' => 'varchar(128)' , 'label' => 'Ref' , 'enabled' => 1 , 'visible' => 1 , 'notnull' => 1 , 'showoncombobox' => 1 , 'index' => 1 , 'position' => 10 , 'searchall' => 1 , 'comment' => 'Reference of object' ),
'entity' => array ( 'type' => 'integer' , 'label' => 'Entity' , 'enabled' => 1 , 'visible' => 0 , 'default' => 1 , 'notnull' => 1 , 'index' => 1 , 'position' => 20 ),
'label' => array ( 'type' => 'varchar(255)' , 'label' => 'Label' , 'enabled' => 1 , 'visible' => 1 , 'position' => 30 , 'searchall' => 1 , 'css' => 'minwidth200' , 'help' => 'Help text' ),
'amount' => array ( 'type' => 'double(24,8)' , 'label' => 'Amount' , 'enabled' => 1 , 'visible' => 1 , 'default' => 'null' , 'position' => 40 , 'searchall' => 0 , 'isameasure' => 1 , 'help' => 'Help text' ),
2020-01-25 19:21:37 +01:00
'fk_soc' => array ( 'type' => 'integer:Societe:societe/class/societe.class.php' , 'label' => 'ThirdParty' , 'visible' => 1 , 'enabled' => 1 , 'position' => 50 , 'notnull' =>- 1 , 'index' => 1 , 'searchall' => 1 , 'help' => 'LinkToThirparty' ),
2018-03-13 20:23:59 +01:00
'description' => array ( 'type' => 'text' , 'label' => 'Descrption' , 'enabled' => 1 , 'visible' => 0 , 'position' => 60 ),
'note_public' => array ( 'type' => 'html' , 'label' => 'NotePublic' , 'enabled' => 1 , 'visible' => 0 , 'position' => 61 ),
'note_private' => array ( 'type' => 'html' , 'label' => 'NotePrivate' , 'enabled' => 1 , 'visible' => 0 , 'position' => 62 ),
'date_creation' => array ( 'type' => 'datetime' , 'label' => 'DateCreation' , 'enabled' => 1 , 'visible' =>- 2 , 'notnull' => 1 , 'position' => 500 ),
'tms' => array ( 'type' => 'timestamp' , 'label' => 'DateModification' , 'enabled' => 1 , 'visible' =>- 2 , 'notnull' => 1 , 'position' => 501 ),
//'date_valid' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-2, 'position'=>502),
'fk_user_creat' => array ( 'type' => 'integer' , 'label' => 'UserAuthor' , 'enabled' => 1 , 'visible' =>- 2 , 'notnull' => 1 , 'position' => 510 ),
'fk_user_modif' => array ( 'type' => 'integer' , 'label' => 'UserModif' , 'enabled' => 1 , 'visible' =>- 2 , 'notnull' =>- 1 , 'position' => 511 ),
//'fk_user_valid' =>array('type'=>'integer', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>512),
'import_key' => array ( 'type' => 'varchar(14)' , 'label' => 'ImportId' , 'enabled' => 1 , 'visible' =>- 2 , 'notnull' =>- 1 , 'index' => 0 , 'position' => 1000 ),
'status' => array ( 'type' => 'integer' , 'label' => 'Status' , 'enabled' => 1 , 'visible' => 1 , 'notnull' => 1 , 'default' => 0 , 'index' => 1 , 'position' => 1000 , 'arrayofkeyval' => array ( 0 => 'Draft' , 1 => 'Active' , - 1 => 'Cancel' )),
); */
$string = 'public $fields=array(' . " \n " ;
2020-01-30 01:48:28 +01:00
$string .= " <br> " ;
$i = 10 ;
2018-03-13 20:23:59 +01:00
while ( $obj = $db -> fetch_object ( $_results ))
{
2019-10-16 11:23:06 +02:00
// fieldname
2018-03-13 20:23:59 +01:00
$fieldname = $obj -> Field ;
2019-10-16 11:23:06 +02:00
// type
2018-03-13 20:23:59 +01:00
$type = $obj -> Type ;
2020-01-30 01:48:28 +01:00
if ( $type == 'int(11)' ) $type = 'integer' ;
2020-01-25 19:21:37 +01:00
if ( $obj -> Field == 'fk_soc' ) $type = 'integer:Societe:societe/class/societe.class.php' ;
if ( preg_match ( '/^fk_proj/' , $obj -> Field )) $type = 'integer:Project:projet/class/project.class.php:1:fk_statut=1' ;
if ( preg_match ( '/^fk_prod/' , $obj -> Field )) $type = 'integer:Product:product/class/product.class.php:1' ;
if ( $obj -> Field == 'fk_warehouse' ) $type = 'integer:Entrepot:product/stock/class/entrepot.class.php' ;
if ( preg_match ( '/^(fk_user|fk_commercial)/' , $obj -> Field )) $type = 'integer:User:user/class/user.class.php' ;
2019-10-16 11:23:06 +02:00
// notnull
2020-01-30 01:48:28 +01:00
$notnull = ( $obj -> Null == 'YES' ? 0 : 1 );
2019-12-20 11:14:16 +01:00
if ( $fieldname == 'fk_user_modif' ) $notnull = - 1 ;
2019-10-16 11:23:06 +02:00
// label
2018-03-13 20:23:59 +01:00
$label = preg_replace ( '/_/' , ' ' , ucfirst ( $fieldname ));
2020-01-30 01:48:28 +01:00
if ( $fieldname == 'rowid' ) $label = 'TechnicalID' ;
if ( $fieldname == 'import_key' ) $label = 'ImportId' ;
if ( $fieldname == 'fk_soc' ) $label = 'ThirdParty' ;
if ( $fieldname == 'tms' ) $label = 'DateModification' ;
if ( $fieldname == 'datec' ) $label = 'DateCreation' ;
if ( $fieldname == 'date_valid' ) $label = 'DateValidation' ;
if ( $fieldname == 'datev' ) $label = 'DateValidation' ;
if ( $fieldname == 'note_private' ) $label = 'NotePublic' ;
if ( $fieldname == 'note_public' ) $label = 'NotePrivate' ;
if ( $fieldname == 'fk_user_creat' ) $label = 'UserAuthor' ;
if ( $fieldname == 'fk_user_modif' ) $label = 'UserModif' ;
if ( $fieldname == 'fk_user_valid' ) $label = 'UserValidation' ;
2019-10-16 11:23:06 +02:00
// visible
$visible = - 1 ;
if ( $fieldname == 'entity' ) $visible = - 2 ;
2019-12-20 11:14:16 +01:00
if ( $fieldname == 'import_key' ) $visible = - 2 ;
if ( $fieldname == 'fk_user_creat' ) $visible = - 2 ;
if ( $fieldname == 'fk_user_modif' ) $visible = - 2 ;
if ( in_array ( $fieldname , array ( 'ref_ext' , 'model_pdf' , 'note_public' , 'note_private' ))) $visible = 0 ;
2019-10-16 11:23:06 +02:00
// enabled
$enabled = 1 ;
// default
$default = '' ;
2020-01-30 01:48:28 +01:00
if ( $fieldname == 'entity' ) $default = 1 ;
2019-10-24 11:16:06 +02:00
// position
$position = $i ;
if ( in_array ( $fieldname , array ( 'status' , 'statut' , 'fk_status' , 'fk_statut' ))) $position = 500 ;
2020-02-08 13:44:31 +01:00
if ( $fieldname == 'import_key' ) $position = 900 ;
2019-12-20 11:14:16 +01:00
// index
$index = 0 ;
2020-01-30 01:48:28 +01:00
if ( $fieldname == 'entity' ) $index = 1 ;
$string .= " ' " . $obj -> Field . " ' =>array('type'=>' " . $type . " ', 'label'=>' " . $label . " ', " ;
if ( $default != '' ) $string .= " 'default'=> " . $default . " , " ;
$string .= " 'enabled'=> " . $enabled . " , " ;
$string .= " 'visible'=> " . $visible ;
if ( $notnull ) $string .= " , 'notnull'=> " . $notnull ;
if ( $fieldname == 'ref' ) $string .= " , 'showoncombobox'=>1 " ;
$string .= " , 'position'=> " . $position ;
if ( $index ) $string .= " , 'index'=> " . $index ;
$string .= " ), \n " ;
$string .= " <br> " ;
$i += 5 ;
2018-03-13 20:23:59 +01:00
}
2020-01-30 01:48:28 +01:00
$string .= ');' . " \n " ;
$string .= " <br> " ;
2018-03-13 20:23:59 +01:00
print $string ;
exit ;
}
}
2017-06-17 19:40:48 +02:00
if ( $dirins && $action == 'initobject' && $module && $objectname )
{
2017-10-11 19:41:19 +02:00
if ( preg_match ( '/[^a-z0-9_]/i' , $objectname ))
2017-10-06 02:42:32 +02:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " SpaceOrSpecialCharAreNotAllowed " ), null , 'errors' );
2019-11-13 19:37:08 +01:00
$tabobj = 'newobject' ;
2017-10-06 02:42:32 +02:00
}
$srcdir = DOL_DOCUMENT_ROOT . '/modulebuilder/template' ;
$destdir = $dirins . '/' . strtolower ( $module );
2017-10-11 19:41:19 +02:00
// The dir was not created by init
dol_mkdir ( $destdir . '/class' );
dol_mkdir ( $destdir . '/img' );
dol_mkdir ( $destdir . '/lib' );
dol_mkdir ( $destdir . '/scripts' );
dol_mkdir ( $destdir . '/sql' );
2017-10-06 02:42:32 +02:00
// Scan dir class to find if an object with same name already exists.
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2019-11-13 19:37:08 +01:00
$dirlist = dol_dir_list ( $destdir . '/class' , 'files' , 0 , '\.txt$' );
$alreadyfound = false ;
foreach ( $dirlist as $key => $val )
2017-10-06 02:42:32 +02:00
{
2019-11-13 19:37:08 +01:00
$filefound = preg_replace ( '/\.txt$/' , '' , $val [ 'name' ]);
2017-10-06 02:42:32 +02:00
if ( strtolower ( $objectname ) == strtolower ( $filefound ) && $objectname != $filefound )
{
2019-11-13 19:37:08 +01:00
$alreadyfound = true ;
2017-10-06 02:42:32 +02:00
$error ++ ;
setEventMessages ( $langs -> trans ( " AnObjectAlreadyExistWithThisNameAndDiffCase " ), null , 'errors' );
break ;
}
}
}
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2018-08-24 11:45:22 +02:00
// Copy some files
2017-10-06 02:42:32 +02:00
$filetogenerate = array (
2019-10-20 01:09:11 +02:00
'myobject_card.php' => strtolower ( $objectname ) . '_card.php' ,
'myobject_note.php' => strtolower ( $objectname ) . '_note.php' ,
'myobject_document.php' => strtolower ( $objectname ) . '_document.php' ,
'myobject_agenda.php' => strtolower ( $objectname ) . '_agenda.php' ,
'myobject_list.php' => strtolower ( $objectname ) . '_list.php' ,
'lib/mymodule_myobject.lib.php' => 'lib/' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '.lib.php' ,
//'test/phpunit/MyObjectTest.php'=>'test/phpunit/'.strtolower($objectname).'Test.php',
'sql/llx_mymodule_myobject.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '.sql' ,
'sql/llx_mymodule_myobject.key.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '.key.sql' ,
2019-10-24 10:54:25 +02:00
'sql/llx_mymodule_myobject_extrafields.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '_extrafields.sql' ,
'sql/llx_mymodule_myobject_extrafields.key.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '_extrafields.key.sql' ,
2019-10-20 01:09:11 +02:00
//'scripts/mymodule.php'=>'scripts/'.strtolower($objectname).'.php',
'img/object_myobject.png' => 'img/object_' . strtolower ( $objectname ) . '.png' ,
'class/myobject.class.php' => 'class/' . strtolower ( $objectname ) . '.class.php' ,
//'class/api_mymodule.class.php'=>'class/api_'.strtolower($module).'.class.php',
2017-10-06 02:42:32 +02:00
);
2019-11-01 17:54:17 +01:00
if ( GETPOST ( 'includerefgeneration' , 'aZ09' ))
2019-11-01 15:53:57 +01:00
{
2019-11-01 17:54:17 +01:00
dol_mkdir ( $destdir . '/core/modules/' . strtolower ( $module ));
2019-11-01 15:53:57 +01:00
$filetogenerate += array (
2019-11-01 17:54:17 +01:00
'core/modules/mymodule/mod_myobject_advanced.php' => 'core/modules/' . strtolower ( $module ) . '/mod_' . strtolower ( $objectname ) . '_advanced.php' ,
'core/modules/mymodule/mod_myobject_standard.php' => 'core/modules/' . strtolower ( $module ) . '/mod_' . strtolower ( $objectname ) . '_standard.php' ,
'core/modules/mymodule/modules_myobject.php' => 'core/modules/' . strtolower ( $module ) . '/modules_' . strtolower ( $objectname ) . '.php' ,
2019-11-01 15:53:57 +01:00
);
}
2019-11-01 17:54:17 +01:00
if ( GETPOST ( 'includedocgeneration' , 'aZ09' ))
2019-11-01 15:53:57 +01:00
{
2019-11-01 17:54:17 +01:00
dol_mkdir ( $destdir . '/core/modules/' . strtolower ( $module ));
dol_mkdir ( $destdir . '/core/modules/' . strtolower ( $module ) . '/doc' );
2019-11-01 15:53:57 +01:00
$filetogenerate += array (
2019-11-01 17:54:17 +01:00
'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' => 'core/modules/' . strtolower ( $module ) . '/doc/doc_generic_' . strtolower ( $objectname ) . '_odt.modules.php'
2019-11-01 15:53:57 +01:00
);
}
2019-11-13 19:37:08 +01:00
foreach ( $filetogenerate as $srcfile => $destfile )
2017-10-06 02:42:32 +02:00
{
$result = dol_copy ( $srcdir . '/' . $srcfile , $destdir . '/' . $destfile , $newmask , 0 );
if ( $result <= 0 )
{
if ( $result < 0 )
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFailToCopyFile " , $srcdir . '/' . $srcfile , $destdir . '/' . $destfile ), null , 'errors' );
}
else // $result == 0
{
setEventMessages ( $langs -> trans ( " FileAlreadyExists " , $destfile ), null , 'warnings' );
}
}
}
2019-11-01 17:54:17 +01:00
// Edit the class 'class/'.strtolower($objectname).'.class.php'
if ( GETPOST ( 'includerefgeneration' , 'aZ09' )) {
// Replace 'visible'=>1, 'noteditable'=>0, 'default'=>''
$arrayreplacement = array ( '/\'visible\'=>1,\s*\'noteditable\'=>0,\s*\'default\'=>\'\'/' => " 'visible'=>4, 'noteditable'=>1, 'default'=>'(PROV)' " );
//var_dump($arrayreplacement);exit;
//var_dump($destdir.'/class/'.strtolower($objectname).'.class.php');exit;
dolReplaceInFile ( $destdir . '/class/' . strtolower ( $objectname ) . '.class.php' , $arrayreplacement , '' , 0 , 0 , 1 );
}
// Edit the setup file and the card page
if ( GETPOST ( 'includedocgeneration' , 'aZ09' )) {
// TODO
// dolReplaceInFile();
}
2019-10-20 01:09:11 +02:00
// Scan for object class files
$listofobject = dol_dir_list ( $destdir . '/class' , 'files' , 0 , '\.class\.php$' );
2017-10-06 02:42:32 +02:00
2020-01-30 01:48:28 +01:00
$firstobjectname = '' ;
foreach ( $listofobject as $fileobj )
2019-10-20 01:09:11 +02:00
{
if ( preg_match ( '/^api_/' , $fileobj [ 'name' ])) continue ;
if ( preg_match ( '/^actions_/' , $fileobj [ 'name' ])) continue ;
2017-10-06 02:42:32 +02:00
2020-01-30 01:48:28 +01:00
$tmpcontent = file_get_contents ( $fileobj [ 'fullname' ]);
$reg = array ();
2019-10-20 01:09:11 +02:00
if ( preg_match ( '/class\s+([^\s]*)\s+extends\s+CommonObject/ims' , $tmpcontent , $reg ))
{
$objectnameloop = $reg [ 1 ];
if ( empty ( $firstobjectname )) $firstobjectname = $objectnameloop ;
2017-12-11 13:50:26 +01:00
}
2019-10-20 01:09:11 +02:00
// Regenerate left menu entry in descriptor for $objectname
$stringtoadd = "
\ $this -> menu [ \ $r ++ ] = array (
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu' => 'fk_mainmenu=mymodule' ,
// This is a Left menu entry
'type' => 'left' ,
'titre' => 'List MyObject' ,
'mainmenu' => 'mymodule' ,
'leftmenu' => 'mymodule_myobject' ,
'url' => '/mymodule/myobject_list.php' ,
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs' => 'mymodule@mymodule' ,
'position' => 1100 + \ $r ,
// Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled' => '\$conf->mymodule->enabled' ,
// Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'perms' => '1' ,
'target' => '' ,
// 0=Menu for internal users, 1=external users, 2=both
'user' => 2 ,
);
\ $this -> menu [ \ $r ++ ] = array (
// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'fk_menu' => 'fk_mainmenu=mymodule,fk_leftmenu=mymodule_myobject' ,
// This is a Left menu entry
'type' => 'left' ,
'titre' => 'New MyObject' ,
'mainmenu' => 'mymodule' ,
'leftmenu' => 'mymodule_myobject' ,
'url' => '/mymodule/myobject_card.php?action=create' ,
// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
'langs' => 'mymodule@mymodule' ,
'position' => 1100 + \ $r ,
// Define condition to show or hide menu entry. Use '\$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '\$leftmenu==\'system\'' to show if leftmenu system is selected.
'enabled' => '\$conf->mymodule->enabled' ,
// Use 'perms'=>'\$user->rights->mymodule->level1->level2' if you want your menu with a permission rules
'perms' => '1' ,
'target' => '' ,
// 0=Menu for internal users, 1=external users, 2=both
'user' => 2
); \n " ;
$stringtoadd = preg_replace ( '/MyObject/' , $objectnameloop , $stringtoadd );
$stringtoadd = preg_replace ( '/mymodule/' , strtolower ( $module ), $stringtoadd );
$stringtoadd = preg_replace ( '/myobject/' , strtolower ( $objectnameloop ), $stringtoadd );
2020-01-30 01:48:28 +01:00
$moduledescriptorfile = $destdir . '/core/modules/mod' . $module . '.class.php' ;
2019-10-20 01:09:11 +02:00
// TODO Allow a replace with regex using dolReplaceInFile with param arryreplacementisregex to 1
// TODO Avoid duplicate addition
dolReplaceInFile ( $moduledescriptorfile , array ( 'END MODULEBUILDER LEFTMENU MYOBJECT */' => '*/' . " \n " . $stringtoadd . " \n \t \t /* END MODULEBUILDER LEFTMENU MYOBJECT */ " ));
// Add module descriptor to list of files to replace "MyObject' string with real name of object.
2020-01-30 01:48:28 +01:00
$filetogenerate [] = 'core/modules/mod' . $module . '.class.php' ;
2019-10-20 01:09:11 +02:00
}
2017-10-06 02:42:32 +02:00
}
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2019-11-01 17:54:17 +01:00
// Edit PHP files to make replacement
2020-01-30 01:48:28 +01:00
foreach ( $filetogenerate as $destfile )
2017-10-06 02:42:32 +02:00
{
$phpfileval [ 'fullname' ] = $destdir . '/' . $destfile ;
//var_dump($phpfileval['fullname']);
2020-01-30 01:48:28 +01:00
$arrayreplacement = array (
2019-03-10 19:33:28 +01:00
'mymodule' => strtolower ( $module ),
'MyModule' => $module ,
'MYMODULE' => strtoupper ( $module ),
'My module' => $module ,
'my module' => $module ,
'mon module' => $module ,
'Mon module' => $module ,
'htdocs/modulebuilder/template/' => strtolower ( $modulename ),
'myobject' => strtolower ( $objectname ),
'MyObject' => $objectname ,
'MYOBJECT' => strtoupper ( $objectname )
2017-10-06 02:42:32 +02:00
);
2019-11-13 19:37:08 +01:00
$result = dolReplaceInFile ( $phpfileval [ 'fullname' ], $arrayreplacement );
2017-10-06 02:42:32 +02:00
//var_dump($result);
if ( $result < 0 )
{
setEventMessages ( $langs -> trans ( " ErrorFailToMakeReplacementInto " , $phpfileval [ 'fullname' ]), null , 'errors' );
}
}
}
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
// Edit the class file to write properties
2020-01-30 01:48:28 +01:00
$object = rebuildObjectClass ( $destdir , $module , $objectname , $newmask );
2017-10-06 02:42:32 +02:00
if ( is_numeric ( $object ) && $object < 0 ) $error ++ ;
}
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
// Edit sql with new properties
2020-01-30 01:48:28 +01:00
$result = rebuildObjectSql ( $destdir , $module , $objectname , $newmask , '' , $object );
2017-10-06 02:42:32 +02:00
if ( $result < 0 ) $error ++ ;
}
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
setEventMessages ( $langs -> trans ( 'FilesForObjectInitialized' , $objectname ), null );
2019-11-01 17:54:17 +01:00
$tabobj = $objectname ;
2017-10-06 02:42:32 +02:00
}
2017-07-12 01:55:07 +02:00
}
2020-01-30 01:48:28 +01:00
if ( $dirins && ( $action == 'droptable' || $action == 'droptableextrafields' ) && ! empty ( $module ) && ! empty ( $tabobj ))
2017-11-21 11:50:57 +01:00
{
$objectname = $tabobj ;
2020-01-30 01:48:28 +01:00
$arrayoftables = array ();
2017-11-21 11:50:57 +01:00
if ( $action == 'droptable' ) $arrayoftables [] = MAIN_DB_PREFIX . strtolower ( $module ) . '_' . strtolower ( $tabobj );
if ( $action == 'droptableextrafields' ) $arrayoftables [] = MAIN_DB_PREFIX . strtolower ( $module ) . '_' . strtolower ( $tabobj ) . '_extrafields' ;
2020-01-30 01:48:28 +01:00
foreach ( $arrayoftables as $tabletodrop )
2017-11-21 11:50:57 +01:00
{
$nb = - 1 ;
2020-01-30 01:48:28 +01:00
$sql = " SELECT COUNT(*) as nb FROM " . $tabletodrop ;
2017-11-21 11:50:57 +01:00
$resql = $db -> query ( $sql );
if ( $resql )
{
$obj = $db -> fetch_object ( $resql );
if ( $obj )
{
$nb = $obj -> nb ;
}
}
else
{
if ( $db -> lasterrno () == 'DB_ERROR_NOSUCHTABLE' )
{
setEventMessages ( $langs -> trans ( " TableDoesNotExists " , $tabletodrop ), null , 'warnings' );
}
else
{
dol_print_error ( $db );
}
}
if ( $nb == 0 )
{
2019-11-13 19:37:08 +01:00
$resql = $db -> DDLDropTable ( $tabletodrop );
2017-11-21 11:50:57 +01:00
//var_dump($resql);
setEventMessages ( $langs -> trans ( " TableDropped " , $tabletodrop ), null , 'mesgs' );
}
elseif ( $nb > 0 )
{
setEventMessages ( $langs -> trans ( " TableNotEmptyDropCanceled " , $tabletodrop ), null , 'warnings' );
}
}
}
2019-11-13 19:37:08 +01:00
if ( $dirins && $action == 'addproperty' && ! empty ( $module ) && ! empty ( $tabobj ))
2017-07-12 01:55:07 +02:00
{
2018-01-15 17:38:15 +01:00
$error = 0 ;
2017-10-06 02:42:32 +02:00
$objectname = $tabobj ;
$srcdir = $dirread . '/' . strtolower ( $module );
$destdir = $dirins . '/' . strtolower ( $module );
dol_mkdir ( $destdir );
2018-01-15 17:38:15 +01:00
// We click on add property
2020-01-30 01:48:28 +01:00
if ( ! GETPOST ( 'regenerateclasssql' ) && ! GETPOST ( 'regeneratemissing' ))
2018-01-15 17:38:15 +01:00
{
2020-01-30 01:48:28 +01:00
if ( ! GETPOST ( 'propname' , 'aZ09' ))
2018-01-15 17:38:15 +01:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Name " )), null , 'errors' );
}
2020-01-30 01:48:28 +01:00
if ( ! GETPOST ( 'proplabel' , 'alpha' ))
2018-01-15 17:38:15 +01:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Label " )), null , 'errors' );
}
2020-01-30 01:48:28 +01:00
if ( ! GETPOST ( 'proptype' , 'alpha' ))
2018-01-15 17:38:15 +01:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Type " )), null , 'errors' );
}
2017-10-06 02:42:32 +02:00
2020-01-30 01:48:28 +01:00
if ( ! $error )
2018-01-15 17:38:15 +01:00
{
$addfieldentry = array (
2020-01-30 01:48:28 +01:00
'name' => GETPOST ( 'propname' , 'aZ09' ), 'label' => GETPOST ( 'proplabel' , 'alpha' ), 'type' => GETPOST ( 'proptype' , 'alpha' ),
'arrayofkeyval' => GETPOST ( 'proparrayofkeyval' , 'none' ), // Example json string '{"0":"Draft","1":"Active","-1":"Cancel"}'
'visible' => GETPOST ( 'propvisible' , 'int' ), 'enabled' => GETPOST ( 'propenabled' , 'int' ),
'position' => GETPOST ( 'propposition' , 'int' ), 'notnull' => GETPOST ( 'propnotnull' , 'int' ), 'index' => GETPOST ( 'propindex' , 'int' ), 'searchall' => GETPOST ( 'propsearchall' , 'int' ),
'isameasure' => GETPOST ( 'propisameasure' , 'int' ), 'comment' => GETPOST ( 'propcomment' , 'alpha' ), 'help' => GETPOST ( 'prophelp' , 'alpha' )
2019-10-20 01:09:11 +02:00
);
2018-01-15 17:38:15 +01:00
2020-01-30 01:48:28 +01:00
if ( ! empty ( $addfieldentry [ 'arrayofkeyval' ]) && ! is_array ( $addfieldentry [ 'arrayofkeyval' ]))
2018-01-15 17:38:15 +01:00
{
$addfieldentry [ 'arrayofkeyval' ] = dol_json_decode ( $addfieldentry [ 'arrayofkeyval' ], true );
}
}
}
2019-05-02 12:03:14 +02:00
/* if ( GETPOST ( 'regeneratemissing' ))
2017-10-06 02:42:32 +02:00
{
2018-01-15 17:38:15 +01:00
setEventMessages ( $langs -> trans ( " FeatureNotYetAvailable " ), null , 'warnings' );
$error ++ ;
2019-05-02 12:03:14 +02:00
} */
2017-10-06 02:42:32 +02:00
// Edit the class file to write properties
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2020-01-30 01:48:28 +01:00
$object = rebuildObjectClass ( $destdir , $module , $objectname , $newmask , $srcdir , $addfieldentry );
2019-08-28 12:10:28 +02:00
if ( is_numeric ( $object ) && $object <= 0 )
{
$error ++ ;
}
2017-10-06 02:42:32 +02:00
}
2017-07-12 11:52:07 +02:00
2017-10-06 02:42:32 +02:00
// Edit sql with new properties
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2020-01-30 01:48:28 +01:00
$result = rebuildObjectSql ( $destdir , $module , $objectname , $newmask , $srcdir , $object );
2017-09-22 23:38:25 +02:00
if ( $result <= 0 )
{
$error ++ ;
}
2017-10-06 02:42:32 +02:00
}
2017-07-12 01:55:07 +02:00
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
setEventMessages ( $langs -> trans ( 'FilesForObjectUpdated' , $objectname ), null );
2017-09-05 22:33:55 +02:00
2017-10-31 23:10:29 +01:00
clearstatcache ( true );
2018-03-13 20:23:59 +01:00
2017-10-06 02:42:32 +02:00
// Make a redirect to reload all data
2020-01-30 01:48:28 +01:00
header ( " Location: " . DOL_URL_ROOT . '/modulebuilder/index.php?tab=objects&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&tabobj=' . $objectname . '&nocache=' . time ());
2017-09-05 22:33:55 +02:00
2017-10-06 02:42:32 +02:00
exit ;
}
2017-06-17 19:40:48 +02:00
}
2017-09-05 20:42:34 +02:00
if ( $dirins && $action == 'confirm_deleteproperty' && $propertykey )
{
$objectname = $tabobj ;
$srcdir = $dirread . '/' . strtolower ( $module );
$destdir = $dirins . '/' . strtolower ( $module );
dol_mkdir ( $destdir );
// Edit the class file to write properties
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-09-05 20:42:34 +02:00
{
2019-11-13 19:37:08 +01:00
$object = rebuildObjectClass ( $destdir , $module , $objectname , $newmask , $srcdir , array (), $propertykey );
2017-09-23 18:17:34 +02:00
if ( is_numeric ( $object ) && $object <= 0 ) $error ++ ;
2017-09-05 20:42:34 +02:00
}
// Edit sql with new properties
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-09-05 20:42:34 +02:00
{
2019-11-13 19:37:08 +01:00
$result = rebuildObjectSql ( $destdir , $module , $objectname , $newmask , $srcdir , $object );
2017-09-05 20:42:34 +02:00
if ( $result <= 0 ) $error ++ ;
}
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-09-05 20:42:34 +02:00
{
setEventMessages ( $langs -> trans ( 'FilesForObjectUpdated' , $objectname ), null );
2017-09-05 22:33:55 +02:00
2017-10-31 23:10:29 +01:00
clearstatcache ( true );
2018-03-13 20:23:59 +01:00
2017-10-06 02:42:32 +02:00
// Make a redirect to reload all data
2020-01-30 01:48:28 +01:00
header ( " Location: " . DOL_URL_ROOT . '/modulebuilder/index.php?tab=objects&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&tabobj=' . $objectname );
2017-09-05 22:33:55 +02:00
2017-10-06 02:42:32 +02:00
exit ;
2017-09-05 20:42:34 +02:00
}
}
2019-11-01 15:53:57 +01:00
if ( $dirins && $action == 'confirm_deletemodule' )
2017-06-14 11:44:12 +02:00
{
2017-10-11 19:41:19 +02:00
if ( preg_match ( '/[^a-z0-9_]/i' , $module ))
2017-10-06 02:42:32 +02:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " SpaceOrSpecialCharAreNotAllowed " ), null , 'errors' );
}
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2019-11-13 19:37:08 +01:00
$modulelowercase = strtolower ( $module );
2017-10-06 02:42:32 +02:00
// Dir for module
$dir = $dirins . '/' . $modulelowercase ;
$result = dol_delete_dir_recursive ( $dir );
if ( $result > 0 )
{
setEventMessages ( $langs -> trans ( " DirWasRemoved " , $modulelowercase ), null );
}
else
{
setEventMessages ( $langs -> trans ( " PurgeNothingToDelete " ), null , 'warnings' );
}
}
$action = '' ;
$module = 'deletemodule' ;
2017-06-18 12:30:18 +02:00
}
if ( $dirins && $action == 'confirm_deleteobject' && $objectname )
{
2017-10-11 19:41:19 +02:00
if ( preg_match ( '/[^a-z0-9_]/i' , $objectname ))
2017-10-06 02:42:32 +02:00
{
$error ++ ;
setEventMessages ( $langs -> trans ( " SpaceOrSpecialCharAreNotAllowed " ), null , 'errors' );
}
2019-11-13 19:37:08 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2019-11-13 19:37:08 +01:00
$modulelowercase = strtolower ( $module );
$objectlowercase = strtolower ( $objectname );
2017-10-06 02:42:32 +02:00
// Dir for module
$dir = $dirins . '/' . $modulelowercase ;
// Delete some files
2019-11-01 15:53:57 +01:00
$filetodelete = array (
'myobject_card.php' => strtolower ( $objectname ) . '_card.php' ,
'myobject_note.php' => strtolower ( $objectname ) . '_note.php' ,
'myobject_document.php' => strtolower ( $objectname ) . '_document.php' ,
'myobject_agenda.php' => strtolower ( $objectname ) . '_agenda.php' ,
'myobject_list.php' => strtolower ( $objectname ) . '_list.php' ,
'lib/mymodule_myobject.lib.php' => 'lib/' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '.lib.php' ,
'test/phpunit/MyObjectTest.php' => 'test/phpunit/' . strtolower ( $objectname ) . 'Test.php' ,
'sql/llx_mymodule_myobject.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '.sql' ,
'sql/llx_mymodule_myobject_extrafields.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '_extrafields.sql' ,
'sql/llx_mymodule_myobject.key.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '.key.sql' ,
2019-11-01 17:54:17 +01:00
'sql/llx_mymodule_myobject_extrafields.key.sql' => 'sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $objectname ) . '_extrafields.key.sql' ,
2019-11-01 15:53:57 +01:00
'scripts/myobject.php' => 'scripts/' . strtolower ( $objectname ) . '.php' ,
'img/object_myobject.png' => 'img/object_' . strtolower ( $objectname ) . '.png' ,
'class/myobject.class.php' => 'class/' . strtolower ( $objectname ) . '.class.php' ,
'class/api_myobject.class.php' => 'class/api_' . strtolower ( $module ) . '.class.php' ,
2019-11-01 17:54:17 +01:00
'core/modules/mymodule/mod_myobject_advanced.php' => 'core/modules/' . strtolower ( $module ) . '/mod_' . strtolower ( $objectname ) . '_advanced.php' ,
'core/modules/mymodule/mod_myobject_standard.php' => 'core/modules/' . strtolower ( $module ) . '/mod_' . strtolower ( $objectname ) . '_standard.php' ,
'core/modules/mymodule/modules_myobject.php' => 'core/modules/' . strtolower ( $module ) . '/modules_' . strtolower ( $objectname ) . '.php' ,
'core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php' => 'core/modules/' . strtolower ( $module ) . '/doc/doc_generic_' . strtolower ( $objectname ) . '_odt.modules.php'
2017-10-06 02:42:32 +02:00
);
$resultko = 0 ;
2020-01-30 01:48:28 +01:00
foreach ( $filetodelete as $filetodelete )
2017-10-06 02:42:32 +02:00
{
$resulttmp = dol_delete_file ( $dir . '/' . $filetodelete , 0 , 0 , 1 );
2020-01-30 01:48:28 +01:00
if ( ! $resulttmp ) $resultko ++ ;
2017-10-06 02:42:32 +02:00
}
if ( $resultko == 0 )
{
setEventMessages ( $langs -> trans ( " FilesDeleted " ), null );
}
else
{
setEventMessages ( $langs -> trans ( " ErrorSomeFilesCouldNotBeDeleted " ), null , 'warnings' );
}
}
$action = '' ;
$tabobj = 'deleteobject' ;
2017-06-14 11:44:12 +02:00
}
2017-07-11 20:47:49 +02:00
2017-06-10 23:50:02 +02:00
if ( $dirins && $action == 'generatepackage' )
2017-05-28 14:43:17 +02:00
{
2019-11-13 19:37:08 +01:00
$modulelowercase = strtolower ( $module );
2017-10-06 02:42:32 +02:00
// Dir for module
$dir = $dirins . '/' . $modulelowercase ;
// Zip file to build
2019-11-13 19:37:08 +01:00
$FILENAMEZIP = '' ;
2017-10-06 02:42:32 +02:00
// Load module
dol_include_once ( $modulelowercase . '/core/modules/mod' . $module . '.class.php' );
2019-11-13 19:37:08 +01:00
$class = 'mod' . $module ;
2017-10-06 02:42:32 +02:00
if ( class_exists ( $class ))
{
try {
$moduleobj = new $class ( $db );
}
2019-11-13 19:37:08 +01:00
catch ( Exception $e )
2017-10-06 02:42:32 +02:00
{
$error ++ ;
dol_print_error ( $e -> getMessage ());
}
}
else
{
$error ++ ;
$langs -> load ( " errors " );
dol_print_error ( $langs -> trans ( " ErrorFailedToLoadModuleDescriptorForXXX " , $module ));
exit ;
}
2019-11-13 19:37:08 +01:00
$arrayversion = explode ( '.' , $moduleobj -> version , 3 );
2017-10-06 02:42:32 +02:00
if ( count ( $arrayversion ))
{
2019-11-13 19:37:08 +01:00
$FILENAMEZIP = " module_ " . $modulelowercase . '-' . $arrayversion [ 0 ] . '.' . $arrayversion [ 1 ] . ( $arrayversion [ 2 ] ? " . " . $arrayversion [ 2 ] : " " ) . " .zip " ;
2017-10-06 02:42:32 +02:00
$dirofmodule = dol_buildpath ( $modulelowercase , 0 ) . '/bin' ;
$outputfilezip = $dirofmodule . '/' . $FILENAMEZIP ;
2017-07-17 11:05:38 +02:00
if ( $dirofmodule )
{
2019-11-13 19:37:08 +01:00
if ( ! dol_is_dir ( $dirofmodule )) dol_mkdir ( $dirofmodule );
2020-01-15 11:55:27 +01:00
$result = dol_compress_dir ( $dir , $outputfilezip , 'zip' , '' , $modulelowercase );
2017-07-17 11:05:38 +02:00
}
else
{
$result = - 1 ;
}
2017-10-06 02:42:32 +02:00
if ( $result > 0 )
{
setEventMessages ( $langs -> trans ( " ZipFileGeneratedInto " , $outputfilezip ), null );
}
else
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorFailToGenerateFile " , $outputfilezip ), null , 'errors' );
}
}
else
{
$error ++ ;
$langs -> load ( " errors " );
setEventMessages ( $langs -> trans ( " ErrorCheckVersionIsDefined " ), null , 'errors' );
}
2017-05-28 14:43:17 +02:00
}
2017-03-29 21:36:50 +02:00
2017-07-17 11:05:38 +02:00
if ( $dirins && $action == 'generatedoc' )
{
2019-11-13 19:37:08 +01:00
$FILENAMEDOC = strtolower ( $module ) . '.html' ;
2017-12-11 13:50:26 +01:00
$dirofmodule = dol_buildpath ( strtolower ( $module ), 0 ) . '/doc' ;
2017-07-17 11:05:38 +02:00
2017-12-11 13:50:26 +01:00
$util = new Utils ( $db );
$result = $util -> generateDoc ( $module );
2017-07-17 11:05:38 +02:00
2017-12-11 13:50:26 +01:00
if ( $result > 0 )
2017-07-17 11:05:38 +02:00
{
2019-03-17 02:46:28 +01:00
setEventMessages ( $langs -> trans ( " DocFileGeneratedInto " , $dirofmodule ), null );
2017-07-17 11:05:38 +02:00
}
else
{
2017-12-11 13:50:26 +01:00
setEventMessages ( $util -> error , $util -> errors , 'errors' );
2017-07-17 11:05:38 +02:00
}
}
2019-03-13 18:11:15 +01:00
2017-07-08 16:52:10 +02:00
// Save file
if ( $action == 'savefile' && empty ( $cancel ))
2017-07-08 15:43:36 +02:00
{
2017-10-06 02:42:32 +02:00
$relofcustom = basename ( $dirins );
if ( $relofcustom )
{
// Check that relative path ($file) start with name 'custom'
2019-11-13 19:37:08 +01:00
if ( ! preg_match ( '/^' . $relofcustom . '/' , $file )) $file = $relofcustom . '/' . $file ;
2017-10-06 02:42:32 +02:00
2019-11-13 19:37:08 +01:00
$pathoffile = dol_buildpath ( $file , 0 );
$pathoffilebackup = dol_buildpath ( $file . '.back' , 0 );
2017-10-06 02:42:32 +02:00
// Save old version
if ( dol_is_file ( $pathoffile ))
{
dol_copy ( $pathoffile , $pathoffilebackup , 0 , 1 );
}
2019-01-27 11:55:16 +01:00
$content = GETPOST ( 'editfilecontent' , 'none' );
2017-10-06 02:42:32 +02:00
// Save file on disk
if ( $content )
{
dol_delete_file ( $pathoffile );
2019-03-17 19:33:25 +01:00
$result = file_put_contents ( $pathoffile , $content );
if ( $result )
{
@ chmod ( $pathoffile , octdec ( $newmask ));
2017-10-06 02:42:32 +02:00
2019-03-17 19:33:25 +01:00
setEventMessages ( $langs -> trans ( " FileSaved " ), null );
}
else
{
setEventMessages ( $langs -> trans ( " ErrorFailedToSaveFile " ), null , 'errors' );
}
2017-10-06 02:42:32 +02:00
}
else
{
2017-09-23 01:24:31 +02:00
setEventMessages ( $langs -> trans ( " ContentCantBeEmpty " ), null , 'errors' );
2017-10-06 02:42:32 +02:00
//$action='editfile';
$error ++ ;
}
}
2017-07-08 15:43:36 +02:00
}
2017-07-16 14:57:30 +02:00
// Enable module
if ( $action == 'set' && $user -> admin )
{
2020-01-30 01:48:28 +01:00
$param = '' ;
if ( $module ) $param .= '&module=' . urlencode ( $module );
if ( $tab ) $param .= '&tab=' . urlencode ( $tab );
if ( $tabobj ) $param .= '&tabobj=' . urlencode ( $tabobj );
2017-07-24 13:55:12 +02:00
2019-01-27 11:55:16 +01:00
$value = GETPOST ( 'value' , 'alpha' );
2017-07-16 14:57:30 +02:00
$resarray = activateModule ( $value );
2020-01-30 01:48:28 +01:00
if ( ! empty ( $resarray [ 'errors' ])) setEventMessages ( '' , $resarray [ 'errors' ], 'errors' );
2017-07-16 14:57:30 +02:00
else
{
//var_dump($resarray);exit;
if ( $resarray [ 'nbperms' ] > 0 )
{
2020-01-30 01:48:28 +01:00
$tmpsql = " SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . " user WHERE admin <> 1 " ;
$resqltmp = $db -> query ( $tmpsql );
2017-07-16 14:57:30 +02:00
if ( $resqltmp )
{
2020-01-30 01:48:28 +01:00
$obj = $db -> fetch_object ( $resqltmp );
2017-07-16 14:57:30 +02:00
//var_dump($obj->nb);exit;
if ( $obj && $obj -> nb > 1 )
{
$msg = $langs -> trans ( 'ModuleEnabledAdminMustCheckRights' );
setEventMessages ( $msg , null , 'warnings' );
}
}
else dol_print_error ( $db );
}
}
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ? " . $param );
exit ;
}
// Disable module
if ( $action == 'reset' && $user -> admin )
{
2020-01-30 01:48:28 +01:00
$param = '' ;
if ( $module ) $param .= '&module=' . urlencode ( $module );
if ( $tab ) $param .= '&tab=' . urlencode ( $tab );
if ( $tabobj ) $param .= '&tabobj=' . urlencode ( $tabobj );
2017-07-24 13:55:12 +02:00
2019-01-27 11:55:16 +01:00
$value = GETPOST ( 'value' , 'alpha' );
2020-01-30 01:48:28 +01:00
$result = unActivateModule ( $value );
2017-07-16 14:57:30 +02:00
if ( $result ) setEventMessages ( $result , null , 'errors' );
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ? " . $param );
exit ;
}
2017-07-08 15:43:36 +02:00
2017-05-27 13:46:34 +02:00
2017-10-31 23:10:29 +01:00
2017-03-29 21:36:50 +02:00
/*
* View
*/
2017-09-05 20:42:34 +02:00
$form = new Form ( $db );
2017-10-05 09:54:48 +02:00
$formadmin = new FormAdmin ( $db );
2017-09-05 20:42:34 +02:00
2017-06-10 23:50:02 +02:00
// Set dir where external modules are installed
2019-11-13 19:37:08 +01:00
if ( ! dol_is_dir ( $dirins ))
2017-06-10 23:50:02 +02:00
{
2017-10-06 02:42:32 +02:00
dol_mkdir ( $dirins );
2017-06-10 23:50:02 +02:00
}
2019-11-13 19:37:08 +01:00
$dirins_ok = ( dol_is_dir ( $dirins ));
2017-06-10 23:50:02 +02:00
2017-07-19 16:38:00 +02:00
llxHeader ( '' , $langs -> trans ( " ModuleBuilder " ), '' , '' , 0 , 0 ,
2017-07-18 12:00:18 +02:00
array (
2019-09-28 13:50:32 +02:00
'/includes/ace/src/ace.js' ,
'/includes/ace/src/ext-statusbar.js' ,
'/includes/ace/src/ext-language_tools.js' ,
//'/includes/ace/src/ext-chromevox.js'
2017-07-18 12:00:18 +02:00
), array ());
2017-03-29 21:36:50 +02:00
2020-01-30 01:48:28 +01:00
$text = $langs -> trans ( " ModuleBuilder " );
2017-03-29 21:36:50 +02:00
print load_fiche_titre ( $text , '' , 'title_setup' );
2019-10-09 15:07:12 +02:00
print '<span class="opacitymedium hideonsmartphone">' . $langs -> trans ( " ModuleBuilderDesc " , 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module' ) . '</span><br>' ;
2019-03-17 02:46:28 +01:00
2020-01-30 01:48:28 +01:00
$dirsrootforscan = array ( $dirread );
2019-05-21 16:16:19 +02:00
// Add also the core modules into the list of modules to show/edit
2020-01-30 01:48:28 +01:00
if ( $dirread != DOL_DOCUMENT_ROOT && ( $conf -> global -> MAIN_FEATURES_LEVEL >= 2 || ! empty ( $conf -> global -> MODULEBUILDER_ADD_DOCUMENT_ROOT ))) { $dirsrootforscan [] = DOL_DOCUMENT_ROOT ; }
2019-03-17 02:46:28 +01:00
2017-08-02 23:50:17 +02:00
// Search modules to edit
2019-05-21 16:16:19 +02:00
print '<!-- Scanned dir -->' . " \n " ;
2020-01-30 01:48:28 +01:00
$listofmodules = array ();
$i = 0 ;
foreach ( $dirsrootforscan as $dirread )
2019-03-17 02:46:28 +01:00
{
2020-01-30 01:48:28 +01:00
$dirsincustom = dol_dir_list ( $dirread , 'directories' );
2019-03-17 02:46:28 +01:00
if ( is_array ( $dirsincustom ) && count ( $dirsincustom ) > 0 ) {
foreach ( $dirsincustom as $dircustomcursor ) {
$fullname = $dircustomcursor [ 'fullname' ];
2020-01-30 01:48:28 +01:00
if ( dol_is_file ( $fullname . '/' . $FILEFLAG ))
2019-03-17 02:46:28 +01:00
{
// Get real name of module (MyModule instead of mymodule)
$dirtoscanrel = basename ( $fullname ) . '/core/modules/' ;
$descriptorfiles = dol_dir_list ( dirname ( $fullname ) . '/' . $dirtoscanrel , 'files' , 0 , 'mod.*\.class\.php$' );
if ( empty ( $descriptorfiles )) // If descriptor not found into module dir, we look into main module dir.
{
$dirtoscanrel = 'core/modules/' ;
$descriptorfiles = dol_dir_list ( $fullname . '/../' . $dirtoscanrel , 'files' , 0 , 'mod' . strtoupper ( basename ( $fullname )) . '\.class\.php$' );
}
$modulenamewithcase = '' ;
$moduledescriptorrelpath = '' ;
$moduledescriptorfullpath = '' ;
foreach ( $descriptorfiles as $descriptorcursor ) {
$modulenamewithcase = preg_replace ( '/^mod/' , '' , $descriptorcursor [ 'name' ]);
$modulenamewithcase = preg_replace ( '/\.class\.php$/' , '' , $modulenamewithcase );
$moduledescriptorrelpath = $dirtoscanrel . $descriptorcursor [ 'name' ];
$moduledescriptorfullpath = $descriptorcursor [ 'fullname' ];
//var_dump($descriptorcursor);
}
if ( $modulenamewithcase )
{
$listofmodules [ $dircustomcursor [ 'name' ]] = array (
'modulenamewithcase' => $modulenamewithcase ,
'moduledescriptorrelpath' => $moduledescriptorrelpath ,
'moduledescriptorfullpath' => $moduledescriptorfullpath ,
'moduledescriptorrootpath' => $dirread
);
}
//var_dump($listofmodules);
}
}
}
2017-05-27 13:46:34 +02:00
2019-03-17 02:46:28 +01:00
if ( $forceddirread && empty ( $listofmodules )) // $forceddirread is 1 if we forced dir to read with dirins=... or with module=...@mydir
{
$listofmodules [ strtolower ( $module )] = array (
'modulenamewithcase' => $module ,
'moduledescriptorrelpath' => 'notyetimplemented' ,
'moduledescriptorfullpath' => 'notyetimplemented' ,
'moduledescriptorrootpath' => 'notyetimplemented' ,
);
}
2018-10-31 15:04:01 +01:00
2019-03-17 02:46:28 +01:00
// Show description of content
2020-01-30 01:48:28 +01:00
$newdircustom = $dirins ;
if ( empty ( $newdircustom )) $newdircustom = img_warning ();
2019-03-17 02:46:28 +01:00
// If dirread was forced to somewhere else, by using URL
// htdocs/modulebuilder/index.php?module=Inventory@/home/ldestailleur/git/dolibarr/htdocs/product
2019-11-01 15:53:57 +01:00
if ( empty ( $i )) print $langs -> trans ( " DirScanned " ) . ' : ' ;
else print ', ' ;
print '<strong class="wordbreakimp">' . $dirread . '</strong>' ;
$i ++ ;
2017-08-02 23:50:17 +02:00
}
2019-11-01 15:53:57 +01:00
print '<br>' ;
2019-03-17 02:46:28 +01:00
//var_dump($listofmodules);
2017-06-10 23:50:02 +02:00
2020-01-30 01:48:28 +01:00
$message = '' ;
if ( ! $dirins )
2017-06-10 23:50:02 +02:00
{
2020-01-30 01:48:28 +01:00
$message = info_admin ( $langs -> trans ( " ConfFileMustContainCustom " , DOL_DOCUMENT_ROOT . '/custom' , DOL_DOCUMENT_ROOT ));
$allowfromweb = - 1 ;
2017-06-10 23:50:02 +02:00
}
else
{
2017-10-06 02:42:32 +02:00
if ( $dirins_ok )
{
2020-01-30 01:48:28 +01:00
if ( ! is_writable ( dol_osencode ( $dirins )))
2017-10-06 02:42:32 +02:00
{
$langs -> load ( " errors " );
2020-01-30 01:48:28 +01:00
$message = info_admin ( $langs -> trans ( " ErrorFailedToWriteInDir " , $dirins ));
$allowfromweb = 0 ;
2017-10-06 02:42:32 +02:00
}
}
else
{
2020-01-30 01:48:28 +01:00
$message = info_admin ( $langs -> trans ( " NotExistsDirect " , $dirins ) . $langs -> trans ( " InfDirAlt " ) . $langs -> trans ( " InfDirExample " ));
$allowfromweb = 0 ;
2017-10-06 02:42:32 +02:00
}
2017-06-10 23:50:02 +02:00
}
if ( $message )
{
2017-10-06 02:42:32 +02:00
print $message ;
2017-06-10 23:50:02 +02:00
}
2017-09-24 01:36:20 +02:00
//print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>';
2019-11-01 15:53:57 +01:00
$infomodulesfound = '<div style="padding: 12px 9px 12px">' . $form -> textwithpicto ( '<span class="opacitymedium">' . $langs -> trans ( " ModuleBuilderDesc3 " , count ( $listofmodules )) . '</span>' , $langs -> trans ( " ModuleBuilderDesc4 " , $FILEFLAG )) . '</div>' ;
2017-05-28 14:43:17 +02:00
// Load module descriptor
2019-11-13 19:37:08 +01:00
$error = 0 ;
2017-05-28 14:43:17 +02:00
$moduleobj = null ;
2019-11-13 19:37:08 +01:00
if ( ! empty ( $module ) && $module != 'initmodule' && $module != 'deletemodule' )
2017-05-28 14:43:17 +02:00
{
2019-11-13 19:37:08 +01:00
$modulelowercase = strtolower ( $module );
2017-06-10 23:50:02 +02:00
2017-10-06 02:42:32 +02:00
// Load module
2018-10-31 15:04:01 +01:00
$fullpathdirtodescriptor = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
dol_include_once ( $fullpathdirtodescriptor );
2019-11-13 19:37:08 +01:00
$class = 'mod' . $module ;
2017-10-06 02:42:32 +02:00
if ( class_exists ( $class ))
{
try {
$moduleobj = new $class ( $db );
}
2019-11-13 19:37:08 +01:00
catch ( Exception $e )
2017-10-06 02:42:32 +02:00
{
$error ++ ;
print $e -> getMessage ();
}
}
else
{
if ( empty ( $forceddirread )) $error ++ ;
$langs -> load ( " errors " );
print img_warning ( '' ) . ' ' . $langs -> trans ( " ErrorFailedToLoadModuleDescriptorForXXX " , $module ) . '<br>' ;
}
2017-05-28 14:43:17 +02:00
}
2017-06-10 23:50:02 +02:00
print '<br>' ;
2017-05-08 23:55:46 +02:00
2017-05-28 14:43:17 +02:00
// Tabs for all modules
2017-05-08 23:55:46 +02:00
$head = array ();
2019-11-13 19:37:08 +01:00
$h = 0 ;
2017-05-08 23:55:46 +02:00
$head [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?module=initmodule' ;
2019-03-25 10:09:02 +01:00
$head [ $h ][ 1 ] = '<span class="valignmiddle text-plus-circle">' . $langs -> trans ( " NewModule " ) . '</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>' ;
2017-05-08 23:55:46 +02:00
$head [ $h ][ 2 ] = 'initmodule' ;
$h ++ ;
2017-06-10 23:50:02 +02:00
2019-11-13 19:37:08 +01:00
foreach ( $listofmodules as $tmpmodule => $tmpmodulearray )
2017-05-08 21:00:23 +02:00
{
2019-11-13 19:37:08 +01:00
$head [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?module=' . $tmpmodulearray [ 'modulenamewithcase' ] . ( $forceddirread ? '@' . $dirread : '' );
2018-10-31 15:04:01 +01:00
$head [ $h ][ 1 ] = $tmpmodulearray [ 'modulenamewithcase' ];
$head [ $h ][ 2 ] = $tmpmodulearray [ 'modulenamewithcase' ];
2017-10-06 02:42:32 +02:00
$h ++ ;
2017-05-08 21:00:23 +02:00
}
2017-05-08 23:55:46 +02:00
2017-06-18 12:30:18 +02:00
$head [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?module=deletemodule' ;
$head [ $h ][ 1 ] = $langs -> trans ( " DangerZone " );
$head [ $h ][ 2 ] = 'deletemodule' ;
$h ++ ;
2017-05-08 23:55:46 +02:00
2019-11-13 19:37:08 +01:00
dol_fiche_head ( $head , $module , $langs -> trans ( " Modules " ), - 1 , 'generic' , 0 , $infomodulesfound ); // Modules
2017-05-08 23:55:46 +02:00
if ( $module == 'initmodule' )
{
2017-10-06 02:42:32 +02:00
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="initmodule">' ;
print '<input type="hidden" name="module" value="initmodule">' ;
2017-06-10 23:50:02 +02:00
2019-08-30 02:21:34 +02:00
//print '<span class="opacitymedium">'.$langs->trans("ModuleBuilderDesc2", 'conf/conf.php', $newdircustom).'</span><br>';
2019-03-17 02:46:28 +01:00
print $langs -> trans ( " EnterNameOfModuleDesc " ) . '<br>' ;
print '<br>' ;
2017-06-10 23:50:02 +02:00
2019-11-01 15:53:57 +01:00
print '<input type="text" name="modulename" value="' . dol_escape_htmltag ( $modulename ) . '" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " ModuleKey " )) . '"><br>' ;
2019-03-10 19:33:28 +01:00
2020-01-30 01:48:28 +01:00
print '<br><input type="submit" class="button" name="create" value="' . dol_escape_htmltag ( $langs -> trans ( " Create " )) . '"' . ( $dirins ? '' : ' disabled="disabled"' ) . '>' ;
2017-10-06 02:42:32 +02:00
print '</form>' ;
2017-05-08 23:55:46 +02:00
}
2017-06-18 12:30:18 +02:00
elseif ( $module == 'deletemodule' )
{
2019-11-01 15:53:57 +01:00
print '<!-- Form to init a module -->' . " \n " ;
2019-03-11 15:58:37 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST" name="delete">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-11-01 15:53:57 +01:00
print '<input type="hidden" name="action" value="confirm_deletemodule">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="module" value="deletemodule">' ;
2017-06-18 12:30:18 +02:00
2017-10-06 02:42:32 +02:00
print $langs -> trans ( " EnterNameOfModuleToDeleteDesc " ) . '<br><br>' ;
2017-06-18 12:30:18 +02:00
2017-10-06 02:42:32 +02:00
print '<input type="text" name="module" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " ModuleKey " )) . '" value="">' ;
2020-01-30 01:48:28 +01:00
print '<input type="submit" class="buttonDelete" value="' . $langs -> trans ( " Delete " ) . '"' . ( $dirins ? '' : ' disabled="disabled"' ) . '>' ;
2017-10-06 02:42:32 +02:00
print '</form>' ;
2017-06-18 12:30:18 +02:00
}
2020-01-30 01:48:28 +01:00
elseif ( ! empty ( $module ))
2017-05-08 23:55:46 +02:00
{
2017-08-02 23:50:17 +02:00
// Tabs for module
2020-01-30 01:48:28 +01:00
if ( ! $error )
2017-10-06 02:42:32 +02:00
{
2019-03-17 02:46:28 +01:00
$dirread = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrootpath' ];
2017-10-06 02:42:32 +02:00
$head2 = array ();
2020-01-30 01:48:28 +01:00
$h = 0 ;
2017-08-05 10:35:12 +02:00
2020-01-30 01:48:28 +01:00
$modulelowercase = strtolower ( $module );
2017-10-06 02:42:32 +02:00
$const_name = 'MAIN_MODULE_' . strtoupper ( $module );
2017-08-05 10:35:12 +02:00
2020-01-30 01:48:28 +01:00
$param = '' ;
if ( $tab ) $param .= '&tab=' . urlencode ( $tab );
if ( $module ) $param .= '&module=' . urlencode ( $module );
if ( $tabobj ) $param .= '&tabobj=' . urlencode ( $tabobj );
2017-08-05 10:35:12 +02:00
2020-01-30 01:48:28 +01:00
$urltomodulesetup = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?search_keyword=' . urlencode ( $module ) . '">' . $langs -> trans ( 'Home' ) . '-' . $langs -> trans ( " Setup " ) . '-' . $langs -> trans ( " Modules " ) . '</a>' ;
$linktoenabledisable = '' ;
if ( ! empty ( $conf -> global -> $const_name )) // If module is already activated
2017-10-06 02:42:32 +02:00
{
2020-01-30 01:48:28 +01:00
$linktoenabledisable .= '<a class="reposition asetresetmodule" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $moduleobj -> numero . '&action=reset&value=mod' . $module . $param . '">' ;
$linktoenabledisable .= img_picto ( $langs -> trans ( " Activated " ), 'switch_on' , '' , false , 0 , 0 , '' , '' , 1 );
$linktoenabledisable .= '</a>' ;
2017-10-06 02:42:32 +02:00
}
else
{
2020-01-30 01:48:28 +01:00
$linktoenabledisable .= '<a class="reposition asetresetmodule" href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $moduleobj -> numero . '&action=set&value=mod' . $module . $param . '">' ;
$linktoenabledisable .= img_picto ( $langs -> trans ( " Disabled " ), 'switch_off' , '' , false , 0 , 0 , '' , '' , 1 );
$linktoenabledisable .= " </a> \n " ;
2017-10-06 02:42:32 +02:00
}
2019-11-01 15:53:57 +01:00
if ( empty ( $conf -> $modulelowercase -> enabled ))
2017-10-06 02:42:32 +02:00
{
2020-01-30 01:48:28 +01:00
$modulestatusinfo = $form -> textwithpicto ( $langs -> trans ( " ModuleIsNotActive " , $urltomodulesetup ), '' , - 1 , 'help' );
2017-10-06 02:42:32 +02:00
}
else
{
2020-01-30 01:48:28 +01:00
$modulestatusinfo = $form -> textwithpicto ( $langs -> trans ( " ModuleIsLive " ), $langs -> trans ( " Warning " ), - 1 , 'warning' );
2017-10-06 02:42:32 +02:00
}
2017-08-05 10:35:12 +02:00
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=description&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Description " );
$head2 [ $h ][ 2 ] = 'description' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=languages&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Languages " );
$head2 [ $h ][ 2 ] = 'languages' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=dictionaries&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2019-10-24 14:56:43 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Dictionaries " );
$head2 [ $h ][ 2 ] = 'dictionaries' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=objects&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Objects " );
$head2 [ $h ][ 2 ] = 'objects' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=menus&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Menus " );
$head2 [ $h ][ 2 ] = 'menus' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=permissions&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Permissions " );
$head2 [ $h ][ 2 ] = 'permissions' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=hooks&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Hooks " );
$head2 [ $h ][ 2 ] = 'hooks' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=triggers&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Triggers " );
$head2 [ $h ][ 2 ] = 'triggers' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=widgets&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Widgets " );
$head2 [ $h ][ 2 ] = 'widgets' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=css&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2019-10-24 11:41:36 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " CSS " );
$head2 [ $h ][ 2 ] = 'css' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=js&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2019-10-24 11:41:36 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " JS " );
$head2 [ $h ][ 2 ] = 'js' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=cli&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2019-03-10 19:33:28 +01:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " CLI " );
$head2 [ $h ][ 2 ] = 'cli' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=cron&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " CronList " );
$head2 [ $h ][ 2 ] = 'cron' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=specifications&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2019-02-09 14:12:36 +01:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " Documentation " );
$head2 [ $h ][ 2 ] = 'specifications' ;
$h ++ ;
2020-01-30 01:48:28 +01:00
$head2 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=buildpackage&module=' . $module . ( $forceddirread ? '@' . $dirread : '' );
2017-10-06 02:42:32 +02:00
$head2 [ $h ][ 1 ] = $langs -> trans ( " BuildPackage " );
$head2 [ $h ][ 2 ] = 'buildpackage' ;
$h ++ ;
2018-10-16 18:09:43 +02:00
// Link to enable / disable
2017-10-06 02:42:32 +02:00
print $modulestatusinfo ;
2019-11-01 15:53:57 +01:00
print ' ' . $linktoenabledisable . '<br>' ;
2018-10-16 18:09:43 +02:00
print '<br>' ;
2017-10-06 02:42:32 +02:00
if ( $tab == 'description' )
{
2018-10-31 15:04:01 +01:00
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
2017-10-06 02:42:32 +02:00
$pathtofilereadme = $modulelowercase . '/README.md' ;
$pathtochangelog = $modulelowercase . '/ChangeLog.md' ;
2017-08-05 10:35:12 +02:00
2017-10-06 02:42:32 +02:00
if ( $action != 'editfile' || empty ( $file ))
{
2019-11-13 19:37:08 +01:00
dol_fiche_head ( $head2 , $tab , '' , - 1 , '' ); // Description - level 2
2017-08-05 10:35:12 +02:00
2019-11-01 15:53:57 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " ModuleBuilderDesc " . $tab ) . '</span>' ;
$infoonmodulepath = '' ;
if ( realpath ( $dirread . '/' . $modulelowercase ) != $dirread . '/' . $modulelowercase )
{
$infoonmodulepath = '<span class="opacitymedium">' . $langs -> trans ( " RealPathOfModule " ) . ' :</span> <strong>' . realpath ( $dirread . '/' . $modulelowercase ) . '</strong><br>' ;
print ' ' . $infoonmodulepath ;
}
print '<br>' ;
2017-08-05 10:35:12 +02:00
2019-03-10 19:33:28 +01:00
print '<table>' ;
print '<tr><td>' ;
2017-11-19 16:26:39 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " DescriptorFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-03-10 19:33:28 +01:00
print '</td></tr>' ;
2017-07-18 14:20:37 +02:00
2019-03-10 19:33:28 +01:00
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " ReadmeFile " ) . ' : <strong>' . $pathtofilereadme . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=markdown&file=' . urlencode ( $pathtofilereadme ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-03-10 19:33:28 +01:00
print '</td></tr>' ;
2017-07-08 16:52:10 +02:00
2019-03-10 19:33:28 +01:00
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " ChangeLog " ) . ' : <strong>' . $pathtochangelog . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=markdown&file=' . urlencode ( $pathtochangelog ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-03-10 19:33:28 +01:00
print '</td></tr>' ;
2017-07-08 16:52:10 +02:00
2019-03-10 19:33:28 +01:00
print '</table>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2019-10-16 12:32:26 +02:00
print load_fiche_titre ( $langs -> trans ( " DescriptorFile " ), '' , '' );
2017-10-06 02:42:32 +02:00
2019-11-13 19:37:08 +01:00
if ( ! empty ( $moduleobj ))
2017-10-06 02:42:32 +02:00
{
print '<div class="underbanner clearboth"></div>' ;
print '<div class="fichecenter">' ;
print '<table class="border centpercent">' ;
print '<tr class="liste_titre"><td class="titlefield">' ;
print $langs -> trans ( " Parameter " );
print '</td><td>' ;
print $langs -> trans ( " Value " );
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " Numero " );
print '</td><td>' ;
print $moduleobj -> numero ;
print ' (<a href="' . DOL_URL_ROOT . '/admin/system/modules.php?mainmenu=home&leftmenu=admintools_info" target="_blank">' . $langs -> trans ( " SeeIDsInUse " ) . '</a>' ;
print ' - <a href="https://wiki.dolibarr.org/index.php/List_of_modules_id" target="_blank">' . $langs -> trans ( " SeeReservedIDsRangeHere " ) . '</a>)' ;
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " Name " );
print '</td><td>' ;
print $moduleobj -> getName ();
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " Version " );
print '</td><td>' ;
print $moduleobj -> getVersion ();
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " Family " );
//print "<br>'crm','financial','hr','projects','products','ecm','technic','interface','other'";
print '</td><td>' ;
print $moduleobj -> family ;
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " EditorName " );
print '</td><td>' ;
print $moduleobj -> editor_name ;
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " EditorUrl " );
print '</td><td>' ;
print $moduleobj -> editor_url ;
print '</td></tr>' ;
print '<tr><td>' ;
print $langs -> trans ( " Description " );
print '</td><td>' ;
print $moduleobj -> getDesc ();
print '</td></tr>' ;
print '</table>' ;
2019-10-16 12:32:26 +02:00
}
else
{
print $langs -> trans ( " ErrorFailedToLoadModuleDescriptorForXXX " , $module ) . '<br>' ;
}
2017-10-06 02:42:32 +02:00
2020-01-30 01:48:28 +01:00
if ( ! empty ( $moduleobj ))
2019-10-16 12:32:26 +02:00
{
2017-10-06 02:42:32 +02:00
print '<br><br>' ;
// Readme file
2019-10-16 12:32:26 +02:00
print load_fiche_titre ( $langs -> trans ( " ReadmeFile " ), '' , '' );
2017-10-06 02:42:32 +02:00
2019-10-16 12:32:26 +02:00
print '<!-- readme file -->' ;
if ( dol_is_file ( $dirread . '/' . $pathtofilereadme )) print '<div class="underbanner clearboth"></div><div class="fichecenter">' . $moduleobj -> getDescLong () . '</div>' ;
else print '<span class="opacitymedium">' . $langs -> trans ( " ErrorFileNotFound " , $pathtofilereadme ) . '</span>' ;
2017-10-06 02:42:32 +02:00
print '<br><br>' ;
// ChangeLog
2019-10-16 12:32:26 +02:00
print load_fiche_titre ( $langs -> trans ( " ChangeLog " ), '' , '' );
2017-10-06 02:42:32 +02:00
2019-10-16 12:32:26 +02:00
print '<!-- changelog file -->' ;
if ( dol_is_file ( $dirread . '/' . $pathtochangelog )) print '<div class="underbanner clearboth"></div><div class="fichecenter">' . $moduleobj -> getChangeLog () . '</div>' ;
else print '<span class="opacitymedium">' . $langs -> trans ( " ErrorFileNotFound " , $pathtochangelog ) . '</span>' ;
2017-10-06 02:42:32 +02:00
}
2017-07-08 16:52:10 +02:00
2017-10-06 02:42:32 +02:00
dol_fiche_end ();
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 , 1 ); // Description - level 2
2017-07-18 14:20:37 +02:00
2017-10-06 02:42:32 +02:00
if ( $fullpathoffile )
{
$content = file_get_contents ( $fullpathoffile );
}
2017-07-18 14:20:37 +02:00
2017-10-06 02:42:32 +02:00
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2017-07-18 03:18:16 +02:00
2017-10-06 02:42:32 +02:00
dol_fiche_head ( $head2 , $tab , '' , - 1 , '' );
2017-07-08 16:52:10 +02:00
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' , '' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
dol_fiche_end ();
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
else
{
2019-11-13 19:37:08 +01:00
dol_fiche_head ( $head2 , $tab , '' , - 1 , '' ); // Level 2
2017-10-06 02:42:32 +02:00
}
2017-06-10 23:50:02 +02:00
2017-10-06 02:42:32 +02:00
if ( $tab == 'languages' )
{
if ( $action != 'editfile' || empty ( $file ))
{
2019-03-10 19:33:28 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " LanguageDefDesc " ) . '</span><br>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2019-03-11 15:58:37 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="addlanguage">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2017-11-19 16:26:39 +01:00
print $formadmin -> select_language ( $conf -> global -> MAIN_LANG_DEFAULT , 'newlangcode' , 0 , 0 , 1 , 0 , 0 , 'minwidth300' , 1 );
2017-10-06 02:42:32 +02:00
print '<input type="submit" name="addlanguage" class="button" value="' . dol_escape_htmltag ( $langs -> trans ( " AddLanguageFile " )) . '"><br>' ;
print '</form>' ;
print '<br>' ;
print '<br>' ;
2019-11-13 19:37:08 +01:00
$langfiles = dol_dir_list ( dol_buildpath ( $modulelowercase . '/langs' , 0 ), 'files' , 1 , '\.lang$' );
2017-10-06 02:42:32 +02:00
2019-03-10 19:33:28 +01:00
print '<table class="none">' ;
2017-10-06 02:42:32 +02:00
foreach ( $langfiles as $langfile )
{
$pathtofile = $modulelowercase . '/langs/' . $langfile [ 'relativename' ];
2019-03-10 19:33:28 +01:00
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " LanguageFile " ) . ' ' . basename ( dirname ( $pathtofile )) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=txt&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-03-10 19:33:28 +01:00
print '</td>' ;
2017-10-06 02:42:32 +02:00
}
2019-03-10 19:33:28 +01:00
print '</table>' ;
2017-10-06 02:42:32 +02:00
}
else
{
// Edit text language file
//print $langs->trans("UseAsciiDocFormat").'<br>';
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'text' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
2019-10-24 14:56:43 +02:00
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
if ( $tab == 'dictionaries' )
{
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
$dicts = $moduleobj -> dictionaries ;
if ( $action != 'editfile' || empty ( $file ))
{
print '<span class="opacitymedium">' ;
2020-01-30 01:48:28 +01:00
$htmlhelp = $langs -> trans ( " DictionariesDefDescTooltip " , '<a href="' . DOL_URL_ROOT . '/admin/dict.php">' . $langs -> trans ( 'Setup' ) . ' - ' . $langs -> trans ( 'Dictionaries' ) . '</a>' );
2019-10-24 14:56:43 +02:00
print $form -> textwithpicto ( $langs -> trans ( " DictionariesDefDesc " ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'helpondesc' ) . '<br>' ;
print '</span>' ;
print '<br>' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " DescriptorFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-10-24 14:56:43 +02:00
print '<br>' ;
2019-11-01 03:10:48 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " LanguageFile " ) . ' :</span> ' ;
2020-01-30 01:48:28 +01:00
if ( ! is_array ( $dicts ) || empty ( $dicts )) print '<span class="opacitymedium">' . $langs -> trans ( " NoDictionaries " ) . '</span>' ;
2019-11-01 03:10:48 +01:00
else print '<strong>' . $dicts [ 'langs' ] . '</strong>' ;
print '<br>' ;
2019-10-24 14:56:43 +02:00
print load_fiche_titre ( $langs -> trans ( " ListOfDictionariesEntries " ), '' , '' );
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-10-24 14:56:43 +02:00
print '<input type="hidden" name="action" value="addproperty">' ;
print '<input type="hidden" name="tab" value="objects">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print '<input type="hidden" name="tabobj" value="' . dol_escape_htmltag ( $tabobj ) . '">' ;
print '<div class="div-table-responsive">' ;
print '<table class="noborder">' ;
print '<tr class="liste_titre">' ;
print_liste_field_titre ( " # " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Table " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Label " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " SQL " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " SQLSort " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " FieldsView " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " FieldsEdit " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " FieldsInsert " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Rowid " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Condition " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print " </tr> \n " ;
if ( is_array ( $dicts ))
{
$i = 0 ;
$maxi = count ( $dicts [ 'tabname' ]);
while ( $i < $maxi )
{
print '<tr class="oddeven">' ;
print '<td>' ;
print ( $i + 1 );
print '</td>' ;
print '<td>' ;
print $dicts [ 'tabname' ][ $i ];
print '</td>' ;
print '<td>' ;
print $dicts [ 'tablib' ][ $i ];
print '</td>' ;
print '<td>' ;
print $dicts [ 'tabsql' ][ $i ];
print '</td>' ;
print '<td>' ;
print $dicts [ 'tabsqlsort' ][ $i ];
print '</td>' ;
print '<td>' ;
print $dicts [ 'tabfield' ][ $i ];
print '</td>' ;
print '<td>' ;
print $dicts [ 'tabfieldvalue' ][ $i ];
print '</td>' ;
print '<td>' ;
print $dicts [ 'tabfieldinsert' ][ $i ];
print '</td>' ;
print '<td class="right">' ;
print $dicts [ 'tabrowid' ][ $i ];
print '</td>' ;
print '<td class="right">' ;
print $dicts [ 'tabcond' ][ $i ];
print '</td>' ;
print '</tr>' ;
$i ++ ;
}
}
else
{
print '<tr><td class="opacitymedium" colspan="5">' . $langs -> trans ( " None " ) . '</td></tr>' ;
}
print '</table>' ;
print '</div>' ;
print '</form>' ;
}
else
{
2020-01-30 01:48:28 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2019-10-24 14:56:43 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-10-24 14:56:43 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2020-01-30 01:48:28 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2019-10-24 14:56:43 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
2017-10-06 02:42:32 +02:00
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
if ( $tab == 'objects' )
{
$head3 = array ();
2020-01-30 01:48:28 +01:00
$h = 0 ;
2017-10-06 02:42:32 +02:00
// Dir for module
$dir = $dirread . '/' . $modulelowercase . '/class' ;
2020-01-30 01:48:28 +01:00
$head3 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=objects&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&tabobj=newobject' ;
2019-11-01 15:53:57 +01:00
$head3 [ $h ][ 1 ] = '<span class="valignmiddle text-plus-circle">' . $langs -> trans ( " NewObjectInModulebuilder " ) . '</span><span class="fa fa-plus-circle valignmiddle paddingleft"></span>' ;
2017-10-06 02:42:32 +02:00
$head3 [ $h ][ 2 ] = 'newobject' ;
$h ++ ;
// Scan for object class files
$listofobject = dol_dir_list ( $dir , 'files' , 0 , '\.class\.php$' );
2019-11-13 19:37:08 +01:00
$firstobjectname = '' ;
foreach ( $listofobject as $fileobj )
2017-10-06 02:42:32 +02:00
{
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/^api_/' , $fileobj [ 'name' ])) continue ;
if ( preg_match ( '/^actions_/' , $fileobj [ 'name' ])) continue ;
2017-10-06 02:42:32 +02:00
2019-11-13 19:37:08 +01:00
$tmpcontent = file_get_contents ( $fileobj [ 'fullname' ]);
2019-01-27 11:55:16 +01:00
if ( preg_match ( '/class\s+([^\s]*)\s+extends\s+CommonObject/ims' , $tmpcontent , $reg ))
2017-10-06 02:42:32 +02:00
{
//$objectname = preg_replace('/\.txt$/', '', $fileobj['name']);
$objectname = $reg [ 1 ];
if ( empty ( $firstobjectname )) $firstobjectname = $objectname ;
2019-11-13 19:37:08 +01:00
$head3 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=objects&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&tabobj=' . $objectname ;
2017-10-06 02:42:32 +02:00
$head3 [ $h ][ 1 ] = $objectname ;
$head3 [ $h ][ 2 ] = $objectname ;
$h ++ ;
}
}
2019-11-13 19:37:08 +01:00
$head3 [ $h ][ 0 ] = $_SERVER [ " PHP_SELF " ] . '?tab=objects&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&tabobj=deleteobject' ;
2017-10-06 02:42:32 +02:00
$head3 [ $h ][ 1 ] = $langs -> trans ( " DangerZone " );
$head3 [ $h ][ 2 ] = 'deleteobject' ;
$h ++ ;
// If tabobj was not defined, then we check if there is one obj. If yes, we force on it, if no, we will show tab to create new objects.
if ( $tabobj == 'newobjectifnoobj' )
{
2019-11-13 19:37:08 +01:00
if ( $firstobjectname ) $tabobj = $firstobjectname ;
2017-10-06 02:42:32 +02:00
else $tabobj = 'newobject' ;
}
2019-11-13 19:37:08 +01:00
dol_fiche_head ( $head3 , $tabobj , '' , - 1 , '' ); // Level 3
2017-10-06 02:42:32 +02:00
if ( $tabobj == 'newobject' )
{
// New object tab
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="initobject">' ;
print '<input type="hidden" name="tab" value="objects">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
2019-03-10 19:33:28 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " EnterNameOfObjectDesc " ) . '</span><br><br>' ;
2017-10-06 02:42:32 +02:00
2020-01-30 01:48:28 +01:00
print '<input type="text" name="objectname" value="' . dol_escape_htmltag ( GETPOST ( 'objectname' , 'alpha' ) ? GETPOST ( 'objectname' , 'alpha' ) : $modulename ) . '" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " ObjectKey " )) . '"><br>' ;
2019-11-01 15:53:57 +01:00
print '<input type="checkbox" name="includerefgeneration" value="includerefgeneration"> ' . $form -> textwithpicto ( $langs -> trans ( " IncludeRefGeneration " ), $langs -> trans ( " IncludeRefGenerationHelp " )) . '<br>' ;
print '<input type="checkbox" name="includedocgeneration" value="includedocgeneration"> ' . $form -> textwithpicto ( $langs -> trans ( " IncludeDocGeneration " ), $langs -> trans ( " IncludeDocGenerationHelp " )) . '<br>' ;
2020-01-30 01:48:28 +01:00
print '<input type="submit" class="button" name="create" value="' . dol_escape_htmltag ( $langs -> trans ( " Generate " )) . '"' . ( $dirins ? '' : ' disabled="disabled"' ) . '>' ;
2018-03-13 20:23:59 +01:00
print '<br>' ;
print '<br>' ;
print '<br>' ;
2019-05-02 12:03:14 +02:00
print $langs -> trans ( " or " );
2018-03-13 20:23:59 +01:00
print '<br>' ;
print '<br>' ;
//print '<input type="checkbox" name="initfromtablecheck"> ';
print $langs -> trans ( " InitStructureFromExistingTable " );
print '<input type="text" name="initfromtablename" value="" placeholder="' . $langs -> trans ( " TableName " ) . '">' ;
2019-11-13 19:37:08 +01:00
print '<input type="submit" class="button" name="createtablearray" value="' . dol_escape_htmltag ( $langs -> trans ( " Generate " )) . '"' . ( $dirins ? '' : ' disabled="disabled"' ) . '>' ;
2018-03-13 20:23:59 +01:00
print '<br>' ;
2017-10-06 02:42:32 +02:00
print '</form>' ;
}
elseif ( $tabobj == 'deleteobject' )
{
// Delete object tab
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="confirm_deleteobject">' ;
print '<input type="hidden" name="tab" value="objects">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print $langs -> trans ( " EnterNameOfObjectToDeleteDesc " ) . '<br><br>' ;
print '<input type="text" name="objectname" value="' . dol_escape_htmltag ( $modulename ) . '" placeholder="' . dol_escape_htmltag ( $langs -> trans ( " ObjectKey " )) . '">' ;
2019-11-13 19:37:08 +01:00
print '<input type="submit" class="buttonDelete" name="delete" value="' . dol_escape_htmltag ( $langs -> trans ( " Delete " )) . '"' . ( $dirins ? '' : ' disabled="disabled"' ) . '>' ;
2017-10-06 02:42:32 +02:00
print '</form>' ;
}
else
{ // tabobj = module
if ( $action == 'deleteproperty' )
{
2019-03-10 19:33:28 +01:00
$formconfirm = $form -> formconfirm (
2019-01-27 11:55:16 +01:00
$_SERVER [ " PHP_SELF " ] . '?propertykey=' . urlencode ( GETPOST ( 'propertykey' , 'alpha' )) . '&objectname=' . urlencode ( $objectname ) . '&tab=' . urlencode ( $tab ) . '&module=' . urlencode ( $module ) . '&tabobj=' . urlencode ( $tabobj ),
$langs -> trans ( 'Delete' ), $langs -> trans ( 'ConfirmDeleteProperty' , GETPOST ( 'propertykey' , 'alpha' )), 'confirm_deleteproperty' , '' , 0 , 1
2017-10-06 02:42:32 +02:00
);
// Print form confirm
print $formconfirm ;
}
if ( $action != 'editfile' || empty ( $file ))
{
try {
2018-11-05 15:31:41 +01:00
//$pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath'];
2017-10-06 02:42:32 +02:00
$pathtoclass = strtolower ( $module ) . '/class/' . strtolower ( $tabobj ) . '.class.php' ;
2017-11-05 18:15:59 +01:00
$pathtoapi = strtolower ( $module ) . '/class/api_' . strtolower ( $module ) . '.class.php' ;
2017-10-06 02:42:32 +02:00
$pathtoagenda = strtolower ( $module ) . '/' . strtolower ( $tabobj ) . '_agenda.php' ;
$pathtocard = strtolower ( $module ) . '/' . strtolower ( $tabobj ) . '_card.php' ;
$pathtodocument = strtolower ( $module ) . '/' . strtolower ( $tabobj ) . '_document.php' ;
$pathtolist = strtolower ( $module ) . '/' . strtolower ( $tabobj ) . '_list.php' ;
$pathtonote = strtolower ( $module ) . '/' . strtolower ( $tabobj ) . '_note.php' ;
2019-05-19 16:21:11 +02:00
$pathtophpunit = strtolower ( $module ) . '/test/phpunit/' . strtolower ( $tabobj ) . 'Test.php' ;
2017-10-29 18:53:08 +01:00
$pathtosql = strtolower ( $module ) . '/sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $tabobj ) . '.sql' ;
$pathtosqlextra = strtolower ( $module ) . '/sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $tabobj ) . '_extrafields.sql' ;
$pathtosqlkey = strtolower ( $module ) . '/sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $tabobj ) . '.key.sql' ;
2019-05-19 16:21:11 +02:00
$pathtosqlextrakey = strtolower ( $module ) . '/sql/llx_' . strtolower ( $module ) . '_' . strtolower ( $tabobj ) . '_extrafields.key.sql' ;
2018-12-22 18:22:12 +01:00
$pathtolib = strtolower ( $module ) . '/lib/' . strtolower ( $module ) . '.lib.php' ;
$pathtoobjlib = strtolower ( $module ) . '/lib/' . strtolower ( $module ) . '_' . strtolower ( $tabobj ) . '.lib.php' ;
2017-10-06 02:42:32 +02:00
$pathtopicto = strtolower ( $module ) . '/img/object_' . strtolower ( $tabobj ) . '.png' ;
2018-01-15 17:38:15 +01:00
$pathtoscript = strtolower ( $module ) . '/scripts/' . strtolower ( $tabobj ) . '.php' ;
2017-10-06 02:42:32 +02:00
2018-11-05 15:31:41 +01:00
//var_dump($pathtolib);
$realpathtoclass = dol_buildpath ( $pathtoclass , 0 , 2 );
$realpathtoapi = dol_buildpath ( $pathtoapi , 0 , 2 );
$realpathtoagenda = dol_buildpath ( $pathtoagenda , 0 , 2 );
$realpathtocard = dol_buildpath ( $pathtocard , 0 , 2 );
$realpathtodocument = dol_buildpath ( $pathtodocument , 0 , 2 );
$realpathtolist = dol_buildpath ( $pathtolist , 0 , 2 );
$realpathtonote = dol_buildpath ( $pathtonote , 0 , 2 );
$realpathtophpunit = dol_buildpath ( $pathtophpunit , 0 , 2 );
$realpathtosql = dol_buildpath ( $pathtosql , 0 , 2 );
$realpathtosqlextra = dol_buildpath ( $pathtosqlextra , 0 , 2 );
$realpathtosqlkey = dol_buildpath ( $pathtosqlkey , 0 , 2 );
2019-05-19 16:21:11 +02:00
$realpathtosqlextrakey = dol_buildpath ( $pathtosqlextrakey , 0 , 2 );
2018-11-05 15:31:41 +01:00
$realpathtolib = dol_buildpath ( $pathtolib , 0 , 2 );
2018-12-22 18:22:12 +01:00
$realpathtoobjlib = dol_buildpath ( $pathtoobjlib , 0 , 2 );
2018-11-05 15:31:41 +01:00
$realpathtopicto = dol_buildpath ( $pathtopicto , 0 , 2 );
$realpathtoscript = dol_buildpath ( $pathtoscript , 0 , 2 );
2017-10-06 02:42:32 +02:00
2019-05-21 16:16:19 +02:00
if ( empty ( $realpathtoapi )) // For compatibility with some old modules
{
$pathtoapi = strtolower ( $module ) . '/class/api_' . strtolower ( $module ) . 's.class.php' ;
$realpathtoapi = dol_buildpath ( $pathtoapi , 0 , 2 );
}
2017-10-06 02:42:32 +02:00
print '<div class="fichehalfleft">' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " ClassFile " ) . ' : <strong>' . ( $realpathtoclass ? '' : '<strike>' ) . $pathtoclass . ( $realpathtoclass ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtoclass ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " ApiClassFile " ) . ' : <strong>' . ( $realpathtoapi ? '' : '<strike>' ) . $pathtoapi . ( $realpathtoapi ? '' : '</strike>' ) . '</strong>' ;
2019-05-02 12:03:14 +02:00
if ( $realpathtoapi )
{
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtoapi ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtoapi ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-05-02 12:03:14 +02:00
print ' ' ;
if ( empty ( $conf -> global -> $const_name )) // If module is not activated
{
print '<a href="#" target="apiexplorer" title="' . $langs -> trans ( " ModuleMustBeEnabled " ) . '"><strike>' . $langs -> trans ( " GoToApiExplorer " ) . '</strike></a>' ;
}
else
{
print '<a href="' . DOL_URL_ROOT . '/api/index.php/explorer/" target="apiexplorer">' . $langs -> trans ( " GoToApiExplorer " ) . '</a>' ;
}
}
else
{
//print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span> ';
2020-01-30 01:48:28 +01:00
print '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initapi&format=php&file=' . urlencode ( $pathtoapi ) . '"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a>' ;
2019-05-02 12:03:14 +02:00
}
2019-05-19 16:21:11 +02:00
// PHPUnit
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " TestClassFile " ) . ' : <strong>' . ( $realpathtophpunit ? '' : '<strike>' ) . $pathtophpunit . ( $realpathtophpunit ? '' : '</strike>' ) . '</strong>' ;
2019-05-19 16:21:11 +02:00
if ( $realpathtophpunit )
{
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtophpunit ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtophpunit ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-05-19 16:21:11 +02:00
}
else
{
//print '<span class="opacitymedium">'.$langs->trans("FileNotYetGenerated").'</span> ';
2020-01-30 01:48:28 +01:00
print '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initphpunit&format=php&file=' . urlencode ( $pathtophpunit ) . '"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a>' ;
2019-05-19 16:21:11 +02:00
}
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForLib " ) . ' : <strong>' . ( $realpathtolib ? '' : '<strike>' ) . $pathtolib . ( $realpathtolib ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtolib ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForObjLib " ) . ' : <strong>' . ( $realpathtoobjlib ? '' : '<strike>' ) . $pathtoobjlib . ( $realpathtoobjlib ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtoobjlib ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2018-12-22 18:22:12 +01:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-image-o"></span> ' . $langs -> trans ( " Image " ) . ' : <strong>' . ( $realpathtopicto ? '' : '<strike>' ) . $pathtopicto . ( $realpathtopicto ? '' : '</strike>' ) . '</strong>' ;
2017-10-06 02:42:32 +02:00
//print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&tabobj='.$tabobj.'&module='.$module.($forceddirread?'@'.$dirread:'').'&action=editfile&format=php&file='.urlencode($pathtopicto).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
print '<br>' ;
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " SqlFile " ) . ' : <strong>' . ( $realpathtosql ? '' : '<strike>' ) . $pathtosql . ( $realpathtosql ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=sql&file=' . urlencode ( $pathtosql ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
print ' <a class="reposition" href="' . $_SERVER [ " PHP_SELF " ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=droptable">' . $langs -> trans ( " DropTableIfEmpty " ) . '</a>' ;
2017-10-06 02:42:32 +02:00
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " SqlFileKey " ) . ' : <strong>' . ( $realpathtosqlkey ? '' : '<strike>' ) . $pathtosqlkey . ( $realpathtosqlkey ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=sql&file=' . urlencode ( $pathtosqlkey ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-10-24 10:54:25 +02:00
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " SqlFileExtraFields " ) . ' : <strong>' . ( $realpathtosqlextra ? '' : '<strike>' ) . $pathtosqlextra . ( $realpathtosqlextra ? '' : '</strike>' ) . '</strong>' ;
2019-08-28 13:04:22 +02:00
if ( $realpathtosqlextra )
{
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&file=' . urlencode ( $pathtosqlextra ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtosqlextra ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ " PHP_SELF " ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=droptableextrafields">' . $langs -> trans ( " DropTableIfEmpty " ) . '</a>' ;
2019-08-28 13:04:22 +02:00
}
else {
2020-01-30 01:48:28 +01:00
print '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initsqlextrafields&format=sql&file=' . urlencode ( $pathtosqlextra ) . '"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a>' ;
2019-08-28 13:04:22 +02:00
}
2017-10-06 02:42:32 +02:00
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " SqlFileKeyExtraFields " ) . ' : <strong>' . ( $realpathtosqlextrakey ? '' : '<strike>' ) . $pathtosqlextrakey . ( $realpathtosqlextrakey ? '' : '</strike>' ) . '</strong>' ;
2019-08-28 13:04:22 +02:00
if ( $realpathtosqlextrakey )
{
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=sql&file=' . urlencode ( $pathtosqlextrakey ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtosqlextrakey ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-08-28 13:04:22 +02:00
}
2019-05-19 16:21:11 +02:00
//print ' <a href="'.$_SERVER["PHP_SELF"].'">'.$langs->trans("RunSql").'</a>';
print '<br>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '</div>' ;
$urloflist = dol_buildpath ( $pathtolist , 1 );
$urlofcard = dol_buildpath ( $pathtocard , 1 );
print '<div class="fichehalfleft">' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForList " ) . ' : <strong><a href="' . $urloflist . '" target="_test">' . ( $realpathtolist ? '' : '<strike>' ) . $pathtolist . ( $realpathtolist ? '' : '</strike>' ) . '</a></strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtolist ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForCreateEditView " ) . ' : <strong><a href="' . $urlofcard . '?action=create" target="_test">' . ( $realpathtocard ? '' : '<strike>' ) . $pathtocard . ( $realpathtocard ? '' : '</strike>' ) . '?action=create</a></strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtocard ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForAgendaTab " ) . ' : <strong>' . ( $realpathtoagenda ? '' : '<strike>' ) . $pathtoagenda . ( $realpathtoagenda ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtoagenda ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-05-21 16:16:19 +02:00
if ( $realpathtoagenda )
{
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtoagenda ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-05-21 16:16:19 +02:00
}
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForDocumentTab " ) . ' : <strong>' . ( $realpathtodocument ? '' : '<strike>' ) . $pathtodocument . ( $realpathtodocument ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtodocument ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-05-21 16:16:19 +02:00
if ( $realpathtodocument )
{
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtodocument ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-05-21 16:16:19 +02:00
}
2017-10-06 02:42:32 +02:00
print '<br>' ;
2020-01-30 01:48:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PageForNoteTab " ) . ' : <strong>' . ( $realpathtonote ? '' : '<strike>' ) . $pathtonote . ( $realpathtonote ? '' : '</strike>' ) . '</strong>' ;
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtonote ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-05-21 16:16:19 +02:00
if ( $realpathtonote )
{
2019-08-28 13:04:22 +02:00
print ' ' ;
2020-01-30 01:48:28 +01:00
print '<a class="reposition editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&file=' . urlencode ( $pathtonote ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a>' ;
2019-05-21 16:16:19 +02:00
}
2017-10-06 02:42:32 +02:00
print '<br>' ;
2019-05-02 12:03:14 +02:00
/* This is already on Tab CLI
2018-01-15 17:38:15 +01:00
print '<br>' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " ScriptFile " ) . ' : <strong>' . ( $realpathtoscript ? '' : '<strike>' ) . $pathtoscript . ( $realpathtoscript ? '' : '</strike>' ) . '</strong>' ;
print ' <a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&tabobj=' . $tabobj . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtoscript ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-05-02 12:03:14 +02:00
print '<br>' ; */
2018-01-15 17:38:15 +01:00
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '</div>' ;
print '<br><br><br>' ;
2019-11-13 19:37:08 +01:00
if ( function_exists ( 'opcache_invalidate' )) opcache_invalidate ( $dirread . '/' . $pathtoclass , true ); // remove the include cache hell !
2018-03-13 20:23:59 +01:00
2017-10-06 02:42:32 +02:00
if ( empty ( $forceddirread ))
{
$result = dol_include_once ( $pathtoclass );
}
else
{
2018-07-26 11:57:25 +02:00
$result = @ include_once $dirread . '/' . $pathtoclass ;
2017-10-06 02:42:32 +02:00
}
if ( class_exists ( $tabobj ))
{
try {
$tmpobjet = @ new $tabobj ( $db );
}
2019-11-13 19:37:08 +01:00
catch ( Exception $e )
2017-10-06 02:42:32 +02:00
{
dol_syslog ( 'Failed to load Constructor of class: ' . $e -> getMessage (), LOG_WARNING );
}
}
2019-11-13 19:37:08 +01:00
if ( ! empty ( $tmpobjet ))
2017-10-06 02:42:32 +02:00
{
$reflector = new ReflectionClass ( $tabobj );
2019-11-13 19:37:08 +01:00
$reflectorproperties = $reflector -> getProperties (); // Can also use get_object_vars
$reflectorpropdefault = $reflector -> getDefaultProperties (); // Can also use get_object_vars
2017-10-06 02:42:32 +02:00
//$propstat = $reflector->getStaticProperties();
2017-10-31 23:10:29 +01:00
//var_dump($reflectorpropdefault);
2017-10-06 02:42:32 +02:00
2018-01-15 17:38:15 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-03-11 15:58:37 +01:00
print '<input type="hidden" name="action" value="addproperty">' ;
print '<input type="hidden" name="tab" value="objects">' ;
2019-11-13 19:37:08 +01:00
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module . ( $forceddirread ? '@' . $dirread : '' )) . '">' ;
2019-03-11 15:58:37 +01:00
print '<input type="hidden" name="tabobj" value="' . dol_escape_htmltag ( $tabobj ) . '">' ;
2018-01-15 17:38:15 +01:00
print '<input class="button" type="submit" name="regenerateclasssql" value="' . $langs -> trans ( " RegenerateClassAndSql " ) . '">' ;
2019-05-02 12:03:14 +02:00
//print '<input class="button" type="submit" name="regeneratemissing" value="'.$langs->trans("RegenerateMissingFiles").'">';
2018-01-15 17:38:15 +01:00
print '<br><br>' ;
2019-05-02 12:03:14 +02:00
print load_fiche_titre ( $langs -> trans ( " ObjectProperties " ), '' , '' );
2017-10-06 02:42:32 +02:00
2019-11-01 17:54:17 +01:00
print '<!-- Table with properties of object -->' . " \n " ;
2017-10-06 02:42:32 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="noborder">' ;
print '<tr class="liste_titre">' ;
2019-11-17 17:36:36 +01:00
print '<th>' . $langs -> trans ( " Property " );
2018-06-30 14:35:33 +02:00
print ' (<a class="" href="https://wiki.dolibarr.org/index.php/Language_and_development_rules#Table_and_fields_structures" target="_blank">' . $langs -> trans ( " SeeExamples " ) . '</a>)' ;
print '</th>' ;
print '<th>' ;
2017-10-06 02:42:32 +02:00
print $form -> textwithpicto ( $langs -> trans ( " Label " ), $langs -> trans ( " YouCanUseTranslationKey " ));
2018-06-30 14:35:33 +02:00
print '</th>' ;
2019-11-01 17:54:17 +01:00
print '<th>' . $form -> textwithpicto ( $langs -> trans ( " Type " ), $langs -> trans ( " TypeOfFieldsHelp " )) . '</th>' ;
2018-06-30 14:35:33 +02:00
print '<th>' . $form -> textwithpicto ( $langs -> trans ( " ArrayOfKeyValues " ), $langs -> trans ( " ArrayOfKeyValuesDesc " )) . '</th>' ;
print '<th class="center">' . $form -> textwithpicto ( $langs -> trans ( " NotNull " ), $langs -> trans ( " NotNullDesc " )) . '</th>' ;
print '<th class="center">' . $langs -> trans ( " DefaultValue " ) . '</th>' ;
print '<th class="center">' . $langs -> trans ( " DatabaseIndex " ) . '</th>' ;
2019-11-01 17:54:17 +01:00
print '<th class="center">' . $langs -> trans ( " ForeignKey " ) . '</th>' ;
2018-06-30 14:35:33 +02:00
print '<th class="right">' . $langs -> trans ( " Position " ) . '</th>' ;
print '<th class="center">' . $form -> textwithpicto ( $langs -> trans ( " Enabled " ), $langs -> trans ( " EnabledDesc " )) . '</th>' ;
print '<th class="center">' . $form -> textwithpicto ( $langs -> trans ( " Visible " ), $langs -> trans ( " VisibleDesc " )) . '</th>' ;
2019-11-01 17:54:17 +01:00
print '<th class="center">' . $langs -> trans ( " NotEditable " ) . '</th>' ;
2018-06-30 14:35:33 +02:00
print '<th class="center">' . $form -> textwithpicto ( $langs -> trans ( " SearchAll " ), $langs -> trans ( " SearchAllDesc " )) . '</th>' ;
2019-11-01 17:54:17 +01:00
print '<th class="center">' . $form -> textwithpicto ( $langs -> trans ( " IsAMeasure " ), $langs -> trans ( " IsAMeasureDesc " )) . '</th>' ;
print '<th class="center">' . $langs -> trans ( " CSSClass " ) . '</th>' ;
print '<th class="center">' . $langs -> trans ( " KeyForTooltip " ) . '</th>' ;
print '<th class="center">' . $langs -> trans ( " ShowOnCombobox " ) . '</th>' ;
//print '<th class="center">'.$langs->trans("Disabled").'</th>';
2018-06-30 14:35:33 +02:00
print '<th>' . $langs -> trans ( " Comment " ) . '</th>' ;
print '<th></th>' ;
2017-10-06 02:42:32 +02:00
print '</tr>' ;
2017-10-31 23:10:29 +01:00
// We must use $reflectorpropdefault['fields'] to get list of fields because $tmpobjet->fields may have been
// modified during the constructor and we want value into head of class before constructor is called.
//$properties = dol_sort_array($tmpobjet->fields, 'position');
$properties = dol_sort_array ( $reflectorpropdefault [ 'fields' ], 'position' );
2017-10-06 02:42:32 +02:00
2019-11-13 19:37:08 +01:00
if ( ! empty ( $properties ))
2017-10-06 02:42:32 +02:00
{
// Line to add a property
print '<tr>' ;
2019-01-27 11:55:16 +01:00
print '<td><input class="text maxwidth75" name="propname" value="' . dol_escape_htmltag ( GETPOST ( 'propname' , 'alpha' )) . '"></td>' ;
print '<td><input class="text maxwidth75" name="proplabel" value="' . dol_escape_htmltag ( GETPOST ( 'proplabel' , 'alpha' )) . '"></td>' ;
print '<td><input class="text maxwidth75" name="proptype" value="' . dol_escape_htmltag ( GETPOST ( 'proptype' , 'alpha' )) . '"></td>' ;
print '<td><input class="text maxwidth75" name="proparrayofkeyval" value="' . dol_escape_htmltag ( GETPOST ( 'proparrayofkeyval' , 'none' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="propnotnull" value="' . dol_escape_htmltag ( GETPOST ( 'propnotnull' , 'alpha' )) . '"></td>' ;
print '<td><input class="text maxwidth50" name="propdefault" value="' . dol_escape_htmltag ( GETPOST ( 'propdefault' , 'alpha' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="propindex" value="' . dol_escape_htmltag ( GETPOST ( 'propindex' , 'alpha' )) . '"></td>' ;
2019-11-01 17:54:17 +01:00
print '<td class="center"><input class="text" size="2" name="propforeignkey" value="' . dol_escape_htmltag ( GETPOST ( 'propforeignkey' , 'alpha' )) . '"></td>' ;
2019-01-27 11:55:16 +01:00
print '<td class="right"><input class="text right" size="2" name="propposition" value="' . dol_escape_htmltag ( GETPOST ( 'propposition' , 'alpha' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="propenabled" value="' . dol_escape_htmltag ( GETPOST ( 'propenabled' , 'alpha' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="propvisible" value="' . dol_escape_htmltag ( GETPOST ( 'propvisible' , 'alpha' )) . '"></td>' ;
2019-11-01 17:54:17 +01:00
print '<td class="center"><input class="text" size="2" name="propnoteditable" value="' . dol_escape_htmltag ( GETPOST ( 'propnoteditable' , 'alpha' )) . '"></td>' ;
2019-01-27 11:55:16 +01:00
print '<td class="center"><input class="text" size="2" name="propsearchall" value="' . dol_escape_htmltag ( GETPOST ( 'propsearchall' , 'alpha' )) . '"></td>' ;
2019-11-01 17:54:17 +01:00
print '<td class="center"><input class="text" size="2" name="propisameasure" value="' . dol_escape_htmltag ( GETPOST ( 'propisameasure' , 'alpha' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="propcss" value="' . dol_escape_htmltag ( GETPOST ( 'propcss' , 'alpha' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="prophelp" value="' . dol_escape_htmltag ( GETPOST ( 'prophelp' , 'alpha' )) . '"></td>' ;
print '<td class="center"><input class="text" size="2" name="propshowoncombobox" value="' . dol_escape_htmltag ( GETPOST ( 'propshowoncombobox' , 'alpha' )) . '"></td>' ;
//print '<td class="center"><input class="text" size="2" name="propdisabled" value="'.dol_escape_htmltag(GETPOST('propdisabled', 'alpha')).'"></td>';
2019-01-27 11:55:16 +01:00
print '<td><input class="text maxwidth100" name="propcomment" value="' . dol_escape_htmltag ( GETPOST ( 'propcomment' , 'alpha' )) . '"></td>' ;
2019-03-03 09:08:29 +01:00
print '<td class="center">' ;
2017-10-06 02:42:32 +02:00
print '<input class="button" type="submit" name="add" value="' . $langs -> trans ( " Add " ) . '">' ;
print '</td></tr>' ;
2019-11-13 19:37:08 +01:00
foreach ( $properties as $propkey => $propval )
2017-10-06 02:42:32 +02:00
{
/* If from Reflection
2017-12-11 13:50:26 +01:00
if ( $propval -> class == $tabobj )
{
$propname = $propval -> getName ();
$comment = $propval -> getDocComment ();
$type = gettype ( $tmpobjet -> $propname );
$default = $propdefault [ $propname ];
// Discard generic properties
if ( in_array ( $propname , array ( 'element' , 'childtables' , 'table_element' , 'table_element_line' , 'class_element_line' , 'ismultientitymanaged' ))) continue ;
// Keep or not lines
if ( in_array ( $propname , array ( 'fk_element' , 'lines' ))) continue ;
} */
2017-09-23 15:12:25 +02:00
2020-01-30 01:48:28 +01:00
$propname = $propkey ;
$proplabel = $propval [ 'label' ];
$proptype = $propval [ 'type' ];
$proparrayofkeyval = $propval [ 'arrayofkeyval' ];
$propnotnull = $propval [ 'notnull' ];
$propdefault = $propval [ 'default' ];
$propindex = $propval [ 'index' ];
$propforeignkey = $propval [ 'foreignkey' ];
$propposition = $propval [ 'position' ];
$propenabled = $propval [ 'enabled' ];
$propvisible = $propval [ 'visible' ];
$propnoteditable = $propval [ 'noteditable' ];
$propsearchall = $propval [ 'searchall' ];
$propisameasure = $propval [ 'isameasure' ];
$propcss = $propval [ 'css' ];
$prophelp = $propval [ 'help' ];
$propshowoncombobox = $propval [ 'showoncombobox' ];
2019-11-01 17:54:17 +01:00
//$propdisabled=$propval['disabled'];
2020-01-30 01:48:28 +01:00
$propcomment = $propval [ 'comment' ];
2017-10-06 02:42:32 +02:00
print '<tr class="oddeven">' ;
print '<td>' ;
print $propname ;
print '</td>' ;
print '<td>' ;
print $proplabel ;
print '</td>' ;
2019-11-01 17:54:17 +01:00
print '<td class="wordbreak">' ;
2017-10-06 02:42:32 +02:00
print $proptype ;
print '</td>' ;
2019-09-07 14:49:48 +02:00
print '<td class="wordbreak">' ;
2019-03-03 09:08:29 +01:00
if ( $proparrayofkeyval ) {
2017-10-06 02:42:32 +02:00
print json_encode ( $proparrayofkeyval );
}
print '</td>' ;
print '<td class="center">' ;
print $propnotnull ;
print '</td>' ;
2017-10-20 21:39:19 +02:00
print '<td>' ;
2017-12-11 13:50:26 +01:00
print $propdefault ;
print '</td>' ;
2017-10-06 02:42:32 +02:00
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propindex ? '1' : '' ;
2017-10-06 02:42:32 +02:00
print '</td>' ;
2019-11-01 17:54:17 +01:00
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propforeignkey ? $propforeignkey : '' ;
2019-11-01 17:54:17 +01:00
print '</td>' ;
2019-03-03 09:08:29 +01:00
print '<td class="right">' ;
2017-10-06 02:42:32 +02:00
print $propposition ;
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propenabled ? $propenabled : '' ;
2017-10-06 02:42:32 +02:00
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propvisible ? $propvisible : '' ;
2017-10-06 02:42:32 +02:00
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propnoteditable ? $propnoteditable : '' ;
2017-10-06 02:42:32 +02:00
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propsearchall ? '1' : '' ;
2017-10-06 02:42:32 +02:00
print '</td>' ;
2019-11-01 17:54:17 +01:00
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propisameasure ? $propisameasure : '' ;
2019-11-01 17:54:17 +01:00
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propcss ? $propcss : '' ;
2019-11-01 17:54:17 +01:00
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $prophelp ? $prophelp : '' ;
2019-11-01 17:54:17 +01:00
print '</td>' ;
print '<td class="center">' ;
2020-01-30 01:48:28 +01:00
print $propshowoncombobox ? $propshowoncombobox : '' ;
2019-11-01 17:54:17 +01:00
print '</td>' ;
/* print '<td class="center">' ;
print $propdisabled ? $propdisabled : '' ;
print '</td>' ; */
2017-10-06 02:42:32 +02:00
print '<td>' ;
print $propcomment ;
print '</td>' ;
print '<td class="center">' ;
2019-11-01 17:54:17 +01:00
if ( $propname != 'rowid' )
{
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?action=deleteproperty&propertykey=' . urlencode ( $propname ) . '&tab=' . urlencode ( $tab ) . '&module=' . urlencode ( $module ) . '&tabobj=' . urlencode ( $tabobj ) . '">' . img_delete () . '</a>' ;
}
2017-10-06 02:42:32 +02:00
print '</td>' ;
print '</tr>' ;
}
}
else
{
2019-03-10 19:33:28 +01:00
if ( $tab == 'specifications' )
{
if ( $action != 'editfile' || empty ( $file ))
{
print '<span class="opacitymedium">' . $langs -> trans ( " SpecDefDesc " ) . '</span><br>' ;
print '<br>' ;
2019-11-13 19:37:08 +01:00
$specs = dol_dir_list ( dol_buildpath ( $modulelowercase . '/doc' , 0 ), 'files' , 1 , '(\.md|\.asciidoc)$' , array ( '\/temp\/' ));
2019-03-10 19:33:28 +01:00
foreach ( $specs as $spec )
{
$pathtofile = $modulelowercase . '/doc/' . $spec [ 'relativename' ];
2019-11-13 19:37:08 +01:00
$format = 'asciidoc' ;
if ( preg_match ( '/\.md$/i' , $spec [ 'name' ])) $format = 'markdown' ;
2019-03-10 19:33:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " SpecificationFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print ' <a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=' . $format . '&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-03-10 19:33:28 +01:00
print '<br>' ;
}
}
else
{
// Use MD or asciidoc
//print $langs->trans("UseAsciiDocFormat").'<br>';
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2019-03-10 19:33:28 +01:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-03-10 19:33:28 +01:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2019-03-10 19:33:28 +01:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
print '<tr><td><span class="warning">' . $langs -> trans ( 'Property $field not found into the class. The class was probably not generated by modulebuilder.' ) . '</warning></td></tr>' ;
2017-10-06 02:42:32 +02:00
}
print '</table>' ;
2017-09-23 15:12:25 +02:00
print '</div>' ;
2017-10-06 02:42:32 +02:00
print '</form>' ;
}
else
{
2017-12-11 13:50:26 +01:00
print '<tr><td><span class="warning">' . $langs -> trans ( 'Failed to init the object with the new.' ) . '</warning></td></tr>' ;
2017-10-06 02:42:32 +02:00
}
}
2019-11-13 19:37:08 +01:00
catch ( Exception $e )
2017-10-06 02:42:32 +02:00
{
print $e -> getMessage ();
}
}
else
{
if ( empty ( $forceddirread ))
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-10-06 02:42:32 +02:00
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = $dirread . '/' . $file ;
2017-10-06 02:42:32 +02:00
}
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="tabobj" value="' . dol_escape_htmltag ( $tabobj ) . '">' ;
2019-11-13 19:37:08 +01:00
print '<input type="hidden" name="module" value="' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '">' ;
2017-10-06 02:42:32 +02:00
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
2019-11-13 19:37:08 +01:00
dol_fiche_end (); // Level 3
2017-10-06 02:42:32 +02:00
}
if ( $tab == 'menus' )
{
2018-10-31 15:04:01 +01:00
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
2017-10-06 02:42:32 +02:00
2019-09-07 14:49:48 +02:00
$menus = $moduleobj -> menu ;
2017-10-06 02:42:32 +02:00
if ( $action != 'editfile' || empty ( $file ))
{
2019-05-02 12:03:14 +02:00
print '<span class="opacitymedium">' ;
2020-01-30 01:48:28 +01:00
$htmlhelp = $langs -> trans ( " MenusDefDescTooltip " , '<a href="' . DOL_URL_ROOT . '/admin/menus/index.php">' . $langs -> trans ( 'Setup' ) . ' - ' . $langs -> trans ( 'Menus' ) . '</a>' );
2019-05-02 12:03:14 +02:00
print $form -> textwithpicto ( $langs -> trans ( " MenusDefDesc " ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'helpondesc' ) . '<br>' ;
print '</span>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2017-11-19 16:26:39 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " DescriptorFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<br>' ;
2017-11-19 16:26:39 +01:00
print load_fiche_titre ( $langs -> trans ( " ListOfMenusEntries " ), '' , '' );
2017-10-06 02:42:32 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="addproperty">' ;
print '<input type="hidden" name="tab" value="objects">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print '<input type="hidden" name="tabobj" value="' . dol_escape_htmltag ( $tabobj ) . '">' ;
2019-09-07 14:49:48 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="noborder">' ;
print '<tr class="liste_titre">' ;
2019-09-08 21:28:17 +02:00
print_liste_field_titre ( " Type " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " fk_menu " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Title " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " mainmenu " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " leftmenu " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " URL " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " LanguageFile " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Position " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Enabled " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
2019-10-24 11:21:05 +02:00
print_liste_field_titre ( " Permission " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
2019-09-08 21:28:17 +02:00
print_liste_field_titre ( " Target " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
2019-10-24 11:21:05 +02:00
print_liste_field_titre ( " UserType " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder , 'right ' );
2019-09-07 14:49:48 +02:00
print " </tr> \n " ;
if ( count ( $menus ))
{
foreach ( $menus as $menu )
{
2019-09-09 11:23:53 +02:00
print '<tr class="oddeven">' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'type' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'fk_menu' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'titre' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'mainmenu' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'left' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'url' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'langs' ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'position' ];
print '</td>' ;
2019-09-07 14:49:48 +02:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'enabled' ];
print '</td>' ;
2019-09-07 14:49:48 +02:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'perms' ];
print '</td>' ;
2019-09-07 14:49:48 +02:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $menu [ 'target' ];
print '</td>' ;
2019-09-07 14:49:48 +02:00
2019-10-24 11:21:05 +02:00
print '<td class="right">' ;
2019-09-09 11:23:53 +02:00
print $menu [ 'user' ];
print '</td>' ;
2019-09-07 14:49:48 +02:00
2019-09-09 11:23:53 +02:00
print '</tr>' ;
}
}
else
{
2019-09-07 14:49:48 +02:00
print '<tr><td class="opacitymedium" colspan="5">' . $langs -> trans ( " None " ) . '</td></tr>' ;
2019-09-09 11:23:53 +02:00
}
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '</table>' ;
print '</div>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '</form>' ;
2017-10-06 02:42:32 +02:00
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-06-10 23:50:02 +02:00
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
2017-06-10 23:50:02 +02:00
2017-10-06 02:42:32 +02:00
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2017-09-23 01:24:31 +02:00
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
2017-09-23 01:24:31 +02:00
2017-10-06 02:42:32 +02:00
print '</form>' ;
}
}
2017-09-23 01:24:31 +02:00
2017-10-06 02:42:32 +02:00
if ( $tab == 'permissions' )
{
2018-10-31 15:04:01 +01:00
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
2017-09-23 01:24:31 +02:00
2019-09-07 14:49:48 +02:00
$perms = $moduleobj -> rights ;
2017-09-23 01:24:31 +02:00
2017-10-06 02:42:32 +02:00
if ( $action != 'editfile' || empty ( $file ))
{
2019-05-02 12:03:14 +02:00
print '<span class="opacitymedium">' ;
2020-01-30 01:48:28 +01:00
$htmlhelp = $langs -> trans ( " PermissionsDefDescTooltip " , '<a href="' . DOL_URL_ROOT . '/admin/perms.php">' . $langs -> trans ( 'DefaultPermissions' ) . '</a>' );
2019-05-02 12:03:14 +02:00
print $form -> textwithpicto ( $langs -> trans ( " PermissionsDefDesc " ), $htmlhelp , 1 , 'help' , '' , 0 , 2 , 'helpondesc' ) . '<br>' ;
print '</span>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2017-11-19 16:26:39 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " DescriptorFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<br>' ;
print load_fiche_titre ( $langs -> trans ( " ListOfPermissionsDefined " ), '' , '' );
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="addproperty">' ;
print '<input type="hidden" name="tab" value="objects">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print '<input type="hidden" name="tabobj" value="' . dol_escape_htmltag ( $tabobj ) . '">' ;
2017-09-23 01:24:31 +02:00
2019-09-07 14:49:48 +02:00
print '<div class="div-table-responsive">' ;
print '<table class="noborder">' ;
2017-12-11 13:50:26 +01:00
2019-09-07 14:49:48 +02:00
print '<tr class="liste_titre">' ;
2019-09-08 21:28:17 +02:00
print_liste_field_titre ( " ID " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Label " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Permission " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " " , $_SERVER [ " PHP_SELF " ], '' , " " , $param , '' , $sortfield , $sortorder );
2019-09-07 14:49:48 +02:00
print " </tr> \n " ;
2017-12-11 13:50:26 +01:00
2019-09-07 14:49:48 +02:00
if ( count ( $perms ))
{
foreach ( $perms as $perm )
{
2019-09-09 11:23:53 +02:00
print '<tr class="oddeven">' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $perm [ 0 ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $perm [ 1 ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $perm [ 4 ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '<td>' ;
print $perm [ 5 ];
print '</td>' ;
2017-12-11 13:50:26 +01:00
2019-09-09 11:23:53 +02:00
print '</tr>' ;
}
2019-09-07 14:49:48 +02:00
}
else
{
print '<tr><td class="opacitymedium" colspan="4">' . $langs -> trans ( " None " ) . '</td></tr>' ;
}
2017-12-11 13:50:26 +01:00
2019-09-07 14:49:48 +02:00
print '</table>' ;
print '</div>' ;
2017-12-11 13:50:26 +01:00
2019-09-07 14:49:48 +02:00
print '</form>' ;
2017-10-06 02:42:32 +02:00
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-09-23 01:24:31 +02:00
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
2017-06-10 23:50:02 +02:00
2017-10-06 02:42:32 +02:00
if ( $tab == 'hooks' )
{
if ( $action != 'editfile' || empty ( $file ))
2017-07-16 12:07:59 +02:00
{
2019-03-10 19:33:28 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " HooksDefDesc " ) . '</span><br>' ;
2017-09-23 12:59:49 +02:00
print '<br>' ;
2019-03-10 19:33:28 +01:00
print '<table><tr><td>' ;
2018-10-31 15:04:01 +01:00
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
2019-03-10 19:33:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " DescriptorFile " ) . ' : <strong class="">' . $pathtofile . '</strong>' ;
print '</td><td>' ;
2020-01-30 01:48:28 +01:00
print '<a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2019-03-10 19:33:28 +01:00
print '</td></tr>' ;
2017-09-23 12:59:49 +02:00
2019-03-10 19:33:28 +01:00
print '<tr><td>' ;
2017-10-06 02:42:32 +02:00
$pathtohook = strtolower ( $module ) . '/class/actions_' . strtolower ( $module ) . '.class.php' ;
2019-03-10 19:33:28 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " HooksFile " ) . ' : ' ;
if ( dol_is_file ( $dirins . '/' . $pathtohook ))
{
print '<strong>' . $pathtohook . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtohook ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a></td>' ;
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtohook ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-03-10 19:33:28 +01:00
}
else
{
print '<span class="opacitymedium">' . $langs -> trans ( " FileNotYetGenerated " ) . '</span>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=inithook&format=php&file=' . urlencode ( $pathtohook ) . '"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a></td>' ;
2019-03-10 19:33:28 +01:00
}
print '</tr>' ;
2017-07-16 12:07:59 +02:00
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
2017-07-16 12:07:59 +02:00
}
2017-10-06 02:42:32 +02:00
}
2017-06-14 11:44:12 +02:00
2017-10-06 02:42:32 +02:00
if ( $tab == 'triggers' )
{
require_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php' ;
2017-06-10 23:50:02 +02:00
2017-05-28 14:43:17 +02:00
$interfaces = new Interfaces ( $db );
$triggers = $interfaces -> getTriggersList ( array ( '/' . strtolower ( $module ) . '/core/triggers' ));
2017-06-10 23:50:02 +02:00
2017-07-08 15:43:36 +02:00
if ( $action != 'editfile' || empty ( $file ))
2017-05-28 14:43:17 +02:00
{
2019-03-10 19:33:28 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " TriggerDefDesc " ) . '</span><br>' ;
2017-09-23 12:59:49 +02:00
print '<br>' ;
2019-03-10 19:33:28 +01:00
print '<table>' ;
2019-11-13 19:37:08 +01:00
if ( ! empty ( $triggers ))
2017-08-26 15:22:13 +02:00
{
2017-10-06 02:42:32 +02:00
foreach ( $triggers as $trigger )
{
$pathtofile = $trigger [ 'relpath' ];
2019-03-10 19:33:28 +01:00
print '<tr><td>' ;
2017-11-19 16:26:39 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " TriggersFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a></td>' ;
print '<td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-03-10 19:33:28 +01:00
print '</tr>' ;
2017-10-06 02:42:32 +02:00
}
2017-08-26 15:22:13 +02:00
}
else
{
2019-03-10 19:33:28 +01:00
print '<tr><td>' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " NoTrigger " );
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=inittrigger&format=php"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a></td>' ;
2019-03-10 19:33:28 +01:00
print '</tr>' ;
2017-08-26 15:22:13 +02:00
}
2019-03-10 19:33:28 +01:00
print '</table>' ;
2017-05-28 14:43:17 +02:00
}
2017-07-08 15:43:36 +02:00
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2019-10-24 11:41:36 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
if ( $tab == 'css' )
{
if ( $action != 'editfile' || empty ( $file ))
{
print '<span class="opacitymedium">' . $langs -> trans ( " CSSDesc " ) . '</span><br>' ;
print '<br>' ;
print '<table>' ;
print '<tr><td>' ;
$pathtohook = strtolower ( $module ) . '/css/' . strtolower ( $module ) . '.css.php' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " CSSFile " ) . ' : ' ;
if ( dol_is_file ( $dirins . '/' . $pathtohook ))
{
print '<strong>' . $pathtohook . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtohook ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a></td>' ;
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtohook ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-10-24 11:41:36 +02:00
}
else
{
print '<span class="opacitymedium">' . $langs -> trans ( " FileNotYetGenerated " ) . '</span>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initcss&format=php&file=' . urlencode ( $pathtohook ) . '"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a></td>' ;
2019-10-24 11:41:36 +02:00
}
print '</tr>' ;
}
else
{
2020-01-30 01:48:28 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2019-10-24 11:41:36 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-10-24 11:41:36 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2020-01-30 01:48:28 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2019-10-24 11:41:36 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
if ( $tab == 'js' )
{
if ( $action != 'editfile' || empty ( $file ))
{
print '<span class="opacitymedium">' . $langs -> trans ( " JSDesc " ) . '</span><br>' ;
print '<br>' ;
print '<table>' ;
print '<tr><td>' ;
$pathtohook = strtolower ( $module ) . '/js/' . strtolower ( $module ) . '.js.php' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " JSFile " ) . ' : ' ;
if ( dol_is_file ( $dirins . '/' . $pathtohook ))
{
print '<strong>' . $pathtohook . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtohook ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a></td>' ;
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtohook ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-10-24 11:41:36 +02:00
}
else
{
print '<span class="opacitymedium">' . $langs -> trans ( " FileNotYetGenerated " ) . '</span>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initjs&format=php&file=' . urlencode ( $pathtohook ) . '"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a></td>' ;
2019-10-24 11:41:36 +02:00
}
print '</tr>' ;
}
else
{
2020-01-30 01:48:28 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2019-10-24 11:41:36 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-10-24 11:41:36 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2020-01-30 01:48:28 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
2017-07-08 15:43:36 +02:00
}
2017-10-06 02:42:32 +02:00
}
2017-05-28 14:43:17 +02:00
2017-10-06 02:42:32 +02:00
if ( $tab == 'widgets' )
{
require_once DOL_DOCUMENT_ROOT . '/core/boxes/modules_boxes.php' ;
2017-07-16 12:07:59 +02:00
$widgets = ModeleBoxes :: getWidgetsList ( array ( '/' . strtolower ( $module ) . '/core/boxes' ));
if ( $action != 'editfile' || empty ( $file ))
{
2019-03-10 19:33:28 +01:00
print '<span class="opacitymedium">' . $langs -> trans ( " WidgetDesc " ) . '</span><br>' ;
print '<br>' ;
print '<table>' ;
2019-11-13 19:37:08 +01:00
if ( ! empty ( $widgets ))
2017-08-26 15:22:13 +02:00
{
2017-10-06 02:42:32 +02:00
foreach ( $widgets as $widget )
{
$pathtofile = $widget [ 'relpath' ];
2019-03-10 19:33:28 +01:00
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " WidgetFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-03-10 19:33:28 +01:00
print '</tr>' ;
2017-10-06 02:42:32 +02:00
}
}
else
{
2019-03-10 19:33:28 +01:00
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " NoWidget " );
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initwidget&format=php"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a>' ;
2019-03-10 19:33:28 +01:00
print '</td></tr>' ;
2017-10-06 02:42:32 +02:00
}
2019-03-10 19:33:28 +01:00
print '</table>' ;
2017-07-16 12:07:59 +02:00
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
2017-07-16 12:07:59 +02:00
}
2017-10-06 02:42:32 +02:00
}
2017-06-14 11:44:12 +02:00
2019-03-10 19:33:28 +01:00
if ( $tab == 'cli' )
{
$clifiles = array ();
$i = 0 ;
2019-11-13 19:37:08 +01:00
$dircli = array ( '/' . strtolower ( $module ) . '/scripts' );
2019-03-10 19:33:28 +01:00
2019-11-13 19:37:08 +01:00
foreach ( $dircli as $reldir )
2019-03-10 19:33:28 +01:00
{
2019-11-13 19:37:08 +01:00
$dir = dol_buildpath ( $reldir , 0 );
$newdir = dol_osencode ( $dir );
2019-03-10 19:33:28 +01:00
// Check if directory exists (we do not use dol_is_dir to avoid loading files.lib.php at each call)
2019-11-13 19:37:08 +01:00
if ( ! is_dir ( $newdir )) continue ;
2019-03-10 19:33:28 +01:00
2019-11-13 19:37:08 +01:00
$handle = opendir ( $newdir );
2019-03-10 19:33:28 +01:00
if ( is_resource ( $handle ))
{
2019-11-13 19:37:08 +01:00
while (( $tmpfile = readdir ( $handle )) !== false )
2019-03-10 19:33:28 +01:00
{
if ( is_readable ( $newdir . '/' . $file ) && preg_match ( '/^(.+)\.php/' , $tmpfile , $reg ))
{
if ( preg_match ( '/\.back$/' , $tmpfile )) continue ;
$clifiles [ $i ][ 'relpath' ] = preg_replace ( '/^\//' , '' , $reldir ) . '/' . $tmpfile ;
$i ++ ;
}
}
closedir ( $handle );
}
}
if ( $action != 'editfile' || empty ( $file ))
{
print '<span class="opacitymedium">' . $langs -> trans ( " CLIDesc " ) . '</span><br>' ;
print '<br>' ;
print '<table>' ;
2019-11-13 19:37:08 +01:00
if ( ! empty ( $clifiles ))
2019-03-10 19:33:28 +01:00
{
foreach ( $clifiles as $clifile )
{
$pathtofile = $clifile [ 'relpath' ];
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " CLIFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a></td>' ;
print '<td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-03-10 19:33:28 +01:00
print '</tr>' ;
}
}
else
{
print '<tr><td><span class="fa fa-file-o"></span> ' . $langs -> trans ( " NoCLIFile " );
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initcli&format=php"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a>' ;
2019-03-10 19:33:28 +01:00
print '</td></tr>' ;
}
print '</table>' ;
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2019-03-10 19:33:28 +01:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-03-10 19:33:28 +01:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2019-03-10 19:33:28 +01:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
}
2017-10-06 02:42:32 +02:00
if ( $tab == 'cron' )
{
2018-10-31 15:04:01 +01:00
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
$cronjobs = $moduleobj -> cronjobs ;
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
if ( $action != 'editfile' || empty ( $file ))
{
2019-05-13 10:26:30 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " CronJobDefDesc " , '<a href="' . DOL_URL_ROOT . '/cron/list.php">' . $langs -> transnoentities ( 'CronList' ) . '</a>' ) . '</span><br>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2017-07-26 10:11:39 +02:00
2017-11-19 16:26:39 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " DescriptorFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print ' <a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=php&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a>' ;
2017-10-06 02:42:32 +02:00
print '<br>' ;
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
print '<br>' ;
print load_fiche_titre ( $langs -> trans ( " CronJobProfiles " ), '' , '' );
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="addproperty">' ;
print '<input type="hidden" name="tab" value="objects">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print '<input type="hidden" name="tabobj" value="' . dol_escape_htmltag ( $tabobj ) . '">' ;
print '<div class="div-table-responsive">' ;
print '<table class="noborder">' ;
print '<tr class="liste_titre">' ;
2019-01-27 11:55:16 +01:00
print_liste_field_titre ( " CronLabel " , $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " CronTask " , '' , '' , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " CronFrequency " , '' , " " , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " StatusAtInstall " , $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder );
print_liste_field_titre ( " Comment " , $_SERVER [ " PHP_SELF " ], " " , " " , $param , '' , $sortfield , $sortorder );
2017-10-06 02:42:32 +02:00
print " </tr> \n " ;
if ( count ( $cronjobs ))
{
foreach ( $cronjobs as $cron )
{
print '<tr class="oddeven">' ;
print '<td>' ;
print $cron [ 'label' ];
print '</td>' ;
print '<td>' ;
2019-11-13 19:37:08 +01:00
if ( $cron [ 'jobtype' ] == 'method' )
2017-10-06 02:42:32 +02:00
{
2019-11-13 19:37:08 +01:00
$text = $langs -> trans ( " CronClass " );
$texttoshow = $langs -> trans ( 'CronModule' ) . ': ' . $module . '<br>' ;
$texttoshow .= $langs -> trans ( 'CronClass' ) . ': ' . $cron [ 'class' ] . '<br>' ;
$texttoshow .= $langs -> trans ( 'CronObject' ) . ': ' . $cron [ 'objectname' ] . '<br>' ;
$texttoshow .= $langs -> trans ( 'CronMethod' ) . ': ' . $cron [ 'method' ];
$texttoshow .= '<br>' . $langs -> trans ( 'CronArgs' ) . ': ' . $cron [ 'parameters' ];
$texttoshow .= '<br>' . $langs -> trans ( 'Comment' ) . ': ' . $langs -> trans ( $cron [ 'comment' ]);
2017-10-06 02:42:32 +02:00
}
2019-11-13 19:37:08 +01:00
elseif ( $cron [ 'jobtype' ] == 'command' )
2017-10-06 02:42:32 +02:00
{
2019-11-13 19:37:08 +01:00
$text = $langs -> trans ( 'CronCommand' );
$texttoshow = $langs -> trans ( 'CronCommand' ) . ': ' . dol_trunc ( $cron [ 'command' ]);
$texttoshow .= '<br>' . $langs -> trans ( 'CronArgs' ) . ': ' . $cron [ 'parameters' ];
$texttoshow .= '<br>' . $langs -> trans ( 'Comment' ) . ': ' . $langs -> trans ( $cron [ 'comment' ]);
2017-10-06 02:42:32 +02:00
}
print $form -> textwithpicto ( $text , $texttoshow , 1 );
print '</td>' ;
print '<td>' ;
2019-11-13 19:37:08 +01:00
if ( $cron [ 'unitfrequency' ] == " 60 " ) print $langs -> trans ( 'CronEach' ) . " " . ( $cron [ 'frequency' ]) . " " . $langs -> trans ( 'Minutes' );
if ( $cron [ 'unitfrequency' ] == " 3600 " ) print $langs -> trans ( 'CronEach' ) . " " . ( $cron [ 'frequency' ]) . " " . $langs -> trans ( 'Hours' );
if ( $cron [ 'unitfrequency' ] == " 86400 " ) print $langs -> trans ( 'CronEach' ) . " " . ( $cron [ 'frequency' ]) . " " . $langs -> trans ( 'Days' );
if ( $cron [ 'unitfrequency' ] == " 604800 " ) print $langs -> trans ( 'CronEach' ) . " " . ( $cron [ 'frequency' ]) . " " . $langs -> trans ( 'Weeks' );
2017-10-06 02:42:32 +02:00
print '</td>' ;
print '<td>' ;
print $cron [ 'status' ];
print '</td>' ;
print '<td>' ;
2019-11-13 19:37:08 +01:00
if ( ! empty ( $cron [ 'comment' ])) { print $cron [ 'comment' ]; }
2017-10-06 02:42:32 +02:00
print '</td>' ;
print '</tr>' ;
}
}
else
{
print '<tr><td class="opacitymedium" colspan="5">' . $langs -> trans ( " None " ) . '</td></tr>' ;
}
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
print '</table>' ;
print '</div>' ;
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
print '</form>' ;
}
else
{
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
$content = file_get_contents ( $fullpathoffile );
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2017-08-27 13:28:37 +02:00
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2017-10-06 02:42:32 +02:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
2017-08-27 13:28:37 +02:00
2017-10-06 02:42:32 +02:00
print '</form>' ;
}
}
2017-08-27 13:28:37 +02:00
2019-03-10 19:33:28 +01:00
if ( $tab == 'specifications' )
{
2019-11-13 19:37:08 +01:00
$specs = dol_dir_list ( dol_buildpath ( $modulelowercase . '/doc' , 0 ), 'files' , 1 , '(\.md|\.asciidoc)$' , array ( '\/temp\/' ));
2019-03-17 19:33:25 +01:00
2019-03-10 19:33:28 +01:00
if ( $action != 'editfile' || empty ( $file ))
{
print '<span class="opacitymedium">' . $langs -> trans ( " SpecDefDesc " ) . '</span><br>' ;
print '<br>' ;
print '<table>' ;
2019-11-13 19:37:08 +01:00
if ( is_array ( $specs ) && ! empty ( $specs ))
2019-03-10 19:33:28 +01:00
{
foreach ( $specs as $spec )
{
$pathtofile = $modulelowercase . '/doc/' . $spec [ 'relativename' ];
2019-11-13 19:37:08 +01:00
$format = 'asciidoc' ;
if ( preg_match ( '/\.md$/i' , $spec [ 'name' ])) $format = 'markdown' ;
2019-03-10 19:33:28 +01:00
print '<tr><td>' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " SpecificationFile " ) . ' : <strong>' . $pathtofile . '</strong>' ;
2020-01-30 01:48:28 +01:00
print '</td><td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=editfile&format=' . $format . '&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Edit " ), 'edit' ) . '</a></td>' ;
print '<td><a class="editfielda" href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=confirm_removefile&format=' . $format . '&file=' . urlencode ( $pathtofile ) . '">' . img_picto ( $langs -> trans ( " Delete " ), 'delete' ) . '</a></td>' ;
2019-03-10 19:33:28 +01:00
print '</tr>' ;
}
}
else
{
print '<tr><td>' ;
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " FileNotYetGenerated " );
2020-01-30 01:48:28 +01:00
print '</td><td><a href="' . $_SERVER [ 'PHP_SELF' ] . '?tab=' . $tab . '&module=' . $module . ( $forceddirread ? '@' . $dirread : '' ) . '&action=initdoc&format=php"><input type="button" class="button" value="' . $langs -> trans ( " Generate " ) . '"></a></td>' ;
2019-03-10 19:33:28 +01:00
print '</tr>' ;
}
print '</table>' ;
}
else
{
// Use MD or asciidoc
//print $langs->trans("UseAsciiDocFormat").'<br>';
2019-11-13 19:37:08 +01:00
$fullpathoffile = dol_buildpath ( $file , 0 );
2019-03-10 19:33:28 +01:00
$content = file_get_contents ( $fullpathoffile );
// New module
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-03-10 19:33:28 +01:00
print '<input type="hidden" name="action" value="savefile">' ;
print '<input type="hidden" name="file" value="' . dol_escape_htmltag ( $file ) . '">' ;
print '<input type="hidden" name="tab" value="' . $tab . '">' ;
print '<input type="hidden" name="module" value="' . $module . '">' ;
2019-11-13 19:37:08 +01:00
$doleditor = new DolEditor ( 'editfilecontent' , $content , '' , '300' , 'Full' , 'In' , true , false , 'ace' , 0 , '99%' );
print $doleditor -> Create ( 1 , '' , false , $langs -> trans ( " File " ) . ' : ' . $file , ( GETPOST ( 'format' , 'aZ09' ) ? GETPOST ( 'format' , 'aZ09' ) : 'html' ));
2019-03-10 19:33:28 +01:00
print '<br>' ;
print '<center>' ;
print '<input type="submit" class="button buttonforacesave" id="savefile" name="savefile" value="' . dol_escape_htmltag ( $langs -> trans ( " Save " )) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . dol_escape_htmltag ( $langs -> trans ( " Cancel " )) . '">' ;
print '</center>' ;
print '</form>' ;
}
2019-03-17 19:33:25 +01:00
print '<br><br><br>' ;
2019-11-13 19:37:08 +01:00
$FILENAMEDOC = $modulelowercase . '.html' ;
$FILENAMEDOCPDF = $modulelowercase . '.pdf' ;
2019-03-17 19:33:25 +01:00
$outputfiledoc = dol_buildpath ( $modulelowercase , 0 ) . '/doc/' . $FILENAMEDOC ;
$outputfiledocurl = dol_buildpath ( $modulelowercase , 1 ) . '/doc/' . $FILENAMEDOC ;
$outputfiledocpdf = dol_buildpath ( $modulelowercase , 0 ) . '/doc/' . $FILENAMEDOCPDF ;
$outputfiledocurlpdf = dol_buildpath ( $modulelowercase , 1 ) . '/doc/' . $FILENAMEDOCPDF ;
// HTML
2019-11-13 19:37:08 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PathToModuleDocumentation " , " HTML " ) . ' : ' ;
if ( ! dol_is_file ( $outputfiledoc )) print '<strong>' . $langs -> trans ( " FileNotYetGenerated " ) . '</strong>' ;
2019-03-17 19:33:25 +01:00
else {
print '<strong>' ;
print '<a href="' . $outputfiledocurl . '" target="_blank">' ;
print $outputfiledoc ;
print '</a>' ;
print '</strong>' ;
print ' (' . $langs -> trans ( " GeneratedOn " ) . ' ' . dol_print_date ( dol_filemtime ( $outputfiledoc ), 'dayhour' ) . ')' ;
}
print '</strong><br>' ;
// PDF
2019-11-13 19:37:08 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PathToModuleDocumentation " , " PDF " ) . ' : ' ;
if ( ! dol_is_file ( $outputfiledocpdf )) print '<strong>' . $langs -> trans ( " FileNotYetGenerated " ) . '</strong>' ;
2019-03-17 19:33:25 +01:00
else {
print '<strong>' ;
print '<a href="' . $outputfiledocurlpdf . '" target="_blank">' ;
print $outputfiledocpdf ;
print '</a>' ;
print '</strong>' ;
print ' (' . $langs -> trans ( " GeneratedOn " ) . ' ' . dol_print_date ( dol_filemtime ( $outputfiledocpdf ), 'dayhour' ) . ')' ;
}
print '</strong><br>' ;
print '<br>' ;
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST" name="generatedoc">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2019-03-17 19:33:25 +01:00
print '<input type="hidden" name="action" value="generatedoc">' ;
print '<input type="hidden" name="tab" value="' . dol_escape_htmltag ( $tab ) . '">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print '<input type="submit" class="button" name="generatedoc" value="' . $langs -> trans ( " BuildDocumentation " ) . '"' ;
2020-01-30 01:48:28 +01:00
if ( ! is_array ( $specs ) || empty ( $specs )) print ' disabled="disabled"' ;
2019-03-17 19:33:25 +01:00
print '>' ;
print '</form>' ;
2019-03-10 19:33:28 +01:00
}
2017-10-06 02:42:32 +02:00
if ( $tab == 'buildpackage' )
{
2019-05-02 12:03:14 +02:00
print '<span class="opacitymedium">' . $langs -> trans ( " BuildPackageDesc " ) . '</span>' ;
print '<br>' ;
2020-01-30 01:48:28 +01:00
if ( ! class_exists ( 'ZipArchive' ) && ! defined ( 'ODTPHP_PATHTOPCLZIP' ))
2017-10-06 02:42:32 +02:00
{
print img_warning () . ' ' . $langs -> trans ( " ErrNoZipEngine " );
print '<br>' ;
}
2017-08-27 13:28:37 +02:00
2020-01-30 01:48:28 +01:00
$modulelowercase = strtolower ( $module );
2017-08-27 13:28:37 +02:00
2017-10-06 02:42:32 +02:00
// Zip file to build
2020-01-30 01:48:28 +01:00
$FILENAMEZIP = '' ;
2017-08-27 13:28:37 +02:00
2017-10-06 02:42:32 +02:00
// Load module
2018-10-31 15:04:01 +01:00
$pathtofile = $listofmodules [ strtolower ( $module )][ 'moduledescriptorrelpath' ];
dol_include_once ( $pathtofile );
2020-01-30 01:48:28 +01:00
$class = 'mod' . $module ;
2017-07-26 10:11:39 +02:00
2017-10-06 02:42:32 +02:00
if ( class_exists ( $class ))
{
try {
$moduleobj = new $class ( $db );
}
2020-01-30 01:48:28 +01:00
catch ( Exception $e )
2017-10-06 02:42:32 +02:00
{
$error ++ ;
dol_print_error ( $e -> getMessage ());
}
}
else
{
$error ++ ;
$langs -> load ( " errors " );
dol_print_error ( $langs -> trans ( " ErrorFailedToLoadModuleDescriptorForXXX " , $module ));
exit ;
}
2017-09-23 01:24:31 +02:00
2019-11-13 19:37:08 +01:00
$arrayversion = explode ( '.' , $moduleobj -> version , 3 );
2017-10-06 02:42:32 +02:00
if ( count ( $arrayversion ))
{
2019-11-13 19:37:08 +01:00
$FILENAMEZIP = " module_ " . $modulelowercase . '-' . $arrayversion [ 0 ] . '.' . $arrayversion [ 1 ] . ( $arrayversion [ 2 ] ? " . " . $arrayversion [ 2 ] : " " ) . " .zip " ;
2017-10-06 02:42:32 +02:00
$outputfilezip = dol_buildpath ( $modulelowercase , 0 ) . '/bin/' . $FILENAMEZIP ;
}
print '<br>' ;
2019-11-13 19:37:08 +01:00
print '<span class="fa fa-file-o"></span> ' . $langs -> trans ( " PathToModulePackage " ) . ' : ' ;
if ( ! dol_is_file ( $outputfilezip )) print '<strong>' . $langs -> trans ( " FileNotYetGenerated " ) . '</strong>' ;
2017-10-06 02:42:32 +02:00
else {
$relativepath = $modulelowercase . '/bin/' . $FILENAMEZIP ;
print '<strong><a href="' . DOL_URL_ROOT . '/document.php?modulepart=packages&file=' . urlencode ( $relativepath ) . '">' . $outputfilezip . '</a></strong>' ;
print ' (' . $langs -> trans ( " GeneratedOn " ) . ' ' . dol_print_date ( dol_filemtime ( $outputfilezip ), 'dayhour' ) . ')' ;
}
print '</strong><br>' ;
print '<br>' ;
2019-03-11 15:58:37 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST" name="generatepackage">' ;
2019-12-18 23:12:31 +01:00
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
2017-10-06 02:42:32 +02:00
print '<input type="hidden" name="action" value="generatepackage">' ;
print '<input type="hidden" name="tab" value="' . dol_escape_htmltag ( $tab ) . '">' ;
print '<input type="hidden" name="module" value="' . dol_escape_htmltag ( $module ) . '">' ;
print '<input type="submit" class="button" name="generatepackage" value="' . $langs -> trans ( " BuildPackage " ) . '">' ;
print '</form>' ;
}
if ( $tab != 'description' )
{
dol_fiche_end ();
}
}
2017-05-08 23:55:46 +02:00
}
2017-07-18 14:20:37 +02:00
dol_fiche_end (); // End modules
2017-05-08 23:55:46 +02:00
2018-08-14 09:55:58 +02:00
// End of page
2017-03-29 21:36:50 +02:00
llxFooter ();
$db -> close ();