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