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);
92 if (
$_POST[
'frequence'] ==
'NONE') {
96 if (!isset(
$_POST[
'until_type']) or
$_POST[
'until_type'] == self::REC_LIMITED) {
98 $this->
setAlert($lng->txt(
"cal_rec_err_limit"));
119 switch (
$_POST[
'frequence']) {
126 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
127 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_WEEKLY']);
128 if (is_array($_POST[
'byday_WEEKLY'])) {
134 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
135 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_MONTHLY']);
136 switch ((
int) $_POST[
'subtype_MONTHLY']) {
142 switch ((
int) $_POST[
'monthly_byday_day']) {
145 $this->
getRecurrence()->setBYSETPOS((
int) $_POST[
'monthly_byday_num']);
151 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_byday_num']);
155 $this->
getRecurrence()->setBYDAY((
int) $_POST[
'monthly_byday_num'] . $_POST[
'monthly_byday_day']);
161 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_bymonthday']);
167 $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
168 $this->
getRecurrence()->setInterval((
int) $_POST[
'count_YEARLY']);
169 switch ((
int) $_POST[
'subtype_YEARLY']) {
175 $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_byday']);
176 $this->
getRecurrence()->setBYDAY((
int) $_POST[
'yearly_byday_num'] . $_POST[
'yearly_byday']);
180 $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_by_monthday']);
181 $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'yearly_bymonthday']);
188 switch ((
int)
$_POST[
'until_type']) {
196 $this->
getRecurrence()->setFrequenceUntilCount((
int) $_POST[
'count']);
201 $dt->setRequired(
true);
202 if ($dt->checkInput()) {
204 $this->
getRecurrence()->setFrequenceUntilDate($dt->getDate());
224 $this->recurrence = $a_rec;
243 $this->allow_unlimited_recurrences = $a_status;
264 $this->enabled_subforms = $a_sub_forms;
287 $tpl =
new ilTemplate(
'tpl.recurrence_input.html',
true,
true,
'Services/Calendar');
289 $options =
array(
'NONE' => $this->lng->txt(
'cal_no_recurrence'));
304 $this->recurrence->getFrequenceType(),
311 array(
'onchange' =>
'ilHideFrequencies();',
'id' =>
'il_recurrence_1')
314 $tpl->setVariable(
'TXT_EVERY', $this->lng->txt(
'cal_every'));
318 $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT', $this->lng->txt(
'cal_day_s'));
319 $tpl->setVariable(
'COUNT_DAILY_VAL', $this->recurrence->getInterval());
324 $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT', $this->lng->txt(
'cal_week_s'));
325 $tpl->setVariable(
'COUNT_WEEKLY_VAL', $this->recurrence->getInterval());
331 $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT', $this->lng->txt(
'cal_month_s'));
332 $tpl->setVariable(
'COUNT_MONTHLY_VAL', $this->recurrence->getInterval());
333 $tpl->setVariable(
'TXT_ON_THE', $this->lng->txt(
'cal_on_the'));
334 $tpl->setVariable(
'TXT_BYMONTHDAY', $this->lng->txt(
'cal_on_the'));
335 $tpl->setVariable(
'TXT_OF_THE_MONTH', $this->lng->txt(
'cal_of_the_month'));
342 $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT', $this->lng->txt(
'cal_year_s'));
343 $tpl->setVariable(
'COUNT_YEARLY_VAL', $this->recurrence->getInterval());
344 $tpl->setVariable(
'TXT_ON_THE', $this->lng->txt(
'cal_on_the'));
352 $a_tpl->setCurrentBlock(
"prop_custom");
353 $a_tpl->setVariable(
"CUSTOM_CONTENT",
$tpl->get());
354 $a_tpl->parseCurrentBlock();
365 $days =
array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
367 $checked_days =
array();
368 foreach ($this->recurrence->getBYDAYList() as $byday) {
369 if (in_array($byday, $days)) {
370 $checked_days[] = $byday;
374 for (
$i = (
int) $this->user_settings->getWeekStart();
$i < 7 + (int) $this->user_settings->getWeekStart();
$i++) {
375 $tpl->setCurrentBlock(
'byday_simple');
377 if (in_array($days[
$i], $checked_days)) {
378 $tpl->setVariable(
'BYDAY_WEEKLY_CHECKED',
'checked="checked"');
380 $tpl->setVariable(
'TXT_ON', $this->lng->txt(
'cal_on'));
381 $tpl->setVariable(
'BYDAY_WEEKLY_VAL', $days[$i]);
383 $tpl->parseCurrentBlock();
396 $byday_list = $this->recurrence->getBYDAYList();
400 foreach ($byday_list as $byday) {
401 if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
403 $chosen_num_day = $parsed[1];
404 $chosen_day = $parsed[2];
408 if (count($this->recurrence->getBYMONTHDAYList()) == 1) {
409 $bymonthday = $this->recurrence->getBYMONTHDAY();
410 if (in_array($bymonthday,
array(1,2,3,4,5,-1))) {
412 $chosen_num_day = $bymonthday;
417 if (count($this->recurrence->getBYSETPOSList()) == 1) {
418 $bysetpos = $this->recurrence->getBYSETPOS();
419 if (in_array($bysetpos,
array(1,2,3,4,5,-1))) {
420 if ($this->recurrence->getBYDAYList() ==
array(
'MO',
'TU',
'WE',
'TH',
'FR')) {
422 $chosen_num_day = $bysetpos;
431 $tpl->setVariable(
'M_BYDAY_CHECKED',
'checked="checked"');
434 $num_options =
array(
435 1 => $this->lng->txt(
'cal_first'),
436 2 => $this->lng->txt(
'cal_second'),
437 3 => $this->lng->txt(
'cal_third'),
438 4 => $this->lng->txt(
'cal_fourth'),
439 5 => $this->lng->txt(
'cal_fifth'),
440 -1 => $this->lng->txt(
'cal_last'));
450 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
453 $days =
array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
455 for (
$i = (
int) $this->user_settings->getWeekStart();
$i < 7 + (int) $this->user_settings->getWeekStart();
$i++) {
458 $days_select[8] = $this->lng->txt(
'cal_weekday');
459 $days_select[9] = $this->lng->txt(
'cal_day_of_month');
468 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
481 $tpl->setVariable(
'TXT_IN', $this->lng->txt(
'cal_in'));
485 if (count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1) {
486 foreach ($bymonthday as $mday) {
487 if ($mday > 0 and $mday < 32) {
495 $tpl->setVariable(
'M_BYMONTHDAY_CHECKED',
'checked="checked"');
498 for (
$i = 1;
$i < 32;
$i++) {
503 'monthly_bymonthday',
509 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")
522 $tpl->setVariable(
'TXT_Y_EVERY', $this->lng->txt(
'cal_every'));
528 foreach ($this->recurrence->getBYMONTHList() as $month) {
529 if ($this->recurrence->getBYMONTHDAYList()) {
530 $chosen_month = $month;
535 foreach ($this->recurrence->getBYMONTHDAYList() as $day) {
539 for (
$i = 1;
$i < 32;
$i++) {
550 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
554 for (
$m = 1;
$m < 13;
$m++) {
559 'yearly_bymonth_by_monthday',
565 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
570 $tpl->setVariable(
'Y_BYMONTHDAY_CHECKED',
'checked="checked"');
583 $tpl->setVariable(
'TXT_ON_THE', $this->lng->txt(
'cal_on_the'));
588 foreach ($this->recurrence->getBYDAYList() as $byday) {
589 if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
591 $chosen_num_day = $parsed[1];
592 $chosen_day = $parsed[2];
597 $num_options =
array(
598 1 => $this->lng->txt(
'cal_first'),
599 2 => $this->lng->txt(
'cal_second'),
600 3 => $this->lng->txt(
'cal_third'),
601 4 => $this->lng->txt(
'cal_fourth'),
602 5 => $this->lng->txt(
'cal_fifth'),
603 -1 => $this->lng->txt(
'cal_last'));
613 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
617 $days =
array(0 =>
'SU',1 =>
'MO',2 =>
'TU',3 =>
'WE',4 =>
'TH',5 =>
'FR',6 =>
'SA',7 =>
'SU');
618 for (
$i = (
int) $this->user_settings->getWeekStart();
$i < 7 + (int) $this->user_settings->getWeekStart();
$i++) {
629 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
635 foreach ($this->recurrence->getBYMONTHList() as $month) {
636 if ($this->recurrence->getBYMONTHDAYList()) {
637 $chosen_month = $month;
643 for (
$m = 1;
$m < 13;
$m++) {
648 'yearly_bymonth_byday',
654 array(
'onchange' =>
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
668 $tpl->setVariable(
'TXT_NO_ENDING', $this->lng->txt(
'cal_no_ending'));
671 $tpl->setVariable(
'TXT_UNTIL_CREATE', $this->lng->txt(
'cal_create'));
672 $tpl->setVariable(
'TXT_APPOINTMENTS', $this->lng->txt(
'cal_appointments'));
674 $tpl->setVariable(
'VAL_COUNT', $this->recurrence->getFrequenceUntilCount() ?
675 $this->recurrence->getFrequenceUntilCount() :
678 if ($this->recurrence->getFrequenceUntilDate()) {
679 $tpl->setVariable(
'UNTIL_END_CHECKED',
'checked="checked"');
681 $tpl->setVariable(
'UNTIL_COUNT_CHECKED',
'checked="checked"');
683 $tpl->setVariable(
'UNTIL_NO_CHECKED',
'checked="checked"');
686 $tpl->setVariable(
'TXT_UNTIL_END', $this->lng->txt(
'cal_repeat_until'));
691 $this->recurrence->getFrequenceUntilDate() ? $this->recurrence->getFrequenceUntilDate() : null
693 $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
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.
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.
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.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options