Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer 2020-01-16 01:54:00 +00:00
parent 74ac6a3204
commit 0aa156db78
6 changed files with 290 additions and 290 deletions

View File

@ -415,17 +415,17 @@ print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans(
// Name
print '<tr class="oddeven"><td class="fieldrequired"><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
print '<input name="nom" id="name" class="minwidth200" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM?$conf->global->MAIN_INFO_SOCIETE_NOM: GETPOST("nom", 'nohtml')) . '"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
print '<input name="nom" id="name" class="minwidth200" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_NOM ? $conf->global->MAIN_INFO_SOCIETE_NOM : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
// Address
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ADDRESS">'.$langs->trans("CompanyAddress").'</label></td><td>';
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'. ($conf->global->MAIN_INFO_SOCIETE_ADDRESS?$conf->global->MAIN_INFO_SOCIETE_ADDRESS:GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')) . '</textarea></td></tr>'."\n";
print '<textarea name="MAIN_INFO_SOCIETE_ADDRESS" id="MAIN_INFO_SOCIETE_ADDRESS" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($conf->global->MAIN_INFO_SOCIETE_ADDRESS ? $conf->global->MAIN_INFO_SOCIETE_ADDRESS : GETPOST("MAIN_INFO_SOCIETE_ADDRESS", 'nohtml')).'</textarea></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_ZIP">'.$langs->trans("CompanyZip").'</label></td><td>';
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP?$conf->global->MAIN_INFO_SOCIETE_ZIP:GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')) . '"></td></tr>'."\n";
print '<input class="minwidth100" name="MAIN_INFO_SOCIETE_ZIP" id="MAIN_INFO_SOCIETE_ZIP" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_ZIP ? $conf->global->MAIN_INFO_SOCIETE_ZIP : GETPOST("MAIN_INFO_SOCIETE_ZIP", 'alpha')).'"></td></tr>'."\n";
print '<tr class="oddeven"><td><label for="MAIN_INFO_SOCIETE_TOWN">'.$langs->trans("CompanyTown").'</label></td><td>';
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'. dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN?$conf->global->MAIN_INFO_SOCIETE_TOWN:GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')) . '"></td></tr>'."\n";
print '<input name="MAIN_INFO_SOCIETE_TOWN" class="minwidth100" id="MAIN_INFO_SOCIETE_TOWN" value="'.dol_escape_htmltag($conf->global->MAIN_INFO_SOCIETE_TOWN ? $conf->global->MAIN_INFO_SOCIETE_TOWN : GETPOST("MAIN_INFO_SOCIETE_TOWN", 'nohtml')).'"></td></tr>'."\n";
// Country
print '<tr class="oddeven"><td class="fieldrequired"><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';

View File

