-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,19 +164,6 @@ protected function assembleWeekSelectors(): void | |
'disabled' => true | ||
]); | ||
|
||
$previousWeek = (clone $chosenWeek)->sub(new DateInterval('P1W')); | ||
/** @var ButtonElement $previousBtn */ | ||
$previousBtn = $this->createElement('button', 'week', [ | ||
'value' => $previousWeek->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($previousWeek) | ||
) | ||
]); | ||
$this->addHtml($previousBtn->addHtml(new Icon('angle-left'))); | ||
|
||
// Let's be pragmatic and offer the user only a limited set of years. | ||
$years = []; | ||
$start = (new DateTime())->sub(new DateInterval('P5Y')); | ||
|
@@ -217,6 +204,19 @@ protected function assembleWeekSelectors(): void | |
&& (int) $firstWeekDayOfMonth->format('o') === $chosenYear | ||
); | ||
|
||
$previousYear = (clone $chosenWeek)->sub(new DateInterval('P1Y')); | ||
/** @var ButtonElement $previousYearBtn */ | ||
$previousYearBtn = $this->createElement('button', 'week', [ | ||
Check failure on line 209 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 209 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 209 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 209 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 209 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 209 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
|
||
'value' => $previousYear->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($previousYear) | ||
) | ||
])->addHtml(new Icon('angle-left')); | ||
$this->addHtml($previousYearBtn); | ||
|
||
$this->addHtml(new HtmlElement( | ||
'div', | ||
Attributes::create(['class' => 'icinga-controls']), | ||
|
@@ -229,7 +229,38 @@ protected function assembleWeekSelectors(): void | |
$this->translate('Show the first week in %s of a different year'), | ||
$this->getLocalizedMonth($chosenWeek) | ||
) | ||
]), | ||
]) | ||
)); | ||
|
||
$nextYear = (clone $chosenWeek)->add(new DateInterval('P1Y')); | ||
/** @var ButtonElement $nextWeekBtn */ | ||
$nextYearBtn = $this->createElement('button', 'week', [ | ||
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest
Check failure on line 237 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest
|
||
'value' => $nextYear->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($nextYear) | ||
) | ||
])->addHtml(new Icon('angle-right')); | ||
$this->addHtml($nextYearBtn); | ||
|
||
$previousMonth = (clone $chosenWeek)->sub(new DateInterval('P1M')); | ||
/** @var ButtonElement $previousMonthBtn */ | ||
$previousMonthBtn = $this->createElement('button', 'week', [ | ||
Check failure on line 250 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 250 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 250 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 250 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 250 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 250 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
|
||
'value' => $previousMonth->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($previousMonth) | ||
) | ||
])->addHtml(new Icon('angle-left')); | ||
$this->addHtml($previousMonthBtn); | ||
|
||
$this->addHtml(new HtmlElement( | ||
'div', | ||
Attributes::create(['class' => 'icinga-controls']), | ||
$this->createElement('select', 'week', [ | ||
'class' => 'autosubmit', | ||
'value' => $chosenWeekFormatted, | ||
|
@@ -239,7 +270,38 @@ protected function assembleWeekSelectors(): void | |
$this->translate('Show a different month in %d'), | ||
$chosenYear | ||
) | ||
]), | ||
]) | ||
)); | ||
|
||
$nextMonth = (clone $chosenWeek)->add(new DateInterval('P1M')); | ||
/** @var ButtonElement $nextWeekBtn */ | ||
$nextMonthBtn = $this->createElement('button', 'week', [ | ||
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest
Check failure on line 278 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.3 on ubuntu-latest
|
||
'value' => $nextMonth->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($nextMonth) | ||
) | ||
])->addHtml(new Icon('angle-right')); | ||
$this->addHtml($nextMonthBtn); | ||
|
||
$previousWeek = (clone $chosenWeek)->sub(new DateInterval('P1W')); | ||
/** @var ButtonElement $previousWeekBtn */ | ||
$previousWeekBtn = $this->createElement('button', 'week', [ | ||
Check failure on line 291 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 291 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 291 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 291 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 291 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 291 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
|
||
'value' => $previousWeek->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($previousWeek) | ||
) | ||
])->addHtml(new Icon('angle-left')); | ||
$this->addHtml($previousWeekBtn); | ||
|
||
$this->addHtml(new HtmlElement( | ||
'div', | ||
Attributes::create(['class' => 'icinga-controls']), | ||
$this->createElement('select', 'week', [ | ||
'class' => 'autosubmit', | ||
'value' => $chosenWeekFormatted, | ||
|
@@ -254,17 +316,17 @@ protected function assembleWeekSelectors(): void | |
)); | ||
|
||
$nextWeek = (clone $chosenWeek)->add(new DateInterval('P1W')); | ||
/** @var ButtonElement $nextBtn */ | ||
$nextBtn = $this->createElement('button', 'week', [ | ||
/** @var ButtonElement $nextWeekBtn */ | ||
$nextWeekBtn = $this->createElement('button', 'week', [ | ||
Check failure on line 320 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 320 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 320 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 320 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 320 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 320 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
|
||
'value' => $nextWeek->format(self::WEEK_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s to %s'), | ||
...$this->getLocalizedWeek($nextWeek) | ||
) | ||
]); | ||
$this->addHtml($nextBtn->addHtml(new Icon('angle-right'))); | ||
])->addHtml(new Icon('angle-right')); | ||
$this->addHtml($nextWeekBtn); | ||
} | ||
|
||
protected function assembleMonthSelectors(): void | ||
|
@@ -286,19 +348,19 @@ protected function assembleMonthSelectors(): void | |
'disabled' => true | ||
]); | ||
|
||
$previousMonth = (clone $chosenMonth)->sub(new DateInterval('P1M')); | ||
/** @var ButtonElement $previousBtn */ | ||
$previousBtn = $this->createElement('button', 'month', [ | ||
'value' => $previousMonth->format(self::MONTH_FORMAT), | ||
$previousYear = (clone $chosenMonth)->sub(new DateInterval('P1Y')); | ||
/** @var ButtonElement $previousYearBtn */ | ||
$previousYearBtn = $this->createElement('button', 'month', [ | ||
Check failure on line 353 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 353 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 353 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 353 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 353 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 353 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
|
||
'value' => $previousYear->format(self::MONTH_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s %d'), | ||
$this->getLocalizedMonth($previousMonth), | ||
$previousMonth->format('Y') | ||
$this->getLocalizedMonth($previousYear), | ||
$previousYear->format('Y') | ||
) | ||
]); | ||
$this->addHtml($previousBtn->addHtml(new Icon('angle-left'))); | ||
])->addHtml(new Icon('angle-left')); | ||
$this->addHtml($previousYearBtn); | ||
|
||
// Let's be pragmatic and offer the user only a limited set of years. | ||
$years = []; | ||
|
@@ -337,7 +399,40 @@ protected function assembleMonthSelectors(): void | |
$this->translate('Show %s of a different year'), | ||
$this->getLocalizedMonth($chosenMonth) | ||
) | ||
]), | ||
]) | ||
)); | ||
|
||
$nextYear = (clone $chosenMonth)->add(new DateInterval('P1Y')); | ||
/** @var ButtonElement $nextYearBtn */ | ||
$nextYearBtn = $this->createElement('button', 'month', [ | ||
Check failure on line 407 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.2 on ubuntu-latest
Check failure on line 407 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.0 on ubuntu-latest
Check failure on line 407 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.3 on ubuntu-latest
Check failure on line 407 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.2 on ubuntu-latest
Check failure on line 407 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 7.4 on ubuntu-latest
Check failure on line 407 in library/Notifications/Widget/Calendar/Controls.php GitHub Actions / phpstan / Static analysis with phpstan and php 8.1 on ubuntu-latest
|
||
'value' => $nextYear->format(self::MONTH_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s %d'), | ||
$this->getLocalizedMonth($nextYear), | ||
$nextYear->format('Y') | ||
) | ||
])->addHtml(new Icon('angle-right')); | ||
$this->addHtml($nextYearBtn); | ||
|
||
$previousMonth = (clone $chosenMonth)->sub(new DateInterval('P1M')); | ||
/** @var ButtonElement $previousMonthBtn */ | ||
$previousMonthBtn = $this->createElement('button', 'month', [ | ||
'value' => $previousMonth->format(self::MONTH_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
'title' => sprintf( | ||
$this->translate('Show %s %d'), | ||
$this->getLocalizedMonth($previousMonth), | ||
$previousMonth->format('Y') | ||
) | ||
])->addHtml(new Icon('angle-left')); | ||
$this->addHtml($previousMonthBtn); | ||
|
||
$this->addHtml(new HtmlElement( | ||
'div', | ||
Attributes::create(['class' => 'icinga-controls']), | ||
$this->createElement('select', 'month', [ | ||
'class' => 'autosubmit', | ||
'value' => $chosenMonthFormatted, | ||
|
@@ -351,8 +446,8 @@ protected function assembleMonthSelectors(): void | |
)); | ||
|
||
$nextMonth = $chosenMonth->add(new DateInterval('P1M')); | ||
/** @var ButtonElement $nextBtn */ | ||
$nextBtn = $this->createElement('button', 'month', [ | ||
/** @var ButtonElement $nextMonthBtn */ | ||
$nextMonthBtn = $this->createElement('button', 'month', [ | ||
'value' => $nextMonth->format(self::MONTH_FORMAT), | ||
'class' => 'control-button', | ||
'type' => 'submit', | ||
|
@@ -361,8 +456,8 @@ protected function assembleMonthSelectors(): void | |
$this->getLocalizedMonth($nextMonth), | ||
$nextMonth->format('Y') | ||
) | ||
]); | ||
$this->addHtml($nextBtn->addHtml(new Icon('angle-right'))); | ||
])->addHtml(new Icon('angle-right')); | ||
$this->addHtml($nextMonthBtn); | ||
} | ||
|
||
/** | ||
|