dolibarr 19.0.3
translation.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2020 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2017 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
25// Load Dolibarr environment
26require '../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
30
31// Load translation files required by the page
32$langs->loadLangs(array("companies", "products", "admin", "sms", "other", "errors"));
33
34if (!$user->admin) {
36}
37
38$id = GETPOST('rowid', 'int');
39$action = GETPOST('action', 'aZ09');
40$optioncss = GETPOST('optionscss', 'aZ09');
41$contextpage = GETPOST('contextpage', 'aZ09');
42
43$mode = GETPOST('mode', 'aZ09') ? GETPOST('mode', 'aZ09') : 'searchkey';
44
45$langcode = GETPOST('langcode', 'alphanohtml');
46$transkey = GETPOST('transkey', 'alphanohtml');
47if ($mode == 'searchkey') {
48 $transvalue = GETPOST('transvalue', 'alphanohtml');
49} else {
50 $transvalue = GETPOST('transvalue', 'restricthtml');
51}
52
53
54$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
55$sortfield = GETPOST('sortfield', 'aZ09comma');
56$sortorder = GETPOST('sortorder', 'aZ09comma');
57$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
58if (empty($page) || $page == -1) {
59 $page = 0;
60} // If $page is not defined, or '' or -1
61$offset = $limit * $page;
62$pageprev = $page - 1;
63$pagenext = $page + 1;
64if (!$sortfield) {
65 $sortfield = 'lang,transkey';
66}
67if (!$sortorder) {
68 $sortorder = 'ASC';
69}
70
71// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
72$hookmanager->initHooks(array('admintranslation', 'globaladmin'));
73
74
75/*
76 * Actions
77 */
78
79if (GETPOST('cancel', 'alpha')) {
80 $action = 'list';
81 $massaction = '';
82}
83if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') {
84 $massaction = '';
85}
86
87$parameters = array();
88$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
89if ($reshook < 0) {
90 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
91}
92
93include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
94
95// Purge search criteria
96if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
97 $transkey = '';
98 $transvalue = '';
99 $toselect = array();
100 $search_array_options = array();
101}
102
103if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION') {
104 if (GETPOST('value')) {
105 dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity);
106 } else {
107 dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity);
108 }
109}
110
111if ($action == 'update') {
112 if ($transkey == '') {
113 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors');
114 $error++;
115 }
116 if ($transvalue == '') {
117 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
118 $error++;
119 }
120 if (!$error) {
121 $db->begin();
122
123 $sql = "UPDATE ".MAIN_DB_PREFIX."overwrite_trans set transkey = '".$db->escape($transkey)."', transvalue = '".$db->escape($transvalue)."' WHERE rowid = ".((int) GETPOST('rowid', 'int'));
124 $result = $db->query($sql);
125 if ($result) {
126 $db->commit();
127 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
128 $action = "";
129 $transkey = "";
130 $transvalue = "";
131 } else {
132 $db->rollback();
133 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
134 setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
135 } else {
136 setEventMessages($db->lasterror(), null, 'errors');
137 }
138 $action = '';
139 }
140 }
141}
142
143if ($action == 'add') {
144 $error = 0;
145
146 if (empty($langcode)) {
147 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")), null, 'errors');
148 $error++;
149 }
150 if ($transkey == '') {
151 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors');
152 $error++;
153 }
154 if ($transvalue == '') {
155 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
156 $error++;
157 }
158 if (!$error) {
159 $db->begin();
160
161 $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue, entity) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."', ".((int) $conf->entity).")";
162 $result = $db->query($sql);
163 if ($result) {
164 $db->commit();
165 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
166 $action = "";
167 $transkey = "";
168 $transvalue = "";
169 } else {
170 $db->rollback();
171 if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
172 setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
173 } else {
174 setEventMessages($db->lasterror(), null, 'errors');
175 }
176 $action = '';
177 }
178 }
179}
180
181// Delete line from delete picto
182if ($action == 'delete') {
183 $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".((int) $id);
184 $result = $db->query($sql);
185 if ($result) {
186 setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
187 } else {
188 dol_print_error($db);
189 }
190}
191
192
193
194
195
196/*
197 * View
198 */
199
200$form = new Form($db);
201$formadmin = new FormAdmin($db);
202
203$wikihelp = 'EN:Setup_Translation|FR:Paramétrage_Traduction|ES:Configuración_Traducción';
204llxHeader('', $langs->trans("Setup"), $wikihelp);
205
206$param = '&mode='.urlencode($mode);
207
208$enabledisablehtml = '';
209$enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' ';
210if (!getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
211 // Button off, click to enable
212 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=1'.$param.'">';
213 $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off');
214 $enabledisablehtml .= '</a>';
215} else {
216 // Button on, click to disable
217 $enabledisablehtml .= '<a class="reposition valignmiddle" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&token='.newToken().'&value=0'.$param.'">';
218 $enabledisablehtml .= img_picto($langs->trans("Activated"), 'switch_on');
219 $enabledisablehtml .= '</a>';
220}
221
222print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup');
223
224$current_language_code = $langs->defaultlang;
225$s = picto_from_langcode($current_language_code);
226print $form->textwithpicto('<span class="opacitymedium">'.$langs->trans("CurrentUserLanguage").':</span> <strong>'.$s.' '.$current_language_code.'</strong>', $langs->trans("TranslationDesc")).'</span><br>';
227
228print '<br>';
229
230if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
231 $param .= '&contextpage='.urlencode($contextpage);
232}
233if ($limit > 0 && $limit != $conf->liste_limit) {
234 $param .= '&limit='.((int) $limit);
235}
236if (isset($optioncss) && $optioncss != '') {
237 $param .= '&optioncss='.urlencode($optioncss);
238}
239if ($langcode) {
240 $param .= '&langcode='.urlencode($langcode);
241}
242if ($transkey) {
243 $param .= '&transkey='.urlencode($transkey);
244}
245if ($transvalue) {
246 $param .= '&transvalue='.urlencode($transvalue);
247}
248
249
250print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">';
251if (isset($optioncss) && $optioncss != '') {
252 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
253}
254print '<input type="hidden" name="token" value="'.newToken().'">';
255print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
256print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
257print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
258
260
261print dol_get_fiche_head($head, $mode, '', -1, '');
262
263
264$langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang;
265
266$newlang = new Translate('', $conf);
267$newlang->setDefaultLang($langcode);
268
269$langsenfileonly = new Translate('', $conf);
270$langsenfileonly->setDefaultLang('en_US');
271
272$newlangfileonly = new Translate('', $conf);
273$newlangfileonly->setDefaultLang($langcode);
274
275$recordtoshow = array();
276
277// Search modules dirs
278$modulesdir = dolGetModulesDirs();
279
280$listoffiles = array();
281$listoffilesexternalmodules = array();
282
283// Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
284$i = 0;
285foreach ($modulesdir as $keydir => $tmpsearchdir) {
286 $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
287
288 // Directory of translation files
289 $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels
290 $dir_lang_osencoded = dol_osencode($dir_lang);
291
292 $filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ? SORT_ASC : SORT_DESC), 1);
293 foreach ($filearray as $file) {
294 $tmpfile = preg_replace('/.lang/i', '', basename($file['name']));
295 $moduledirname = (basename(dirname(dirname($dir_lang))));
296
297 $langkey = $tmpfile;
298 if ($i > 0) {
299 $langkey .= '@'.$moduledirname;
300 }
301 //var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
302
303 $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
304 $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
305 if ($result < 0) {
306 print 'Failed to load language file '.$tmpfile.'<br>'."\n";
307 } else {
308 $listoffiles[$langkey] = $tmpfile;
309 if (strpos($langkey, '@') !== false) {
310 $listoffilesexternalmodules[$langkey] = $tmpfile;
311 }
312 }
313 //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
314
315 $result = $langsenfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
316 }
317 $i++;
318}
319
320$nbtotaloffiles = count($listoffiles);
321$nbtotaloffilesexternal = count($listoffilesexternalmodules);
322
323if ($mode == 'overwrite') {
324 print '<input type="hidden" name="page" value="'.$page.'">';
325
326 $disabled = '';
327 if ($action == 'edit' || !getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
328 $disabled = ' disabled="disabled"';
329 }
330 $disablededit = '';
331 if ($action == 'edit' || !getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
332 $disablededit = ' disabled';
333 }
334
335 print '<div class="justify"><span class="opacitymedium">';
336 print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
337 $urlwikitranslatordoc = 'https://wiki.dolibarr.org/index.php/Translator_documentation';
338 print ' ('.str_replace('{s1}', '<a href="'.$urlwikitranslatordoc.'" target="_blank" rel="noopener noreferrer external">'.$langs->trans("Here").'</a>', $langs->trans("SeeAlso", '{s1}')).')<br>';
339 print $langs->trans("TranslationOverwriteDesc", $langs->transnoentitiesnoconv("Language"), $langs->transnoentitiesnoconv("Key"), $langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
340 print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
341 print '</span></div>';
342
343 print '<br>';
344
345
346 print '<input type="hidden" name="action" value="'.($action == 'edit' ? 'update' : 'add').'">';
347 print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
348
349 print '<div class="div-table-responsive-no-min">';
350 print '<table class="noborder centpercent">';
351 print '<tr class="liste_titre">';
352 print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
353 print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
354 print_liste_field_titre("NewTranslationStringToShow", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
355 //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
356 print '<td align="center"></td>';
357 print "</tr>\n";
358
359
360 // Line to add new record
361 print "\n";
362
363 print '<tr class="oddeven"><td>';
364 print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit ? 1 : 0, 'maxwidth250', 1);
365 print '</td>'."\n";
366 print '<td>';
367 print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey) ? $transkey : "").'">';
368 print '</td><td>';
369 print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue) ? $transvalue : "").'">';
370 print '</td>';
371 print '<td class="center">';
372 print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
373 print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnableTranslationOverwriteBefore")).'">';
374 print "</td>\n";
375 print '</tr>';
376
377
378 // Show constants
379 $sql = "SELECT rowid, entity, lang, transkey, transvalue";
380 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
381 $sql .= " WHERE 1 = 1";
382 $sql .= " AND entity IN (".getEntity('overwrite_trans').")";
383 $sql .= $db->order($sortfield, $sortorder);
384
385 dol_syslog("translation::select from table", LOG_DEBUG);
386 $result = $db->query($sql);
387 if ($result) {
388 $num = $db->num_rows($result);
389 $i = 0;
390
391 while ($i < $num) {
392 $obj = $db->fetch_object($result);
393
394 print "\n";
395
396 print '<tr class="oddeven">';
397
398 print '<td>'.$obj->lang.'</td>'."\n";
399 print '<td>';
400 if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) {
401 print '<input type="text" class="quatrevingtpercent" name="transkey" value="'.dol_escape_htmltag($obj->transkey).'">';
402 } else {
403 print $obj->transkey;
404 }
405 print '</td>'."\n";
406
407 // Value
408 print '<td class="small">';
409 /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
410 print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
411 print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
412 print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
413 */
414 if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) {
415 print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($obj->transvalue).'">';
416 } else {
417 //print $obj->transkey.' '.$langsenfileonly->tab_translate[$obj->transkey];
418 $titleforvalue = $langs->trans("Translation").' en_US for key '.$obj->transkey.':<br>'.($langsenfileonly->tab_translate[$obj->transkey] ? $langsenfileonly->trans($obj->transkey) : '<span class="opacitymedium">'.$langs->trans("None").'</span>');
419 /*if ($obj->lang != 'en_US') {
420 $titleforvalue .= '<br>'.$langs->trans("Translation").' '.$obj->lang.' '...;
421 }*/
422 print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
423 print dol_escape_htmltag($obj->transvalue);
424 print '</span>';
425 }
426 print '</td>';
427
428 print '<td class="center">';
429 if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) {
430 print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
431 print '<input type="submit" class="button buttongen button-save" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
432 print ' &nbsp; ';
433 print '<input type="submit" class="button buttongen button-cancel" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
434 } else {
435 print '<a class="reposition editfielda paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=edit&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_edit().'</a>';
436 print ' &nbsp; ';
437 print '<a class="reposition" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().((empty($user->entity) && $debug) ? '&debug=1' : '').'">'.img_delete().'</a>';
438 }
439 print '</td>';
440
441 print "</tr>\n";
442 print "\n";
443 $i++;
444 }
445 }
446
447 print '</table>';
448 print '</div>';
449}
450
451if ($mode == 'searchkey') {
452 $nbempty = 0;
453 //var_dump($langcode);
454 //var_dump($transkey);
455 //var_dump($transvalue);
456 if (empty($langcode) || $langcode == '-1') {
457 $nbempty++;
458 }
459 if (empty($transkey)) {
460 $nbempty++;
461 }
462 if (empty($transvalue)) {
463 $nbempty++;
464 }
465
466 if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this
467 setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
468 } else {
469 // Now search into translation array
470 foreach ($newlang->tab_translate as $key => $val) {
471 $newtranskey = preg_replace('/\$$/', '', preg_replace('/^\^/', '', $transkey));
472 $newtranskeystart = preg_match('/^\^/', $transkey);
473 $newtranskeyend = preg_match('/\$$/', $transkey);
474 $regexstring = ($newtranskeystart ? '^' : '').preg_quote($newtranskey, '/').($newtranskeyend ? '$' : '');
475 if ($transkey && !preg_match('/'.$regexstring.'/i', $key)) {
476 continue;
477 }
478 if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) {
479 continue;
480 }
481 $recordtoshow[$key] = $val;
482 }
483 }
484
485 //print '<br>';
486 $nbtotalofrecordswithoutfilters = count($newlang->tab_translate);
487 $nbtotalofrecords = count($recordtoshow);
488 $num = $limit + 1;
489 if (($offset + $num) > $nbtotalofrecords) {
490 $num = $limit;
491 }
492
493 //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
494 $title = $langs->trans("Translation");
495 if ($nbtotalofrecords > 0) {
496 $title .= ' <span class="opacitymedium colorblack paddingleft">('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - <span title="'.dol_escape_htmltag(($nbtotaloffiles - $nbtotaloffilesexternal).' core - '.($nbtotaloffilesexternal).' external').'">'.$nbtotaloffiles.' '.$langs->trans("Files").'</span>)</span>';
497 }
498 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1);
499
500 $massactionbutton = '';
501
502 print '<input type="hidden" id="action" name="action" value="search">';
503 print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
504
505 print '<div class="div-table-responsive-no-min">';
506 print '<table class="noborder centpercent">';
507
508 print '<tr class="liste_titre_filter"><td>';
509 //print $formadmin->select_language($langcode,'langcode',0,null,$langs->trans("All"),0,0,'',1);
510 print $formadmin->select_language($langcode, 'langcode', 0, null, 0, 0, 0, 'maxwidth250', 1);
511 print '</td>'."\n";
512 print '<td>';
513 print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="'.dol_escape_htmltag($transkey).'">';
514 print '</td><td>';
515 print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.dol_escape_htmltag($transvalue).'">';
516 // Limit to superadmin
517 /*if (isModEnabled('multicompany') && !$user->entity)
518 {
519 print '</td><td>';
520 print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
521 }
522 else
523 {*/
524 print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
525 //}
526 print '</td>';
527 // Action column
528 print '<td class="right nowraponall">';
529 $searchpicto = $form->showFilterAndCheckAddButtons(!empty($massactionbutton) ? 1 : 0, 'checkforselect', 1);
530 print $searchpicto;
531 print '</td>';
532 print '</tr>';
533
534 print '<tr class="liste_titre">';
535 print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
536 print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
537 print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
538 //if (isModEnabled('multicompany') && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);
539 print '<td align="center"></td>';
540 print "</tr>\n";
541
542
543 if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') {
544 ksort($recordtoshow);
545 }
546 if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') {
547 krsort($recordtoshow);
548 }
549 if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') {
550 asort($recordtoshow);
551 }
552 if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') {
553 arsort($recordtoshow);
554 }
555
556 // Show result
557 $i = 0;
558 foreach ($recordtoshow as $key => $val) {
559 $i++;
560 if ($i <= $offset) {
561 continue;
562 }
563 if ($i > ($offset + $limit)) {
564 break;
565 }
566 print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td class="small">';
567 $titleforvalue = $langs->trans("Translation").' en_US for key '.$key.':<br>'.(!empty($langsenfileonly->tab_translate[$key]) ? $langsenfileonly->trans($key) : '<span class="opacitymedium">'.$langs->trans("None").'</span>');
568 print '<span title="'.dol_escape_htmltag($titleforvalue).'" class="classfortooltip">';
569 print dol_escape_htmltag($val);
570 print '</span>';
571 print '</td>';
572 print '<td class="right nowraponall">';
573 if (!empty($newlangfileonly->tab_translate[$key])) {
574 if ($val != $newlangfileonly->tab_translate[$key]) {
575 // retrieve rowid
576 $sql = "SELECT rowid";
577 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
578 $sql .= " WHERE entity IN (".getEntity('overwrite_trans').")";
579 $sql .= " AND transkey = '".$db->escape($key)."'";
580 dol_syslog("translation::select from table", LOG_DEBUG);
581 $result = $db->query($sql);
582 if ($result) {
583 $obj = $db->fetch_object($result);
584 }
585 print '<a class="editfielda reposition marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode=overwrite&action=edit&token='.newToken().'">'.img_edit().'</a>';
586 print ' ';
587 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().'&mode='.urlencode($mode).'">'.img_delete().'</a>';
588 print '&nbsp;&nbsp;';
589 $htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
590 print $form->textwithpicto('', $htmltext, 1, 'info');
591 } elseif (getDolGlobalString('MAIN_ENABLE_OVERWRITE_TRANSLATION')) {
592 //print $key.'-'.$val;
593 print '<a class="reposition paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=overwrite&langcode='.urlencode($langcode).'&transkey='.urlencode($key).'">'.img_edit_add($langs->trans("TranslationOverwriteKey")).'</a>';
594 }
595
596 if (getDolGlobalInt('MAIN_FEATURES_LEVEL')) {
597 $transifexlangfile = '$'; // $ means 'All'
598 //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
599 $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
600
601 print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>';
602 }
603 } else {
604 // retrieve rowid
605 $sql = "SELECT rowid";
606 $sql .= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
607 $sql .= " WHERE entity IN (".getEntity('overwrite_trans').")";
608 $sql .= " AND transkey = '".$db->escape($key)."'";
609 dol_syslog("translation::select from table", LOG_DEBUG);
610 $result = $db->query($sql);
611 if ($result) {
612 $obj = $db->fetch_object($result);
613 }
614 print '<a class="editfielda reposition marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode=overwrite&action=edit&token='.newToken().'">'.img_edit().'</a>';
615 print ' ';
616 print '<a class="marginleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&mode='.urlencode($mode).'&action=delete&token='.newToken().'&mode='.urlencode($mode).'">'.img_delete().'</a>';
617 print '&nbsp;&nbsp;';
618
619 $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
620 print $form->textwithpicto('', $htmltext, 1, 'warning');
621 }
622 /*if (isModEnabled('multicompany') && !$user->entity)
623 {
624 print '<td>'.$val.'</td>';
625 }*/
626 print '</td></tr>'."\n";
627 }
628
629 if (empty($recordtoshow)) {
630 print '<tr><td colspan="4"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
631 }
632
633 print '</table>';
634 print '</div>';
635}
636
637print dol_get_fiche_end();
638
639print "</form>\n";
640
641if (!empty($langcode)) {
642 dol_set_focus('#transvalue');
643}
644
645// End of page
646llxFooter();
647$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
translation_prepare_head()
Prepare array with list of tabs.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to generate html code for admin pages.
Class to manage generation of HTML components Only common components must be here.
Class to manage translations.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition files.lib.php:62
dolGetModulesDirs($subdir='')
Return list of modules directories.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_edit_add($titlealt='default', $other='')
Show logo +.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
img_info($titlealt='default')
Show info logo.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.