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