dolibarr  7.0.0-beta
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@capnetworks.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 $langs->loadLangs(array("companies","products","admin","sms","other","errors"));
31 
32 if (!$user->admin) accessforbidden();
33 
34 $id=GETPOST('rowid','int');
35 $action=GETPOST('action','alpha');
36 
37 $langcode=GETPOST('langcode','alpha');
38 $transkey=GETPOST('transkey','alpha');
39 $transvalue=GETPOST('transvalue','alpha');
40 
41 
42 $mode = GETPOST('mode')?GETPOST('mode'):'overwrite';
43 
44 $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
45 $sortfield = GETPOST("sortfield",'alpha');
46 $sortorder = GETPOST("sortorder",'alpha');
47 $page = GETPOST("page",'int');
48 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
49 $offset = $limit * $page;
50 $pageprev = $page - 1;
51 $pagenext = $page + 1;
52 if (! $sortfield) $sortfield='lang,transkey';
53 if (! $sortorder) $sortorder='ASC';
54 
55 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
56 $hookmanager->initHooks(array('admintranslation','globaladmin'));
57 
58 
59 /*
60  * Actions
61  */
62 
63 if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
64 if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
65 
66 $parameters=array('socid'=>$socid);
67 $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
68 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
69 
70 include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
71 
72 // Purge search criteria
73 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
74 {
75  $transkey='';
76  $transvalue='';
77  $toselect='';
78  $search_array_options=array();
79 }
80 
81 if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION')
82 {
83  if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity);
84  else dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity);
85 }
86 
87 if ($action == 'update')
88 {
89  if ($transvalue == '')
90  {
91  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
92  $error++;
93  }
94  if (! $error)
95  {
96  $db->begin();
97 
98  $sql = "UPDATE ".MAIN_DB_PREFIX."overwrite_trans set transvalue = '".$db->escape($transvalue)."' WHERE rowid = ".GETPOST('rowid','int');
99  $result = $db->query($sql);
100  if ($result > 0)
101  {
102  $db->commit();
103  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
104  $action="";
105  $transkey="";
106  $transvalue="";
107  }
108  else
109  {
110 
111  $db->rollback();
112  if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
113  {
114  setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
115  }
116  else
117  {
118  setEventMessages($db->lasterror(), null, 'errors');
119  }
120  $action='';
121  }
122  }
123 }
124 
125 if ($action == 'add')
126 {
127  $error=0;
128 
129  if (empty($langcode))
130  {
131  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")), null, 'errors');
132  $error++;
133  }
134  if ($transkey == '')
135  {
136  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors');
137  $error++;
138  }
139  if ($transvalue == '')
140  {
141  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors');
142  $error++;
143  }
144  if (! $error)
145  {
146  $db->begin();
147 
148  $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).")";
149  $result = $db->query($sql);
150  if ($result > 0)
151  {
152  $db->commit();
153  setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
154  $action="";
155  $transkey="";
156  $transvalue="";
157  }
158  else
159  {
160 
161  $db->rollback();
162  if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
163  {
164  setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings');
165  }
166  else
167  {
168  setEventMessages($db->lasterror(), null, 'errors');
169  }
170  $action='';
171  }
172  }
173 }
174 
175 // Delete line from delete picto
176 if ($action == 'delete')
177 {
178  $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".$db->escape($id);
179  $result = $db->query($sql);
180  if ($result >= 0)
181  {
182  setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
183  }
184  else
185  {
186  dol_print_error($db);
187  }
188 }
189 
190 
191 
192 
193 
194 
195 /*
196  * View
197  */
198 
199 $form = new Form($db);
200 $formadmin = new FormAdmin($db);
201 
202 $wikihelp='EN:Setup|FR:Paramétrage|ES:Configuración';
203 llxHeader('',$langs->trans("Setup"),$wikihelp);
204 
205 $param='&mode='.$mode;
206 
207 $enabledisablehtml='';
208 $enabledisablehtml.= $langs->trans("EnableOverwriteTranslation").' ';
209 if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
210 {
211  // Button off, click to enable
212  $enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=1'.$param.'">';
213  $enabledisablehtml.=img_picto($langs->trans("Disabled"),'switch_off');
214  $enabledisablehtml.='</a>';
215 }
216 else
217 {
218  // Button on, click to disable
219  $enabledisablehtml.='<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setMAIN_ENABLE_OVERWRITE_TRANSLATION&value=0'.$param.'">';
220  $enabledisablehtml.=img_picto($langs->trans("Activated"),'switch_on');
221  $enabledisablehtml.='</a>';
222 }
223 
224 print load_fiche_titre($langs->trans("Translation"), $enabledisablehtml, 'title_setup');
225 
226 //print '<span class="opacitymedium">';
227 print $langs->trans("TranslationDesc")."<br>\n";
228 //print '</span>';
229 print "<br>\n";
230 
231 $current_language_code=$langs->defaultlang;
232 $s=picto_from_langcode($current_language_code);
233 print $langs->trans("CurrentUserLanguage").': <strong>'.$s.' '.$current_language_code.'</strong><br>';
234 
235 print '<br>';
236 
237 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
238 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
239 if ($optioncss != '') $param.='&optioncss='.$optioncss;
240 if ($langcode) $param.='&langcode='.urlencode($langcode);
241 if ($transkey) $param.='&transkey='.urlencode($transkey);
242 if ($transvalue) $param.='&transvalue='.urlencode($transvalue);
243 
244 
245 print '<form action="'.$_SERVER["PHP_SELF"].((empty($user->entity) && $debug)?'?debug=1':'').'" method="POST">';
246 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
247 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
248 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
249 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
250 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
251 print '<input type="hidden" name="page" value="'.$page.'">';
252 
254 
255 dol_fiche_head($head, $mode, '', -1, '');
256 
257 if ($mode == 'overwrite')
258 {
259  //print load_fiche_titre($langs->trans("TranslationOverwriteKey"), '', '')."\n";
260 
261  $disabled='';
262  if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disabled=' disabled="disabled"';
263  $disablededit='';
264  if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit=' disabled';
265 
266  print '<div class="justify"><span class="opacitymedium">';
267  print img_info().' '.$langs->trans("SomeTranslationAreUncomplete");
268  $urlwikitranslatordoc='https://wiki.dolibarr.org/index.php/Translator_documentation';
269  print ' ('.$langs->trans("SeeAlso").': <a href="'.$urlwikitranslatordoc.'" target="_blank">'.$langs->trans("Here").'</a>)<br>';
270  print $langs->trans("TranslationOverwriteDesc",$langs->transnoentitiesnoconv("Language"),$langs->transnoentitiesnoconv("Key"),$langs->transnoentitiesnoconv("NewTranslationStringToShow"))."\n";
271  print ' ('.$langs->trans("TranslationOverwriteDesc2").').'."<br>\n";
272  print '</span></div>';
273 
274  print '<br>';
275 
276 
277  print '<input type="hidden" name="action" value="'.($action=='edit'?'update':'add').'">';
278  print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
279 
280  print '<div class="div-table-responsive-no-min">';
281  print '<table class="noborder" width="100%">';
282  print '<tr class="liste_titre">';
283  print_liste_field_titre( $langs->trans("Language").' (en_US, es_MX, ...)',$_SERVER["PHP_SELF"],'lang,transkey','',$param,'',$sortfield,$sortorder);
284  print_liste_field_titre("Key",$_SERVER["PHP_SELF"],'transkey','',$param,'',$sortfield,$sortorder);
285  print_liste_field_titre("NewTranslationStringToShow",$_SERVER["PHP_SELF"],'transvalue','',$param,'',$sortfield,$sortorder);
286  //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity"),$_SERVER["PHP_SELF"],'entity,transkey','',$param,'',$sortfield,$sortorder);
287  print '<td align="center"></td>';
288  print "</tr>\n";
289 
290 
291  // Line to add new record
292  print "\n";
293 
294  print '<tr class="oddeven"><td>';
295  print $formadmin->select_language(GETPOST('langcode'), 'langcode', 0, null, 1, 0, $disablededit?1:0, 'maxwidthonsmartphone', 1);
296  print '</td>'."\n";
297  print '<td>';
298  print '<input type="text" class="flat maxwidthonsmartphone"'.$disablededit.' name="transkey" id="transkey" value="'.(!empty($transkey)?$transkey:"").'">';
299  print '</td><td>';
300  print '<input type="text" class="quatrevingtpercent"'.$disablededit.' name="transvalue" id="transvalue" value="'.(!empty($transvalue)?$transvalue:"").'">';
301  print '</td>';
302  // Limit to superadmin
303  /*if (! empty($conf->multicompany->enabled) && !$user->entity)
304  {
305  print '<td>';
306  print '<input type="text" class="flat" size="1" name="entity" value="'.$conf->entity.'">';
307  print '</td>';
308  print '<td align="center">';
309  }
310  else
311  {*/
312  print '<td align="center">';
313  print '<input type="hidden" name="entity" value="'.$conf->entity.'">';
314  //}
315  print '<input type="submit" class="button"'.$disabled.' value="'.$langs->trans("Add").'" name="add" title="'.dol_escape_htmltag($langs->trans("YouMustEnabledTranslationOverwriteBefore")).'">';
316  print "</td>\n";
317  print '</tr>';
318 
319 
320  // Show constants
321  $sql = "SELECT rowid, entity, lang, transkey, transvalue";
322  $sql.= " FROM ".MAIN_DB_PREFIX."overwrite_trans";
323  $sql.= " WHERE 1 = 1";
324  $sql.= " AND entity IN (".getEntity('overwrite_trans').")";
325  $sql.= $db->order($sortfield, $sortorder);
326 
327  dol_syslog("translation::select from table", LOG_DEBUG);
328  $result = $db->query($sql);
329  if ($result)
330  {
331  $num = $db->num_rows($result);
332  $i = 0;
333 
334  while ($i < $num)
335  {
336  $obj = $db->fetch_object($result);
337 
338  print "\n";
339 
340  print '<tr class="oddeven">';
341 
342  print '<td>'.$obj->lang.'</td>'."\n";
343  print '<td>'.$obj->transkey.'</td>'."\n";
344 
345  // Value
346  print '<td>';
347  /*print '<input type="hidden" name="const['.$i.'][rowid]" value="'.$obj->rowid.'">';
348  print '<input type="hidden" name="const['.$i.'][lang]" value="'.$obj->lang.'">';
349  print '<input type="hidden" name="const['.$i.'][name]" value="'.$obj->transkey.'">';
350  print '<input type="text" id="value_'.$i.'" class="flat inputforupdate" size="30" name="const['.$i.'][value]" value="'.dol_escape_htmltag($obj->transvalue).'">';
351  */
352  if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int'))
353  {
354  print '<input type="text" class="quatrevingtpercent" name="transvalue" value="'.$obj->transvalue.'">';
355  }
356  else
357  {
358  print $obj->transvalue;
359  }
360  print '</td>';
361 
362  print '<td align="center">';
363  if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int'))
364  {
365  print '<input type="hidden" class="button" name="rowid" value="'.$obj->rowid.'">';
366  print '<input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
367  print ' &nbsp; ';
368  print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
369  }
370  else
371  {
372  print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=edit'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_edit().'</a>';
373  print ' &nbsp; ';
374  print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$obj->entity.'&action=delete'.((empty($user->entity) && $debug)?'&debug=1':'').'">'.img_delete().'</a>';
375  }
376  print '</td>';
377 
378  print "</tr>\n";
379  print "\n";
380  $i++;
381  }
382  }
383 
384  print '</table>';
385  print '</div>';
386 
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  print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto('FixOnTransifex', 'object_globe').'</a>';
557  }
558  }
559  else
560  {
561  $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);
562  print $form->textwithpicto('', $htmltext, 1, 'warning');
563  }
564  /*if (! empty($conf->multicompany->enabled) && !$user->entity)
565  {
566  print '<td>'.$val.'</td>';
567  }*/
568  print '</td></tr>'."\n";
569  }
570 
571  print '</table>';
572  print '</div>';
573 }
574 
575 dol_fiche_end();
576 
577 print "</form>\n";
578 
579 if (! empty($langcode))
580 {
581  dol_set_focus('#transvalue');
582 }
583 
584 llxFooter();
585 
586 $db->close();
dol_osencode($str)
Return a string encoded into OS filesystem encoding.
llxFooter()
Empty footer.
Definition: wrapper.php:58
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='')
Show tab header of a card.
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:485
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
if(empty($reshook)) $form
View.
Definition: perms.php:103
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...
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="")
Scan a directory and return a list of files/directories.
Definition: files.lib.php:58
translation_prepare_head()
Prepare array with list of tabs.
Definition: admin.lib.php:633
GETPOST($paramname, $check='none', $method=0, $filter=NULL, $options=NULL, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
if(GETPOST('button_removefilter_x','alpha')||GETPOST('button_removefilter.x','alpha')||GETPOST('button_removefilter','alpha')) if($action=="save"&&empty($cancel)) if(preg_match('/set_(.*)/', $action, $reg)) if(preg_match('/del_(.*)/', $action, $reg) $wikihelp)
View.
Definition: agenda.php:143
if($_POST["cancel"]==$langs->trans("Cancel")&&!$id) if($action== 'setdatev'&&$user->rights->tax->charges->creer) if($action== 'add'&&$_POST["cancel"]<> $langs->trans("Cancel")) if($action== 'delete') $title
Actions.
Definition: card.php:183
dol_fiche_end($notab=0)
Show tab footer of a card.
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
Load a title with picto.
llxHeader()
Empty header.
Definition: wrapper.php:46
getEntity($element, $shared=1, $forceentity=null)
Get list of entity id to use.
Class to manage translations.
img_delete($titlealt= 'default', $other= 'class="pictodelete"')
Show delete logo.
img_edit_add($titlealt= 'default', $other= '')
Show logo +.
print
Draft customers invoices.
Definition: index.php:91
img_info($titlealt= 'default')
Show info logo.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="")
Show title line of an array.
img_edit($titlealt= 'default', $float=0, $other= 'class="pictoedit"')
Show logo editer/modifier fiche.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.