3 declare(strict_types=1);
46 public function __construct(
string $a_title,
string $a_postvar)
50 $DIC->ui()->mainTemplate()->addJavaScript(
"./Services/Calendar/js/recurrence_input.js");
51 $this->
user = $DIC->user();
55 $this->
lng->loadLanguageModule(
'dateplaner');
85 $this->
setAlert($this->
lng->txt(
"cal_rec_err_limit"));
93 if ($this->
http->wrapper()->post()->has($input)) {
94 return $this->
http->wrapper()->post()->retrieve(
104 if ($this->
http->wrapper()->post()->has($input)) {
105 return $this->
http->wrapper()->post()->retrieve(
107 $this->
refinery->kindlyTo()->string()
129 if ($this->
http->wrapper()->post()->has(
'byday_WEEKLY')) {
130 $weekly_days = $this->
http->wrapper()->post()->retrieve(
132 $this->
refinery->kindlyTo()->dictOf(
133 $this->
refinery->kindlyTo()->string()
137 if ($weekly_days !== []) {
138 $this->
getRecurrence()->setBYDAY(implode(
',', $weekly_days));
215 $dt->setRequired(
true);
216 if ($dt->checkInput()) {
218 $this->
getRecurrence()->setFrequenceUntilDate($dt->getDate());
229 $this->recurrence = $a_rec;
242 $this->allow_unlimited_recurrences = $a_status;
257 $this->enabled_subforms = $a_sub_forms;
270 $tpl =
new ilTemplate(
'tpl.recurrence_input.html',
true,
true,
'Services/Calendar');
272 $options = array(
'NONE' => $this->
lng->txt(
'cal_no_recurrence'));
289 $this->recurrence->getFrequenceType(),
296 [
'onchange' =>
'ilHideFrequencies();',
'id' =>
'il_recurrence_1']
300 $tpl->setVariable(
'TXT_EVERY', $this->
lng->txt(
'cal_every'));
304 $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT', $this->
lng->txt(
'cal_day_s'));
305 $tpl->setVariable(
'COUNT_DAILY_VAL', $this->recurrence->getInterval());
310 $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT', $this->
lng->txt(
'cal_week_s'));
311 $tpl->setVariable(
'COUNT_WEEKLY_VAL', $this->recurrence->getInterval());
317 $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT', $this->
lng->txt(
'cal_month_s'));
318 $tpl->setVariable(
'COUNT_MONTHLY_VAL', $this->recurrence->getInterval());
319 $tpl->setVariable(
'TXT_ON_THE', $this->
lng->txt(
'cal_on_the'));
320 $tpl->setVariable(
'TXT_BYMONTHDAY', $this->
lng->txt(
'cal_on_the'));
321 $tpl->setVariable(
'TXT_OF_THE_MONTH', $this->
lng->txt(
'cal_of_the_month'));
328 $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT', $this->
lng->txt(
'cal_year_s'));
329 $tpl->setVariable(
'COUNT_YEARLY_VAL', $this->recurrence->getInterval());
330 $tpl->setVariable(
'TXT_ON_THE', $this->
lng->txt(
'cal_on_the'));
348 $days = array(0 =>
'SU', 1 =>
'MO', 2 =>
'TU', 3 =>
'WE', 4 =>
'TH', 5 =>
'FR', 6 =>
'SA', 7 =>
'SU');
350 $checked_days = array();
351 foreach ($this->recurrence->getBYDAYList() as $byday) {
352 if (in_array($byday, $days)) {
353 $checked_days[] = $byday;
357 for (
$i = $this->user_settings->getWeekStart();
$i < 7 + $this->user_settings->getWeekStart();
$i++) {
360 if (in_array($days[
$i], $checked_days)) {
361 $tpl->
setVariable(
'BYDAY_WEEKLY_CHECKED',
'checked="checked"');
376 $byday_list = $this->recurrence->getBYDAYList();
380 foreach ($byday_list as $byday) {
381 if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
383 $chosen_num_day = $parsed[1];
384 $chosen_day = $parsed[2];
388 if (count($this->recurrence->getBYMONTHDAYList()) == 1) {
389 $bymonthday = $this->recurrence->getBYMONTHDAY();
390 if (in_array($bymonthday, array(1, 2, 3, 4, 5, -1))) {
392 $chosen_num_day = $bymonthday;
397 if (count($this->recurrence->getBYSETPOSList()) == 1) {
398 $bysetpos = $this->recurrence->getBYSETPOS();
399 if (in_array($bysetpos, array(1, 2, 3, 4, 5, -1))) {
400 if ($this->recurrence->getBYDAYList() == array(
'MO',
'TU',
'WE',
'TH',
'FR')) {
402 $chosen_num_day = $bysetpos;
409 $tpl->
setVariable(
'M_BYDAY_CHECKED',
'checked="checked"');
412 $num_options = array(
413 1 => $this->
lng->txt(
'cal_first'),
414 2 => $this->
lng->txt(
'cal_second'),
415 3 => $this->
lng->txt(
'cal_third'),
416 4 => $this->
lng->txt(
'cal_fourth'),
417 5 => $this->
lng->txt(
'cal_fifth'),
418 -1 => $this->
lng->txt(
'cal_last')
429 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
432 $days = array(0 =>
'SU', 1 =>
'MO', 2 =>
'TU', 3 =>
'WE', 4 =>
'TH', 5 =>
'FR', 6 =>
'SA', 7 =>
'SU');
434 for (
$i = $this->user_settings->getWeekStart();
$i < 7 + $this->user_settings->getWeekStart();
$i++) {
437 $days_select[8] = $this->
lng->txt(
'cal_weekday');
438 $days_select[9] = $this->
lng->txt(
'cal_day_of_month');
447 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
460 if (count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1) {
461 foreach ($bymonthday as $mday) {
462 if ($mday > 0 and $mday < 32) {
470 $tpl->
setVariable(
'M_BYMONTHDAY_CHECKED',
'checked="checked"');
473 for (
$i = 1;
$i < 32;
$i++) {
478 'monthly_bymonthday',
484 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")
495 foreach ($this->recurrence->getBYMONTHList() as $month) {
496 if ($this->recurrence->getBYMONTHDAYList()) {
497 $chosen_month = $month;
502 foreach ($this->recurrence->getBYMONTHDAYList() as $day) {
506 for (
$i = 1;
$i < 32;
$i++) {
517 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
521 for ($m = 1; $m < 13; $m++) {
526 'yearly_bymonth_by_monthday',
532 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
536 $tpl->
setVariable(
'Y_BYMONTHDAY_CHECKED',
'checked="checked"');
547 foreach ($this->recurrence->getBYDAYList() as $byday) {
548 if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
550 $chosen_num_day = $parsed[1];
551 $chosen_day = $parsed[2];
555 $num_options = array(
556 1 => $this->
lng->txt(
'cal_first'),
557 2 => $this->
lng->txt(
'cal_second'),
558 3 => $this->
lng->txt(
'cal_third'),
559 4 => $this->
lng->txt(
'cal_fourth'),
560 5 => $this->
lng->txt(
'cal_fifth'),
561 -1 => $this->
lng->txt(
'cal_last')
572 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
575 $days = array(0 =>
'SU', 1 =>
'MO', 2 =>
'TU', 3 =>
'WE', 4 =>
'TH', 5 =>
'FR', 6 =>
'SA', 7 =>
'SU');
577 for (
$i = $this->user_settings->getWeekStart();
$i < 7 + $this->user_settings->getWeekStart();
$i++) {
588 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
593 foreach ($this->recurrence->getBYMONTHList() as $month) {
594 if ($this->recurrence->getBYMONTHDAYList()) {
595 $chosen_month = $month;
601 for ($m = 1; $m < 13; $m++) {
606 'yearly_bymonth_byday',
612 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
622 $tpl->
setVariable(
'TXT_NO_ENDING', $this->
lng->txt(
'cal_no_ending'));
625 $tpl->
setVariable(
'TXT_UNTIL_CREATE', $this->
lng->txt(
'cal_create'));
626 $tpl->
setVariable(
'TXT_APPOINTMENTS', $this->
lng->txt(
'cal_appointments'));
628 $tpl->
setVariable(
'VAL_COUNT', $this->recurrence->getFrequenceUntilCount() ?:
631 if ($this->recurrence->getFrequenceUntilDate()) {
632 $tpl->
setVariable(
'UNTIL_END_CHECKED',
'checked="checked"');
634 $tpl->
setVariable(
'UNTIL_COUNT_CHECKED',
'checked="checked"');
636 $tpl->
setVariable(
'UNTIL_NO_CHECKED',
'checked="checked"');
639 $tpl->
setVariable(
'TXT_UNTIL_END', $this->
lng->txt(
'cal_repeat_until'));
644 $this->recurrence->getFrequenceUntilDate() ?: null
646 $tpl->
setVariable(
'UNTIL_END_DATE', $dt->getTableFilterHTML());
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static _numericMonthToString(int $a_month, bool $a_long=true)
numeric month to string
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getInstanceByUserId(int $a_user_id)
static http()
Fetches the global http state from ILIAS.
setVariable($variable, $value='')
Sets a variable value.
static _numericDayToString(int $a_day, bool $a_long=true)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl