dolibarr
x.y.z
|
A set of functions for Dolibarr This file contains all rare functions. More...
Go to the source code of this file.
Functions | |
jsUnEscape ($source) | |
Same function than javascript unescape() function but in PHP. More... | |
dolGetModulesDirs ($subdir='') | |
Return list of modules directories. More... | |
dol_getDefaultFormat (Translate $outputlangs=null) | |
Try to guess default paper format according to language into $langs. More... | |
dol_print_file ($langs, $filename, $searchalt=0) | |
Output content of a file $filename in version of current language (otherwise may use an alternate language) More... | |
dol_print_object_info ($object, $usetable=0) | |
Show informations on an object TODO Move this into html.formother. More... | |
dolAddEmailTrackId ($email, $trackingid) | |
Return an email formatted to include a tracking id For example myema becom il@e xampl e.co mmyema. il+t racki ngid @exam ple. comMore... | |
isValidMailDomain ($mail) | |
Return true if email has a domain name that can be resolved to MX type. More... | |
isValidUrl ($url, $http=0, $pass=0, $port=0, $path=0, $query=0, $anchor=0) | |
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor]. More... | |
isValidVATID ($company) | |
Check if VAT numero is valid (check done on syntax only, no database or remote access) More... | |
clean_url ($url, $http=1) | |
Clean an url string. More... | |
dolObfuscateEmail ($mail, $replace="*", $nbreplace=8, $nbdisplaymail=4, $nbdisplaydomain=3, $displaytld=true) | |
Returns an email value with obfuscated parts. More... | |
array2tr ($data, $troptions='', $tdoptions='') | |
Return lines of an html table from an array Used by array2table function only. More... | |
array2table ($data, $tableMarkup=1, $tableoptions='', $troptions='', $tdoptions='') | |
Return an html table from an array. More... | |
get_next_value ($db, $mask, $table, $field, $where='', $objsoc='', $date='', $mode='next', $bentityon=true, $objuser=null, $forceentity=null) | |
Return last or next value for a mask (according to area we should not reset) More... | |
get_string_between ($string, $start, $end) | |
Get string between. More... | |
check_value ($mask, $value) | |
Check value. More... | |
binhex ($bin, $pad=false, $upper=false) | |
Convert a binary data to string that represent hexadecimal value. More... | |
hexbin ($hexa) | |
Convert an hexadecimal string into a binary string. More... | |
numero_semaine ($time) | |
Retourne le numero de la semaine par rapport a une date. More... | |
weight_convert ($weight, &$from_unit, $to_unit) | |
Convertit une masse d'une unite vers une autre unite. More... | |
dol_set_user_param ($db, $conf, &$user, $tab) | |
Save personnal parameter. More... | |
dol_print_reduction ($reduction, $langs) | |
Returns formated reduction. More... | |
version_os ($option='') | |
Return OS version. More... | |
version_php () | |
Return PHP version. More... | |
version_dolibarr () | |
Return Dolibarr version. More... | |
version_webserver () | |
Return web server version. More... | |
getListOfModels ($db, $type, $maxfilenamelength=0) | |
Return list of activated modules usable for document generation. More... | |
is_ip ($ip) | |
This function evaluates a string that should be a valid IPv4 Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25). More... | |
dol_buildlogin ($lastname, $firstname) | |
Build a login from lastname, firstname. More... | |
getSoapParams () | |
Return array to use for SoapClient constructor. More... | |
dolGetElementUrl ($objectid, $objecttype, $withpicto=0, $option='') | |
Return link url to an object. More... | |
cleanCorruptedTree ($db, $tabletocleantree, $fieldfkparent) | |
Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop. More... | |
colorArrayToHex ($arraycolor, $colorifnotfound='888888') | |
Convert an array with RGB value into hex RGB value. More... | |
colorStringToArray ($stringcolor, $colorifnotfound=array(88, 88, 88)) | |
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255). More... | |
colorValidateHex ($color, $allow_white=true) | |
colorAgressiveness ($hex, $ratio=-50, $brightness=0) | |
Change color to make it less aggressive (ratio is negative) or more aggressive (ratio is positive) More... | |
colorAdjustBrightness ($hex, $steps) | |
colorDarker ($hex, $percent) | |
colorLighten ($hex, $percent) | |
colorHexToRgb ($hex, $alpha=false, $returnArray=false) | |
cartesianArray (array $input) | |
Applies the Cartesian product algorithm to an array Source: http://stackoverflow.com/a/15973172. More... | |
getModuleDirForApiClass ($moduleobject) | |
Get name of directory where the api_...class.php file is stored. More... | |
randomColorPart ($min=0, $max=255) | |
Return 2 hexa code randomly. More... | |
randomColor ($min=0, $max=255) | |
Return hexadecimal color randomly. More... | |
if(!function_exists('dolEscapeXML')) | convertBackOfficeMediasLinksToPublicLinks ($notetoshow) |
Convert links to local wrapper to medias files into a string into a public external URL readable on internet. More... | |
price2fec ($amount) | |
Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) Function used into accountancy FEC export. More... | |
phpSyntaxError ($code) | |
Check the syntax of some PHP code. More... | |
acceptLocalLinktoMedia () | |
Check the syntax of some PHP code. More... | |
A set of functions for Dolibarr This file contains all rare functions.
Definition in file functions2.lib.php.
acceptLocalLinktoMedia | ( | ) |
Check the syntax of some PHP code.
Definition at line 2865 of file functions2.lib.php.
array2table | ( | $data, | |
$tableMarkup = 1 , |
|||
$tableoptions = '' , |
|||
$troptions = '' , |
|||
$tdoptions = '' |
|||
) |
Return an html table from an array.
array | $data | Array of data |
int | $tableMarkup | Table markup |
string | $tableoptions | Options for table |
string | $troptions | Options for tr |
string | $tdoptions | Options for td |
Definition at line 932 of file functions2.lib.php.
array2tr | ( | $data, | |
$troptions = '' , |
|||
$tdoptions = '' |
|||
) |
Return lines of an html table from an array Used by array2table function only.
array | $data | Array of data |
string | $troptions | Options for tr |
string | $tdoptions | Options for td |
Definition at line 912 of file functions2.lib.php.
binhex | ( | $bin, | |
$pad = false , |
|||
$upper = false |
|||
) |
Convert a binary data to string that represent hexadecimal value.
string | $bin | Value to convert |
boolean | $pad | Add 0 |
boolean | $upper | Convert to tupper |
Definition at line 1644 of file functions2.lib.php.
References dol_strlen().
cartesianArray | ( | array | $input | ) |
Applies the Cartesian product algorithm to an array Source: http://stackoverflow.com/a/15973172.
array | $input | Array of products |
Definition at line 2596 of file functions2.lib.php.
check_value | ( | $mask, | |
$value | |||
) |
Check value.
string | $mask | Mask to use |
string | $value | Value |
Definition at line 1520 of file functions2.lib.php.
clean_url | ( | $url, | |
$http = 1 |
|||
) |
cleanCorruptedTree | ( | $db, | |
$tabletocleantree, | |||
$fieldfkparent | |||
) |
Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop.
DoliDB | $db | Database handler |
string | $tabletocleantree | Table to clean |
string | $fieldfkparent | Field name that contains id of parent |
Definition at line 2279 of file functions2.lib.php.
colorAdjustBrightness | ( | $hex, | |
$steps | |||
) |
string | $hex | Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') |
integer | $steps | Step/offset added to each color component. It should be between -255 and 255. Negative = darker, positive = lighter |
Definition at line 2512 of file functions2.lib.php.
Referenced by colorDarker(), and colorLighten().
colorAgressiveness | ( | $hex, | |
$ratio = -50 , |
|||
$brightness = 0 |
|||
) |
Change color to make it less aggressive (ratio is negative) or more aggressive (ratio is positive)
string | $hex | Color in hex ('#AA1122' or 'AA1122' or '#a12' or 'a12') |
integer | $ratio | Default=-50. Note: 0=Component color is unchanged, -100=Component color become 88, +100=Component color become 00 or FF |
integer | $brightness | Default=0. Adjust brightness. -100=Decrease brightness by 100%, +100=Increase of 100%. |
Definition at line 2455 of file functions2.lib.php.
colorArrayToHex | ( | $arraycolor, | |
$colorifnotfound = '888888' |
|||
) |
Convert an array with RGB value into hex RGB value.
This is the opposite function of colorStringToArray
array | $arraycolor | Array |
string | $colorifnotfound | Color code to return if entry not defined or not a RGB format |
Definition at line 2391 of file functions2.lib.php.
colorDarker | ( | $hex, | |
$percent | |||
) |
string | $hex | color in hex |
integer | $percent | 0 to 100 |
Definition at line 2541 of file functions2.lib.php.
References colorAdjustBrightness().
colorHexToRgb | ( | $hex, | |
$alpha = false , |
|||
$returnArray = false |
|||
) |
string | $hex | color in hex |
float | $alpha | 0 to 1 to add alpha channel |
bool | $returnArray | true=return an array instead, false=return string |
Definition at line 2565 of file functions2.lib.php.
colorLighten | ( | $hex, | |
$percent | |||
) |
string | $hex | color in hex |
integer | $percent | 0 to 100 |
Definition at line 2552 of file functions2.lib.php.
References colorAdjustBrightness().
colorStringToArray | ( | $stringcolor, | |
$colorifnotfound = array(88, 88, 88) |
|||
) |
Convert a string RGB value ('FFFFFF', '255,255,255') into an array RGB array(255,255,255).
This is the opposite function of colorArrayToHex. If entry is already an array, return it.
string | $stringcolor | String with hex (FFFFFF) or comma RGB ('255,255,255') |
array | $colorifnotfound | Color code array to return if entry not defined |
Definition at line 2412 of file functions2.lib.php.
colorValidateHex | ( | $color, | |
$allow_white = true |
|||
) |
string | $color | the color you need to valid |
boolean | $allow_white | in case of white isn't valid |
Definition at line 2434 of file functions2.lib.php.
if (!function_exists( 'dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks | ( | $notetoshow | ) |
Convert links to local wrapper to medias files into a string into a public external URL readable on internet.
string | $notetoshow | Text to convert |
Definition at line 2723 of file functions2.lib.php.
dol_buildlogin | ( | $lastname, | |
$firstname | |||
) |
Build a login from lastname, firstname.
string | $lastname | Lastname |
string | $firstname | Firstname |
Definition at line 2045 of file functions2.lib.php.
dol_getDefaultFormat | ( | Translate | $outputlangs = null | ) |
Try to guess default paper format according to language into $langs.
Translate | $outputlangs | Output lang to use to autodetect output format if setup not done |
Definition at line 119 of file functions2.lib.php.
dol_print_file | ( | $langs, | |
$filename, | |||
$searchalt = 0 |
|||
) |
Output content of a file $filename in version of current language (otherwise may use an alternate language)
Translate | $langs | Object language to use for output |
string | $filename | Relative filename to output |
int | $searchalt | 1=Search also in alternative languages |
Definition at line 145 of file functions2.lib.php.
dol_print_object_info | ( | $object, | |
$usetable = 0 |
|||
) |
Show informations on an object TODO Move this into html.formother.
object | $object | Objet to show |
int | $usetable | Output into a table |
Definition at line 205 of file functions2.lib.php.
dol_print_reduction | ( | $reduction, | |
$langs | |||
) |
Returns formated reduction.
int | $reduction | Reduction percentage |
Translate | $langs | Output language |
Definition at line 1856 of file functions2.lib.php.
dol_set_user_param | ( | $db, | |
$conf, | |||
& | $user, | ||
$tab | |||
) |
Save personnal parameter.
DoliDB | $db | Handler database |
Conf | $conf | Object conf |
User | $user | Object user |
array | $tab | Array (key=>value) with all parameters to save |
Definition at line 1792 of file functions2.lib.php.
dolAddEmailTrackId | ( | $email, | |
$trackingid | |||
) |
Return an email formatted to include a tracking id For example myema becom il@e xampl e.co mmyema. il+t racki ngid @exam ple. com
string | Email address (Ex: "toto@example.com", "John Do <johndo@example.com>") | |
string | $trackingid | Tracking id (Ex: thi123 for thirdparty with id 123) |
Definition at line 717 of file functions2.lib.php.
dolGetElementUrl | ( | $objectid, | |
$objecttype, | |||
$withpicto = 0 , |
|||
$option = '' |
|||
) |
Return link url to an object.
int | $objectid | Id of record |
string | $objecttype | Type of object ('invoice', 'order', 'expedition_bon', 'myobject@mymodule', ...) |
int | $withpicto | Picto to show |
string | $option | More options |
Definition at line 2119 of file functions2.lib.php.
dolGetModulesDirs | ( | $subdir = '' | ) |
Return list of modules directories.
We detect directories that contains a subdirectory /core/modules We discard directory modules that contains 'disabled' into their name.
string | $subdir | Sub directory (Example: '/mailings') |
Definition at line 80 of file functions2.lib.php.
dolObfuscateEmail | ( | $mail, | |
$replace = "*" , |
|||
$nbreplace = 8 , |
|||
$nbdisplaymail = 4 , |
|||
$nbdisplaydomain = 3 , |
|||
$displaytld = true |
|||
) |
Returns an email value with obfuscated parts.
string | ||
string | $replace | Replacement character (defaul: *) |
int | $nbreplace | Number of replacement character (default: 8) |
int | $nbdisplaymail | Number of character unchanged (default: 4) |
int | $nbdisplaydomain | Number of character unchanged of domain (default: 3) |
bool | $displaytld | Display tld (default: true) |
Definition at line 870 of file functions2.lib.php.
References isValidEmail().
get_next_value | ( | $db, | |
$mask, | |||
$table, | |||
$field, | |||
$where = '' , |
|||
$objsoc = '' , |
|||
$date = '' , |
|||
$mode = 'next' , |
|||
$bentityon = true , |
|||
$objuser = null , |
|||
$forceentity = null |
|||
) |
Return last or next value for a mask (according to area we should not reset)
DoliDB | $db | Database handler |
string | $mask | Mask to use |
string | $table | Table containing field with counter |
string | $field | Field containing already used values of counter |
string | $where | To add a filter on selection (for exemple to filter on invoice types) |
Societe | $objsoc | The company that own the object we need a counter for |
string | $date | Date to use for the {y},{m},{d} tags. |
string | $mode | 'next' for next value or 'last' for last value |
bool | $bentityon | Activate the entity filter. Default is true (for modules not compatible with multicompany) |
User | $objuser | Object user we need data from. |
int | $forceentity | Entity id to force |
Definition at line 970 of file functions2.lib.php.
get_string_between | ( | $string, | |
$start, | |||
$end | |||
) |
Get string between.
string | $string | String to test |
int | $start | Value for start |
int | $end | Value for end |
Definition at line 1501 of file functions2.lib.php.
getListOfModels | ( | $db, | |
$type, | |||
$maxfilenamelength = 0 |
|||
) |
Return list of activated modules usable for document generation.
DoliDB | $db | Database handler |
string | $type | Type of models (company, invoice, ...) |
int | $maxfilenamelength | Max length of value to show |
Definition at line 1925 of file functions2.lib.php.
getModuleDirForApiClass | ( | $moduleobject | ) |
Get name of directory where the api_...class.php file is stored.
string | $moduleobject | Module object name |
Definition at line 2626 of file functions2.lib.php.
getSoapParams | ( | ) |
Return array to use for SoapClient constructor.
Definition at line 2072 of file functions2.lib.php.
hexbin | ( | $hexa | ) |
Convert an hexadecimal string into a binary string.
string | $hexa | Hexadecimal string to convert (example: 'FF') |
Definition at line 1668 of file functions2.lib.php.
is_ip | ( | $ip | ) |
This function evaluates a string that should be a valid IPv4 Note: For ip 169.254.0.0, it returns 0 with some PHP (5.6.24) and 2 with some minor patchs of PHP (5.6.25).
See https://github.com/php/php-src/pull/1954.
string | $ip | IP Address |
Definition at line 2018 of file functions2.lib.php.
isValidMailDomain | ( | ) |
Return true if email has a domain name that can be resolved to MX type.
string | Email address (Ex: "toto@example.com", "John Do <johndo@example.com>") |
Definition at line 729 of file functions2.lib.php.
isValidUrl | ( | $url, | |
$http = 0 , |
|||
$pass = 0 , |
|||
$port = 0 , |
|||
$path = 0 , |
|||
$query = 0 , |
|||
$anchor = 0 |
|||
) |
Url string validation <http[s]> :// [user[:pass]@] hostname [port] [/path] [?getquery] [anchor].
string | $url | Url |
int | $http | 1: verify http is provided, 0: not verify http |
int | $pass | 1: verify user and pass is provided, 0: not verify user and pass |
int | $port | 1: verify port is provided, 0: not verify port |
int | $path | 1: verify a path is provided "/" or "/..." or "/.../", 0: not verify path |
int | $query | 1: verify query is provided, 0: not verify query |
int | $anchor | 1: verify anchor is provided, 0: not verify anchor |
Definition at line 748 of file functions2.lib.php.
isValidVATID | ( | $company | ) |
Check if VAT numero is valid (check done on syntax only, no database or remote access)
Societe | $company | VAT number |
Definition at line 801 of file functions2.lib.php.
jsUnEscape | ( | $source | ) |
Same function than javascript unescape() function but in PHP.
string | $source | String to decode |
Definition at line 40 of file functions2.lib.php.
numero_semaine | ( | $time | ) |
Retourne le numero de la semaine par rapport a une date.
string | $time | Date au format 'timestamp' |
Definition at line 1684 of file functions2.lib.php.
phpSyntaxError | ( | $code | ) |
Check the syntax of some PHP code.
string | $code | PHP code to check. |
Definition at line 2771 of file functions2.lib.php.
price2fec | ( | $amount | ) |
Function to format a value into a defined format for French administration (no thousand separator & decimal separator force to ',' with two decimals) Function used into accountancy FEC export.
float | $amount | Amount to format |
Definition at line 2742 of file functions2.lib.php.
randomColor | ( | $min = 0 , |
|
$max = 255 |
|||
) |
Return hexadecimal color randomly.
int | $min | Between 0 and 255 |
int | $max | Between 0 and 255 |
Encode string for xml usage
string | $string | String to encode |
Definition at line 2697 of file functions2.lib.php.
randomColorPart | ( | $min = 0 , |
|
$max = 255 |
|||
) |
Return 2 hexa code randomly.
int | $min | Between 0 and 255 |
int | $max | Between 0 and 255 |
Definition at line 2685 of file functions2.lib.php.
version_dolibarr | ( | ) |
Return Dolibarr version.
Definition at line 1902 of file functions2.lib.php.
version_os | ( | $option = '' | ) |
Return OS version.
Note that PHP_OS returns only OS (not version) and OS PHP was built on, not necessarly OS PHP runs on.
string | $option | Option string |
Definition at line 1875 of file functions2.lib.php.
version_php | ( | ) |
Return PHP version.
Definition at line 1891 of file functions2.lib.php.
version_webserver | ( | ) |
Return web server version.
Definition at line 1912 of file functions2.lib.php.
weight_convert | ( | $weight, | |
& | $from_unit, | ||
$to_unit | |||
) |
Convertit une masse d'une unite vers une autre unite.
float | $weight | Masse a convertir |
int | $from_unit | Unite originale en puissance de 10 |
int | $to_unit | Nouvelle unite en puissance de 10 |
Definition at line 1757 of file functions2.lib.php.