dolibarr  9.0.0
translation.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2007-2016 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 <http://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','alpha');
37 
38 $langcode=GETPOST('langcode','alpha');
39 $transkey=GETPOST('transkey','alpha');
40 $transvalue=GETPOST('transvalue','alpha');
41 
42 
43 $mode = GETPOST('mode','aZ09')?GETPOST('mode','aZ09'):'overwrite';
44 
45 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
46 $sortfield = GETPOST("sortfield",'alpha');
47 $sortorder = GETPOST("sortorder",'alpha');
48 $page = 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  }
109  else
110  {
111 
112  $db->rollback();
113  if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
114  {
115  setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
116  }
117  else
118  {
119  setEventMessages($db->lasterror(), null, 'errors');
120  }
121  $action='';
122  }
123  }
124 }
125 
126 if ($action == 'add')
127 {
128  $error=0;
129 
130  if (empty($langcode))
131  {
132  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")), null, 'errors');
133  $error++;
134  }
135  if ($transkey == '')
136  {
137  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors');
138  $error++;
139  }
140  if ($transvalue == '')
141  {
142  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
143  $error++;
144  }
145  if (! $error)
146  {
147  $db->begin();
148 
149  $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).")";
150  $result = $db->query($sql);
151  if ($result > 0)
152  {
153  $db->commit();
154  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
155  $action="";
156  $transkey="";
157  $transvalue="";
158  }
159  else
160  {
161 
162  $db->rollback();
163  if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
164  {
165  setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
166  }
167  else
168  {
169  setEventMessages($db->lasterror(), null, 'errors');
170  }
171  $action='';
172  }
173  }
174 }
175 
176 // Delete line from delete picto
177 if ($action == 'delete')
178 {
179  $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".$db->escape($id);
180  $result = $db->query($sql);
181  if ($result >= 0)
182  {
183  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
184  }
185  else
186  {
187  dol_print_error($db);
188  }
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|FR:Paramétrage|ES:Configuración';
204 llxHeader('',$langs->trans("Setup"),$wikihelp);
205 
206 $param='&mode='.$mode;
207 
208 $enabledisablehtml='';
209 $enabledisablehtml.= $langs->trans("EnableOverwriteTranslation").' ';
210 if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
211 {
212  // Button off, click to enable
213  $enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=1'.$param.'">';
214  $enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off');
215  $enabledisablehtml.='</a>';
216 }
217 else
218 {
219  // Button on, click to disable
220  $enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=0'.$param.'">';
221  $enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on');
222  $enabledisablehtml.='</a>';
223 }
224 
225 print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup');
226 
227 //print '<span class="opacitymedium">';
228 print $langs->trans("TranslationDesc")."<br>\n";
229 //print '</span>';
230 print "<br>\n";
231 
232 $current_language_code=$langs->defaultlang;
233 $s=picto_from_langcode($current_language_code);
234 print $langs->trans("CurrentUserLanguage").': <strong>'.$s.' '.$current_language_code.'</strong><br>';
235 
236 print '<br>';
237 
238 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
239 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
240 if ($optioncss != '') $param.='&optioncss='.$optioncss;
241 if ($langcode) $param.='&langcode='.urlencode($langcode);
242 if ($transkey) $param.='&transkey='.urlencode($transkey);
243 if ($transvalue) $param.='&transvalue='.urlencode($transvalue);
244 
245 
246 print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';
247 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
248 print '<input type="hidden" name="token" value="'.$_SESSION['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 print '<input type="hidden" name="page" value="'.$page.'">';
253 
255 
256 dol_fiche_head($head, $mode, '', -1, '');
257 
258 if ($mode == 'overwrite')
259 {
260  //print load_fiche_titre($langs->trans("TranslationOverwriteKey"), '', '')."\n";
261 
262  $disabled='';
263  if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disabled=' disabled="disabled"';
264  $disablededit='';
265  if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit=' disabled';
266 
267  print '<div class="justify"><span class="opacitymedium">';
268  print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
269  $urlwikitranslatordoc='https://wiki.dolibarr.org/index.php/Translator_documentation';
270  print ' ('.$langs->trans("SeeAlso", '<a href="'.$urlwikitranslatordoc.'" target="_blank">'.$langs->trans("Here").'</a>').')<br>';
271  print $langs->trans("TranslationOverwriteDesc",$langs->transnoentitiesnoconv("Language"),$langs->transnoentitiesnoconv("Key"),$langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
272  print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
273  print '</span></div>';
274 
275  print '<br>';
276 
277 
278  print '<input type="hidden" name="action" value="'.($action=='edit'?'update':'add').'">';
279  print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
280 
281  print '<div class="div-table-responsive-no-min">';
282  print '<table class="noborder" width="100%">';
283  print '<tr class="liste_titre">';
284  print_liste_field_titre( $langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder);
285  print_liste_field_titre("Key",$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
286  print_liste_field_titre("NewTranslationStringToShow",$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
287  //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
288  print '<td align="center"></td>';
289  print "</tr>\n";
290 
291 
292  // Line to add new record
293  print "\n";
294 
295  print '<tr class="oddeven"><td>';
296  print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit?1:0, 'maxwidthonsmartphone', 1);
297  print '</td>'."\n";
298  print '<td>';
299  print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey)?$transkey:"").'">';
300  print '</td><td>';
301  print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue)?$transvalue:"").'">';
302  print '</td>';
303  // Limit to superadmin
304  /*if (! empty($conf->multicompany->enabled) && !$user->entity)
305  {
306  print '<td>';
307  print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
308  print '</td>';
309  print '<td align="center">';
310  }
311  else
312  {*/
313  print '<td align="center">';
314  print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
315  //}
316  print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnabledTranslationOverwriteBefore")).'">';
317  print "</td>\n";
318  print '</tr>';
319 
320 
321  // Show constants
322  $sql = "SELECT rowid, entity, lang, transkey, transvalue";
323  $sql.= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
324  $sql.= " WHERE 1 = 1";
325  $sql.= " AND entity IN (".getEntity('overwrite_trans').")";
326  $sql.= $db->order($sortfield, $sortorder);
327 
328  dol_syslog("translation::select from table", LOG_DEBUG);
329  $result = $db->query($sql);
330  if ($result)
331  {
332  $num = $db->num_rows($result);
333  $i = 0;
334 
335  while ($i < $num)
336  {
337  $obj = $db->fetch_object($result);
338 
339  print "\n";
340 
341  print '<tr class="oddeven">';
342 
343  print '<td>'.$obj->lang.'</td>'."\n";
344  print '<td>'.$obj->transkey.'</td>'."\n";
345 
346  // Value
347  print '<td>';
348  /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
349  print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
350  print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
351  print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
352  */
353  if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int'))
354  {
355  print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$obj->transvalue.'">';
356  }
357  else
358  {
359  print $obj->transvalue;
360  }
361  print '</td>';
362 
363  print '<td align="center">';
364  if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int'))
365  {
366  print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
367  print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
368  print ' &nbsp; ';
369  print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
370  }
371  else
372  {
373  print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=edit'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_edit().'</a>';
374  print ' &nbsp; ';
375  print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_delete().'</a>';
376  }
377  print '</td>';
378 
379  print "</tr>\n";
380  print "\n";
381  $i++;
382  }
383  }
384 
385  print '</table>';
386  print '</div>';
387 }
388 
389 if ($mode == 'searchkey')
390 {
391  $langcode=GETPOST('langcode')?GETPOST('langcode'):$langs->defaultlang;
392 
393  $newlang=new Translate('',$conf);
394  $newlang->setDefaultLang($langcode);
395 
396  $newlangfileonly=new Translate('',$conf);
397  $newlangfileonly->setDefaultLang($langcode);
398 
399  $recordtoshow=array();
400 
401  // Search modules dirs
402  $modulesdir = dolGetModulesDirs();
403 
404  $nbtotaloffiles=0;
405  $nbempty=0;
406  /*var_dump($langcode);
407  var_dump($transkey);
408  var_dump($transvalue);*/
409  if (empty($langcode) || $langcode == '-1') $nbempty++;
410  if (empty($transkey)) $nbempty++;
411  if (empty($transvalue)) $nbempty++;
412  if ($action == 'search' && ($nbempty > 999)) // 999 to disable this
413  {
414  setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings');
415  }
416  else
417  {
418  // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root)
419  $i=0;
420  foreach($modulesdir as $keydir => $tmpsearchdir)
421  {
422  $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/'
423 
424  // Directory of translation files
425  $dir_lang = dirname(dirname($searchdir))."/langs/".$langcode; // The 2 dirname is to go up in dir for 2 levels
426  $dir_lang_osencoded=dol_osencode($dir_lang);
427 
428  $filearray=dol_dir_list($dir_lang_osencoded,'files',0,'','',$sortfield,(strtolower($sortorder)=='asc'?SORT_ASC:SORT_DESC),1);
429  foreach($filearray as $file)
430  {
431  $tmpfile=preg_replace('/.lang/i', '', basename($file['name']));
432  $moduledirname =(basename(dirname(dirname($dir_lang))));
433 
434  $langkey=$tmpfile;
435  if ($i > 0) $langkey.='@'.$moduledirname;
436  //var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey);
437 
438  $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite
439  $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only
440  if ($result < 0) print 'Failed to load language file '.$tmpfile.'<br>'."\n";
441  else $nbtotaloffiles++;
442  //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records<br>'."\n";
443  }
444  $i++;
445  }
446 
447  // Now search into translation array
448  foreach($newlang->tab_translate as $key => $val)
449  {
450  if ($transkey && ! preg_match('/'.preg_quote($transkey,'/').'/i', $key)) continue;
451  if ($transvalue && ! preg_match('/'.preg_quote($transvalue,'/').'/i', $val)) continue;
452  $recordtoshow[$key]=$val;
453  }
454  }
455 
456  //print '<br>';
457  $nbtotalofrecordswithoutfilters = count($newlang->tab_translate);
458  $nbtotalofrecords = count($recordtoshow);
459  $num = $limit + 1;
460  if (($offset + $num) > $nbtotalofrecords) $num = $limit;
461 
462  //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
463  $title = $langs->trans("TranslationKeySearch");
464  if ($nbtotalofrecords > 0) $title.=' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')';
465  print print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit)."\n";
466 
467  print '<input type="hidden" id="action" name="action" value="search">';
468  print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
469 
470  print '<div class="div-table-responsive-no-min">';
471  print '<table class="noborder" width="100%">';
472  print '<tr class="liste_titre">';
473  print_liste_field_titre( $langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder).'</td>';
474  print_liste_field_titre("Key",$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
475  print_liste_field_titre("CurrentTranslationString",$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
476  //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity",$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
477  print '<td align="center"></td>';
478  print "</tr>\n";
479 
480  // Line to search new record
481  print "\n";
482 
483  print '<tr class="oddeven"><td>';
484  //print $formadmin->select_language($langcode,'langcode',0,null,$langs->trans("All"),0,0,'',1);
485  print $formadmin->select_language($langcode,'langcode', 0, null, 0, 0, 0, 'maxwidthonsmartphone', 1);
486  print '</td>'."\n";
487  print '<td>';
488  print '<input type="text" class="flat maxwidthonsmartphone" name="transkey" value="'.$transkey.'">';
489  print '</td><td>';
490  print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$transvalue.'">';
491  // Limit to superadmin
492  /*if (! empty($conf->multicompany->enabled) && !$user->entity)
493  {
494  print '</td><td>';
495  print '<input type="text" class="flat" size="1" name="entitysearch" value="'.$conf->entity.'">';
496  }
497  else
498  {*/
499  print '<input type="hidden" name="entitysearch" value="'.$conf->entity.'">';
500  //}
501  print '</td>';
502  // Action column
503  print '<td class="nowrap" align="right">';
504  $searchpicto=$form->showFilterAndCheckAddButtons($massactionbutton?1:0, 'checkforselect', 1);
505  print $searchpicto;
506  print '</td>';
507  print '</tr>';
508 
509  if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') ksort($recordtoshow);
510  if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') krsort($recordtoshow);
511  if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') asort($recordtoshow);
512  if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') arsort($recordtoshow);
513 
514  // Show result
515  $i=0;
516  foreach($recordtoshow as $key => $val)
517  {
518  $i++;
519  if ($i <= $offset) continue;
520  if ($i > ($offset + $limit)) break;
521  print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>';
522  print dol_escape_htmltag($val);
523  print '</td><td align="right">';
524  if (! empty($newlangfileonly->tab_translate[$key]))
525  {
526  if ($val != $newlangfileonly->tab_translate[$key])
527  {
528  // retrieve rowid
529  $sql = "SELECT rowid";
530  $sql.= " FROM " . MAIN_DB_PREFIX . "overwrite_trans";
531  $sql.= " WHERE transkey = '".$key."'";
532  $sql.= " AND entity IN (" . getEntity('overwrite_trans') . ")";
533  dol_syslog("translation::select from table", LOG_DEBUG);
534  $result = $db->query($sql);
535  if ($result)
536  {
537  $obj = $db->fetch_object($result);
538  }
539  print '<a href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $obj->rowid . '&entity=' . $conf->entity . '&action=edit">' . img_edit() . '</a>';
540  print '&nbsp;&nbsp;';
541  print '<a href="' . $_SERVER['PHP_SELF'] . '?rowid=' . $obj->rowid . '&entity=' . $conf->entity . '&action=delete">' . img_delete() . '</a>';
542  print '&nbsp;&nbsp;';
543  $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
544  print $form->textwithpicto('', $htmltext, 1, 'info');
545  }
546  else if (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
547  {
548  //print $key.'-'.$val;
549  print '<a href="' . $_SERVER['PHP_SELF'] . '?mode=overwrite&amp;langcode=' . $langcode . '&amp;transkey=' . $key . '">' . img_edit_add($langs->trans("Overwrite")) . '</a>';
550  }
551 
552  if (! empty($conf->global->MAIN_FEATURES_LEVEL))
553  {
554  $transifexlangfile='$'; // $ means 'All'
555  //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
556  $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
557 
558  print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto('FixOnTransifex', 'object_globe').'</a>';
559  }
560  }
561  else
562  {
563  $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
564  print $form->textwithpicto('', $htmltext, 1, 'warning');
565  }
566  /*if (! empty($conf->multicompany->enabled) && !$user->entity)
567  {
568  print '<td>'.$val.'</td>';
569  }*/
570  print '</td></tr>'."\n";
571  }
572 
573  print '</table>';
574  print '</div>';
575 }
576 
577 dol_fiche_end();
578 
579 print "</form>\n";
580 
581 if (! empty($langcode))
582 {
583  dol_set_focus('#transvalue');
584 }
585 
586 // End of page
587 llxFooter();
588 $db->close();
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
picto_from_langcode($codelang, $moreatt='')
Return img flag of country for a language code or country code.
img_edit($titlealt='default', $float=0, $other='class="pictoedit"')
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:510
img_info($titlealt='default')
Show info logo.
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...
translation_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:676
img_delete($titlealt='default', $other='class="pictodelete"')
Show delete logo.
Class to generate html code for admin pages.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Class to manage generation of HTML components Only common components must be here.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
Print a title with navigation controls for pagination.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
dol_fiche_end($notab=0)
Show tab footer of a card.
llxHeader()
Empty header.
Definition: wrapper.php:44
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:59
img_edit_add($titlealt='default', $other='')
Show logo +.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of &#39;autofocus&#39; HTML5 tag)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.
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