dolibarr
21.0.0-beta
Main Page
Related Pages
Topics
Classes
Files
File List
File Members
dolibarr_dev
htdocs
core
class
extralanguages.class.php
Go to the documentation of this file.
1
<?php
2
/* Copyright (C) 2020 Laurent Destailleur <eldy@users.sourceforge.net>
3
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
29
class
ExtraLanguages
30
{
34
public
$db;
35
39
public
$attributes;
40
44
public
$error =
''
;
45
49
public
$errors = array();
50
54
public
$errno;
55
56
62
public
function
__construct
($db)
63
{
64
$this->db = $db;
65
$this->error =
''
;
66
$this->errors = array();
67
$this->attributes = array();
68
}
69
70
71
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
82
public
function
fetch_name_extralanguages
($elementtype, $forceload =
false
)
83
{
84
// phpcs:enable
85
global
$conf
;
86
87
if
(empty($elementtype)) {
88
return
array();
89
}
90
91
if
($elementtype ==
'thirdparty'
) {
92
$elementtype =
'societe'
;
93
}
94
if
($elementtype ==
'contact'
) {
95
$elementtype =
'socpeople'
;
96
}
97
if
($elementtype ==
'order_supplier'
) {
98
$elementtype =
'commande_fournisseur'
;
99
}
100
101
102
$array_name_label = array();
103
if
(
getDolGlobalString
(
'MAIN_USE_ALTERNATE_TRANSLATION_FOR'
)) {
104
$tmpelement = explode(
';'
,
getDolGlobalString
(
'MAIN_USE_ALTERNATE_TRANSLATION_FOR'
));
105
foreach
($tmpelement as $elementstring) {
106
$reg = array();
107
preg_match(
'/^(.*):(.*)$/'
, $elementstring, $reg);
108
$element = $reg[1];
109
$array_name_label[$element] = array();
110
$tmpfields = explode(
','
, $reg[2]);
111
foreach
($tmpfields as $field) {
112
//var_dump($fields);
113
//$tmpkeyvar = explode(':', $fields);
114
//$array_name_label[$element][$tmpkeyvar[0]] = $tmpkeyvar[1];
115
$array_name_label[$element][$field] = $field;
116
}
117
}
118
}
119
//var_dump($array_name_label);
120
$this->attributes = $array_name_label;
121
122
return
$array_name_label;
123
}
124
125
141
public
function
showInputField
($key, $value, $extrafieldsobjectkey, $moreparam =
''
, $keysuffix =
''
, $keyprefix =
''
, $morecss =
''
, $objectid = 0, $mode = 0)
142
{
143
global
$conf
, $langs, $form;
144
145
if
(!is_object($form)) {
146
require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php'
;
147
$form =
new
Form
($this->db);
148
}
149
150
$out =
''
;
151
152
if
(!preg_match(
'/options_$/'
, $keyprefix)) {
// Because we work on extrafields, we add 'options_' to prefix if not already added
153
$keyprefix .=
'options_'
;
154
}
155
156
return
$out;
157
}
158
159
169
public
function
showOutputField
($key, $value, $extrafieldsobjectkey, $moreparam =
''
)
170
{
171
global
$conf
, $langs;
172
173
$out = $this->attributes[$extrafieldsobjectkey][$key];
174
175
return
$out;
176
}
177
}
ExtraLanguages
Class to manage standard extra languages.
Definition
extralanguages.class.php:30
ExtraLanguages\showOutputField
showOutputField($key, $value, $extrafieldsobjectkey, $moreparam='')
Return HTML string to put an output field into a page.
Definition
extralanguages.class.php:169
ExtraLanguages\fetch_name_extralanguages
fetch_name_extralanguages($elementtype, $forceload=false)
Load array this->attributes with list of fields per object that need an alternate translation.
Definition
extralanguages.class.php:82
ExtraLanguages\showInputField
showInputField($key, $value, $extrafieldsobjectkey, $moreparam='', $keysuffix='', $keyprefix='', $morecss='', $objectid=0, $mode=0)
Return HTML string to put an input field into a page Code very similar with showInputField of common ...
Definition
extralanguages.class.php:141
ExtraLanguages\__construct
__construct($db)
Constructor.
Definition
extralanguages.class.php:62
Form
Class to manage generation of HTML components Only common components must be here.
Definition
html.form.class.php:57
getDolGlobalString
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
Definition
functions.lib.php:217
$conf
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition
member.php:79
Generated on Sun Dec 1 2024 01:00:26 for
dolibarr
by Doxygen 1.11.0