Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .tx/class/autotranslator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*/
class AutoTranslator
{
private $translatedFiles = array();
private $translatedFiles = [];
private $destlang = '';
private $refLang = '';
private $langDir = '';
Expand Down Expand Up @@ -88,9 +88,9 @@ private function parseRefLangTranslationFiles()
print "Processing file " . $file . ", with " . count($fileContent) . " lines<br>\n";

// Define target dirs
$targetlangs = array($this->destlang);
$targetlangs = [$this->destlang];
if ($this->destlang == 'all') {
$targetlangs = array();
$targetlangs = [];

// If we must process all languages
$arraytmp = dol_dir_list($this->langDir, 'directories', 0);
Expand Down Expand Up @@ -130,7 +130,7 @@ private function parseRefLangTranslationFiles()

// Process translation of source file for each target languages
foreach ($targetlangs as $my_destlang) {
$this->translatedFiles = array();
$this->translatedFiles = [];

$destPath = $this->langDir . $my_destlang . self::DIR_SEPARATOR . $file;
// Check destination file presence
Expand Down Expand Up @@ -238,9 +238,9 @@ private function translateFileLine($content, $file, $key, $value, $my_destlang)
} else {
// If not translated then translate
if ($this->outputpagecode == 'UTF-8') {
$val = $this->translateTexts(array($value), substr($this->refLang, 0, 2), substr($my_destlang, 0, 2));
$val = $this->translateTexts([$value], substr($this->refLang, 0, 2), substr($my_destlang, 0, 2));
} else {
$val = utf8_decode($this->translateTexts(array($value), substr($this->refLang, 0, 2), substr($my_destlang, 0, 2)));
$val = utf8_decode($this->translateTexts([$value], substr($this->refLang, 0, 2), substr($my_destlang, 0, 2)));
}
}

Expand Down
50 changes: 25 additions & 25 deletions .tx/class/translate.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class Translate
public $shortlang; // Short 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 of all translations key=>value
private $tab_loaded = []; // 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
public $cache_labels = []; // Cache for labels return by getLabelFromKey method
public $cache_currencies = []; // Cache to store currency symbols
private $cache_currencies_all_loaded = false;

/**
Expand All @@ -49,7 +49,7 @@ class Translate
*/
public function __construct($dir)
{
$this->dir = array($dir);
$this->dir = [$dir];
}


Expand Down Expand Up @@ -80,13 +80,13 @@ public function setDefaultLang($srclang = 'en_US')
//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
// Array force long code from first part, even if long code is defined
$longforshort = array('ar' => 'ar_SA');
$longforshortexcep = array('ar_EG');
$longforshort = ['ar' => 'ar_SA'];
$longforshortexcep = ['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');
$longforlong = ['no_nb' => 'nb_NO'];
if (isset($longforlong[strtolower($srclang)])) {
$srclang = $longforlong[strtolower($srclang)];
}
Expand All @@ -95,12 +95,12 @@ public function setDefaultLang($srclang = 'en_US')
}
} else { // If it's for a codetouse that is a short code xx
// Array to convert short lang code into long code.
$longforshort = array(
$longforshort = [
'am' => 'am_ET', 'ar' => 'ar_SA', 'bn' => 'bn_DB', 'el' => 'el_GR', 'ca' => 'ca_ES', 'cs' => 'cs_CZ', 'en' => 'en_US', 'fa' => 'fa_IR',
'gl' => 'gl_ES', 'he' => 'he_IL', 'hi' => 'hi_IN', 'ja' => 'ja_JP',
'ka' => 'ka_GE', 'km' => 'km_KH', 'kn' => 'kn_IN', 'ko' => 'ko_KR', 'lo' => 'lo_LA', 'nb' => 'nb_NO', 'no' => 'nb_NO', 'ne' => 'ne_NP',
'sl' => 'sl_SI', 'sq' => 'sq_AL', 'sr' => 'sr_RS', 'sv' => 'sv_SE', 'uk' => 'uk_UA', 'vi' => 'vi_VN', 'zh' => 'zh_CN'
);
];
if (isset($longforshort[strtolower($langpart[0])])) {
$srclang = $longforshort[strtolower($langpart[0])];
} elseif (!empty($langpart[0])) {
Expand Down Expand Up @@ -185,7 +185,7 @@ public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir =
$modulename = '';

// Search if a module directory name is provided into lang file name
$regs = array();
$regs = [];
if (preg_match('/^([^@]+)@([^@]+)$/i', $domain, $regs)) {
$newdomain = $regs[1];
$modulename = $regs[2];
Expand All @@ -204,7 +204,7 @@ public function load($domain, $alt = 0, $stopafterdirection = 0, $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')))) {
if ($alt < 1 && isset($langarray[1]) && (strtolower($langarray[0]) == strtolower($langarray[1]) || in_array(strtolower($langofdir), ['el_gr']))) {
$alt = 1;
}
if ($alt < 2 && strtolower($langofdir) == 'en_us') {
Expand Down Expand Up @@ -255,7 +255,7 @@ public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir =
continue;
} else {
// Convert some strings: Parse and render carriage returns. Also, change '\\s' into '\s' because transifex sync pull the string '\s' into string '\\s'
$this->tab_translate[$key] = str_replace(array('\\n', '\\\\s'), array("\n", '\s'), $value);
$this->tab_translate[$key] = str_replace(['\\n', '\\\\s'], ["\n", '\s'], $value);
}
}
}
Expand Down Expand Up @@ -359,7 +359,7 @@ private function getTradFromKey($key)
}

$newstr = $key;
$reg = array();
$reg = [];
if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg)) {
$newstr = $this->getLabelFromKey($db, $reg[1], 'c_civility', 'code', 'label');
} elseif (preg_match('/^Currency([A-Z][A-Z][A-Z])$/i', $key, $reg)) {
Expand Down Expand Up @@ -412,8 +412,8 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 =
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities because
// we want to keep '"' '<b>' '</b>' '<strong' '</strong>' '<a ' '</a>' '<br>' '< ' '<span' '</span>' that are reliable HTML tags inside translation strings.
$str = str_replace(
array('"', '<b>', '</b>', '<u>', '</u>', '<i', '</i>', '<center>', '</center>', '<strong>', '</strong>', '<a ', '</a>', '<br>', '<span', '</span>', '< ', '>'), // We accept '< ' but not '<'. We can accept however '>'
array('__quot__', '__tagb__', '__tagbend__', '__tagu__', '__taguend__', '__tagi__', '__tagiend__', '__tagcenter__', '__tagcenterend__', '__tagb__', '__tagbend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__ltspace__', '__gt__'),
['"', '<b>', '</b>', '<u>', '</u>', '<i', '</i>', '<center>', '</center>', '<strong>', '</strong>', '<a ', '</a>', '<br>', '<span', '</span>', '< ', '>'], // We accept '< ' but not '<'. We can accept however '>'
['__quot__', '__tagb__', '__tagbend__', '__tagu__', '__taguend__', '__tagi__', '__tagiend__', '__tagcenter__', '__tagcenterend__', '__tagb__', '__tagbend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__ltspace__', '__gt__'],
$str
);

Expand All @@ -426,8 +426,8 @@ public function trans($key, $param1 = '', $param2 = '', $param3 = '', $param4 =

// Restore reliable HTML tags into original translation string
$str = str_replace(
array('__quot__', '__tagb__', '__tagbend__', '__tagu__', '__taguend__', '__tagi__', '__tagiend__', '__tagcenter__', '__tagcenterend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__ltspace__', '__gt__'),
array('"', '<b>', '</b>', '<u>', '</u>', '<i', '</i>', '<center>', '</center>', '<a ', '</a>', '<br>', '<span', '</span>', '< ', '>'),
['__quot__', '__tagb__', '__tagbend__', '__tagu__', '__taguend__', '__tagi__', '__tagiend__', '__tagcenter__', '__tagcenterend__', '__taga__', '__tagaend__', '__tagbr__', '__tagspan__', '__tagspanend__', '__ltspace__', '__gt__'],
['"', '<b>', '</b>', '<u>', '</u>', '<i', '</i>', '<center>', '</center>', '<a ', '</a>', '<br>', '<span', '</span>', '< ', '>'],
$str
);

Expand Down Expand Up @@ -584,13 +584,13 @@ public function getAvailableLanguages($langdir = DOL_DOCUMENT_ROOT, $maxlength =

// We scan directory langs to detect available languages
$handle = opendir($langdir . "/langs");
$langs_available = array();
$langs_available = [];
while ($dir = trim(readdir($handle))) {
$regs = array();
$regs = [];
if (preg_match('/^([a-z]+)_([A-Z]+)/i', $dir, $regs)) {
// We must keep only main languages
if ($mainlangonly) {
$arrayofspecialmainlanguages = array(
$arrayofspecialmainlanguages = [
'en' => 'en_US',
'am' => 'am_ET',
'ar' => 'ar_SA',
Expand Down Expand Up @@ -619,7 +619,7 @@ public function getAvailableLanguages($langdir = DOL_DOCUMENT_ROOT, $maxlength =
'uk' => 'uk_UA',
'vi' => 'vi_VN',
'zh' => 'zh_CN'
);
];
if (strtolower($regs[1]) != strtolower($regs[2]) && !in_array($dir, $arrayofspecialmainlanguages)) {
continue;
}
Expand Down Expand Up @@ -697,7 +697,7 @@ public function getLabelFromNumber($number, $isamount = '')

$newnumber = $number;

$dirsubstitutions = array_merge(array(), $conf->modules_parts['substitutions']);
$dirsubstitutions = array_merge([], $conf->modules_parts['substitutions']);
foreach ($dirsubstitutions as $reldir) {
$dir = dol_buildpath($reldir, 0);
$newdir = dol_osencode($dir);
Expand Down Expand Up @@ -798,7 +798,7 @@ public function getCurrencyAmount($currency_code, $amount)
{
$symbol = $this->getCurrencySymbol($currency_code);

if (in_array($currency_code, array('USD'))) {
if (in_array($currency_code, ['USD'])) {
return $symbol . $amount;
} else {
return $amount . $symbol;
Expand Down Expand Up @@ -859,7 +859,7 @@ public function loadCacheCurrencies($currency_code)
$resql = $db->query($sql);
if ($resql) {
$this->load("dict");
$label = array();
$label = [];
if (!empty($currency_code)) {
foreach ($this->cache_currencies as $key => $val) {
$label[$key] = $val['label']; // Label in already loaded cache
Expand Down
9 changes: 0 additions & 9 deletions .tx/config

This file was deleted.

6 changes: 3 additions & 3 deletions admin/oauthlogintokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
use League\OAuth2\Client\Provider\GoogleUser;

// Load translation files required by the page
$langs->loadLangs(array('admin', 'oauth', 'googleapi@googleapi'));
$langs->loadLangs(["errors","admin","googleapi@googleapi"]);

if (!$user->admin) {
accessforbidden();
Expand All @@ -46,12 +46,12 @@
$value = GETPOST('value', 'alpha');
$varname = GETPOST('varname', 'alpha');

$key = array(
$key = [
'OAUTH_GOOGLEAPI_NAME',
'OAUTH_GOOGLEAPI_ID',
'OAUTH_GOOGLEAPI_SECRET',
'OAUTH_GOOGLEAPI_DESC',
);
];


/*
Expand Down
32 changes: 16 additions & 16 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use Cache\Adapter\Filesystem\FilesystemCachePool;

// Translations
$langs->loadLangs(array("admin", 'oauth', "googleapi@googleapi"));
$langs->loadLangs(["errors","admin","googleapi@googleapi"]);

// Access control
if (! $user->admin) {
Expand All @@ -56,35 +56,35 @@
$urlwithroot = $urlwithouturlroot . DOL_URL_ROOT;
//$urlwithroot = DOL_MAIN_URL_ROOT; // This is to use same domain name than current

$arrayofparameters = array(
'OAUTH_GOOGLEAPI_ID' => array(
$arrayofparameters = [
'OAUTH_GOOGLEAPI_ID' => [
'css' => 'minwidth500',
'type' => 'text',
'enabled' => 1,
),
'OAUTH_GOOGLEAPI_SECRET' => array(
],
'OAUTH_GOOGLEAPI_SECRET' => [
'css' => 'minwidth500',
'type' => 'password',
'enabled' => 1,
),
'OAUTH_GOOGLEAPI_URI' => array(
],
'OAUTH_GOOGLEAPI_URI' => [
'css' => 'minwidth500',
'default' => $urlwithroot . dol_buildpath('/googleapi/core/modules/oauth/googleapi_oauthcallback.php', 1),
),
// 'GOOGLEAPI_MYPARAM1' => array(
],
// 'GOOGLEAPI_MYPARAM1' => [
// 'css' => 'minwidth500',
// 'type' => 'text',
// 'enabled' => 1,
// ),
// 'GOOGLEAPI_MYPARAM2' => array(
// ],
// 'GOOGLEAPI_MYPARAM2' => [
// 'css' => 'minwidth500',
// 'type' => 'text',
// 'enabled' => 1,
// )
);
// ],
];

// Paramètres ON/OFF GOOGLEAPI_ est rajouté au paramètre
$modules = array(
$modules = [
'GOOGLEAPI_ENABLE_PUSH_ME_EVENTS' => 'GoogleApiEnablePushMeEvents',
'GOOGLEAPI_ENABLE_PUSH_ME_MESSAGES' => 'GoogleApiEnablePushMeMessages',
'GOOGLEAPI_ENABLE_PUSH_ME_CONTACTS' => 'GoogleApiEnablePushMeContacts',
Expand All @@ -93,7 +93,7 @@
'GOOGLEAPI_ENABLE_DEVELOPPER_MODE' => 'GoogleApiEnableDevelopperMode',
// tweak dolibarr
'CHECKLASTVERSION_EXTERNALMODULE' => 'CHECKLASTVERSION_EXTERNALMODULE',
);
];

/*
* Actions
Expand Down Expand Up @@ -236,7 +236,7 @@
print '<br>' . PHP_EOL;
}

dol_fiche_end();
print dol_get_fiche_end();

// TESTS

Expand Down
10 changes: 7 additions & 3 deletions class/actions_googleapi.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class ActionsGoogleApi
*/
public $errors = [];

/**
* @var array Warnings
*/
public $warnings = [];

/**
* @var array Hook results. Propagated to $hookmanager->resArray for later reuse
Expand Down Expand Up @@ -282,7 +286,7 @@ public function sendMail($parameters, $object, &$action, $hookmanager)
// what TODO with context 'emailing'
// context notification?
// https://developers.google.com/resources/api-libraries/documentation/gmail/v1/php/latest/class-Google_Service_Gmail_Message.html
if (in_array('mail', $contexts) && !in_array($object->sendcontext, array('emailing', 'notification'))) {
if (in_array('mail', $contexts) && !in_array($object->sendcontext, ['emailing', 'notification'])) {
dol_include_once('/googleapi/lib/googleapi.lib.php');
$fromsender = $this->getArrayAddress($object->addr_from);
if (!empty($user->array_options['options_googleapi_email']) && $fromsender[0]['address'] == $user->array_options['options_googleapi_email']) {
Expand Down Expand Up @@ -475,10 +479,10 @@ private function getArrayAddress($address)
$name = null;
$email = trim($val);
}
$ret[] = array(
$ret[] = [
'name' => empty($conf->global->MAIN_MAIL_NO_FULL_EMAIL) ? $name : null,
'address' => $email,
);
];
}
}

Expand Down
Loading
Loading