Skip to content

Commit

Permalink
chore: fix ecs bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cgoIT committed Sep 4, 2024
1 parent 1a7b3aa commit 1dddd47
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
24 changes: 12 additions & 12 deletions src/Classes/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public static function getUntilAndRecurring(CalendarEventsModel $objEvent, PageM
$arrFixedDates = StringUtil::deserialize($objEvent->repeatFixedDates);

if (!empty($arrFixedDates) && \is_array($arrFixedDates)) {
$until = ' '.sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
$until = ' '.\sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd));

$arrFixedDates = array_map(static fn ($val) => Date::parse($objPage->dateFormat, $val), array_column($arrFixedDates, 'new_repeat'));
$strDates = self::implodeFixedDates($arrFixedDates);

$recurring = sprintf($GLOBALS['TL_LANG']['tl_calendar_events']['cal_repeat_fixed_dates'], $strDates, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : ''));
$recurring = \sprintf($GLOBALS['TL_LANG']['tl_calendar_events']['cal_repeat_fixed_dates'], $strDates, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : ''));
}
} elseif (!empty($objEvent->recurringExt)) {
$arrRange = StringUtil::deserialize($objEvent->repeatEachExt, true);
Expand All @@ -92,15 +92,15 @@ public static function getUntilAndRecurring(CalendarEventsModel $objEvent, PageM
$repeat = $GLOBALS['TL_LANG']['tl_calendar_events'][$arg].' '.$GLOBALS['TL_LANG']['tl_calendar_events'][$unit];

if ($objEvent->recurrences > 0) {
$until = ' '.sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
$until = ' '.\sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
}

if ($objEvent->recurrences > 0 && $objEvent->repeatEnd <= time()) {
$recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until);
$recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until);
} elseif ($objEvent->addTime) {
$recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : ''));
$recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : ''));
} else {
$recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate);
$recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate);
}
}
} elseif (!empty($objEvent->recurring)) {
Expand All @@ -110,19 +110,19 @@ public static function getUntilAndRecurring(CalendarEventsModel $objEvent, PageM
if (1 === $arrRange['value']) {
$repeat = $GLOBALS['TL_LANG']['MSC']['cal_single_'.$arrRange['unit']];
} else {
$repeat = sprintf($GLOBALS['TL_LANG']['MSC']['cal_multiple_'.$arrRange['unit']], $arrRange['value']);
$repeat = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_multiple_'.$arrRange['unit']], $arrRange['value']);
}

if ($objEvent->recurrences > 0) {
$until = ' '.sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
$until = ' '.\sprintf($GLOBALS['TL_LANG']['MSC']['cal_until'], Date::parse($objPage->dateFormat, $objEvent->repeatEnd));
}

if ($objEvent->recurrences > 0 && $objEvent->repeatEnd <= time()) {
$recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until);
$recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat_ended'], $repeat, $until);
} elseif ($objEvent->addTime) {
$recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : ''));
$recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d\TH:i:sP', $intStartTime), $strDate.($strTime ? ' '.$strTime : ''));
} else {
$recurring = sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate);
$recurring = \sprintf($GLOBALS['TL_LANG']['MSC']['cal_repeat'], $repeat, $until, date('Y-m-d', $intStartTime), $strDate);
}
}
}
Expand Down Expand Up @@ -194,7 +194,7 @@ private static function implodeFixedDates(array|null $arrFixedDates): string
$arrFixedDates = \array_slice($arrFixedDates, 0, 4);

return implode(', ', $arrFixedDates).' '.
sprintf($cntOtherDates > 1 ? $GLOBALS['TL_LANG']['MSC']['count_other_dates_plural'] : $GLOBALS['TL_LANG']['MSC']['count_other_dates_singular'], $cntOtherDates);
\sprintf($cntOtherDates > 1 ? $GLOBALS['TL_LANG']['MSC']['count_other_dates_plural'] : $GLOBALS['TL_LANG']['MSC']['count_other_dates_singular'], $cntOtherDates);
}
if (1 === \count($arrFixedDates)) {
return $arrFixedDates[0];
Expand Down
4 changes: 0 additions & 4 deletions src/EventListener/DataContainer/CalendarEventsCallbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,6 @@ public function checkRecurring(mixed $value, DataContainer $dc): mixed
$activeRecord->recurring = false; // @phpstan-ignore-line

$this->redirect($this->addToUrl($this->requestStack->getCurrentRequest()->getUri()));

return false;
}

return $value;
Expand All @@ -227,8 +225,6 @@ public function checkRecurringExt(mixed $value, DataContainer $dc): mixed
$activeRecord->recurringExt = false; // @phpstan-ignore-line

$this->redirect($this->addToUrl($this->requestStack->getCurrentRequest()->getUri()));

return false;
}

return $value;
Expand Down
6 changes: 3 additions & 3 deletions src/Widget/TimePeriodExt.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function generate()
}

foreach ($this->arrValues as $arrValue) {
$arrValues[] = sprintf(
$arrValues[] = \sprintf(
'<option value="%s"%s>%s</option>',
StringUtil::specialchars($arrValue['value']),
$this->isSelectedExt($arrValue, 'value'),
Expand All @@ -113,7 +113,7 @@ public function generate()
}

foreach ($this->arrUnits as $arrUnit) {
$arrUnits[] = sprintf(
$arrUnits[] = \sprintf(
'<option value="%s"%s>%s</option>',
StringUtil::specialchars($arrUnit['value']),
$this->isSelectedExt($arrUnit, 'unit'),
Expand All @@ -125,7 +125,7 @@ public function generate()
$this->varValue = ['value' => $this->varValue];
}

return sprintf(
return \sprintf(
'<select name="%s[value]" class="tl_select_interval" onfocus="Backend.getScrollOffset();"%s>%s</select> <select name="%s[unit]" class="tl_select_interval" onfocus="Backend.getScrollOffset();"%s>%s</select>%s',
$this->strName,
$this->getAttribute('disabled'),
Expand Down

0 comments on commit 1dddd47

Please sign in to comment.