Merge pull request #22083 from ksar-ksar/patch-15

Fix #22079 : Elephant model error messages update lokk and feel
This commit is contained in:
Laurent Destailleur 2022-09-07 14:01:46 +02:00 committed by GitHub
commit ec2dfb4366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -161,31 +161,39 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
*/ */
public function getExample($langs, $objsoc = 0, $type = -1) public function getExample($langs, $objsoc = 0, $type = -1)
{ {
$error = 0;
$examplecust = ''; $examplecust = '';
$examplesup = ''; $examplesup = '';
$errmsg = array( $errmsg = array(
"ErrorBadMask", "ErrorBadMask",
"ErrorCantUseRazIfNoYearInMask", "ErrorCantUseRazIfNoYearInMask",
"ErrorCantUseRazInStartedYearIfNoYearMonthInMask", "ErrorCantUseRazInStartedYearIfNoYearMonthInMask",
"ErrorCounterMustHaveMoreThan3Digits",
"ErrorBadMaskBadRazMonth",
"ErrorCantUseRazWithYearOnOneDigit",
); );
if ($type != 1) { if ($type != 1) {
$examplecust = $this->getNextValue($objsoc, 0); $examplecust = $this->getNextValue($objsoc, 0);
if (!$examplecust) { if (!$examplecust) {
$examplecust = $langs->trans('NotConfigured'); $examplecust = '<div class="error">'.$langs->trans('NotConfigured').'</div>';
$error = 1;
} }
if (in_array($examplecust, $errmsg)) { if (in_array($examplecust, $errmsg)) {
$langs->load("errors"); $langs->load("errors");
$examplecust = $langs->trans($examplecust); $examplecust = '<div class="error">'.$langs->trans($examplecust).'</div>';
$error = 1;
} }
} }
if ($type != 0) { if ($type != 0) {
$examplesup = $this->getNextValue($objsoc, 1); $examplesup = $this->getNextValue($objsoc, 1);
if (!$examplesup) { if (!$examplesup) {
$examplesup = $langs->trans('NotConfigured'); $examplesup = '<div class="error">'.$langs->trans('NotConfigured').'</div>';
$error = 1;
} }
if (in_array($examplesup, $errmsg)) { if (in_array($examplesup, $errmsg)) {
$langs->load("errors"); $langs->load("errors");
$examplesup = $langs->trans($examplesup); $examplesup = '<div class="error">'.$langs->trans($examplesup).'</div>';
$error = 1;
} }
} }
@ -194,7 +202,11 @@ class mod_codeclient_elephant extends ModeleThirdPartyCode
} elseif ($type == 1) { } elseif ($type == 1) {
return $examplesup; return $examplesup;
} else { } else {
return $examplecust.'<br>'.$examplesup; if ($error == 1) {
return $examplecust.' '.$examplesup;
} else {
return $examplecust.'<br>'.$examplesup;
}
} }
} }