25 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
26 include_once
'./Services/Calendar/classes/class.ilCalendarRecurrence.php';
67 $this->lng->loadLanguageModule(
'dateplaner');
70 $tpl->addJavascript(
"./Services/Calendar/js/recurrence_input.js");
74 parent::__construct($a_title,$a_postvar);
93 if(
$_POST[
'frequence'] ==
'NONE')
102 $this->
setAlert($lng->txt(
"cal_rec_err_limit"));
124 switch(
$_POST[
'frequence'])
132 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
133 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_WEEKLY']);
134 if(is_array($_POST[
'byday_WEEKLY']))
141 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
142 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_MONTHLY']);
143 switch((
int) $_POST[
'subtype_MONTHLY'])
150 switch((
int) $_POST[
'monthly_byday_day'])
154 $this->
getRecurrence()->setBYSETPOS((
int) $_POST[
'monthly_byday_num']);
160 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_byday_num']);
164 $this->
getRecurrence()->setBYDAY((
int) $_POST[
'monthly_byday_num'].$_POST[
'monthly_byday_day']);
170 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_bymonthday']);
176 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
177 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_YEARLY']);
178 switch((
int) $_POST[
'subtype_YEARLY'])
185 $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_byday']);
186 $this->
getRecurrence()->setBYDAY((
int) $_POST[
'yearly_byday_num'].$_POST[
'yearly_byday']);
190 $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_by_monthday']);
191 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'yearly_bymonthday']);
198 switch((
int)
$_POST[
'until_type'])
207 $this->
getRecurrence()->setFrequenceUntilCount((
int) $_POST[
'count']);
212 $dt->setRequired(
true);
213 if($dt->checkInput())
216 $this->
getRecurrence()->setFrequenceUntilDate($dt->getDate());
238 $this->recurrence = $a_rec;
257 $this->allow_unlimited_recurrences = $a_status;
278 $this->enabled_subforms = $a_sub_forms;
301 $tpl =
new ilTemplate(
'tpl.recurrence_input.html',
true,
true,
'Services/Calendar');
303 $options =
array(
'NONE' => $this->lng->txt(
'cal_no_recurrence'));
322 $this->recurrence->getFrequenceType(),
329 array(
'onchange' =>
'ilHideFrequencies();',
'id' =>
'il_recurrence_1')));
331 $tpl->setVariable(
'TXT_EVERY',$this->lng->txt(
'cal_every'));
336 $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT',$this->lng->txt(
'cal_day_s'));
337 $tpl->setVariable(
'COUNT_DAILY_VAL',$this->recurrence->getInterval());
343 $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT',$this->lng->txt(
'cal_week_s'));
344 $tpl->setVariable(
'COUNT_WEEKLY_VAL',$this->recurrence->getInterval());
351 $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT',$this->lng->txt(
'cal_month_s'));
352 $tpl->setVariable(
'COUNT_MONTHLY_VAL',$this->recurrence->getInterval());
353 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
354 $tpl->setVariable(
'TXT_BYMONTHDAY',$this->lng->txt(
'cal_on_the'));
355 $tpl->setVariable(
'TXT_OF_THE_MONTH',$this->lng->txt(
'cal_of_the_month'));
363 $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT',$this->lng->txt(
'cal_year_s'));
364 $tpl->setVariable(
'COUNT_YEARLY_VAL',$this->recurrence->getInterval());
365 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
373 $a_tpl->setCurrentBlock(
"prop_custom");
374 $a_tpl->setVariable(
"CUSTOM_CONTENT",
$tpl->get());
375 $a_tpl->parseCurrentBlock();
387 $days =
array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
389 $checked_days =
array();
390 foreach($this->recurrence->getBYDAYList() as $byday)
392 if(in_array($byday,$days))
394 $checked_days[] = $byday;
398 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
400 $tpl->setCurrentBlock(
'byday_simple');
402 if(in_array($days[$i],$checked_days))
404 $tpl->setVariable(
'BYDAY_WEEKLY_CHECKED',
'checked="checked"');
406 $tpl->setVariable(
'TXT_ON',$this->lng->txt(
'cal_on'));
407 $tpl->setVariable(
'BYDAY_WEEKLY_VAL',$days[$i]);
409 $tpl->parseCurrentBlock();
423 $byday_list = $this->recurrence->getBYDAYList();
427 foreach($byday_list as $byday)
429 if(preg_match(
'/^(-?\d)([A-Z][A-Z])/',$byday,$parsed) === 1)
432 $chosen_num_day = $parsed[1];
433 $chosen_day = $parsed[2];
437 if(count($this->recurrence->getBYMONTHDAYList()) == 1)
439 $bymonthday = $this->recurrence->getBYMONTHDAY();
440 if(in_array($bymonthday,
array(1,2,3,4,5,-1)))
443 $chosen_num_day = $bymonthday;
448 if(count($this->recurrence->getBYSETPOSList()) == 1)
450 $bysetpos = $this->recurrence->getBYSETPOS();
451 if(in_array($bysetpos,
array(1,2,3,4,5,-1)))
453 if($this->recurrence->getBYDAYList() ==
array(
'MO',
'TU',
'WE',
'TH',
'FR'))
456 $chosen_num_day = $bysetpos;
466 $tpl->setVariable(
'M_BYDAY_CHECKED',
'checked="checked"');
469 $num_options =
array(
470 1 => $this->lng->txt(
'cal_first'),
471 2 => $this->lng->txt(
'cal_second'),
472 3 => $this->lng->txt(
'cal_third'),
473 4 => $this->lng->txt(
'cal_fourth'),
474 5 => $this->lng->txt(
'cal_fifth'),
475 -1 => $this->lng->txt(
'cal_last'));
485 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")));
487 $days =
array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
489 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
493 $days_select[8] = $this->lng->txt(
'cal_weekday');
494 $days_select[9] = $this->lng->txt(
'cal_day_of_month');
503 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")));
515 $tpl->setVariable(
'TXT_IN',$this->lng->txt(
'cal_in'));
519 if(count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1)
521 foreach($bymonthday as $mday)
523 if($mday > 0
and $mday < 32)
533 $tpl->setVariable(
'M_BYMONTHDAY_CHECKED',
'checked="checked"');
536 for($i = 1; $i < 32;$i++)
542 'monthly_bymonthday',
548 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")));
560 $tpl->setVariable(
'TXT_Y_EVERY',$this->lng->txt(
'cal_every'));
566 foreach($this->recurrence->getBYMONTHList() as $month)
568 if($this->recurrence->getBYMONTHDAYList())
570 $chosen_month = $month;
575 foreach($this->recurrence->getBYMONTHDAYList() as $day)
580 for($i = 1; $i < 32;$i++)
593 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")));
596 for($m = 1;$m < 13;$m++)
602 'yearly_bymonth_by_monthday',
608 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")));
613 $tpl->setVariable(
'Y_BYMONTHDAY_CHECKED',
'checked="checked"');
627 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
632 foreach($this->recurrence->getBYDAYList() as $byday)
634 if(preg_match(
'/^(-?\d)([A-Z][A-Z])/',$byday,$parsed) === 1)
637 $chosen_num_day = $parsed[1];
638 $chosen_day = $parsed[2];
643 $num_options =
array(
644 1 => $this->lng->txt(
'cal_first'),
645 2 => $this->lng->txt(
'cal_second'),
646 3 => $this->lng->txt(
'cal_third'),
647 4 => $this->lng->txt(
'cal_fourth'),
648 5 => $this->lng->txt(
'cal_fifth'),
649 -1 => $this->lng->txt(
'cal_last'));
659 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
662 $days =
array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
663 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
675 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
680 foreach($this->recurrence->getBYMONTHList() as $month)
682 if($this->recurrence->getBYMONTHDAYList())
684 $chosen_month = $month;
690 for($m = 1;$m < 13;$m++)
696 'yearly_bymonth_byday',
702 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
718 $tpl->setVariable(
'TXT_NO_ENDING',$this->lng->txt(
'cal_no_ending'));
721 $tpl->setVariable(
'TXT_UNTIL_CREATE',$this->lng->txt(
'cal_create'));
722 $tpl->setVariable(
'TXT_APPOINTMENTS',$this->lng->txt(
'cal_appointments'));
724 $tpl->setVariable(
'VAL_COUNT',$this->recurrence->getFrequenceUntilCount() ?
725 $this->recurrence->getFrequenceUntilCount() :
728 if($this->recurrence->getFrequenceUntilDate())
730 $tpl->setVariable(
'UNTIL_END_CHECKED',
'checked="checked"');
734 $tpl->setVariable(
'UNTIL_COUNT_CHECKED',
'checked="checked"');
738 $tpl->setVariable(
'UNTIL_NO_CHECKED',
'checked="checked"');
741 $tpl->setVariable(
'TXT_UNTIL_END',$this->lng->txt(
'cal_repeat_until'));
746 $this->recurrence->getFrequenceUntilDate() ? $this->recurrence->getFrequenceUntilDate() : null);
747 $tpl->setVariable(
'UNTIL_END_DATE',$dt->getTableFilterHTML());
const IL_CAL_FREQ_MONTHLY
static _numericDayToString($a_day, $a_long=true)
get
static _getInstanceByUserId($a_user_id)
get singleton instance
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
if(!is_array($argv)) $options
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
static formSelect($selected, $varname, $options, $multiple=false, $direct_text=false, $size="0", $style_class="", $attribs="", $disabled=false)
Builds a select form field with options and shows the selected option first.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.