@ -898,90 +898,90 @@ class DolGraph
return;
}
$legends=array();
$nblot=0;
$legends = array();
$nblot = 0;
if (is_array($this->data) && is_array($this->data[0])) {
$nblot=count($this->data[0])-1; // -1 to remove legend
$nblot = count($this->data[0]) - 1; // -1 to remove legend
}
if ($nblot < 0) dol_syslog('Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
$firstlot=0;
$firstlot = 0;
// Works with line but not with bars
//if ($nblot > 2) $firstlot = ($nblot - 2); // We limit nblot to 2 because jflot can't manage more than 2 bars on same x
$i=$firstlot;
$serie=array();
$i = $firstlot;
$serie = array();
while ($i < $nblot) // Loop on each serie
{
$values=array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
$serie[$i]="var d".$i." = [];\n";
$values = array(); // Array with horizontal y values (specific values of a serie) for each abscisse x
$serie[$i] = "var d".$i." = [];\n";
// Fill array $values
$x=0;
foreach($this->data as $valarray) // Loop on each x
$x = 0;
foreach ($this->data as $valarray) // Loop on each x
{
$legends[$x] = $valarray[0];
$values[$x] = (is_numeric($valarray[$i+1]) ? $valarray[$i+1] : null);
$values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] : null);
$x++;
}
// TODO Avoid push by adding generated long array...
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
{
foreach($values as $x => $y) {
if (isset($y)) $serie[$i].='d'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
foreach ($values as $x => $y) {
if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n";
}
}
else
{
foreach($values as $x => $y) {
if (isset($y)) $serie[$i].='d'.$i.'.push(['.$x.', '.$y.']);'."\n";
foreach ($values as $x => $y) {
if (isset($y)) $serie[$i] .= 'd'.$i.'.push(['.$x.', '.$y.']);'."\n";
}
}
unset($values);
$i++;
}
$tag=dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-','.'))));
$tag = dol_escape_htmltag(dol_string_unaccent(dol_string_nospecial(basename($file), '_', array('-', '.'))));
$this->stringtoshow ='<!-- Build using '.$this->_library.' -->'."\n";
if (! empty($this->title)) $this->stringtoshow.='<div class="center dolgraphtitle'.(empty($this->cssprefix)?'':' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
if (! empty($this->shownographyet))
$this->stringtoshow = '<!-- Build using '.$this->_library.' -->'."\n";
if (!empty($this->title)) $this->stringtoshow .= '<div class="center dolgraphtitle'.(empty($this->cssprefix) ? '' : ' dolgraphtitle'.$this->cssprefix).'">'.$this->title.'</div>';
if (!empty($this->shownographyet))
{
$this->stringtoshow.='<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
$this->stringtoshow.='<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
$this->stringtoshow .= '<div style="width:'.$this->width.'px;height:'.$this->height.'px;" class="nographyet"></div>';
$this->stringtoshow .= '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
return;
}
$this->stringtoshow.='<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix)?'':' dolgraph'.$this->cssprefix).' center"></div>'."\n";
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="width:'.$this->width.'px;height:'.$this->height.'px;" class="dolgraph'.(empty($this->cssprefix) ? '' : ' dolgraph'.$this->cssprefix).' center"></div>'."\n";
$this->stringtoshow.='<script id="'.$tag.'">'."\n";
$this->stringtoshow.='$(function () {'."\n";
$i=$firstlot;
$this->stringtoshow .= '<script id="'.$tag.'">'."\n";
$this->stringtoshow .= '$(function () {'."\n";
$i = $firstlot;
if ($nblot < 0)
{
$this->stringtoshow.='<!-- No series of data -->';
$this->stringtoshow .= '<!-- No series of data -->';
}
else
{
while ($i < $nblot)
{
$this->stringtoshow.=$serie[$i];
$this->stringtoshow .= $serie[$i];
$i++;
}
}
$this->stringtoshow.="\n";
$this->stringtoshow .= "\n";
// Special case for Graph of type 'pie'
if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie')
{
$datacolor=array();
foreach($this->datacolor as $val) $datacolor[]="#".sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]);
$datacolor = array();
foreach ($this->datacolor as $val) $datacolor[] = "#".sprintf("%02x%02x%02x", $val[0], $val[1], $val[2]);
$urltemp=''; // TODO Add support for url link into labels
$showlegend=$this->showlegend;
$showpointvalue=$this->showpointvalue;
$showpercent=$this->showpercent;
$urltemp = ''; // TODO Add support for url link into labels
$showlegend = $this->showlegend;
$showpointvalue = $this->showpointvalue;
$showpercent = $this->showpercent;
$this->stringtoshow.= '
$this->stringtoshow .= '
function plotWithOptions_'.$tag.'() {
$.plot($("#placeholder_'.$tag.'"), d0,
{

View File

@ -29,17 +29,17 @@
*/
class Translate
{
public $dir; // Directories that contains /langs subdirectory
public $dir; // Directories that contains /langs subdirectory
public $defaultlang; // Current language for current user
public $charset_output='UTF-8'; // Codage used by "trans" method outputs
public $defaultlang; // Current language for current user
public $charset_output = 'UTF-8'; // Codage used by "trans" method outputs
public $tab_translate=array(); // Array of all translations key=>value
private $_tab_loaded=array(); // Array to store result after loading each language file
public $tab_translate = array(); // Array of all translations key=>value
private $_tab_loaded = array(); // Array to store result after loading each language file
public $cache_labels=array(); // Cache for labels return by getLabelFromKey method
public $cache_currencies=array(); // Cache to store currency symbols
private $cache_currencies_all_loaded=false;
public $cache_labels = array(); // Cache for labels return by getLabelFromKey method
public $cache_currencies = array(); // Cache to store currency symbols
private $cache_currencies_all_loaded = false;
/**
@ -50,9 +50,9 @@ class Translate
*/
public function __construct($dir, $conf)
{
if (! empty($conf->file->character_set_client)) $this->charset_output=$conf->file->character_set_client; // If charset output is forced
if ($dir) $this->dir=array($dir);
else $this->dir=$conf->file->dol_document_root;
if (!empty($conf->file->character_set_client)) $this->charset_output = $conf->file->character_set_client; // If charset output is forced
if ($dir) $this->dir = array($dir);
else $this->dir = $conf->file->dol_document_root;
}
@ -69,59 +69,59 @@ class Translate
//dol_syslog(get_class($this)."::setDefaultLang srclang=".$srclang,LOG_DEBUG);
// If a module ask to force a priority on langs directories (to use its own lang files)
if (! empty($conf->global->MAIN_FORCELANGDIR))
if (!empty($conf->global->MAIN_FORCELANGDIR))
{
$more=array();
$i=0;
foreach($conf->file->dol_document_root as $dir)
$more = array();
$i = 0;
foreach ($conf->file->dol_document_root as $dir)
{
$newdir=$dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
if (! in_array($newdir, $this->dir))
$newdir = $dir.$conf->global->MAIN_FORCELANGDIR; // For example $conf->global->MAIN_FORCELANGDIR is '/mymodule' meaning we search files into '/mymodule/langs/xx_XX'
if (!in_array($newdir, $this->dir))
{
$more['module_'.$i]=$newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
$more['module_'.$i] = $newdir; $i++; // We add the forced dir into the array $more. Just after, we add entries into $more to list of lang dir $this->dir.
}
}
$this->dir=array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
$this->dir = array_merge($more, $this->dir); // Forced dir ($more) are before standard dirs ($this->dir)
}
$this->origlang=$srclang;
$this->origlang = $srclang;
if (empty($srclang) || $srclang == 'auto')
{
// $_SERVER['HTTP_ACCEPT_LANGUAGE'] can be 'fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,it;q=0.6' but can contains also malicious content
$langpref=empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])?'':$_SERVER['HTTP_ACCEPT_LANGUAGE'];
$langpref=preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part
$langpref=str_replace("-", "_", $langpref);
$langlist=preg_split("/[;,]/", $langpref);
$codetouse=preg_replace('/[^_a-zA-Z]/', '', $langlist[0]);
$langpref = empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? '' : $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$langpref = preg_replace("/;([^,]*)/i", "", $langpref); // Remove the 'q=x.y,' part
$langpref = str_replace("-", "_", $langpref);
$langlist = preg_split("/[;,]/", $langpref);
$codetouse = preg_replace('/[^_a-zA-Z]/', '', $langlist[0]);
}
else $codetouse=$srclang;
else $codetouse = $srclang;
// We redefine $srclang
$langpart=explode("_", $codetouse);
$langpart = explode("_", $codetouse);
//print "Short code before _ : ".$langpart[0].' / Short code after _ : '.$langpart[1].'<br>';
if (! empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
if (!empty($langpart[1])) // If it's for a codetouse that is a long code xx_YY
{
// Array force long code from first part, even if long code is defined
$longforshort=array('ar'=>'ar_SA');
$longforshortexcep=array('ar_EG');
if (isset($longforshort[strtolower($langpart[0])]) && ! in_array($codetouse, $longforshortexcep)) $srclang=$longforshort[strtolower($langpart[0])];
elseif (! is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
$srclang=strtolower($langpart[0])."_".strtoupper($langpart[1]);
$longforlong=array('no_nb'=>'nb_NO');
if (isset($longforlong[strtolower($srclang)])) $srclang=$longforlong[strtolower($srclang)];
$longforshort = array('ar'=>'ar_SA');
$longforshortexcep = array('ar_EG');
if (isset($longforshort[strtolower($langpart[0])]) && !in_array($codetouse, $longforshortexcep)) $srclang = $longforshort[strtolower($langpart[0])];
elseif (!is_numeric($langpart[1])) { // Second part YY may be a numeric with some Chrome browser
$srclang = strtolower($langpart[0])."_".strtoupper($langpart[1]);
$longforlong = array('no_nb'=>'nb_NO');
if (isset($longforlong[strtolower($srclang)])) $srclang = $longforlong[strtolower($srclang)];
}
else $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
}
else { // If it's for a codetouse that is a short code xx
// Array to convert short lang code into long code.
$longforshort=array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO');
if (isset($longforshort[strtolower($langpart[0])])) $srclang=$longforshort[strtolower($langpart[0])];
elseif (! empty($langpart[0])) $srclang=strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang='en_US';
$longforshort = array('ar'=>'ar_SA', 'el'=>'el_GR', 'ca'=>'ca_ES', 'en'=>'en_US', 'nb'=>'nb_NO', 'no'=>'nb_NO');
if (isset($longforshort[strtolower($langpart[0])])) $srclang = $longforshort[strtolower($langpart[0])];
elseif (!empty($langpart[0])) $srclang = strtolower($langpart[0])."_".strtoupper($langpart[0]);
else $srclang = 'en_US';
}
$this->defaultlang=$srclang;
$this->defaultlang = $srclang;
//print 'this->defaultlang='.$this->defaultlang;
}
@ -148,7 +148,7 @@ class Translate
*/
public function loadLangs($domains)
{
foreach($domains as $domain)
foreach ($domains as $domain)
{
$this->load($domain);
}
@ -176,7 +176,7 @@ class Translate
*/
public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0)
{
global $conf,$db;
global $conf, $db;
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
@ -186,18 +186,18 @@ class Translate
dol_print_error('', get_class($this)."::Load ErrorWrongParameters");
return -1;
}
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
if ($this->defaultlang == 'none_NONE') return 0; // Special language code to not translate keys
// Load $this->tab_translate[] from database
if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
if (empty($loadfromfileonly) && count($this->tab_translate) == 0) $this->loadFromDatabase($db); // No translation was never loaded yet, so we load database.
$newdomain = $domain;
$modulename = '';
// Search if a module directory name is provided into lang file name
$regs=array();
$regs = array();
if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs))
{
$newdomain = $regs[1];
@ -205,19 +205,19 @@ class Translate
}
// Check cache
if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
{
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
return 0;
}
$fileread=0;
$langofdir=(empty($forcelangdir)?$this->defaultlang:$forcelangdir);
$fileread = 0;
$langofdir = (empty($forcelangdir) ? $this->defaultlang : $forcelangdir);
// Redefine alt
$langarray=explode('_', $langofdir);
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt=1;
if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt=2;
$langarray = explode('_', $langofdir);
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), array('el_gr')))) $alt = 1;
if ($alt < 2 && strtolower($langofdir) == 'en_us') $alt = 2;
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
{
@ -225,13 +225,13 @@ class Translate
return -1;
}
foreach($this->dir as $searchdir)
foreach ($this->dir as $searchdir)
{
// Directory of translation files
$file_lang = $searchdir.($modulename?'/'.$modulename:'')."/langs/".$langofdir."/".$newdomain.".lang";
$file_lang_osencoded=dol_osencode($file_lang);
$file_lang = $searchdir.($modulename ? '/'.$modulename : '')."/langs/".$langofdir."/".$newdomain.".lang";
$file_lang_osencoded = dol_osencode($file_lang);
$filelangexists=is_file($file_lang_osencoded);
$filelangexists = is_file($file_lang_osencoded);
//dol_syslog(get_class($this).'::Load Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' file_lang='.$file_lang." => filelangexists=".$filelangexists);
//print 'Try to read for alt='.$alt.' langofdir='.$langofdir.' domain='.$domain.' newdomain='.$newdomain.' modulename='.$modulename.' this->_tab_loaded[newdomain]='.$this->_tab_loaded[$newdomain].' file_lang='.$file_lang." => filelangexists=".$filelangexists."\n";
@ -239,19 +239,19 @@ class Translate
if ($filelangexists)
{
// TODO Move cache read out of loop on dirs or at least filelangexists
$found=false;
$found = false;
// Enable caching of lang file in memory (not by default)
$usecachekey='';
$usecachekey = '';
// Using a memcached server
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER))
{
$usecachekey=$newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
$usecachekey = $newdomain.'_'.$langofdir.'_'.md5($file_lang); // Should not contains special chars
}
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
{
$usecachekey=$newdomain;
$usecachekey = $newdomain;
}
if ($usecachekey)
@ -259,23 +259,23 @@ class Translate
//dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
//global $aaa; $aaa+=1;
//print $aaa." ".$usecachekey."\n";
require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php';
$tmparray=dol_getcache($usecachekey);
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$tmparray = dol_getcache($usecachekey);
if (is_array($tmparray) && count($tmparray))
{
$this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
$this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a value already exists into tab_translate, value into tmparaay is not added.
//print $newdomain."\n";
//var_dump($this->tab_translate);
if ($alt == 2) $fileread=1;
$found=true; // Found in dolibarr PHP cache
if ($alt == 2) $fileread = 1;
$found = true; // Found in dolibarr PHP cache
}
}
if (! $found)
if (!$found)
{
if ($fp = @fopen($file_lang, "rt"))
{
if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache
if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache
/**
* Read each lines until a '=' (with any combination of spaces around it)
@ -316,21 +316,21 @@ class Translate
}
}
fclose($fp);
$fileread=1;
$fileread = 1;
// TODO Move cache write out of loop on dirs
// To save lang content for usecachekey into cache
if ($usecachekey && count($tabtranslatedomain))
{
$ressetcache=dol_setcache($usecachekey, $tabtranslatedomain);
$ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
if ($ressetcache < 0)
{
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
$error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
dol_syslog($error, LOG_ERR);
}
}
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
}
}
}
@ -341,10 +341,10 @@ class Translate
{
// This function MUST NOT contains call to syslog
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
$langofdir=strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
$this->load($domain, $alt+1, $stopafterdirection, $langofdir);
$langofdir = strtolower($langarray[0]).'_'.strtoupper($langarray[0]);
if ($langofdir == 'el_EL') $langofdir = 'el_GR'; // main parent for el_CY is not 'el_EL' but 'el_GR'
if ($langofdir == 'ar_AR') $langofdir = 'ar_SA'; // main parent for ar_EG is not 'ar_AR' but 'ar_SA'
$this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
}
// Now we complete with reference file (en_US)
@ -352,38 +352,38 @@ class Translate
{
// This function MUST NOT contains call to syslog
//dol_syslog("Translate::Load loading alternate translation file (to complete ".$this->defaultlang."/".$newdomain.".lang file)", LOG_DEBUG);
$langofdir='en_US';
$this->load($domain, $alt+1, $stopafterdirection, $langofdir);
$langofdir = 'en_US';
$this->load($domain, $alt + 1, $stopafterdirection, $langofdir);
}
// We are in the pass of the reference file. No more files to scan to complete.
if ($alt == 2)
{
if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as found so loaded
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as found so loaded
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Set this file as not found
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Set this file as not found
}
// This part is deprecated and replaced with table llx_overwrite_trans
// Kept for backward compatibility.
if (empty($loadfromfileonly))
{
$overwritekey='MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2
$overwritekey = 'MAIN_OVERWRITE_TRANS_'.$this->defaultlang;
if (!empty($conf->global->$overwritekey)) // Overwrite translation with key1:newstring1,key2:newstring2
{
// Overwrite translation with param MAIN_OVERWRITE_TRANS_xx_XX
$tmparray=explode(',', $conf->global->$overwritekey);
foreach($tmparray as $tmp)
$tmparray = explode(',', $conf->global->$overwritekey);
foreach ($tmparray as $tmp)
{
$tmparray2=explode(':', $tmp);
if (! empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]]=$tmparray2[1];
$tmparray2 = explode(':', $tmp);
if (!empty($tmparray2[1])) $this->tab_translate[$tmparray2[0]] = $tmparray2[1];
}
}
}
// Check to be sure that SeparatorDecimal differs from SeparatorThousand
if (! empty($this->tab_translate["SeparatorDecimal"]) && ! empty($this->tab_translate["SeparatorThousand"])
&& $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"]='';
if (!empty($this->tab_translate["SeparatorDecimal"]) && !empty($this->tab_translate["SeparatorThousand"])
&& $this->tab_translate["SeparatorDecimal"] == $this->tab_translate["SeparatorThousand"]) $this->tab_translate["SeparatorThousand"] = '';
return 1;
}
@ -404,26 +404,26 @@ class Translate
{
global $conf;
$domain='database';
$domain = 'database';
// Check parameters
if (empty($db)) return 0; // Database handler can't be used
if (empty($db)) return 0; // Database handler can't be used
//dol_syslog("Translate::Load Start domain=".$domain." alt=".$alt." forcelangdir=".$forcelangdir." this->defaultlang=".$this->defaultlang);
$newdomain = $domain;
// Check cache
if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database'
if (!empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain 'database'
{
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
return 0;
}
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
$this->_tab_loaded[$newdomain] = 1; // We want to be sure this function is called once only for domain 'database'
$fileread=0;
$langofdir=$this->defaultlang;
$fileread = 0;
$langofdir = $this->defaultlang;
if (empty($langofdir)) // This may occurs when load is called without setting the language and without providing a value for forcelangdir
{
@ -432,19 +432,19 @@ class Translate
}
// TODO Move cache read out of loop on dirs or at least filelangexists
$found=false;
$found = false;
// Enable caching of lang file in memory (not by default)
$usecachekey='';
$usecachekey = '';
// Using a memcached server
if (! empty($conf->memcached->enabled) && ! empty($conf->global->MEMCACHED_SERVER))
if (!empty($conf->memcached->enabled) && !empty($conf->global->MEMCACHED_SERVER))
{
$usecachekey=$newdomain.'_'.$langofdir; // Should not contains special chars
$usecachekey = $newdomain.'_'.$langofdir; // Should not contains special chars
}
// Using cache with shmop. Speed gain: 40ms - Memory overusage: 200ko (Size of session cache file)
elseif (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_SPEED & 0x02))
{
$usecachekey=$newdomain;
$usecachekey = $newdomain;
}
if ($usecachekey)
@ -452,40 +452,40 @@ class Translate
//dol_syslog('Translate::Load we will cache result into usecachekey '.$usecachekey);
//global $aaa; $aaa+=1;
//print $aaa." ".$usecachekey."\n";
require_once DOL_DOCUMENT_ROOT .'/core/lib/memory.lib.php';
$tmparray=dol_getcache($usecachekey);
require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php';
$tmparray = dol_getcache($usecachekey);
if (is_array($tmparray) && count($tmparray))
{
$this->tab_translate+=$tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
$this->tab_translate += $tmparray; // Faster than array_merge($tmparray,$this->tab_translate). Note: If a valuer already exists into tab_translate, value into tmparaay is not added.
//print $newdomain."\n";
//var_dump($this->tab_translate);
$fileread=1;
$found=true; // Found in dolibarr PHP cache
$fileread = 1;
$found = true; // Found in dolibarr PHP cache
}
}
if (! $found && ! empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
if (!$found && !empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
{
// Overwrite translation with database read
$sql ="SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL";
$sql.=" AND entity IN (0, ".getEntity('overwrite_trans').")";
$sql.=$db->order("lang", "DESC");
$resql=$db->query($sql);
$sql = "SELECT transkey, transvalue FROM ".MAIN_DB_PREFIX."overwrite_trans where lang='".$db->escape($this->defaultlang)."' OR lang IS NULL";
$sql .= " AND entity IN (0, ".getEntity('overwrite_trans').")";
$sql .= $db->order("lang", "DESC");
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
if ($usecachekey) $tabtranslatedomain=array(); // To save lang content in cache
if ($usecachekey) $tabtranslatedomain = array(); // To save lang content in cache
$i = 0;
while ($i < $num) // Ex: Need 225ms for all fgets on all lang file for Third party page. Same speed than file_get_contents
{
$obj=$db->fetch_object($resql);
$obj = $db->fetch_object($resql);
$key=$obj->transkey;
$value=$obj->transvalue;
$key = $obj->transkey;
$value = $obj->transvalue;
//print "Domain=$domain, found a string for $tab[0] with value $tab[1]<br>";
if (empty($this->tab_translate[$key])) // If translation was already found, we must not continue, even if MAIN_FORCELANGDIR is set (MAIN_FORCELANGDIR is to replace lang dir, not to overwrite entries)
@ -493,22 +493,22 @@ class Translate
// Convert some strings: Parse and render carriage returns. Also, change '\\s' int '\s' because transifex sync pull the string '\s' into string '\\s'
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache
if ($usecachekey) $tabtranslatedomain[$key] = $value; // To save lang content in cache
}
$i++;
}
$fileread=1;
$fileread = 1;
// TODO Move cache write out of loop on dirs
// To save lang content for usecachekey into cache
if ($usecachekey && count($tabtranslatedomain))
{
$ressetcache=dol_setcache($usecachekey, $tabtranslatedomain);
$ressetcache = dol_setcache($usecachekey, $tabtranslatedomain);
if ($ressetcache < 0)
{
$error='Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
$error = 'Failed to set cache for usecachekey='.$usecachekey.' result='.$ressetcache;
dol_syslog($error, LOG_ERR);
}
}
@ -520,9 +520,9 @@ class Translate
}
}
if ($fileread) $this->_tab_loaded[$newdomain]=1; // Set domain file as loaded
if ($fileread) $this->_tab_loaded[$newdomain] = 1; // Set domain file as loaded
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain]=2; // Marque ce cas comme non trouve (no lines found for language)
if (empty($this->_tab_loaded[$newdomain])) $this->_tab_loaded[$newdomain] = 2; // Marque ce cas comme non trouve (no lines found for language)
return 1;
}
@ -544,28 +544,28 @@ class Translate
{
global $conf, $db;
if (! is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
if (!is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
$newstr=$key;
$newstr = $key;
if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
}
elseif (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_currencies', 'code_iso', 'label');
}
elseif (preg_match('/^SendingMethod([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_shipment_mode', 'code', 'libelle');
}
elseif (preg_match('/^PaymentTypeShort([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1);
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_paiement', 'code', 'libelle', '', 1);
}
elseif (preg_match('/^OppStatus([0-9A-Z]+)$/i', $key, $reg))
{
$newstr=$this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label');
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_lead_status', 'code', 'label');
}
elseif (preg_match('/^OrderSource([0-9A-Z]+)$/i', $key, $reg))
{
@ -601,37 +601,37 @@ class Translate
{
global $conf;
if (! empty($this->tab_translate[$key])) // Translation is available
if (!empty($this->tab_translate[$key])) // Translation is available
{
$str=$this->tab_translate[$key];
$str = $this->tab_translate[$key];
// Make some string replacement after translation
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
$replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
{
$tmparray=explode(';', $conf->global->$replacekey);
foreach($tmparray as $tmp)
$tmparray = explode(';', $conf->global->$replacekey);
foreach ($tmparray as $tmp)
{
$tmparray2=explode(':', $tmp);
$str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
$tmparray2 = explode(':', $tmp);
$str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
}
}
if (strpos($key, 'Format') !== 0)
{
$str=sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
$str = sprintf($str, $param1, $param2, $param3, $param4); // Replace %s and %d except for FormatXXX strings.
}
if ($maxsize) $str=dol_trunc($str, $maxsize);
if ($maxsize) $str = dol_trunc($str, $maxsize);
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities
$str=str_replace(array('<','>','"',), array('__lt__','__gt__','__quot__'), $str);
$str = str_replace(array('<', '>', '"',), array('__lt__', '__gt__', '__quot__'), $str);
// Crypt string into HTML
$str=htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
$str = htmlentities($str, ENT_COMPAT, $this->charset_output); // Do not convert simple quotes in translation (strings in html are enmbraced by "). Use dol_escape_htmltag around text in HTML content
// Restore HTML tags
$str=str_replace(array('__lt__','__gt__','__quot__'), array('<','>','"',), $str);
$str = str_replace(array('__lt__', '__gt__', '__quot__'), array('<', '>', '"',), $str);
return $str;
}
@ -682,26 +682,26 @@ class Translate
{
global $conf;
if (! empty($this->tab_translate[$key])) // Translation is available
if (!empty($this->tab_translate[$key])) // Translation is available
{
$str=$this->tab_translate[$key];
$str = $this->tab_translate[$key];
// Make some string replacement after translation
$replacekey='MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (! empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
$replacekey = 'MAIN_REPLACE_TRANS_'.$this->defaultlang;
if (!empty($conf->global->$replacekey)) // Replacement translation variable with string1:newstring1;string2:newstring2
{
$tmparray=explode(';', $conf->global->$replacekey);
foreach($tmparray as $tmp)
$tmparray = explode(';', $conf->global->$replacekey);
foreach ($tmparray as $tmp)
{
$tmparray2=explode(':', $tmp);
$str=preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
$tmparray2 = explode(':', $tmp);
$str = preg_replace('/'.preg_quote($tmparray2[0]).'/', $tmparray2[1], $str);
}
}
if (! preg_match('/^Format/', $key))
if (!preg_match('/^Format/', $key))
{
//print $str;
$str=sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
$str = sprintf($str, $param1, $param2, $param3, $param4, $param5); // Replace %s and %d except for FormatXXX strings.
}
return $str;
@ -751,8 +751,8 @@ class Translate
*/
public function convToOutputCharset($str, $pagecodefrom = 'UTF-8')
{
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str=utf8_encode($str);
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str=utf8_decode(str_replace('€', chr(128), $str));
if ($pagecodefrom == 'ISO-8859-1' && $this->charset_output == 'UTF-8') $str = utf8_encode($str);
if ($pagecodefrom == 'UTF-8' && $this->charset_output == 'ISO-8859-1') $str = utf8_decode(str_replace('€', chr(128), $str));
return $str;
}
@ -772,21 +772,21 @@ class Translate
global $conf;
// We scan directory langs to detect available languages
$handle=opendir($langdir."/langs");
$langs_available=array();
$handle = opendir($langdir."/langs");
$langs_available = array();
while ($dir = trim(readdir($handle)))
{
if (preg_match('/^[a-z]+_[A-Z]+/i', $dir))
{
$this->load("languages");
if (! empty($conf->global->MAIN_LANGUAGES_ALLOWED) && ! in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED)) ) continue;
if (!empty($conf->global->MAIN_LANGUAGES_ALLOWED) && !in_array($dir, explode(',', $conf->global->MAIN_LANGUAGES_ALLOWED))) continue;
if ($usecode == 2)
{
$langs_available[$dir] = $dir;
}
if ($usecode == 1 || ! empty($conf->global->MAIN_SHOW_LANGUAGE_CODE))
if ($usecode == 1 || !empty($conf->global->MAIN_SHOW_LANGUAGE_CODE))
{
$langs_available[$dir] = $dir.': '.dol_trunc($this->trans('Language_'.$dir), $maxlength);
}
@ -812,7 +812,7 @@ class Translate
{
// phpcs:enable
// Test si fichier dans repertoire de la langue
foreach($this->dir as $searchdir)
foreach ($this->dir as $searchdir)
{
if (is_readable(dol_osencode($searchdir."/langs/".$this->defaultlang."/".$filename))) return true;
@ -844,22 +844,22 @@ class Translate
{
global $conf;
$newnumber=$number;
$newnumber = $number;
$dirsubstitutions=array_merge(array(), $conf->modules_parts['substitutions']);
foreach($dirsubstitutions as $reldir)
$dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']);
foreach ($dirsubstitutions as $reldir)
{
$dir=dol_buildpath($reldir, 0);
$newdir=dol_osencode($dir);
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
// Check if directory exists
if (! is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded
if (!is_dir($newdir)) continue; // We must not use dol_is_dir here, function may not be loaded
$fonc='numberwords';
$fonc = 'numberwords';
if (file_exists($newdir.'/functions_'.$fonc.'.lib.php'))
{
include_once $newdir.'/functions_'.$fonc.'.lib.php';
$newnumber=numberwords_getLabelFromNumber($this, $number, $isamount);
$newnumber = numberwords_getLabelFromNumber($this, $number, $isamount);
break;
}
}
@ -891,36 +891,36 @@ class Translate
//print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
// Check if a translation is available (this can call getTradFromKey)
$tmp=$this->transnoentitiesnoconv($key);
$tmp = $this->transnoentitiesnoconv($key);
if ($tmp != $key && $tmp != 'ErrorBadValueForParamNotAString')
{
return $tmp; // Found in language array
return $tmp; // Found in language array
}
// Check in cache
if (isset($this->cache_labels[$tablename][$key])) // Can be defined to 0 or ''
{
return $this->cache_labels[$tablename][$key]; // Found in cache
return $this->cache_labels[$tablename][$key]; // Found in cache
}
$sql = "SELECT ".$fieldlabel." as label";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".$db->escape($keyforselect?$keyforselect:$key)."'";
if ($filteronentity) $sql.= " AND entity IN (" . getEntity($tablename). ')';
$sql .= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql .= " WHERE ".$fieldkey." = '".$db->escape($keyforselect ? $keyforselect : $key)."'";
if ($filteronentity) $sql .= " AND entity IN (".getEntity($tablename).')';
dol_syslog(get_class($this).'::getLabelFromKey', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
if ($obj) $this->cache_labels[$tablename][$key]=$obj->label;
else $this->cache_labels[$tablename][$key]=$key;
if ($obj) $this->cache_labels[$tablename][$key] = $obj->label;
else $this->cache_labels[$tablename][$key] = $key;
$db->free($resql);
return $this->cache_labels[$tablename][$key];
}
else
{
$this->error=$db->lasterror();
$this->error = $db->lasterror();
return -1;
}
}
@ -937,7 +937,7 @@ class Translate
*/
public function getCurrencyAmount($currency_code, $amount)
{
$symbol=$this->getCurrencySymbol($currency_code);
$symbol = $this->getCurrencySymbol($currency_code);
if (in_array($currency_code, array('USD'))) return $symbol.$amount;
else return $amount.$symbol;
@ -953,22 +953,22 @@ class Translate
*/
public function getCurrencySymbol($currency_code, $forceloadall = 0)
{
$currency_sign = ''; // By default return iso code
$currency_sign = ''; // By default return iso code
if (function_exists("mb_convert_encoding"))
{
$this->loadCacheCurrencies($forceloadall?'':$currency_code);
$this->loadCacheCurrencies($forceloadall ? '' : $currency_code);
if (isset($this->cache_currencies[$currency_code]) && ! empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
if (isset($this->cache_currencies[$currency_code]) && !empty($this->cache_currencies[$currency_code]['unicode']) && is_array($this->cache_currencies[$currency_code]['unicode']))
{
foreach($this->cache_currencies[$currency_code]['unicode'] as $unicode)
foreach ($this->cache_currencies[$currency_code]['unicode'] as $unicode)
{
$currency_sign .= mb_convert_encoding("&#{$unicode};", "UTF-8", 'HTML-ENTITIES');
}
}
}
return ($currency_sign?$currency_sign:$currency_code);
return ($currency_sign ? $currency_sign : $currency_code);
}
/**
@ -981,13 +981,13 @@ class Translate
{
global $db;
if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all
if (! empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency
if ($this->cache_currencies_all_loaded) return 0; // Cache already loaded for all
if (!empty($currency_code) && isset($this->cache_currencies[$currency_code])) return 0; // Cache already loaded for the currency
$sql = "SELECT code_iso, label, unicode";
$sql.= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql.= " WHERE active = 1";
if (! empty($currency_code)) $sql.=" AND code_iso = '".$db->escape($currency_code)."'";
$sql .= " FROM ".MAIN_DB_PREFIX."c_currencies";
$sql .= " WHERE active = 1";
if (!empty($currency_code)) $sql .= " AND code_iso = '".$db->escape($currency_code)."'";
//$sql.= " ORDER BY code_iso ASC"; // Not required, a sort is done later
dol_syslog(get_class($this).'::loadCacheCurrencies', LOG_DEBUG);
@ -995,8 +995,8 @@ class Translate
if ($resql)
{
$this->load("dict");
$label=array();
if (! empty($currency_code)) foreach($this->cache_currencies as $key => $val) $label[$key]=$val['label']; // Label in already loaded cache
$label = array();
if (!empty($currency_code)) foreach ($this->cache_currencies as $key => $val) $label[$key] = $val['label']; // Label in already loaded cache
$num = $db->num_rows($resql);
$i = 0;
@ -1005,12 +1005,12 @@ class Translate
$obj = $db->fetch_object($resql);
// Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso)!="Currency".$obj->code_iso?$this->trans("Currency".$obj->code_iso):($obj->label!='-'?$obj->label:''));
$this->cache_currencies[$obj->code_iso]['label'] = ($obj->code_iso && $this->trans("Currency".$obj->code_iso) != "Currency".$obj->code_iso ? $this->trans("Currency".$obj->code_iso) : ($obj->label != '-' ? $obj->label : ''));
$this->cache_currencies[$obj->code_iso]['unicode'] = (array) json_decode($obj->unicode, true);
$label[$obj->code_iso] = $this->cache_currencies[$obj->code_iso]['label'];
$i++;
}
if (empty($currency_code)) $this->cache_currencies_all_loaded=true;
if (empty($currency_code)) $this->cache_currencies_all_loaded = true;
//print count($label).' '.count($this->cache_currencies);
// Resort cache
@ -1037,7 +1037,7 @@ class Translate
// phpcs:enable
$substitutionarray = array();
foreach($this->tab_translate as $code => $label) {
foreach ($this->tab_translate as $code => $label) {
$substitutionarray['lang_'.$code] = $label;
$substitutionarray['__('.$code.')__'] = $label;
}

View File

@ -30,7 +30,7 @@
* \ingroup agenda
* \brief File of class to describe and enable/disable module Agenda
*/
include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php';
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
/**
* Class to describe and enable/disable module Agenda
@ -59,7 +59,7 @@ class modAgenda extends DolibarrModules
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
$this->picto='action';
$this->picto = 'action';
// Data directories to create when module is enabled
$this->dirs = array("/agenda/temp");
@ -68,12 +68,12 @@ class modAgenda extends DolibarrModules
$this->config_page_url = array("agenda_other.php");
// Dependencies
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->hidden = false; // A condition to hide module
$this->depends = array(); // List of module class names as string that must be enabled if this module is enabled
$this->requiredby = array(); // List of module ids to disable if this one is disabled
$this->conflictwith = array(); // List of module class names as string this module is in conflict with
$this->langfiles = array("companies");
$this->phpmin = array(5,4); // Minimum version of PHP required by module
$this->phpmin = array(5, 4); // Minimum version of PHP required by module
// Module parts
$this->module_parts = array();
@ -86,14 +86,14 @@ class modAgenda extends DolibarrModules
// );
$this->const = array();
//$this->const[] = array('AGENDA_DEFAULT_FILTER_TYPE', 'chaine', 'AC_NON_AUTO', 'Default filter for type of event on agenda', 0, 'current');
$sqlreadactions="SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
$sqlreadactions = "SELECT code, label, description FROM ".MAIN_DB_PREFIX."c_action_trigger ORDER by rang";
$resql = $this->db->query($sqlreadactions);
if ($resql)
{
while ($obj = $this->db->fetch_object($resql))
{
//if (preg_match('/_CREATE$/',$obj->code) && (! in_array($obj->code, array('COMPANY_CREATE','PRODUCT_CREATE','TASK_CREATE')))) continue; // We don't track such events (*_CREATE) by default, we prefer validation (except thirdparty/product/task creation because there is no validation).
if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.
if (preg_match('/^TASK_/', $obj->code)) continue; // We don't track such events by default.
//if (preg_match('/^_MODIFY/',$obj->code)) continue; // We don't track such events by default.
$this->const[] = array('MAIN_AGENDA_ACTIONAUTO_'.$obj->code, "chaine", "1", '', 0, 'current');
}
@ -109,11 +109,11 @@ class modAgenda extends DolibarrModules
// Boxes
//------
$this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home'));
$this->boxes = array(0=>array('file'=>'box_actions.php', 'enabledbydefaulton'=>'Home'));
// Cronjobs
//------------
$datestart=dol_now();
$datestart = dol_now();
$this->cronjobs = array(
0=>array('label'=>'SendEmailsReminders', 'jobtype'=>'method', 'class'=>'comm/action/class/actioncomm.class.php', 'objectname'=>'ActionComm', 'method'=>'sendEmailsReminder', 'parameters'=>'', 'comment'=>'SendEMailsReminder', 'frequency'=>10, 'unitfrequency'=>60, 'priority'=>10, 'status'=>1, 'test'=>'$conf->agenda->enabled', 'datestart'=>$datestart),
);
@ -122,7 +122,7 @@ class modAgenda extends DolibarrModules
//------------
$this->rights = array();
$this->rights_class = 'agenda';
$r=0;
$r = 0;
// $this->rights[$r][0] Id permission (unique tous modules confondus)
// $this->rights[$r][1] Libelle par defaut si traduction de cle "PermissionXXX" non trouvee (XXX = Id permission)
@ -187,8 +187,8 @@ class modAgenda extends DolibarrModules
$this->rights[$r][4] = 'export';
// Main menu entries
$this->menu = array(); // List of menus to add
$r=0;
$this->menu = array(); // List of menus to add
$r = 0;
// Add here entries to declare new menus
// Example to declare the Top Menu entry:
@ -204,7 +204,7 @@ class modAgenda extends DolibarrModules
// 'target'=>'',
// 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both
// $r++;
$this->menu[$r]=array(
$this->menu[$r] = array(
'fk_menu'=>0,
'type'=>'top',
'titre'=>'TMenuAgenda',
@ -424,50 +424,50 @@ class modAgenda extends DolibarrModules
// Exports
//--------
$r=0;
$r = 0;
$r++;
$this->export_code[$r]=$this->rights_class.'_'.$r;
$this->export_label[$r]="ExportDataset_event1";
$this->export_permission[$r]=array(array("agenda","export"));
$this->export_fields_array[$r]=array('ac.id'=>"IdAgenda",'ac.ref_ext'=>"ExternalRef",'ac.datec'=>"DateCreation",'ac.datep'=>"DateActionBegin",
'ac.datep2'=>"DateActionEnd",'ac.label'=>"Title",'ac.note'=>"Note",'ac.percent'=>"Percent",'ac.durationp'=>"Duration",
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "ExportDataset_event1";
$this->export_permission[$r] = array(array("agenda", "export"));
$this->export_fields_array[$r] = array('ac.id'=>"IdAgenda", 'ac.ref_ext'=>"ExternalRef", 'ac.datec'=>"DateCreation", 'ac.datep'=>"DateActionBegin",
'ac.datep2'=>"DateActionEnd", 'ac.label'=>"Title", 'ac.note'=>"Note", 'ac.percent'=>"Percent", 'ac.durationp'=>"Duration",
'cac.libelle'=>"ActionType",
's.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town',
'co.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6',
's.code_compta'=>'CustomerAccountancyCode','s.code_compta_fournisseur'=>'SupplierAccountancyCode','s.tva_intra'=>'VATIntra',
's.rowid'=>"IdCompany", 's.nom'=>'CompanyName', 's.address'=>'Address', 's.zip'=>'Zip', 's.town'=>'Town',
'co.code'=>'CountryCode', 's.phone'=>'Phone', 's.siren'=>'ProfId1', 's.siret'=>'ProfId2', 's.ape'=>'ProfId3', 's.idprof4'=>'ProfId4', 's.idprof5'=>'ProfId5', 's.idprof6'=>'ProfId6',
's.code_compta'=>'CustomerAccountancyCode', 's.code_compta_fournisseur'=>'SupplierAccountancyCode', 's.tva_intra'=>'VATIntra',
'p.ref' => 'ProjectRef',
);
$this->export_TypeFields_array[$r]=array('ac.ref_ext'=>"Text",'ac.datec'=>"Date",'ac.datep'=>"Date",
'ac.datep2'=>"Date",'ac.label'=>"Text",'ac.note'=>"Text",'ac.percent'=>"Numeric",
$this->export_TypeFields_array[$r] = array('ac.ref_ext'=>"Text", 'ac.datec'=>"Date", 'ac.datep'=>"Date",
'ac.datep2'=>"Date", 'ac.label'=>"Text", 'ac.note'=>"Text", 'ac.percent'=>"Numeric",
'ac.durationp'=>"Duree",
'cac.libelle'=>"List:c_actioncomm:libelle:libelle",
's.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text',
'co.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text',
's.code_compta'=>'Text','s.code_compta_fournisseur'=>'Text','s.tva_intra'=>'Text',
's.nom'=>'Text', 's.address'=>'Text', 's.zip'=>'Text', 's.town'=>'Text',
'co.code'=>'Text', 's.phone'=>'Text', 's.siren'=>'Text', 's.siret'=>'Text', 's.ape'=>'Text', 's.idprof4'=>'Text', 's.idprof5'=>'Text', 's.idprof6'=>'Text',
's.code_compta'=>'Text', 's.code_compta_fournisseur'=>'Text', 's.tva_intra'=>'Text',
'p.ref' => 'Text',
);
$this->export_entities_array[$r]=array('ac.id'=>"action",'ac.ref_ext'=>"action",'ac.datec'=>"action",'ac.datep'=>"action",
'ac.datep2'=>"action",'ac.label'=>"action",'ac.note'=>"action",'ac.percent'=>"action",'ac.durationp'=>"action",
$this->export_entities_array[$r] = array('ac.id'=>"action", 'ac.ref_ext'=>"action", 'ac.datec'=>"action", 'ac.datep'=>"action",
'ac.datep2'=>"action", 'ac.label'=>"action", 'ac.note'=>"action", 'ac.percent'=>"action", 'ac.durationp'=>"action",
'cac.libelle'=>"action",
's.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company',
'co.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company',
's.code_compta'=>'company','s.code_compta_fournisseur'=>'company','s.tva_intra'=>'company',
's.rowid'=>"company", 's.nom'=>'company', 's.address'=>'company', 's.zip'=>'company', 's.town'=>'company',
'co.code'=>'company', 's.phone'=>'company', 's.siren'=>'company', 's.siret'=>'company', 's.ape'=>'company', 's.idprof4'=>'company', 's.idprof5'=>'company', 's.idprof6'=>'company',
's.code_compta'=>'company', 's.code_compta_fournisseur'=>'company', 's.tva_intra'=>'company',
'p.ref' => 'project',
);
$this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
if (! empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
if (! empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet as p ON p.rowid = ac.fk_project";
$this->export_sql_end[$r] .=' WHERE ac.entity IN ('.getEntity('agenda').')';
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .=' AND (sc.fk_user = '.(empty($user)?0:$user->id).' OR ac.fk_soc IS NULL)';
if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .=' AND acr.fk_element = '.(empty($user)?0:$user->id);
$this->export_sql_order[$r] =' ORDER BY ac.datep';
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'actioncomm as ac';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_actioncomm as cac on ac.fk_action = cac.id';
if (!empty($user) && empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'actioncomm_resources acr on ac.id = acr.fk_actioncomm';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'socpeople as sp on ac.fk_contact = sp.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s on ac.fk_soc = s.rowid';
if (!empty($user) && empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as co on s.fk_pays = co.rowid';
$this->export_sql_end[$r] .= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = ac.fk_project";
$this->export_sql_end[$r] .= ' WHERE ac.entity IN ('.getEntity('agenda').')';
if (empty($user->rights->societe->client->voir)) $this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR ac.fk_soc IS NULL)';
if (empty($user->rights->agenda->allactions->read)) $this->export_sql_end[$r] .= ' AND acr.fk_element = '.(empty($user) ? 0 : $user->id);
$this->export_sql_order[$r] = ' ORDER BY ac.datep';
}
}

View File

@ -28,14 +28,14 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
// Load translation files required by the page
$langs->loadLangs(array("loan","compta","banks","bills"));
$langs->loadLangs(array("loan", "compta", "banks", "bills"));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) $socid=$user->socid;
if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'loan', '', '', '');
$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'alpha');
$sortorder = GETPOST('sortorder', 'alpha');
$page = GETPOST('page', 'int');
@ -144,18 +144,18 @@ if ($resql)
{
$i = 0;
$param='';
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
if ($search_ref) $param.="&search_ref=".urlencode($search_ref);
if ($search_label) $param.="&search_label=".urlencode($search_label);
if ($search_amount) $param.="&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
$param = '';
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
if ($search_ref) $param .= "&search_ref=".urlencode($search_ref);
if ($search_label) $param .= "&search_label=".urlencode($search_label);
if ($search_amount) $param .= "&search_amount=".urlencode($search_amount);
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
$newcardbutton='';
$newcardbutton = '';
if ($user->rights->loan->write)
{
$newcardbutton.= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create');
$newcardbutton .= dolGetButtonTitle($langs->trans('NewLoan'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/loan/card.php?action=create');
}
print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";

View File

@ -436,14 +436,14 @@ class WebsitePage extends CommonObject
$object = new self($this->db);
// Clean parameters
if (empty($newref) && ! empty($newtitle)) {
$newref=strtolower(dol_sanitizeFileName(preg_replace('/\s+/', '-', $newtitle), '-', 1));
if (empty($newref) && !empty($newtitle)) {
$newref = strtolower(dol_sanitizeFileName(preg_replace('/\s+/', '-', $newtitle), '-', 1));
}
// Check parameters
if (empty($newref)) {
$langs->load("errors");
$this->error=$langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE"));
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("WEBSITE_TITLE"));
return -1;
}