Merge pull request #22120 from frederic34/multilangs

fix php8 warnings
This commit is contained in:
Laurent Destailleur 2022-09-07 12:26:53 +02:00 committed by GitHub
commit 157f5d4e01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 16 deletions

View File

@ -722,7 +722,7 @@ if (empty($reshook)) {
$ret = $deposit->fetch($deposit->id); // Reload to get new records $ret = $deposit->fetch($deposit->id); // Reload to get new records
$outputlangs = $langs; $outputlangs = $langs;
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$outputlangs = new Translate('', $conf); $outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang($deposit->thirdparty->default_lang); $outputlangs->setDefaultLang($deposit->thirdparty->default_lang);
$outputlangs->load('products'); $outputlangs->load('products');

View File

@ -793,7 +793,7 @@ class pdf_azur extends ModelePDFPropales
// Find the desire PDF // Find the desire PDF
$filetomerge = new Propalmergepdfproduct($this->db); $filetomerge = new Propalmergepdfproduct($this->db);
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang); $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
} else { } else {
$filetomerge->fetch_by_product($line->fk_product); $filetomerge->fetch_by_product($line->fk_product);

View File

@ -918,7 +918,7 @@ class pdf_cyan extends ModelePDFPropales
// Find the desire PDF // Find the desire PDF
$filetomerge = new Propalmergepdfproduct($this->db); $filetomerge = new Propalmergepdfproduct($this->db);
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang); $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
} else { } else {
$filetomerge->fetch_by_product($line->fk_product); $filetomerge->fetch_by_product($line->fk_product);

View File

@ -106,7 +106,7 @@ print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?l='.$l.'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="setvalue">'; print '<input type="hidden" name="action" value="setvalue">';
print '<table>'; print '<table>';
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', null, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n"; print '<tr><td>'.$form->editfieldkey('DefaultLang', 'default_lang', '', null, 0).'</td><td colspan="3" class="maxwidthonsmartphone">'."\n";
print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone'); print $formadmin->select_language((GETPOST('l') ? GETPOST('l') : $langs->defaultlang), 'default_lang', 0, 0, 1, 0, 0, 'maxwidth200onsmartphone');
print '</tr>'; print '</tr>';

View File

@ -107,7 +107,7 @@ class Propalmergepdfproduct extends CommonObject
$sql = "INSERT INTO ".$this->db->prefix()."propal_merge_pdf_product("; $sql = "INSERT INTO ".$this->db->prefix()."propal_merge_pdf_product(";
$sql .= "fk_product,"; $sql .= "fk_product,";
$sql .= "file_name,"; $sql .= "file_name,";
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$sql .= "lang,"; $sql .= "lang,";
} }
$sql .= "fk_user_author,"; $sql .= "fk_user_author,";
@ -116,7 +116,7 @@ class Propalmergepdfproduct extends CommonObject
$sql .= ") VALUES ("; $sql .= ") VALUES (";
$sql .= " ".(!isset($this->fk_product) ? 'NULL' : ((int) $this->fk_product)).","; $sql .= " ".(!isset($this->fk_product) ? 'NULL' : ((int) $this->fk_product)).",";
$sql .= " ".(!isset($this->file_name) ? 'NULL' : "'".$this->db->escape($this->file_name)."'").","; $sql .= " ".(!isset($this->file_name) ? 'NULL' : "'".$this->db->escape($this->file_name)."'").",";
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$sql .= " ".(!isset($this->lang) ? 'NULL' : "'".$this->db->escape($this->lang)."'").","; $sql .= " ".(!isset($this->lang) ? 'NULL' : "'".$this->db->escape($this->lang)."'").",";
} }
$sql .= " ".((int) $user->id).","; $sql .= " ".((int) $user->id).",";
@ -186,7 +186,7 @@ class Propalmergepdfproduct extends CommonObject
$this->fk_product = $obj->fk_product; $this->fk_product = $obj->fk_product;
$this->file_name = $obj->file_name; $this->file_name = $obj->file_name;
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$this->lang = $obj->lang; $this->lang = $obj->lang;
} }
$this->fk_user_author = $obj->fk_user_author; $this->fk_user_author = $obj->fk_user_author;
@ -311,7 +311,7 @@ class Propalmergepdfproduct extends CommonObject
$sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").","; $sql .= " fk_product=".(isset($this->fk_product) ? $this->fk_product : "null").",";
$sql .= " file_name=".(isset($this->file_name) ? "'".$this->db->escape($this->file_name)."'" : "null").","; $sql .= " file_name=".(isset($this->file_name) ? "'".$this->db->escape($this->file_name)."'" : "null").",";
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$sql .= " lang=".(isset($this->lang) ? "'".$this->db->escape($this->lang)."'" : "null").","; $sql .= " lang=".(isset($this->lang) ? "'".$this->db->escape($this->lang)."'" : "null").",";
} }
$sql .= " fk_user_mod=".$user->id; $sql .= " fk_user_mod=".$user->id;

View File

@ -154,14 +154,14 @@ if ($action == 'filemerge' && $permissiontoadd) {
$filetomerge_file_array = GETPOST('filetoadd'); $filetomerge_file_array = GETPOST('filetoadd');
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$lang_id = GETPOST('lang_id', 'aZ09'); $lang_id = GETPOST('lang_id', 'aZ09');
} }
// Delete all file already associated // Delete all file already associated
$filetomerge = new Propalmergepdfproduct($db); $filetomerge = new Propalmergepdfproduct($db);
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$result = $filetomerge->delete_by_product($user, $object->id, $lang_id); $result = $filetomerge->delete_by_product($user, $object->id, $lang_id);
} else { } else {
$result = $filetomerge->delete_by_product($user, $object->id); $result = $filetomerge->delete_by_product($user, $object->id);
@ -176,7 +176,7 @@ if ($action == 'filemerge' && $permissiontoadd) {
$filetomerge->fk_product = $object->id; $filetomerge->fk_product = $object->id;
$filetomerge->file_name = $filetomerge_file; $filetomerge->file_name = $filetomerge_file;
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$filetomerge->lang = $lang_id; $filetomerge->lang = $lang_id;
} }
@ -271,7 +271,7 @@ if ($object->id) {
if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) { if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {
$filetomerge = new Propalmergepdfproduct($db); $filetomerge = new Propalmergepdfproduct($db);
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$lang_id = GETPOST('lang_id', 'aZ09'); $lang_id = GETPOST('lang_id', 'aZ09');
$result = $filetomerge->fetch_by_product($object->id, $lang_id); $result = $filetomerge->fetch_by_product($object->id, $lang_id);
} else { } else {
@ -305,7 +305,7 @@ if ($object->id) {
print '<table class="noborder">'; print '<table class="noborder">';
// Get language // Get language
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
$langs->load("languages"); $langs->load("languages");
print '<tr class="liste_titre"><td>'; print '<tr class="liste_titre"><td>';
@ -316,7 +316,7 @@ if ($object->id) {
print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC'); print Form::selectarray('lang_id', $langs_available, $default_lang, 0, 0, 0, '', 0, 0, 0, 'ASC');
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
print '<input type="submit" class="button" name="refresh" value="'.$langs->trans('Refresh').'">'; print '<input type="submit" class="button" name="refresh" value="'.$langs->trans('Refresh').'">';
} }
@ -328,7 +328,7 @@ if ($object->id) {
$checked = ''; $checked = '';
$filename = $filetoadd['name']; $filename = $filetoadd['name'];
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) { if (array_key_exists($filetoadd['name'].'_'.$default_lang, $filetomerge->lines)) {
$filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang); $filename = $filetoadd['name'].' - '.$langs->trans('Language_'.$default_lang);
$checked = ' checked '; $checked = ' checked ';

View File

@ -1467,7 +1467,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
$allowgenifempty = 0; $allowgenifempty = 0;
// Language code (if multilang) // Language code (if multilang)
if ($conf->global->MAIN_MULTILANGS) { if (!empty($conf->global->MAIN_MULTILANGS)) {
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
$formadmin = new FormAdmin($db); $formadmin = new FormAdmin($db);
$defaultlang = $langs->getDefaultLang(); $defaultlang = $langs->getDefaultLang();