25include_once(
'./Services/Calendar/classes/class.ilCalendarUserSettings.php');
 
   26include_once 
'./Services/Calendar/classes/class.ilCalendarRecurrence.php';
 
   71        $this->lng->loadLanguageModule(
'dateplaner');
 
   74        $tpl->addJavascript(
"./Services/Calendar/js/recurrence_input.js");
 
   78        parent::__construct($a_title, $a_postvar);
 
   98        if (
$_POST[
'frequence'] == 
'NONE') {
 
  102        if (!isset(
$_POST[
'until_type']) or 
$_POST[
'until_type'] == self::REC_LIMITED) {
 
  125        switch (
$_POST[
'frequence']) {
 
  132                $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
 
  133                $this->
getRecurrence()->setInterval((
int) $_POST[
'count_WEEKLY']);
 
  134                if (is_array(
$_POST[
'byday_WEEKLY'])) {
 
  140                $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
 
  141                $this->
getRecurrence()->setInterval((
int) $_POST[
'count_MONTHLY']);
 
  142                switch ((
int) 
$_POST[
'subtype_MONTHLY']) {
 
  148                        switch ((
int) 
$_POST[
'monthly_byday_day']) {
 
  151                                $this->
getRecurrence()->setBYSETPOS((
int) $_POST[
'monthly_byday_num']);
 
  157                                $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_byday_num']);
 
  161                                $this->
getRecurrence()->setBYDAY((
int) $_POST[
'monthly_byday_num'] . 
$_POST[
'monthly_byday_day']);
 
  167                        $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'monthly_bymonthday']);
 
  173                $this->
getRecurrence()->setFrequenceType($_POST[
'frequence']);
 
  174                $this->
getRecurrence()->setInterval((
int) $_POST[
'count_YEARLY']);
 
  175                switch ((
int) 
$_POST[
'subtype_YEARLY']) {
 
  181                        $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_byday']);
 
  182                        $this->
getRecurrence()->setBYDAY((
int) $_POST[
'yearly_byday_num'] . 
$_POST[
'yearly_byday']);
 
  186                        $this->
getRecurrence()->setBYMONTH((
int) $_POST[
'yearly_bymonth_by_monthday']);
 
  187                        $this->
getRecurrence()->setBYMONTHDAY((
int) $_POST[
'yearly_bymonthday']);
 
  194        switch ((
int) 
$_POST[
'until_type']) {
 
  202                $this->
getRecurrence()->setFrequenceUntilCount((
int) $_POST[
'count']);
 
  207                $dt->setRequired(
true);
 
  208                if ($dt->checkInput()) {
 
  210                    $this->
getRecurrence()->setFrequenceUntilDate($dt->getDate());
 
  230        $this->recurrence = $a_rec;
 
  249        $this->allow_unlimited_recurrences = $a_status;
 
  270        $this->enabled_subforms = $a_sub_forms;
 
  293        $tpl = 
new ilTemplate(
'tpl.recurrence_input.html', 
true, 
true, 
'Services/Calendar');
 
  295        $options = array(
'NONE' => $this->lng->txt(
'cal_no_recurrence'));
 
  310            $this->recurrence->getFrequenceType(),
 
  317            array(
'onchange' => 
'ilHideFrequencies();',
'id' => 
'il_recurrence_1')
 
  320        $tpl->setVariable(
'TXT_EVERY', $this->lng->txt(
'cal_every'));
 
  324            $tpl->setVariable(
'TXT_DAILY_FREQ_UNIT', $this->lng->txt(
'cal_day_s'));
 
  325            $tpl->setVariable(
'COUNT_DAILY_VAL', $this->recurrence->getInterval());
 
  330            $tpl->setVariable(
'TXT_WEEKLY_FREQ_UNIT', $this->lng->txt(
'cal_week_s'));
 
  331            $tpl->setVariable(
'COUNT_WEEKLY_VAL', $this->recurrence->getInterval());
 
  337            $tpl->setVariable(
'TXT_MONTHLY_FREQ_UNIT', $this->lng->txt(
'cal_month_s'));
 
  338            $tpl->setVariable(
'COUNT_MONTHLY_VAL', $this->recurrence->getInterval());
 
  339            $tpl->setVariable(
'TXT_ON_THE', $this->lng->txt(
'cal_on_the'));
 
  340            $tpl->setVariable(
'TXT_BYMONTHDAY', $this->lng->txt(
'cal_on_the'));
 
  341            $tpl->setVariable(
'TXT_OF_THE_MONTH', $this->lng->txt(
'cal_of_the_month'));
 
  348            $tpl->setVariable(
'TXT_YEARLY_FREQ_UNIT', $this->lng->txt(
'cal_year_s'));
 
  349            $tpl->setVariable(
'COUNT_YEARLY_VAL', $this->recurrence->getInterval());
 
  350            $tpl->setVariable(
'TXT_ON_THE', $this->lng->txt(
'cal_on_the'));
 
  358        $a_tpl->setCurrentBlock(
"prop_custom");
 
  359        $a_tpl->setVariable(
"CUSTOM_CONTENT", 
$tpl->get());
 
  360        $a_tpl->parseCurrentBlock();
 
  371        $days = array(0 => 
'SU',1 => 
'MO',2 => 
'TU',3 => 
'WE',4 => 
'TH',5 => 
'FR',6 => 
'SA',7 => 
'SU');
 
  373        $checked_days = array();
 
  374        foreach ($this->recurrence->getBYDAYList() as $byday) {
 
  375            if (in_array($byday, $days)) {
 
  376                $checked_days[] = $byday;
 
  380        for (
$i = (
int) $this->user_settings->getWeekStart();
$i < 7 + (
int) $this->user_settings->getWeekStart();
$i++) {
 
  381            $tpl->setCurrentBlock(
'byday_simple');
 
  383            if (in_array($days[
$i], $checked_days)) {
 
  384                $tpl->setVariable(
'BYDAY_WEEKLY_CHECKED', 
'checked="checked"');
 
  386            $tpl->setVariable(
'TXT_ON', $this->lng->txt(
'cal_on'));
 
  387            $tpl->setVariable(
'DAY_COUNT', 
$i);
 
  388            $tpl->setVariable(
'BYDAY_WEEKLY_VAL', $days[
$i]);
 
  390            $tpl->parseCurrentBlock();
 
  403        $byday_list = $this->recurrence->getBYDAYList();
 
  407        foreach ($byday_list as $byday) {
 
  408            if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
 
  410                $chosen_num_day = $parsed[1];
 
  411                $chosen_day = $parsed[2];
 
  415        if (count($this->recurrence->getBYMONTHDAYList()) == 1) {
 
  416            $bymonthday = $this->recurrence->getBYMONTHDAY();
 
  417            if (in_array($bymonthday, array(1,2,3,4,5,-1))) {
 
  419                $chosen_num_day = $bymonthday;
 
  424        if (count($this->recurrence->getBYSETPOSList()) == 1) {
 
  425            $bysetpos = $this->recurrence->getBYSETPOS();
 
  426            if (in_array($bysetpos, array(1,2,3,4,5,-1))) {
 
  427                if ($this->recurrence->getBYDAYList() == array(
'MO',
'TU',
'WE',
'TH',
'FR')) {
 
  429                    $chosen_num_day = $bysetpos;
 
  438            $tpl->setVariable(
'M_BYDAY_CHECKED', 
'checked="checked"');
 
  441        $num_options = array(
 
  442            1 => $this->lng->txt(
'cal_first'),
 
  443            2 => $this->lng->txt(
'cal_second'),
 
  444            3 => $this->lng->txt(
'cal_third'),
 
  445            4 => $this->lng->txt(
'cal_fourth'),
 
  446            5 => $this->lng->txt(
'cal_fifth'),
 
  447           -1 => $this->lng->txt(
'cal_last'));
 
  457            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
 
  460        $days = array(0 => 
'SU',1 => 
'MO',2 => 
'TU',3 => 
'WE',4 => 
'TH',5 => 
'FR',6 => 
'SA',7 => 
'SU');
 
  462        for (
$i = (
int) $this->user_settings->getWeekStart();
$i < 7 + (
int) $this->user_settings->getWeekStart();
$i++) {
 
  465        $days_select[8] = $this->lng->txt(
'cal_weekday');
 
  466        $days_select[9] = $this->lng->txt(
'cal_day_of_month');
 
  475            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_monthly_radio_1');")
 
  488        $tpl->setVariable(
'TXT_IN', $this->lng->txt(
'cal_in'));
 
  492        if (count($bymonthday = $this->recurrence->getBYMONTHDAYList()) == 1) {
 
  493            foreach ($bymonthday as $mday) {
 
  494                if ($mday > 0 and $mday < 32) {
 
  502            $tpl->setVariable(
'M_BYMONTHDAY_CHECKED', 
'checked="checked"');
 
  505        for (
$i = 1; 
$i < 32;
$i++) {
 
  510            'monthly_bymonthday',
 
  516            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_monthly_radio_2');")
 
  529        $tpl->setVariable(
'TXT_Y_EVERY', $this->lng->txt(
'cal_every'));
 
  535        foreach ($this->recurrence->getBYMONTHList() as $month) {
 
  536            if ($this->recurrence->getBYMONTHDAYList()) {
 
  537                $chosen_month = $month;
 
  542        foreach ($this->recurrence->getBYMONTHDAYList() as $day) {
 
  546        for (
$i = 1; 
$i < 32;
$i++) {
 
  557            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
 
  561        for (
$m = 1;
$m < 13;
$m++) {
 
  566            'yearly_bymonth_by_monthday',
 
  572            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_2');")
 
  577            $tpl->setVariable(
'Y_BYMONTHDAY_CHECKED', 
'checked="checked"');
 
  590        $tpl->setVariable(
'TXT_ON_THE', $this->lng->txt(
'cal_on_the'));
 
  595        foreach ($this->recurrence->getBYDAYList() as $byday) {
 
  596            if (preg_match(
'/^(-?\d)([A-Z][A-Z])/', $byday, $parsed) === 1) {
 
  598                $chosen_num_day = $parsed[1];
 
  599                $chosen_day = $parsed[2];
 
  604        $num_options = array(
 
  605            1 => $this->lng->txt(
'cal_first'),
 
  606            2 => $this->lng->txt(
'cal_second'),
 
  607            3 => $this->lng->txt(
'cal_third'),
 
  608            4 => $this->lng->txt(
'cal_fourth'),
 
  609            5 => $this->lng->txt(
'cal_fifth'),
 
  610           -1 => $this->lng->txt(
'cal_last'));
 
  620            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
 
  624        $days = array(0 => 
'SU',1 => 
'MO',2 => 
'TU',3 => 
'WE',4 => 
'TH',5 => 
'FR',6 => 
'SA',7 => 
'SU');
 
  625        for (
$i = (
int) $this->user_settings->getWeekStart();
$i < 7 + (
int) $this->user_settings->getWeekStart();
$i++) {
 
  636            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
 
  642        foreach ($this->recurrence->getBYMONTHList() as $month) {
 
  643            if ($this->recurrence->getBYMONTHDAYList()) {
 
  644                $chosen_month = $month;
 
  650        for (
$m = 1;
$m < 13;
$m++) {
 
  655            'yearly_bymonth_byday',
 
  661            array(
'onchange' => 
"ilUpdateSubTypeSelection('sub_yearly_radio_1');")
 
  675            $tpl->setVariable(
'TXT_NO_ENDING', $this->lng->txt(
'cal_no_ending'));
 
  678        $tpl->setVariable(
'TXT_UNTIL_CREATE', $this->lng->txt(
'cal_create'));
 
  679        $tpl->setVariable(
'TXT_APPOINTMENTS', $this->lng->txt(
'cal_appointments'));
 
  681        $tpl->setVariable(
'VAL_COUNT', $this->recurrence->getFrequenceUntilCount() ?
 
  682            $this->recurrence->getFrequenceUntilCount() :
 
  685        if ($this->recurrence->getFrequenceUntilDate()) {
 
  686            $tpl->setVariable(
'UNTIL_END_CHECKED', 
'checked="checked"');
 
  687        } elseif ($this->recurrence->getFrequenceUntilCount() or !$this->isUnlimitedRecurrenceAllowed()) {
 
  688            $tpl->setVariable(
'UNTIL_COUNT_CHECKED', 
'checked="checked"');
 
  690            $tpl->setVariable(
'UNTIL_NO_CHECKED', 
'checked="checked"');
 
  693        $tpl->setVariable(
'TXT_UNTIL_END', $this->lng->txt(
'cal_repeat_until'));
 
  698            $this->recurrence->getFrequenceUntilDate() ? $this->recurrence->getFrequenceUntilDate() : 
null 
  700        $tpl->setVariable(
'UNTIL_END_DATE', $dt->getTableFilterHTML());
 
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_FREQ_MONTHLY
static _getInstanceByUserId($a_user_id)
get singleton instance
static _numericDayToString($a_day, $a_long=true)
get
static _numericMonthToString($a_month, $a_long=true)
numeric month to string
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
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.
const IL_CAL_FREQ_DAILY
Model of calendar entry recurrcences.