Fixing style errors.

This commit is contained in:
stickler-ci 2022-09-27 17:31:22 +00:00
parent b4881e629b
commit 310f95f173

View File

@ -118,67 +118,67 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
// Remove to check file size to large
/*if ($_FILES[$varforimage]["tmp_name"]) {*/
$reg = array();
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
$original_file = $reg[1];
if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) {
$original_file = $reg[1];
$isimage = image_format_supported($original_file);
if ($isimage >= 0) {
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (!is_dir($dirforimage)) {
dol_mkdir($dirforimage);
$isimage = image_format_supported($original_file);
if ($isimage >= 0) {
dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file);
if (!is_dir($dirforimage)) {
dol_mkdir($dirforimage);
}
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0) {
$constant = "MAIN_INFO_SOCIETE_LOGO";
if ($varforimage == 'logo_squarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
$result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']);
if ($result > 0) {
$constant = "MAIN_INFO_SOCIETE_LOGO";
if ($varforimage == 'logo_squarred') {
$constant = "MAIN_INFO_SOCIETE_LOGO_SQUARRED";
}
dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
dolibarr_set_const($db, $constant, $original_file, 'chaine', 0, '', $conf->entity);
// Create thumbs of logo (Note that PDF use original file and not thumbs)
if ($isimage > 0) {
// Create thumbs
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
// Create thumbs of logo (Note that PDF use original file and not thumbs)
if ($isimage > 0) {
// Create thumbs
//$object->addThumbs($newfile); // We can't use addThumbs here yet because we need name of generated thumbs to add them into constants. TODO Check if need such constants. We should be able to retrieve value with get...
// Create small thumb, Used on logon for example
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
$imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else {
dol_syslog($imgThumbSmall);
}
// Create mini thumb, Used on menu or for setup page for example
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
$imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else {
dol_syslog($imgThumbMini);
}
// Create small thumb, Used on logon for example
$imgThumbSmall = vignette($dirforimage.$original_file, $maxwidthsmall, $maxheightsmall, '_small', $quality);
if (image_format_supported($imgThumbSmall) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbSmall, $reg)) {
$imgThumbSmall = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_SMALL", $imgThumbSmall, 'chaine', 0, '', $conf->entity);
} else {
dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
dol_syslog($imgThumbSmall);
}
// Create mini thumb, Used on menu or for setup page for example
$imgThumbMini = vignette($dirforimage.$original_file, $maxwidthmini, $maxheightmini, '_mini', $quality);
if (image_format_supported($imgThumbMini) >= 0 && preg_match('/([^\\/:]+)$/i', $imgThumbMini, $reg)) {
$imgThumbMini = $reg[1]; // Save only basename
dolibarr_set_const($db, $constant."_MINI", $imgThumbMini, 'chaine', 0, '', $conf->entity);
} else {
dol_syslog($imgThumbMini);
}
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
$error++;
$langs->load("errors");
$tmparray = explode(':', $result);
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
} elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) {
$error++;
setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors');
} else {
$error++;
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
dol_syslog("ErrorImageFormatNotSupported", LOG_WARNING);
}
} else {
} elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
$tmparray = explode(':', $result);
setEventMessages($langs->trans('ErrorFileIsInfectedWithAVirus', $tmparray[1]), null, 'errors');
} elseif (preg_match('/^ErrorFileSizeTooLarge/', $result)) {
$error++;
setEventMessages($langs->trans("ErrorFileSizeTooLarge"), null, 'errors');
} else {
$error++;
setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
}
} else {
$error++;
$langs->load("errors");
setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
}
}
/*}*/
}