19 declare(strict_types=1);
45 public function __construct(
string $a_title,
string $a_postvar)
49 $DIC->ui()->mainTemplate()->addJavaScript(
"assets/js/recurrence_input.js");
50 $this->
user = $DIC->user();
54 $this->
lng->loadLanguageModule(
'dateplaner');
84 $this->
setAlert($this->
lng->txt(
"cal_rec_err_limit"));
92 if ($this->
http->wrapper()->post()->has($input)) {
93 return $this->
http->wrapper()->post()->retrieve(
103 if ($this->
http->wrapper()->post()->has($input)) {
104 return $this->
http->wrapper()->post()->retrieve(
106 $this->
refinery->kindlyTo()->string()
128 if ($this->
http->wrapper()->post()->has(
'byday_WEEKLY')) {
129 $weekly_days = $this->
http->wrapper()->post()->retrieve(
131 $this->
refinery->kindlyTo()->dictOf(
132 $this->
refinery->kindlyTo()->string()
136 if ($weekly_days !== []) {
137 $this->
getRecurrence()->setBYDAY(implode(
',', $weekly_days));
214 $dt->setRequired(
true);
215 if ($dt->checkInput()) {
217 $this->
getRecurrence()->setFrequenceUntilDate($dt->getDate());
228 $this->recurrence = $a_rec;
241 $this->allow_unlimited_recurrences = $a_status;
256 $this->enabled_subforms = $a_sub_forms;
269 $tpl =
new ilTemplate(
'tpl.recurrence_input.html',
true,
true,
'components/ILIAS/Calendar');
271 $options = array(
'NONE' => $this->
lng->txt(
'cal_no_recurrence'));
288 $this->recurrence->getFrequenceType(),
295 [
'onchange' =>
'ilHideFrequencies();',
'id' =>
'il_recurrence_1']
299 $tpl->setVariable(
'TXT_EVERY', $this->
lng->txt(
'cal_every'));
303 $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT', $this->
lng->txt(
'cal_day_s'));
304 $tpl->setVariable(
'COUNT_DAILY_VAL', $this->recurrence->getInterval());
309 $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT', $this->
lng->txt(
'cal_week_s'));
310 $tpl->setVariable(
'COUNT_WEEKLY_VAL', $this->recurrence->getInterval());
316 $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT', $this->
lng->txt(
'cal_month_s'));
317 $tpl->setVariable(
'COUNT_MONTHLY_VAL', $this->recurrence->getInterval());
318 $tpl->setVariable(
'TXT_ON_THE', $this->
lng->txt(
'cal_on_the'));
319 $tpl->setVariable(
'TXT_BYMONTHDAY', $this->
lng->txt(
'cal_on_the'));
320 $tpl->setVariable(
'TXT_OF_THE_MONTH', $this->
lng->txt(
'cal_of_the_month'));
327 $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT', $this->
lng->txt(
'cal_year_s'));
328 $tpl->setVariable(
'COUNT_YEARLY_VAL', $this->recurrence->getInterval());
329 $tpl->setVariable(
'TXT_ON_THE', $this->
lng->txt(
'cal_on_the'));
338 $a_tpl->
setVariable(
"CUSTOM_CONTENT", $tpl->get());
347 $days = array(0 =>
'SU', 1 =>
'MO', 2 =>
'TU', 3 =>
'WE', 4 =>
'TH', 5 =>
'FR', 6 =>
'SA', 7 =>
'SU');
349 $checked_days = array();
350 foreach ($this->recurrence->getBYDAYList() as $byday) {
351 if (in_array($byday, $days)) {
352 $checked_days[] = $byday;
356 for ($i = $this->user_settings->getWeekStart(); $i < 7 + $this->user_settings->getWeekStart(); $i++) {
359 if (in_array($days[$i], $checked_days)) {
360 $tpl->
setVariable(
'BYDAY_WEEKLY_CHECKED',
'checked="checked"');
375 $byday_list = $this->recurrence->getBYDAYList();
379 foreach ($byday_list as $byday) {
380 if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
382 $chosen_num_day = $parsed[1];
383 $chosen_day = $parsed[2];
387 if (count($this->recurrence->getBYMONTHDAYList()) == 1) {
388 $bymonthday = $this->recurrence->getBYMONTHDAY();
389 if (in_array($bymonthday, array(1, 2, 3, 4, 5, -1))) {
391 $chosen_num_day = $bymonthday;
396 if (count($this->recurrence->getBYSETPOSList()) == 1) {
397 $bysetpos = $this->recurrence->getBYSETPOS();
398 if (in_array($bysetpos, array(1, 2, 3, 4, 5, -1))) {
399 if ($this->recurrence->getBYDAYList() == array(
'MO',
'TU',
'WE',
'TH',
'FR')) {
401 $chosen_num_day = $bysetpos;
408 $tpl->
setVariable(
'M_BYDAY_CHECKED',
'checked="checked"');
411 $num_options = array(
412 1 => $this->
lng->txt(
'cal_first'),
413 2 => $this->
lng->txt(
'cal_second'),
414 3 => $this->
lng->txt(
'cal_third'),
415 4 => $this->
lng->txt(
'cal_fourth'),
416 5 => $this->
lng->txt(
'cal_fifth'),
417 -1 => $this->
lng->txt(
'cal_last')
428 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
431 $days = array(0 =>
'SU', 1 =>
'MO', 2 =>
'TU', 3 =>
'WE', 4 =>
'TH', 5 =>
'FR', 6 =>
'SA', 7 =>
'SU');
433 for ($i = $this->user_settings->getWeekStart(); $i < 7 + $this->user_settings->getWeekStart(); $i++) {
436 $days_select[8] = $this->
lng->txt(
'cal_weekday');
437 $days_select[9] = $this->
lng->txt(
'cal_day_of_month');
446 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
459 if (count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1) {
460 foreach ($bymonthday as $mday) {
461 if ($mday > 0 and $mday < 32) {
469 $tpl->
setVariable(
'M_BYMONTHDAY_CHECKED',
'checked="checked"');
472 for ($i = 1; $i < 32; $i++) {
477 'monthly_bymonthday',
483 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")
494 foreach ($this->recurrence->getBYMONTHList() as $month) {
495 if ($this->recurrence->getBYMONTHDAYList()) {
496 $chosen_month = $month;
501 foreach ($this->recurrence->getBYMONTHDAYList() as $day) {
505 for ($i = 1; $i < 32; $i++) {
516 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
520 for ($m = 1; $m < 13; $m++) {
525 'yearly_bymonth_by_monthday',
531 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
535 $tpl->
setVariable(
'Y_BYMONTHDAY_CHECKED',
'checked="checked"');
546 foreach ($this->recurrence->getBYDAYList() as $byday) {
547 if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
549 $chosen_num_day = $parsed[1];
550 $chosen_day = $parsed[2];
554 $num_options = array(
555 1 => $this->
lng->txt(
'cal_first'),
556 2 => $this->
lng->txt(
'cal_second'),
557 3 => $this->
lng->txt(
'cal_third'),
558 4 => $this->
lng->txt(
'cal_fourth'),
559 5 => $this->
lng->txt(
'cal_fifth'),
560 -1 => $this->
lng->txt(
'cal_last')
571 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
574 $days = array(0 =>
'SU', 1 =>
'MO', 2 =>
'TU', 3 =>
'WE', 4 =>
'TH', 5 =>
'FR', 6 =>
'SA', 7 =>
'SU');
576 for ($i = $this->user_settings->getWeekStart(); $i < 7 + $this->user_settings->getWeekStart(); $i++) {
587 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
592 foreach ($this->recurrence->getBYMONTHList() as $month) {
593 if ($this->recurrence->getBYMONTHDAYList()) {
594 $chosen_month = $month;
600 for ($m = 1; $m < 13; $m++) {
605 'yearly_bymonth_byday',
611 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
621 $tpl->
setVariable(
'TXT_NO_ENDING', $this->
lng->txt(
'cal_no_ending'));
624 $tpl->
setVariable(
'TXT_UNTIL_CREATE', $this->
lng->txt(
'cal_create'));
625 $tpl->
setVariable(
'TXT_APPOINTMENTS', $this->
lng->txt(
'cal_appointments'));
627 $tpl->
setVariable(
'VAL_COUNT', $this->recurrence->getFrequenceUntilCount() ?:
630 if ($this->recurrence->getFrequenceUntilDate()) {
631 $tpl->
setVariable(
'UNTIL_END_CHECKED',
'checked="checked"');
633 $tpl->
setVariable(
'UNTIL_COUNT_CHECKED',
'checked="checked"');
635 $tpl->
setVariable(
'UNTIL_NO_CHECKED',
'checked="checked"');
638 $tpl->
setVariable(
'TXT_UNTIL_END', $this->
lng->txt(
'cal_repeat_until'));
643 $this->recurrence->getFrequenceUntilDate() ?:
null 645 $tpl->
setVariable(
'UNTIL_END_DATE', $dt->getTableFilterHTML());
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static _numericMonthToString(int $a_month, bool $a_long=true, ?ilLanguage $lng=null)
numeric month to string
static _getInstanceByUserId(int $a_user_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _numericDayToString(int $a_day, bool $a_long=true, ?ilLanguage $lng=null)
static http()
Fetches the global http state from ILIAS.
setVariable($variable, $value='')
Sets a variable value.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
const string FREQ_MONTHLY
__construct(Container $dic, ilPlugin $plugin)