25 include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
66 $this->lng->loadLanguageModule(
'dateplaner');
69 $tpl->addJavascript(
"./Services/Calendar/js/recurrence_input.js");
85 if(
$_POST[
'frequence'] ==
'NONE')
94 $this->
setAlert($lng->txt(
"cal_rec_err_limit"));
111 $this->recurrence = $a_rec;
122 $this->until_selection = $a_enabled;
146 $this->enabled_subforms = $a_sub_forms;
169 $tpl =
new ilTemplate(
'tpl.recurrence_input.html',
true,
true,
'Services/Calendar');
170 $options = array(
'NONE' => $this->lng->txt(
'cal_no_recurrences'),
176 $this->recurrence->getFrequenceType(),
183 array(
'onchange' =>
'ilHideFrequencies();',
'id' =>
'il_recurrence_1')));
185 $tpl->setVariable(
'TXT_EVERY',$this->lng->txt(
'cal_every'));
188 $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT',$this->lng->txt(
'cal_day_s'));
189 $tpl->setVariable(
'COUNT_DAILY_VAL',$this->recurrence->getInterval());
192 $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT',$this->lng->txt(
'cal_week_s'));
193 $tpl->setVariable(
'COUNT_WEEKLY_VAL',$this->recurrence->getInterval());
197 $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT',$this->lng->txt(
'cal_month_s'));
198 $tpl->setVariable(
'COUNT_MONTHLY_VAL',$this->recurrence->getInterval());
199 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
200 $tpl->setVariable(
'TXT_BYMONTHDAY',$this->lng->txt(
'cal_on_the'));
201 $tpl->setVariable(
'TXT_OF_THE_MONTH',$this->lng->txt(
'cal_of_the_month'));
206 $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT',$this->lng->txt(
'cal_year_s'));
207 $tpl->setVariable(
'COUNT_YEARLY_VAL',$this->recurrence->getInterval());
208 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
215 $a_tpl->setCurrentBlock(
"prop_custom");
216 $a_tpl->setVariable(
"CUSTOM_CONTENT",
$tpl->get());
217 $a_tpl->parseCurrentBlock();
229 $days = array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
231 $checked_days = array();
232 foreach($this->recurrence->getBYDAYList() as $byday)
234 if(in_array($byday,$days))
236 $checked_days[] = $byday;
240 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
242 $tpl->setCurrentBlock(
'byday_simple');
244 if(in_array($days[$i],$checked_days))
246 $tpl->setVariable(
'BYDAY_WEEKLY_CHECKED',
'checked="checked"');
248 $tpl->setVariable(
'TXT_ON',$this->lng->txt(
'cal_on'));
249 $tpl->setVariable(
'BYDAY_WEEKLY_VAL',$days[$i]);
251 $tpl->parseCurrentBlock();
265 $byday_list = $this->recurrence->getBYDAYList();
269 foreach($byday_list as $byday)
271 if(preg_match(
'/^(-?\d)([A-Z][A-Z])/',$byday,$parsed) === 1)
274 $chosen_num_day = $parsed[1];
275 $chosen_day = $parsed[2];
279 if(count($this->recurrence->getBYMONTHDAYList()) == 1)
281 $bymonthday = $this->recurrence->getBYMONTHDAY();
282 if(in_array($bymonthday,array(1,2,3,4,5,-1)))
285 $chosen_num_day = $bymonthday;
290 if(count($this->recurrence->getBYSETPOSList()) == 1)
292 $bysetpos = $this->recurrence->getBYSETPOS();
293 if(in_array($bysetpos,array(1,2,3,4,5,-1)))
295 if($this->recurrence->getBYDAYList() == array(
'MO',
'TU',
'WE',
'TH',
'FR'))
298 $chosen_num_day = $bysetpos;
308 $tpl->setVariable(
'M_BYDAY_CHECKED',
'checked="checked"');
311 $num_options = array(
312 1 => $this->lng->txt(
'cal_first'),
313 2 => $this->lng->txt(
'cal_second'),
314 3 => $this->lng->txt(
'cal_third'),
315 4 => $this->lng->txt(
'cal_fourth'),
316 5 => $this->lng->txt(
'cal_fifth'),
317 -1 => $this->lng->txt(
'cal_last'));
327 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")));
329 $days = array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
331 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
335 $days_select[8] = $this->lng->txt(
'cal_weekday');
336 $days_select[9] = $this->lng->txt(
'cal_day_of_month');
345 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")));
357 $tpl->setVariable(
'TXT_IN',$this->lng->txt(
'cal_in'));
361 if(count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1)
363 foreach($bymonthday as $mday)
365 if($mday > 0 and $mday < 32)
375 $tpl->setVariable(
'M_BYMONTHDAY_CHECKED',
'checked="checked"');
378 for($i = 1; $i < 32;$i++)
384 'monthly_bymonthday',
390 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")));
402 $tpl->setVariable(
'TXT_Y_EVERY',$this->lng->txt(
'cal_every'));
408 foreach($this->recurrence->getBYMONTHList() as $month)
410 if($this->recurrence->getBYMONTHDAYList())
412 $chosen_month = $month;
417 foreach($this->recurrence->getBYMONTHDAYList() as $day)
422 for($i = 1; $i < 32;$i++)
435 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")));
438 for($m = 1;$m < 13;$m++)
444 'yearly_bymonth_by_monthday',
450 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")));
455 $tpl->setVariable(
'Y_BYMONTHDAY_CHECKED',
'checked="checked"');
469 $tpl->setVariable(
'TXT_ON_THE',$this->lng->txt(
'cal_on_the'));
474 foreach($this->recurrence->getBYDAYList() as $byday)
476 if(preg_match(
'/^(-?\d)([A-Z][A-Z])/',$byday,$parsed) === 1)
479 $chosen_num_day = $parsed[1];
480 $chosen_day = $parsed[2];
485 $num_options = array(
486 1 => $this->lng->txt(
'cal_first'),
487 2 => $this->lng->txt(
'cal_second'),
488 3 => $this->lng->txt(
'cal_third'),
489 4 => $this->lng->txt(
'cal_fourth'),
490 5 => $this->lng->txt(
'cal_fifth'),
491 -1 => $this->lng->txt(
'cal_last'));
501 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
504 $days = array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
505 for($i = (
int) $this->user_settings->getWeekStart();$i < 7 + (int) $this->user_settings->getWeekStart();$i++)
517 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
522 foreach($this->recurrence->getBYMONTHList() as $month)
524 if($this->recurrence->getBYMONTHDAYList())
526 $chosen_month = $month;
532 for($m = 1;$m < 13;$m++)
538 'yearly_bymonth_byday',
544 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")));
560 $tpl->setVariable(
'TXT_NO_ENDING',$this->lng->txt(
'cal_no_ending'));
561 $tpl->setVariable(
'TXT_UNTIL_CREATE',$this->lng->txt(
'cal_create'));
562 $tpl->setVariable(
'TXT_APPOINTMENTS',$this->lng->txt(
'cal_appointments'));
564 $tpl->setVariable(
'VAL_COUNT',$this->recurrence->getFrequenceUntilCount() ?
565 $this->recurrence->getFrequenceUntilCount() :
567 if($this->recurrence->getFrequenceUntilCount())
569 $tpl->setVariable(
'UNTIL_COUNT_CHECKED',
'checked="checked"');
573 $tpl->setVariable(
'UNTIL_NO_CHECKED',
'checked="checked"');
578 $tpl->setVariable(
'TXT_FIXED_UNTIL_CREATE',$this->lng->txt(
'cal_create'));
579 $tpl->setVariable(
'TXT_FIXED_APPOINTMENTS',$this->lng->txt(
'cal_appointments'));
581 $tpl->setVariable(
'VAL_FIXED_COUNT',$this->recurrence->getFrequenceUntilCount() ?
582 $this->recurrence->getFrequenceUntilCount() :