class ExtraLanguages (View source)

Class to manage standard extra languages

Properties

DoliDB $db
array<string, array<string, string>> $attributes
string $error
string[] $errors
string $errno

Methods

__construct($db)

Constructor

fetch_name_extralanguages(string $elementtype, $forceload = false)

Load array this->attributes with list of fields per object that need an alternate translation. The object and field must be managed with the widgetForTranslation() method.

string
showInputField(string $key, string $value, string $extrafieldsobjectkey, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', string $morecss = '', int $objectid = 0, int $mode = 0)

Return HTML string to put an input field into a page Code very similar with showInputField of common object

string
showOutputField(string $key, string $value, string $extrafieldsobjectkey, string $moreparam = '')

Return HTML string to put an output field into a page

Details

__construct($db)

Constructor

@param DoliDB $db Database handler

Parameters

$db

fetch_name_extralanguages(string $elementtype, $forceload = false)

Load array this->attributes with list of fields per object that need an alternate translation. The object and field must be managed with the widgetForTranslation() method.

You must set variable MAIN_USE_ALTERNATE_TRANSLATION_FOR=elementA:fieldname,fieldname2;elementB:... Example: MAIN_USE_ALTERNATE_TRANSLATION_FOR=societe:name,town;contact:firstname,lastname

Parameters

string $elementtype

Type of element ('' = all, 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...). @param boolean $forceload Force load of extra fields whatever is status of cache. @return array<string,array<string,string>> Array of attributes keys+label for all extra fields.

$forceload

string showInputField(string $key, string $value, string $extrafieldsobjectkey, string $moreparam = '', string $keysuffix = '', string $keyprefix = '', string $morecss = '', int $objectid = 0, int $mode = 0)

Return HTML string to put an input field into a page Code very similar with showInputField of common object

Parameters

string $key

Key of attribute

string $value

Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)

string $extrafieldsobjectkey

If defined (for example $object->table_element), use the new method to get extrafields data

string $moreparam

To add more parameters on html input tag

string $keysuffix

Prefix string to add after name and id of field (can be used to avoid duplicate names)

string $keyprefix

Suffix string to add before name and id of field (can be used to avoid duplicate names)

string $morecss

More css (to defined size of field. Old behaviour: may also be a numeric)

int $objectid

Current object id

int $mode

1=Used for search filters

Return Value

string

string showOutputField(string $key, string $value, string $extrafieldsobjectkey, string $moreparam = '')

Return HTML string to put an output field into a page

Parameters

string $key

Key of attribute

string $value

Value to show

string $extrafieldsobjectkey

If defined (for example $object->table_element), function uses the new method to get extrafields data

string $moreparam

To add more parameters on html input tag (only checkbox use html input for output rendering)

Return Value

string

Formatted value