|
dolibarr 24.0.0-beta
|
Set of function for modulebuilder management. More...
Go to the source code of this file.
Functions | |
| rebuildObjectClass ($destdir, $module, $objectname, $newmask, $readdir='', $addfieldentry=array(), $delfieldentry='') | |
| Regenerate files .class.php. | |
| rebuildObjectSql ($destdir, $module, $objectname, $newmask, $readdir='', $object=null, $moduletype='external') | |
| Save data into a memory area shared by all users, all sessions on server. | |
| dolGetListOfObjectClasses ($destdir) | |
| Get list of existing objects from a directory. | |
| checkExistComment ($file, $number) | |
| Function to check if comment BEGIN and END exists in modMyModule class. | |
| deletePerms ($file) | |
| Delete all permissions. | |
| compareFirstValue ($a, $b) | |
| Compare two values. | |
| reWriteAllPermissions ($file, $permissions, $key, $right, $objectname, $module, $action) | |
| Rewriting all permissions after any actions. | |
| parsePropertyString ($string) | |
| Converts a formatted properties string into an associative array. | |
| writePropsInAsciiDoc ($file, $objectname, $destfile) | |
| Write all properties of the object in AsciiDoc format. | |
| deletePropsAndPermsFromDoc ($file, $objectname) | |
| Delete property and permissions from documentation ascii file if we delete an object. | |
| getFromFile ($file, $start, $end, $excludestart='', $includese=0) | |
| Search a string and return all lines needed from file. | |
| writePermsInAsciiDoc ($file, $destfile) | |
| Write all permissions of each object in AsciiDoc format. | |
| addObjectsToApiFile ($srcfile, $file, $objects, $modulename) | |
| Add Object in ModuleApi File. | |
| removeObjectFromApiFile ($file, $objects, $objectname) | |
| Remove Object variables and methods from API_Module File. | |
| reWriteAllMenus ($file, $menus, $menuWantTo, $key, $action) | |
| updateDictionaryInFile ($module, $file, $dicts) | |
| Updates a dictionary in a module descriptor file. | |
| createNewDictionnary ($modulename, $file, $namedic, $dictionnaires=null) | |
| Create a new dictionary table. | |
| writeApiUrlsInDoc ($file_api, $file_doc) | |
| Generate Urls and add them to documentation module. | |
| countItemsInDirectory ($path, $type=1) | |
| count directories or files in modulebuilder folder | |
| getModuleBuilderObjectTabs () | |
| Return the map of optional tabs that can be generated for a ModuleBuilder object. | |
| filterEnabledTabs ($requested, $map) | |
| Filter a list of requested tab keys against the known optional tabs map. | |
| dolReplaceInFilePreservingModuleBuilderMarkers ($file, $arrayreplacement) | |
| Apply substitutions to a module descriptor file while preserving the MODULEBUILDER comment markers. | |
Set of function for modulebuilder management.
Definition in file modulebuilder.lib.php.
| addObjectsToApiFile | ( | $srcfile, | |
| $file, | |||
| $objects, | |||
| $modulename ) |
Add Object in ModuleApi File.
| string | $srcfile | Source file to use as example |
| string | $file | Path of modified file |
| string[] | $objects | Array of objects in the module |
| string | $modulename | Name of module |
Definition at line 1000 of file modulebuilder.lib.php.
References dol_now(), dol_print_date(), dol_syslog(), dolChmod(), dolReplaceInFile(), and getFromFile().
| checkExistComment | ( | $file, | |
| $number ) |
Function to check if comment BEGIN and END exists in modMyModule class.
| string | $file | Filename or path |
| int<0,2> | $number 0 = For Menus, 1 = For permissions, 2 = For Dictionaries |
Definition at line 486 of file modulebuilder.lib.php.
| compareFirstValue | ( | $a, | |
| $b ) |
Compare two values.
| int | string | $a | value 1 |
| int | string | $b | value 2 |
Definition at line 563 of file modulebuilder.lib.php.
| countItemsInDirectory | ( | $path, | |
| $type = 1 ) |
count directories or files in modulebuilder folder
| string | $path | path of directory |
| int<1,2> | $type type of file 1= file,2=directory |
Definition at line 1448 of file modulebuilder.lib.php.
| createNewDictionnary | ( | $modulename, | |
| $file, | |||
| $namedic, | |||
| $dictionnaires = null ) |
Create a new dictionary table.
It generates the necessary SQL code to define the table structure, including columns such as 'rowid', 'code', 'label', 'position', 'use_default', 'active', etc. The table name is constructed based on the provided $namedic parameter.
| string | $modulename | The lowercase name of the module for which the dictionary table is being created. |
| string | $file | The file path to the Dolibarr module builder file where the dictionaries are defined. |
| string | $namedic | The name of the dictionary, which will also be used as the base for the table name. |
| ?array{langs:string,tabname:string[],tablib:string[],tabsql:string[],tabsqlsort:string[],tabfield:string[],tabfieldvalue:string[],tabfieldinsert:string[],tabrowid:string[],tabcond:array<string|bool|int>,tabhelp:array<array{code:string,field2:string}>} | $dictionnaires An optional array containing pre-existing dictionary data, including tabname, tablib, tabsql, etc. |
Definition at line 1310 of file modulebuilder.lib.php.
References $db, dol_print_error(), isModEnabled(), setEventMessages(), and updateDictionaryInFile().
| deletePerms | ( | $file | ) |
Delete all permissions.
| string | $file | file with path |
Definition at line 530 of file modulebuilder.lib.php.
References dolReplaceInFile().
Referenced by reWriteAllPermissions().
| deletePropsAndPermsFromDoc | ( | $file, | |
| $objectname ) |
Delete property and permissions from documentation ascii file if we delete an object.
| string | $file | file or path |
| string | $objectname | name of object wants to deleted |
Definition at line 839 of file modulebuilder.lib.php.
References dol_is_file(), and dolChmod().
| dolGetListOfObjectClasses | ( | $destdir | ) |
Get list of existing objects from a directory.
| string | $destdir | Directory |
Definition at line 453 of file modulebuilder.lib.php.
References dol_dir_list().
| dolReplaceInFilePreservingModuleBuilderMarkers | ( | $file, | |
| $arrayreplacement ) |
Apply substitutions to a module descriptor file while preserving the MODULEBUILDER comment markers.
Markers such as "BEGIN MODULEBUILDER LEFTMENU MYOBJECT" must keep their MYOBJECT/MYMODULE placeholder so that generating subsequent objects can still locate them (see checkExistComment()). A blanket substitution would rewrite them to the first object name and break the generation of further objects.
| string | $file | Path to the module descriptor file |
| array<string,string> | $arrayreplacement Substitution map (search => replace), applied as literal strings |
Definition at line 1518 of file modulebuilder.lib.php.
| filterEnabledTabs | ( | $requested, | |
| $map ) |
Filter a list of requested tab keys against the known optional tabs map.
Protects against injection of unknown keys, removes duplicates, normalizes order.
| string[] | $requested | Raw tab keys requested by the user (e.g. from GETPOST array) |
| array<string,array{file:string,var:string,marker:string,label:string}> | $map Map from getModuleBuilderObjectTabs() |
Definition at line 1494 of file modulebuilder.lib.php.
| getFromFile | ( | $file, | |
| $start, | |||
| $end, | |||
| $excludestart = '', | |||
| $includese = 0 ) |
Search a string and return all lines needed from file.
Does not include line $start nor $end
| string | $file | file for searching |
| string | $start | start line if it exists |
| string | $end | end line if it exists |
| string | $excludestart | Ignore if start line is $excludestart |
| int<0,1> | $includese Include start and end line |
Definition at line 873 of file modulebuilder.lib.php.
References dol_osencode().
Referenced by addObjectsToApiFile(), removeObjectFromApiFile(), reWriteAllMenus(), updateDictionaryInFile(), writeApiUrlsInDoc(), and writePermsInAsciiDoc().
| getModuleBuilderObjectTabs | ( | ) |
Return the map of optional tabs that can be generated for a ModuleBuilder object.
The CARD tab is always generated and is therefore not listed here. HISTORY is an alias of AGENDA (object event history is the agenda tab in Dolibarr).
Definition at line 1476 of file modulebuilder.lib.php.
| parsePropertyString | ( | $string | ) |
Converts a formatted properties string into an associative array.
| string | $string | The formatted properties string. |
Definition at line 695 of file modulebuilder.lib.php.
References parsePropertyString().
Referenced by parsePropertyString(), and writePropsInAsciiDoc().
| rebuildObjectClass | ( | $destdir, | |
| $module, | |||
| $objectname, | |||
| $newmask, | |||
| $readdir = '', | |||
| $addfieldentry = array(), | |||
| $delfieldentry = '' ) |
Regenerate files .class.php.
| string | $destdir | Directory |
| string | $module | Module name |
| string | $objectname | Name of object |
| string | $newmask | New mask |
| string | $readdir | Directory source (use $destdir when not defined) |
| array{}|array{name:string,key:string,type:string,label:string,picot?:string,enabled:int<0,1>,notnull:int<0,1>,position:int,visible:int,noteditable?:int<0,1>,alwayseditable?:int<0,1>,default?:string,index?:int,foreignkey?:string,searchall?:int,isameasure?:int<0,1>,css?:string,cssview?:string,csslist?:string,help?:string,showoncombobox?:int<0,1>,disabled?:int<0,1>,autofocusoncreate?:int<0,1>,arrayofkeyval?:array<string,string>,validate?:int<0,1>,comment?:string} | $addfieldentry Array of 1 field entry to add | |
| string | $delfieldentry | Id of field to remove |
Definition at line 41 of file modulebuilder.lib.php.
References $db, $object, dol_copy(), dol_escape_js(), dol_escape_php(), dol_is_file(), dol_mkdir(), dol_osencode(), dol_print_error(), dol_sort_array(), dolChmod(), and setEventMessages().
| rebuildObjectSql | ( | $destdir, | |
| $module, | |||
| $objectname, | |||
| $newmask, | |||
| $readdir = '', | |||
| $object = null, | |||
| $moduletype = 'external' ) |
Save data into a memory area shared by all users, all sessions on server.
| string | $destdir | Directory |
| string | $module | Module name |
| string | $objectname | Name of object |
| string | $newmask | New mask |
| string | $readdir | Directory source (use $destdir when not defined) |
| Object | $object | If object was already loaded/known, it is pass to avoid another include and new. |
| string | $moduletype | 'external' or 'internal' |
Definition at line 269 of file modulebuilder.lib.php.
References $db, $object, dol_copy(), dol_is_file(), dol_mkdir(), dol_osencode(), dolChmod(), and setEventMessages().
| removeObjectFromApiFile | ( | $file, | |
| $objects, | |||
| $objectname ) |
Remove Object variables and methods from API_Module File.
| string | $file | File api module |
| string[] | $objects | Array of objects in the module |
| string | $objectname | Name of object want to remove |
Definition at line 1081 of file modulebuilder.lib.php.
References dolChmod(), dolReplaceInFile(), and getFromFile().
| reWriteAllMenus | ( | $file, | |
| $menus, | |||
| $menuWantTo, | |||
| $key, | |||
| $action ) |
| string | $file | path of filename |
| array<int,array{commentgroup?:string,fk_menu:string,type:string,titre:string,mainmenu:string,leftmenu:string,url:string,langs:string,position:int|string,enabled:int|string,perms:string,target:string,user:int}> | $menus all menus for module | |
| null|string|array{commentgroup?:string,fk_menu:string,type:string,titre:string,mainmenu:string,leftmenu:string,url:string,langs:string,position:int|string,enabled:int|string,perms:string,target:string,user:int} | $menuWantTo menu get for do actions | |
| ?int | $key | key for the concerned menu |
| int<-1,2> | $action for specify what action (0 = delete perm, 1 = add perm, 2 = update perm, -1 = when we delete object) |
Definition at line 1132 of file modulebuilder.lib.php.
References dolReplaceInFile(), and getFromFile().
| reWriteAllPermissions | ( | $file, | |
| $permissions, | |||
| $key, | |||
| $right, | |||
| $objectname, | |||
| $module, | |||
| $action ) |
Rewriting all permissions after any actions.
| string | $file | filename or path |
| array<int,string[]> | $permissions permissions existing in file | |
| ?int | $key | key for permission needed |
| ?array{0:string,1:string} | $right $right to update or add | |
| string | $objectname | name of object |
| string | $module | name of module |
| int<-2,2> | $action 0 for delete, 1 for add, 2 for update, -1 when delete object completely, -2 for generate rights after add |
Definition at line 578 of file modulebuilder.lib.php.
References $object, deletePerms(), and dolReplaceInFile().
| updateDictionaryInFile | ( | $module, | |
| $file, | |||
| $dicts ) |
Updates a dictionary in a module descriptor file.
| string | $module | The name of the module. |
| string | $file | The path to the module descriptor file. |
| array{langs:string,tabname:string[],tablib:string[],tabsql:string[],tabsqlsort:string[],tabfield:string[],tabfieldvalue:string[],tabfieldinsert:string[],tabrowid:string[],tabcond:array<string|bool|int>,tabhelp:array<array{code:string,field2:string}>} | $dicts The dictionary data to be updated. |
| bool | string | int | $val |
| string | $val |
Definition at line 1237 of file modulebuilder.lib.php.
References dolReplaceInFile(), and getFromFile().
Referenced by createNewDictionnary().
| writeApiUrlsInDoc | ( | $file_api, | |
| $file_doc ) |
Generate Urls and add them to documentation module.
| string | $file_api | filename or path of api |
| string | $file_doc | filename or path of documentation |
Definition at line 1391 of file modulebuilder.lib.php.
References dol_is_file(), dolReplaceInFile(), and getFromFile().
| writePermsInAsciiDoc | ( | $file, | |
| $destfile ) |
Write all permissions of each object in AsciiDoc format.
| string | $file | path of the class |
| string | $destfile | file where write table of permissions |
Definition at line 913 of file modulebuilder.lib.php.
References dolReplaceInFile(), and getFromFile().
| writePropsInAsciiDoc | ( | $file, | |
| $objectname, | |||
| $destfile ) |
Write all properties of the object in AsciiDoc format.
| string | $file | path of the class |
| string | $objectname | name of the objectClass |
| string | $destfile | file where write table of properties |
Definition at line 741 of file modulebuilder.lib.php.
References dolReplaceInFile(), and parsePropertyString().