@@ -76,8 +76,8 @@ discard block |
||
| 76 | 76 | static private $recur_egw2ical_2_0 = array( |
| 77 | 77 | self::DAILY => 'DAILY', |
| 78 | 78 | self::WEEKLY => 'WEEKLY', |
| 79 | - self::MONTHLY_WDAY => 'MONTHLY', // BYDAY={1..7, -1}{MO..SO, last workday} |
|
| 80 | - self::MONTHLY_MDAY => 'MONTHLY', // BYMONHTDAY={1..31, -1 for last day of month} |
|
| 79 | + self::MONTHLY_WDAY => 'MONTHLY', // BYDAY={1..7, -1}{MO..SO, last workday} |
|
| 80 | + self::MONTHLY_MDAY => 'MONTHLY', // BYMONHTDAY={1..31, -1 for last day of month} |
|
| 81 | 81 | self::YEARLY => 'YEARLY', |
| 82 | 82 | ); |
| 83 | 83 | |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | static private $recur_egw2ical_1_0 = array( |
| 88 | 88 | self::DAILY => 'D', |
| 89 | 89 | self::WEEKLY => 'W', |
| 90 | - self::MONTHLY_WDAY => 'MP', // BYDAY={1..7,-1}{MO..SO, last workday} |
|
| 91 | - self::MONTHLY_MDAY => 'MD', // BYMONHTDAY={1..31,-1} |
|
| 90 | + self::MONTHLY_WDAY => 'MP', // BYDAY={1..7,-1}{MO..SO, last workday} |
|
| 91 | + self::MONTHLY_MDAY => 'MD', // BYMONHTDAY={1..31,-1} |
|
| 92 | 92 | self::YEARLY => 'YM', |
| 93 | 93 | ); |
| 94 | 94 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | const THURSDAY = 16; |
| 139 | 139 | const FRIDAY = 32; |
| 140 | 140 | const SATURDAY = 64; |
| 141 | - const WORKDAYS = 62; // Mo, ..., Fr |
|
| 141 | + const WORKDAYS = 62; // Mo, ..., Fr |
|
| 142 | 142 | const ALLDAYS = 127; |
| 143 | 143 | /** |
| 144 | 144 | * Translate weekday bitmasks to labels |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | * |
| 167 | 167 | * @var array |
| 168 | 168 | */ |
| 169 | - public $exceptions=array(); |
|
| 169 | + public $exceptions = array(); |
|
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Array of exceptions as DateTime/egw_time objects |
| 173 | 173 | * |
| 174 | 174 | * @var array |
| 175 | 175 | */ |
| 176 | - public $exceptions_objs=array(); |
|
| 176 | + public $exceptions_objs = array(); |
|
| 177 | 177 | |
| 178 | 178 | /** |
| 179 | 179 | * Starttime of series |
@@ -216,9 +216,9 @@ discard block |
||
| 216 | 216 | * @param int $weekdays =0 self::SUNDAY=1|self::MONDAY=2|...|self::SATURDAY=64 |
| 217 | 217 | * @param array $exceptions =null DateTime objects with exceptions |
| 218 | 218 | */ |
| 219 | - public function __construct(DateTime $time,$type,$interval=1,DateTime $enddate=null,$weekdays=0,array $exceptions=null) |
|
| 219 | + public function __construct(DateTime $time, $type, $interval = 1, DateTime $enddate = null, $weekdays = 0, array $exceptions = null) |
|
| 220 | 220 | { |
| 221 | - switch($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
| 221 | + switch ($GLOBALS['egw_info']['user']['preferences']['calendar']['weekdaystarts']) |
|
| 222 | 222 | { |
| 223 | 223 | case 'Sunday': |
| 224 | 224 | $this->lastdayofweek = self::SATURDAY; |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $this->time = $time instanceof Api\DateTime ? $time : new Api\DateTime($time); |
| 234 | 234 | |
| 235 | - if (!in_array($type,array(self::NONE, self::DAILY, self::WEEKLY, self::MONTHLY_MDAY, self::MONTHLY_WDAY, self::YEARLY))) |
|
| 235 | + if (!in_array($type, array(self::NONE, self::DAILY, self::WEEKLY, self::MONTHLY_MDAY, self::MONTHLY_WDAY, self::YEARLY))) |
|
| 236 | 236 | { |
| 237 | 237 | throw new Api\Exception\WrongParameter(__METHOD__."($time,$type,$interval,$enddate,$weekdays,...) type $type is NOT valid!"); |
| 238 | 238 | } |
@@ -242,16 +242,16 @@ discard block |
||
| 242 | 242 | if ($type == self::MONTHLY_WDAY) |
| 243 | 243 | { |
| 244 | 244 | // check for last week of month |
| 245 | - if (($day = $this->time->format('d')) >= 21 && $day > self::daysInMonth($this->time)-7) |
|
| 245 | + if (($day = $this->time->format('d')) >= 21 && $day > self::daysInMonth($this->time) - 7) |
|
| 246 | 246 | { |
| 247 | 247 | $this->monthly_byday_num = -1; |
| 248 | 248 | } |
| 249 | 249 | else |
| 250 | 250 | { |
| 251 | - $this->monthly_byday_num = 1 + floor(($this->time->format('d')-1) / 7); |
|
| 251 | + $this->monthly_byday_num = 1 + floor(($this->time->format('d') - 1) / 7); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | - elseif($type == self::MONTHLY_MDAY) |
|
| 254 | + elseif ($type == self::MONTHLY_MDAY) |
|
| 255 | 255 | { |
| 256 | 256 | $this->monthly_bymonthday = (int)$this->time->format('d'); |
| 257 | 257 | // check for last day of month |
@@ -268,7 +268,7 @@ discard block |
||
| 268 | 268 | |
| 269 | 269 | if ((int)$interval < 1) |
| 270 | 270 | { |
| 271 | - $interval = 1; // calendar stores no (extra) interval as null, so using default 1 here |
|
| 271 | + $interval = 1; // calendar stores no (extra) interval as null, so using default 1 here |
|
| 272 | 272 | } |
| 273 | 273 | $this->interval = (int)$interval; |
| 274 | 274 | |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | } |
| 298 | 298 | if ($exceptions) |
| 299 | 299 | { |
| 300 | - foreach($exceptions as $exception) |
|
| 300 | + foreach ($exceptions as $exception) |
|
| 301 | 301 | { |
| 302 | 302 | $exception->setTimezone($this->time->getTimezone()); |
| 303 | 303 | $this->exceptions[] = $exception->format('Ymd'); |
@@ -313,22 +313,22 @@ discard block |
||
| 313 | 313 | * @param int $interval =1 |
| 314 | 314 | * @return int |
| 315 | 315 | */ |
| 316 | - public static function recurrence_interval($type, $interval=1) |
|
| 316 | + public static function recurrence_interval($type, $interval = 1) |
|
| 317 | 317 | { |
| 318 | - switch($type) |
|
| 318 | + switch ($type) |
|
| 319 | 319 | { |
| 320 | 320 | case self::DAILY: |
| 321 | - $duration = 24*3600; |
|
| 321 | + $duration = 24 * 3600; |
|
| 322 | 322 | break; |
| 323 | 323 | case self::WEEKLY: |
| 324 | - $duration = 7*24*3600; |
|
| 324 | + $duration = 7 * 24 * 3600; |
|
| 325 | 325 | break; |
| 326 | 326 | case self::MONTHLY_MDAY: |
| 327 | 327 | case self::MONTHLY_WDAY: |
| 328 | - $duration = 31*24*3600; |
|
| 328 | + $duration = 31 * 24 * 3600; |
|
| 329 | 329 | break; |
| 330 | 330 | case self::YEARLY: |
| 331 | - $duration = 366*24*3600; |
|
| 331 | + $duration = 366 * 24 * 3600; |
|
| 332 | 332 | break; |
| 333 | 333 | } |
| 334 | 334 | if ($interval > 1) $duration *= $interval; |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | */ |
| 345 | 345 | private static function daysInMonth(DateTime $time) |
| 346 | 346 | { |
| 347 | - list($year,$month) = explode('-',$time->format('Y-m')); |
|
| 347 | + list($year, $month) = explode('-', $time->format('Y-m')); |
|
| 348 | 348 | $last_day = new Api\DateTime(); |
| 349 | - $last_day->setDate($year,$month+1,0); |
|
| 349 | + $last_day->setDate($year, $month + 1, 0); |
|
| 350 | 350 | |
| 351 | 351 | return (int)$last_day->format('d'); |
| 352 | 352 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | public function next_no_exception() |
| 378 | 378 | { |
| 379 | - switch($this->type) |
|
| 379 | + switch ($this->type) |
|
| 380 | 380 | { |
| 381 | 381 | case self::NONE: // need to add at least one day, to end "series", as enddate == current date |
| 382 | 382 | case self::DAILY: |
@@ -391,28 +391,28 @@ discard block |
||
| 391 | 391 | // --> on the last day of the week we have to additionally advance interval-1 weeks |
| 392 | 392 | if ($this->interval > 1 && self::getWeekday($this->current) == $this->lastdayofweek) |
| 393 | 393 | { |
| 394 | - $this->current->modify(($this->interval-1).' week'); |
|
| 394 | + $this->current->modify(($this->interval - 1).' week'); |
|
| 395 | 395 | } |
| 396 | 396 | $this->current->modify('1 day'); |
| 397 | 397 | //echo __METHOD__.'() '.$this->current->format('l').', '.$this->current.": $this->weekdays & ".self::getWeekday($this->current)."<br />\n"; |
| 398 | 398 | } |
| 399 | - while(!($this->weekdays & self::getWeekday($this->current))); |
|
| 399 | + while (!($this->weekdays&self::getWeekday($this->current))); |
|
| 400 | 400 | break; |
| 401 | 401 | |
| 402 | 402 | case self::MONTHLY_WDAY: // iCal: BYDAY={1, ..., 5, -1}{MO..SO} |
| 403 | 403 | // advance to start of next month |
| 404 | - list($year,$month) = explode('-',$this->current->format('Y-m')); |
|
| 405 | - $month += $this->interval+($this->monthly_byday_num < 0 ? 1 : 0); |
|
| 406 | - $this->current->setDate($year,$month,$this->monthly_byday_num < 0 ? 0 : 1); |
|
| 404 | + list($year, $month) = explode('-', $this->current->format('Y-m')); |
|
| 405 | + $month += $this->interval + ($this->monthly_byday_num < 0 ? 1 : 0); |
|
| 406 | + $this->current->setDate($year, $month, $this->monthly_byday_num < 0 ? 0 : 1); |
|
| 407 | 407 | //echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).": setDate($year,$month,1): ".$this->current->format('l').', '.$this->current."<br />\n"; |
| 408 | 408 | // now advance to n-th week |
| 409 | 409 | if ($this->monthly_byday_num > 1) |
| 410 | 410 | { |
| 411 | - $this->current->modify(($this->monthly_byday_num-1).' week'); |
|
| 411 | + $this->current->modify(($this->monthly_byday_num - 1).' week'); |
|
| 412 | 412 | //echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).': modify('.($this->monthly_byday_num-1).' week): '.$this->current->format('l').', '.$this->current."<br />\n"; |
| 413 | 413 | } |
| 414 | 414 | // advance to given weekday |
| 415 | - while(!($this->weekdays & self::getWeekday($this->current))) |
|
| 415 | + while (!($this->weekdays&self::getWeekday($this->current))) |
|
| 416 | 416 | { |
| 417 | 417 | $this->current->modify(($this->monthly_byday_num < 0 ? -1 : 1).' day'); |
| 418 | 418 | //echo __METHOD__."() $this->monthly_byday_num".substr(self::$days[$this->monthly_byday_wday],0,2).': modify(1 day): '.$this->current->format('l').', '.$this->current."<br />\n"; |
@@ -420,10 +420,10 @@ discard block |
||
| 420 | 420 | break; |
| 421 | 421 | |
| 422 | 422 | case self::MONTHLY_MDAY: // iCal: monthly_bymonthday={1, ..., 31, -1} |
| 423 | - list($year,$month) = explode('-',$this->current->format('Y-m')); |
|
| 424 | - $day = $this->monthly_bymonthday+($this->monthly_bymonthday < 0 ? 1 : 0); |
|
| 425 | - $month += $this->interval+($this->monthly_bymonthday < 0 ? 1 : 0); |
|
| 426 | - $this->current->setDate($year,$month,$day); |
|
| 423 | + list($year, $month) = explode('-', $this->current->format('Y-m')); |
|
| 424 | + $day = $this->monthly_bymonthday + ($this->monthly_bymonthday < 0 ? 1 : 0); |
|
| 425 | + $month += $this->interval + ($this->monthly_bymonthday < 0 ? 1 : 0); |
|
| 426 | + $this->current->setDate($year, $month, $day); |
|
| 427 | 427 | //echo __METHOD__."() setDate($year,$month,$day): ".$this->current->format('l').', '.$this->current."<br />\n"; |
| 428 | 428 | break; |
| 429 | 429 | |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | { |
| 446 | 446 | $this->next_no_exception(); |
| 447 | 447 | } |
| 448 | - while($this->exceptions && in_array($this->current->format('Ymd'),$this->exceptions)); |
|
| 448 | + while ($this->exceptions && in_array($this->current->format('Ymd'), $this->exceptions)); |
|
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | /** |
@@ -477,7 +477,7 @@ discard block |
||
| 477 | 477 | if (isset($this->current)) $backup = $this->current; |
| 478 | 478 | $this->rewind(); |
| 479 | 479 | |
| 480 | - while(--$count > 0) |
|
| 480 | + while (--$count > 0) |
|
| 481 | 481 | { |
| 482 | 482 | $this->next_no_exception(); |
| 483 | 483 | } |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | // if enddate is now before next acurrence, but not on same day, we use previous recurrence |
| 503 | 503 | // this can happen if client gives an enddate which is NOT a recurrence date |
| 504 | 504 | // eg. for a on Monday recurring weekly event a Tuesday as enddate |
| 505 | - if ($this->enddate < $this->current && $this->current->format('Ymd') != $this->enddate->format('Ymd')) |
|
| 505 | + if ($this->enddate < $this->current && $this->current->format('Ymd') != $this->enddate->format('Ymd')) |
|
| 506 | 506 | { |
| 507 | 507 | $last = $previous; |
| 508 | 508 | } |
@@ -521,7 +521,7 @@ discard block |
||
| 521 | 521 | $this->current = clone $this->time; |
| 522 | 522 | while ($this->valid() && |
| 523 | 523 | $this->exceptions && |
| 524 | - in_array($this->current->format('Ymd'),$this->exceptions)) |
|
| 524 | + in_array($this->current->format('Ymd'), $this->exceptions)) |
|
| 525 | 525 | { |
| 526 | 526 | $this->next_no_exception(); |
| 527 | 527 | } |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | * @param boolean $use_just_date =false default use also time |
| 534 | 534 | * @return boolean |
| 535 | 535 | */ |
| 536 | - public function valid($use_just_date=false) |
|
| 536 | + public function valid($use_just_date = false) |
|
| 537 | 537 | { |
| 538 | 538 | if ($use_just_date) |
| 539 | 539 | { |
@@ -551,9 +551,9 @@ discard block |
||
| 551 | 551 | { |
| 552 | 552 | $str = ''; |
| 553 | 553 | // Repeated Events |
| 554 | - if($this->type != self::NONE) |
|
| 554 | + if ($this->type != self::NONE) |
|
| 555 | 555 | { |
| 556 | - list($str) = explode(' (',lang(self::$types[$this->type])); // remove (by day/date) from Monthly |
|
| 556 | + list($str) = explode(' (', lang(self::$types[$this->type])); // remove (by day/date) from Monthly |
|
| 557 | 557 | |
| 558 | 558 | $str_extra = array(); |
| 559 | 559 | switch ($this->type) |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | { |
| 570 | 570 | $repeat_days[] = $this->type == self::WEEKLY ? lang('all') : lang('day'); |
| 571 | 571 | } |
| 572 | - elseif($this->weekdays == self::WORKDAYS) |
|
| 572 | + elseif ($this->weekdays == self::WORKDAYS) |
|
| 573 | 573 | { |
| 574 | 574 | $repeat_days[] = $this->type == self::WEEKLY ? lang('workdays') : lang('workday'); |
| 575 | 575 | } |
@@ -577,24 +577,24 @@ discard block |
||
| 577 | 577 | { |
| 578 | 578 | foreach (self::$days as $mask => $label) |
| 579 | 579 | { |
| 580 | - if ($this->weekdays & $mask) |
|
| 580 | + if ($this->weekdays&$mask) |
|
| 581 | 581 | { |
| 582 | 582 | $repeat_days[] = lang($label); |
| 583 | 583 | } |
| 584 | 584 | } |
| 585 | 585 | } |
| 586 | - if($this->type == self::WEEKLY && count($repeat_days)) |
|
| 586 | + if ($this->type == self::WEEKLY && count($repeat_days)) |
|
| 587 | 587 | { |
| 588 | - $str_extra[] = lang('days repeated').': '.implode(', ',$repeat_days); |
|
| 588 | + $str_extra[] = lang('days repeated').': '.implode(', ', $repeat_days); |
|
| 589 | 589 | } |
| 590 | - elseif($this->type == self::MONTHLY_WDAY) |
|
| 590 | + elseif ($this->type == self::MONTHLY_WDAY) |
|
| 591 | 591 | { |
| 592 | - $str_extra[] = ($this->monthly_byday_num == -1 ? lang('last') : $this->monthly_byday_num.'.').' '.implode(', ',$repeat_days); |
|
| 592 | + $str_extra[] = ($this->monthly_byday_num == -1 ? lang('last') : $this->monthly_byday_num.'.').' '.implode(', ', $repeat_days); |
|
| 593 | 593 | } |
| 594 | 594 | break; |
| 595 | 595 | |
| 596 | 596 | } |
| 597 | - if($this->interval > 1) |
|
| 597 | + if ($this->interval > 1) |
|
| 598 | 598 | { |
| 599 | 599 | $str_extra[] = lang('Interval').': '.$this->interval; |
| 600 | 600 | } |
@@ -610,9 +610,9 @@ discard block |
||
| 610 | 610 | { |
| 611 | 611 | $str_extra[] = $this->time->getTimezone()->getName(); |
| 612 | 612 | } |
| 613 | - if(count($str_extra)) |
|
| 613 | + if (count($str_extra)) |
|
| 614 | 614 | { |
| 615 | - $str .= ' ('.implode(', ',$str_extra).')'; |
|
| 615 | + $str .= ' ('.implode(', ', $str_extra).')'; |
|
| 616 | 616 | } |
| 617 | 617 | } |
| 618 | 618 | return $str; |
@@ -624,24 +624,24 @@ discard block |
||
| 624 | 624 | * |
| 625 | 625 | * $return array vCalendar RRULE |
| 626 | 626 | */ |
| 627 | - public function generate_rrule($version='2.0') |
|
| 627 | + public function generate_rrule($version = '2.0') |
|
| 628 | 628 | { |
| 629 | 629 | $repeat_days = array(); |
| 630 | 630 | $rrule = array(); |
| 631 | 631 | |
| 632 | - if ($this->type == self::NONE) return false; // no recuring event |
|
| 632 | + if ($this->type == self::NONE) return false; // no recuring event |
|
| 633 | 633 | |
| 634 | 634 | if ($version == '1.0') |
| 635 | 635 | { |
| 636 | - $rrule['FREQ'] = self::$recur_egw2ical_1_0[$this->type] . $this->interval; |
|
| 636 | + $rrule['FREQ'] = self::$recur_egw2ical_1_0[$this->type].$this->interval; |
|
| 637 | 637 | switch ($this->type) |
| 638 | 638 | { |
| 639 | 639 | case self::WEEKLY: |
| 640 | 640 | foreach (self::$days as $mask => $label) |
| 641 | 641 | { |
| 642 | - if ($this->weekdays & $mask) |
|
| 642 | + if ($this->weekdays&$mask) |
|
| 643 | 643 | { |
| 644 | - $repeat_days[] = strtoupper(substr($label,0,2)); |
|
| 644 | + $repeat_days[] = strtoupper(substr($label, 0, 2)); |
|
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | 647 | $rrule['BYDAY'] = implode(' ', $repeat_days); |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | case self::MONTHLY_WDAY: // weekday of the month: BDAY={1..5}+ {MO..SO} |
| 655 | 655 | $rrule['BYDAY'] = abs($this->monthly_byday_num); |
| 656 | 656 | $rrule['BYDAY'] .= ($this->monthly_byday_num < 0) ? '- ' : '+ '; |
| 657 | - $rrule['BYDAY'] .= strtoupper(substr($this->time->format('l'),0,2)); |
|
| 657 | + $rrule['BYDAY'] .= strtoupper(substr($this->time->format('l'), 0, 2)); |
|
| 658 | 658 | $rrule['FREQ'] = $rrule['FREQ'].' '.$rrule['BYDAY']; |
| 659 | 659 | break; |
| 660 | 660 | } |
@@ -672,9 +672,9 @@ discard block |
||
| 672 | 672 | case self::WEEKLY: |
| 673 | 673 | foreach (self::$days as $mask => $label) |
| 674 | 674 | { |
| 675 | - if ($this->weekdays & $mask) |
|
| 675 | + if ($this->weekdays&$mask) |
|
| 676 | 676 | { |
| 677 | - $repeat_days[] = strtoupper(substr($label,0,2)); |
|
| 677 | + $repeat_days[] = strtoupper(substr($label, 0, 2)); |
|
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | $rrule['BYDAY'] = implode(',', $repeat_days); |
@@ -685,8 +685,8 @@ discard block |
||
| 685 | 685 | break; |
| 686 | 686 | |
| 687 | 687 | case self::MONTHLY_WDAY: // weekday of the month: BDAY={1..5}{MO..SO} |
| 688 | - $rrule['BYDAY'] = $this->monthly_byday_num . |
|
| 689 | - strtoupper(substr($this->time->format('l'),0,2)); |
|
| 688 | + $rrule['BYDAY'] = $this->monthly_byday_num. |
|
| 689 | + strtoupper(substr($this->time->format('l'), 0, 2)); |
|
| 690 | 690 | break; |
| 691 | 691 | } |
| 692 | 692 | if ($this->interval > 1) |
@@ -721,12 +721,12 @@ discard block |
||
| 721 | 721 | * |
| 722 | 722 | * @return calendar_rrule false on error |
| 723 | 723 | */ |
| 724 | - public static function event2rrule(array $event,$usertime=true,$to_tz=null) |
|
| 724 | + public static function event2rrule(array $event, $usertime = true, $to_tz = null) |
|
| 725 | 725 | { |
| 726 | - if (!is_array($event) || !isset($event['tzid'])) return false; |
|
| 726 | + if (!is_array($event) || !isset($event['tzid'])) return false; |
|
| 727 | 727 | if (!$to_tz) $to_tz = $event['tzid']; |
| 728 | 728 | $timestamp_tz = $usertime ? Api\DateTime::$user_timezone : Api\DateTime::$server_timezone; |
| 729 | - $time = is_a($event['start'],'DateTime') ? $event['start'] : new Api\DateTime($event['start'],$timestamp_tz); |
|
| 729 | + $time = is_a($event['start'], 'DateTime') ? $event['start'] : new Api\DateTime($event['start'], $timestamp_tz); |
|
| 730 | 730 | |
| 731 | 731 | if (!isset(self::$tz_cache[$to_tz])) |
| 732 | 732 | { |
@@ -739,16 +739,16 @@ discard block |
||
| 739 | 739 | |
| 740 | 740 | if ($event['recur_enddate']) |
| 741 | 741 | { |
| 742 | - $enddate = is_a($event['recur_enddate'],'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'],$timestamp_tz); |
|
| 742 | + $enddate = is_a($event['recur_enddate'], 'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'], $timestamp_tz); |
|
| 743 | 743 | } |
| 744 | 744 | if (is_array($event['recur_exception'])) |
| 745 | 745 | { |
| 746 | - foreach($event['recur_exception'] as $exception) |
|
| 746 | + foreach ($event['recur_exception'] as $exception) |
|
| 747 | 747 | { |
| 748 | - $exceptions[] = is_a($exception,'DateTime') ? $exception : new Api\DateTime($exception,$timestamp_tz); |
|
| 748 | + $exceptions[] = is_a($exception, 'DateTime') ? $exception : new Api\DateTime($exception, $timestamp_tz); |
|
| 749 | 749 | } |
| 750 | 750 | } |
| 751 | - return new calendar_rrule($time,$event['recur_type'],$event['recur_interval'],$enddate,$event['recur_data'],$exceptions); |
|
| 751 | + return new calendar_rrule($time, $event['recur_type'], $event['recur_interval'], $enddate, $event['recur_data'], $exceptions); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
@@ -774,7 +774,7 @@ discard block |
||
| 774 | 774 | * @param DateTime/string starttime of the event (in servertime) |
| 775 | 775 | * @param string $to_tz new timezone |
| 776 | 776 | */ |
| 777 | - public static function rrule2tz(array &$event,$starttime,$to_tz) |
|
| 777 | + public static function rrule2tz(array &$event, $starttime, $to_tz) |
|
| 778 | 778 | { |
| 779 | 779 | // We assume that the difference between timezones can result |
| 780 | 780 | // in a maximum of one day |
@@ -795,7 +795,7 @@ discard block |
||
| 795 | 795 | self::$tz_cache[$to_tz] = calendar_timezones::DateTimeZone($to_tz); |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | - $time = is_a($starttime,'DateTime') ? |
|
| 798 | + $time = is_a($starttime, 'DateTime') ? |
|
| 799 | 799 | $starttime : new Api\DateTime($starttime, Api\DateTime::$server_timezone); |
| 800 | 800 | $time->setTimezone(self::$tz_cache[$event['tzid']]); |
| 801 | 801 | $remote = clone $time; |
@@ -813,11 +813,11 @@ discard block |
||
| 813 | 813 | if ($delta == 1 || $delta == -6) |
| 814 | 814 | { |
| 815 | 815 | $mask = $mask << 1; |
| 816 | - if ($mask & 128) $mask = $mask - 127; // overflow |
|
| 816 | + if ($mask&128) $mask = $mask - 127; // overflow |
|
| 817 | 817 | } |
| 818 | 818 | else |
| 819 | 819 | { |
| 820 | - if ($mask & 1) $mask = $mask + 128; // underflow |
|
| 820 | + if ($mask&1) $mask = $mask + 128; // underflow |
|
| 821 | 821 | $mask = $mask >> 1; |
| 822 | 822 | } |
| 823 | 823 | $event['recur_data'] = $mask; |
@@ -828,15 +828,15 @@ discard block |
||
| 828 | 828 | |
| 829 | 829 | if (isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) // some tests |
| 830 | 830 | { |
| 831 | - ini_set('display_errors',1); |
|
| 832 | - error_reporting(E_ALL & ~E_NOTICE); |
|
| 831 | + ini_set('display_errors', 1); |
|
| 832 | + error_reporting(E_ALL&~E_NOTICE); |
|
| 833 | 833 | function lang($str) { return $str; } |
| 834 | 834 | $GLOBALS['egw_info']['user']['preferences']['common']['tz'] = $_REQUEST['user-tz'] ? $_REQUEST['user-tz'] : 'Europe/Berlin'; |
| 835 | 835 | require_once('../../api/src/autoload.php'); |
| 836 | 836 | |
| 837 | 837 | if (!isset($_REQUEST['time'])) |
| 838 | 838 | { |
| 839 | - $now = new Api\DateTime('now',new DateTimeZone($_REQUEST['tz'] = 'UTC')); |
|
| 839 | + $now = new Api\DateTime('now', new DateTimeZone($_REQUEST['tz'] = 'UTC')); |
|
| 840 | 840 | $_REQUEST['time'] = $now->format(); |
| 841 | 841 | $_REQUEST['type'] = calendar_rrule::WEEKLY; |
| 842 | 842 | $_REQUEST['interval'] = 2; |
@@ -845,29 +845,29 @@ discard block |
||
| 845 | 845 | $_REQUEST['user-tz'] = 'Europe/Berlin'; |
| 846 | 846 | } |
| 847 | 847 | echo "<html>\n<head>\n\t<title>Test calendar_rrule class</title>\n</head>\n<body>\n<form method='GET'>\n"; |
| 848 | - echo "<p>Date+Time: ".Api\Html::input('time',$_REQUEST['time']). |
|
| 849 | - Api\Html::select('tz',$_REQUEST['tz'],Api\DateTime::getTimezones())."</p>\n"; |
|
| 850 | - echo "<p>Type: ".Api\Html::select('type',$_REQUEST['type'],calendar_rrule::$types)."\n". |
|
| 851 | - "Interval: ".Api\Html::input('interval',$_REQUEST['interval'])."</p>\n"; |
|
| 848 | + echo "<p>Date+Time: ".Api\Html::input('time', $_REQUEST['time']). |
|
| 849 | + Api\Html::select('tz', $_REQUEST['tz'], Api\DateTime::getTimezones())."</p>\n"; |
|
| 850 | + echo "<p>Type: ".Api\Html::select('type', $_REQUEST['type'], calendar_rrule::$types)."\n". |
|
| 851 | + "Interval: ".Api\Html::input('interval', $_REQUEST['interval'])."</p>\n"; |
|
| 852 | 852 | echo "<table><tr><td>\n"; |
| 853 | - echo "Weekdays:<br />".Api\Html::checkbox_multiselect('weekdays',$_REQUEST['weekdays'],calendar_rrule::$days,false,'','7',false,'height: 150px;')."\n"; |
|
| 853 | + echo "Weekdays:<br />".Api\Html::checkbox_multiselect('weekdays', $_REQUEST['weekdays'], calendar_rrule::$days, false, '', '7', false, 'height: 150px;')."\n"; |
|
| 854 | 854 | echo "</td><td>\n"; |
| 855 | - echo "<p>Exceptions:<br />".Api\Html::textarea('exceptions',$_REQUEST['exceptions'],'style="height: 150px;"')."\n"; |
|
| 855 | + echo "<p>Exceptions:<br />".Api\Html::textarea('exceptions', $_REQUEST['exceptions'], 'style="height: 150px;"')."\n"; |
|
| 856 | 856 | echo "</td></tr></table>\n"; |
| 857 | - echo "<p>Enddate: ".Api\Html::input('enddate',$_REQUEST['enddate'])."</p>\n"; |
|
| 858 | - echo "<p>Display recurances in ".Api\Html::select('user-tz',$_REQUEST['user-tz'],Api\DateTime::getTimezones())."</p>\n"; |
|
| 859 | - echo "<p>".Api\Html::submit_button('calc','Calculate')."</p>\n"; |
|
| 857 | + echo "<p>Enddate: ".Api\Html::input('enddate', $_REQUEST['enddate'])."</p>\n"; |
|
| 858 | + echo "<p>Display recurances in ".Api\Html::select('user-tz', $_REQUEST['user-tz'], Api\DateTime::getTimezones())."</p>\n"; |
|
| 859 | + echo "<p>".Api\Html::submit_button('calc', 'Calculate')."</p>\n"; |
|
| 860 | 860 | echo "</form>\n"; |
| 861 | 861 | |
| 862 | 862 | $tz = new DateTimeZone($_REQUEST['tz']); |
| 863 | - $time = new Api\DateTime($_REQUEST['time'],$tz); |
|
| 864 | - if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'],$tz); |
|
| 865 | - $weekdays = 0; foreach((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; } |
|
| 866 | - if ($_REQUEST['exceptions']) foreach(preg_split("/[,\r\n]+ ?/",$_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); } |
|
| 863 | + $time = new Api\DateTime($_REQUEST['time'], $tz); |
|
| 864 | + if ($_REQUEST['enddate']) $enddate = new Api\DateTime($_REQUEST['enddate'], $tz); |
|
| 865 | + $weekdays = 0; foreach ((array)$_REQUEST['weekdays'] as $mask) { $weekdays |= $mask; } |
|
| 866 | + if ($_REQUEST['exceptions']) foreach (preg_split("/[,\r\n]+ ?/", $_REQUEST['exceptions']) as $exception) { $exceptions[] = new Api\DateTime($exception); } |
|
| 867 | 867 | |
| 868 | - $rrule = new calendar_rrule($time,$_REQUEST['type'],$_REQUEST['interval'],$enddate,$weekdays,$exceptions); |
|
| 868 | + $rrule = new calendar_rrule($time, $_REQUEST['type'], $_REQUEST['interval'], $enddate, $weekdays, $exceptions); |
|
| 869 | 869 | echo "<h3>".$time->format('l').', '.$time.' ('.$tz->getName().') '.$rrule."</h3>\n"; |
| 870 | - foreach($rrule as $rtime) |
|
| 870 | + foreach ($rrule as $rtime) |
|
| 871 | 871 | { |
| 872 | 872 | $rtime->setTimezone(Api\DateTime::$user_timezone); |
| 873 | 873 | echo ++$n.': '.$rtime->format('l').', '.$rtime."<br />\n"; |