Completed
Push — 1.10.x ( 51aeba...107530 )
by Yannick
123:47 queued 78:53
created
main/inc/lib/icalcreator/iCalcreator.class.php 1 patch
Braces   +2268 added lines, -1344 removed lines patch added patch discarded remove patch
@@ -44,8 +44,10 @@  discard block
 block discarded – undo
44 44
 }
45 45
 */
46 46
 /* only for phpversion 5.x, date management, default timezone setting */
47
-if( substr( phpversion(), 0, 1) >= '5' ) // && ( 'UTC' == date_default_timezone_get() )) {
47
+if( substr( phpversion(), 0, 1) >= '5' ) {
48
+    // && ( 'UTC' == date_default_timezone_get() )) {
48 49
     date_default_timezone_set( 'Europe/Stockholm' );
50
+}
49 51
 /* version string, do NOT remove!! */
50 52
 define( 'ICALCREATOR_VERSION', 'iCalcreator 2.6' );
51 53
 /*********************************************************************************/
@@ -96,8 +98,9 @@  discard block
 block discarded – undo
96 98
         /**
97 99
          *   language = <Text identifying a language, as defined in [RFC 1766]>
98 100
          */
99
-        if( defined( 'ICAL_LANG' ))
100
-            $this->setConfig( 'language', ICAL_LANG );
101
+        if( defined( 'ICAL_LANG' )) {
102
+                    $this->setConfig( 'language', ICAL_LANG );
103
+        }
101 104
         $this->setConfig( 'allowEmpty', TRUE );
102 105
         $this->setConfig( 'nl',         "\n" );
103 106
         $this->setConfig( 'format',     'iCal');
@@ -120,7 +123,9 @@  discard block
 block discarded – undo
120 123
      * @return string
121 124
      */
122 125
     function createCalscale() {
123
-        if( empty( $this->calscale )) return FALSE;
126
+        if( empty( $this->calscale )) {
127
+            return FALSE;
128
+        }
124 129
         switch( $this->format ) {
125 130
             case 'xcal':
126 131
                 return ' calscale="'.$this->calscale.'"'.$this->nl;
@@ -139,7 +144,9 @@  discard block
 block discarded – undo
139 144
      * @return void
140 145
      */
141 146
     function setCalscale( $value ) {
142
-        if( empty( $value )) return FALSE;
147
+        if( empty( $value )) {
148
+            return FALSE;
149
+        }
143 150
         $this->calscale = $value;
144 151
     }
145 152
     /*********************************************************************************/
@@ -154,7 +161,9 @@  discard block
 block discarded – undo
154 161
      * @return string
155 162
      */
156 163
     function createMethod() {
157
-        if( empty( $this->method )) return FALSE;
164
+        if( empty( $this->method )) {
165
+            return FALSE;
166
+        }
158 167
         switch( $this->format ) {
159 168
             case 'xcal':
160 169
                 return ' method="'.$this->method.'"'.$this->nl;
@@ -173,7 +182,9 @@  discard block
 block discarded – undo
173 182
      * @return bool
174 183
      */
175 184
     function setMethod( $value ) {
176
-        if( empty( $value )) return FALSE;
185
+        if( empty( $value )) {
186
+            return FALSE;
187
+        }
177 188
         $this->method = $value;
178 189
         return TRUE;
179 190
     }
@@ -193,8 +204,9 @@  discard block
 block discarded – undo
193 204
      * @return string
194 205
      */
195 206
     function createProdid() {
196
-        if( !isset( $this->prodid ))
197
-            $this->_makeProdid();
207
+        if( !isset( $this->prodid )) {
208
+                    $this->_makeProdid();
209
+        }
198 210
         switch( $this->format ) {
199 211
             case 'xcal':
200 212
                 return ' prodid="'.$this->prodid.'"'.$this->nl;
@@ -245,8 +257,9 @@  discard block
 block discarded – undo
245 257
      * @return string
246 258
      */
247 259
     function createVersion() {
248
-        if( empty( $this->version ))
249
-            $this->_makeVersion();
260
+        if( empty( $this->version )) {
261
+                    $this->_makeVersion();
262
+        }
250 263
         switch( $this->format ) {
251 264
             case 'xcal':
252 265
                 return ' version="'.$this->version.'"'.$this->nl;
@@ -275,7 +288,9 @@  discard block
 block discarded – undo
275 288
      * @return void
276 289
      */
277 290
     function setVersion( $value ) {
278
-        if( empty( $value )) return FALSE;
291
+        if( empty( $value )) {
292
+            return FALSE;
293
+        }
279 294
         $this->version = $value;
280 295
         return TRUE;
281 296
     }
@@ -291,10 +306,12 @@  discard block
 block discarded – undo
291 306
      * @return string
292 307
      */
293 308
     function createXprop() {
294
-        if( 'xcal' == $this->format )
295
-            return false;
296
-        if( 0 >= count( $this->xprop ))
297
-            return;
309
+        if( 'xcal' == $this->format ) {
310
+                    return false;
311
+        }
312
+        if( 0 >= count( $this->xprop )) {
313
+                    return;
314
+        }
298 315
         $output = null;
299 316
         $toolbox = new calendarComponent();
300 317
         $toolbox->setConfig( 'language', $this->getConfig( 'language' ));
@@ -307,12 +324,13 @@  discard block
 block discarded – undo
307 324
             }
308 325
             $attributes = $toolbox->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
309 326
             if( is_array( $xpropPart['value'] )) {
310
-                foreach( $xpropPart['value'] as $pix => $theXpart )
311
-                    $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
327
+                foreach( $xpropPart['value'] as $pix => $theXpart ) {
328
+                                    $xpropPart['value'][$pix] = $toolbox->_strrep( $theXpart );
329
+                }
312 330
                 $xpropPart['value']  = implode( ',', $xpropPart['value'] );
331
+            } else {
332
+                            $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
313 333
             }
314
-            else
315
-                $xpropPart['value'] = $toolbox->_strrep( $xpropPart['value'] );
316 334
             $output    .= $toolbox->_createElement( $label, $attributes, $xpropPart['value'] );
317 335
         }
318 336
         return $output;
@@ -328,12 +346,20 @@  discard block
 block discarded – undo
328 346
      * @return bool
329 347
      */
330 348
     function setXprop( $label, $value, $params=FALSE ) {
331
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
332
-        if( empty( $label )) return FALSE;
349
+        if( empty( $value )) {
350
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
351
+        } else {
352
+            return FALSE;
353
+        }
354
+        if( empty( $label )) {
355
+            return FALSE;
356
+        }
333 357
         $xprop           = array( 'value' => $value );
334 358
         $toolbox         = new calendarComponent();
335 359
         $xprop['params'] = $toolbox->_setParams( $params );
336
-        if( !is_array( $this->xprop )) $this->xprop = array();
360
+        if( !is_array( $this->xprop )) {
361
+            $this->xprop = array();
362
+        }
337 363
         $this->xprop[strtoupper( $label )] = $xprop;
338 364
         return TRUE;
339 365
     }
@@ -349,8 +375,9 @@  discard block
 block discarded – undo
349 375
      */
350 376
     function deleteProperty( $propName, $propix=FALSE ) {
351 377
         $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
352
-        if( !$propix )
353
-            $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
378
+        if( !$propix ) {
379
+                    $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
380
+        }
354 381
         $this->propdelix[$propName] = --$propix;
355 382
         $return = FALSE;
356 383
         switch( $propName ) {
@@ -369,18 +396,23 @@  discard block
 block discarded – undo
369 396
             default:
370 397
                 $reduced = array();
371 398
                 if( $propName != 'X-PROP' ) {
372
-                    if( !isset( $this->xprop[$propName] )) return FALSE;
399
+                    if( !isset( $this->xprop[$propName] )) {
400
+                        return FALSE;
401
+                    }
373 402
                     foreach( $this->xprop as $k => $a ) {
374
-                        if(( $k != $propName ) && !empty( $a ))
375
-                            $reduced[$k] = $a;
403
+                        if(( $k != $propName ) && !empty( $a )) {
404
+                                                    $reduced[$k] = $a;
405
+                        }
406
+                    }
407
+                } else {
408
+                    if( count( $this->xprop ) <= $propix ) {
409
+                        return FALSE;
376 410
                     }
377
-                }
378
-                else {
379
-                    if( count( $this->xprop ) <= $propix )  return FALSE;
380 411
                     $xpropno = 0;
381 412
                     foreach( $this->xprop as $xpropkey => $xpropvalue ) {
382
-                        if( $propix != $xpropno )
383
-                            $reduced[$xpropkey] = $xpropvalue;
413
+                        if( $propix != $xpropno ) {
414
+                                                    $reduced[$xpropkey] = $xpropvalue;
415
+                        }
384 416
                         $xpropno++;
385 417
                     }
386 418
                 }
@@ -402,8 +434,9 @@  discard block
 block discarded – undo
402 434
     function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE ) {
403 435
         $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
404 436
         if( 'X-PROP' == $propName ) {
405
-            if( !$propix )
406
-                $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
437
+            if( !$propix ) {
438
+                            $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
439
+            }
407 440
             $this->propix[$propName] = --$propix;
408 441
         }
409 442
         switch( $propName ) {
@@ -414,8 +447,9 @@  discard block
 block discarded – undo
414 447
                 return ( !empty( $this->method )) ? $this->method : null;
415 448
                 break;
416 449
             case 'PRODID':
417
-                if( empty( $this->prodid ))
418
-                    $this->_makeProdid();
450
+                if( empty( $this->prodid )) {
451
+                                    $this->_makeProdid();
452
+                }
419 453
                 return $this->prodid;
420 454
                 break;
421 455
             case 'VERSION':
@@ -423,19 +457,23 @@  discard block
 block discarded – undo
423 457
                 break;
424 458
             default:
425 459
                 if( $propName != 'X-PROP' ) {
426
-                    if( !isset( $this->xprop[$propName] )) return FALSE;
460
+                    if( !isset( $this->xprop[$propName] )) {
461
+                        return FALSE;
462
+                    }
427 463
                     return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
428 464
                         : array( $propName, $this->xprop[$propName]['value'] );
429
-                }
430
-                else {
431
-                    if( empty( $this->xprop )) return FALSE;
465
+                } else {
466
+                    if( empty( $this->xprop )) {
467
+                        return FALSE;
468
+                    }
432 469
                     $xpropno = 0;
433 470
                     foreach( $this->xprop as $xpropkey => $xpropvalue ) {
434
-                        if( $propix == $xpropno )
435
-                            return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
471
+                        if( $propix == $xpropno ) {
472
+                                                    return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
436 473
                                 : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
437
-                        else
438
-                            $xpropno++;
474
+                        } else {
475
+                                                    $xpropno++;
476
+                        }
439 477
                     }
440 478
                     return FALSE; // not found ??
441 479
                 }
@@ -454,8 +492,9 @@  discard block
 block discarded – undo
454 492
      */
455 493
     function setProperty () {
456 494
         $numargs    = func_num_args();
457
-        if( 1 > $numargs )
458
-            return FALSE;
495
+        if( 1 > $numargs ) {
496
+                    return FALSE;
497
+        }
459 498
         $arglist    = func_get_args();
460 499
         $arglist[0] = strtoupper( $arglist[0] );
461 500
         switch( $arglist[0] ) {
@@ -466,8 +505,12 @@  discard block
 block discarded – undo
466 505
             case 'VERSION':
467 506
                 return $this->setVersion( $arglist[1] );
468 507
             default:
469
-                if( !isset( $arglist[1] )) $arglist[1] = null;
470
-                if( !isset( $arglist[2] )) $arglist[2] = null;
508
+                if( !isset( $arglist[1] )) {
509
+                    $arglist[1] = null;
510
+                }
511
+                if( !isset( $arglist[2] )) {
512
+                    $arglist[2] = null;
513
+                }
471 514
                 return $this->setXprop( $arglist[0], $arglist[1], $arglist[2] );
472 515
         }
473 516
         return FALSE;
@@ -490,7 +533,9 @@  discard block
 block discarded – undo
490 533
                 unset( $this->compix );
491 534
                 $info = array();
492 535
                 foreach( $this->components as $cix => $component ) {
493
-                    if( empty( $component )) continue;
536
+                    if( empty( $component )) {
537
+                        continue;
538
+                    }
494 539
                     unset( $component->propix );
495 540
                     $info[$cix]['ordno'] = $cix + 1;
496 541
                     $info[$cix]['type']  = $component->objName;
@@ -505,8 +550,9 @@  discard block
 block discarded – undo
505 550
                 return $this->delimiter;
506 551
                 break;
507 552
             case 'DIRECTORY':
508
-                if( empty( $this->directory ))
509
-                    $this->directory = '.';
553
+                if( empty( $this->directory )) {
554
+                                    $this->directory = '.';
555
+                }
510 556
                 return $this->directory;
511 557
                 break;
512 558
             case 'DIRFILE':
@@ -519,10 +565,13 @@  discard block
 block discarded – undo
519 565
                 break;
520 566
             case 'FILENAME':
521 567
                 if( empty( $this->filename )) {
522
-                    if( 'xcal' == $this->format )
523
-                        $this->filename = date( 'YmdHis' ).'.xml'; // recommended xcs.. .
524
-                    else
525
-                        $this->filename = date( 'YmdHis' ).'.ics';
568
+                    if( 'xcal' == $this->format ) {
569
+                                            $this->filename = date( 'YmdHis' ).'.xml';
570
+                    }
571
+                    // recommended xcs.. .
572
+                    else {
573
+                                            $this->filename = date( 'YmdHis' ).'.ics';
574
+                    }
526 575
                 }
527 576
                 return $this->filename;
528 577
                 break;
@@ -530,8 +579,9 @@  discard block
 block discarded – undo
530 579
                 $size    = 0;
531 580
                 if( empty( $this->url )) {
532 581
                     $dirfile = $this->getConfig( 'dirfile' );
533
-                    if( FALSE === ( $size = filesize( $dirfile )))
534
-                        $size = 0;
582
+                    if( FALSE === ( $size = filesize( $dirfile ))) {
583
+                                            $size = 0;
584
+                    }
535 585
                     clearstatcache();
536 586
                 }
537 587
                 return $size;
@@ -551,10 +601,11 @@  discard block
 block discarded – undo
551 601
                 return $this->unique_id;
552 602
                 break;
553 603
             case 'URL':
554
-                if( !empty( $this->url ))
555
-                    return $this->url;
556
-                else
557
-                    return FALSE;
604
+                if( !empty( $this->url )) {
605
+                                    return $this->url;
606
+                } else {
607
+                                    return FALSE;
608
+                }
558 609
                 break;
559 610
         }
560 611
     }
@@ -582,17 +633,18 @@  discard block
 block discarded – undo
582 633
             case 'DIRECTORY':
583 634
                 $value   = trim( $value );
584 635
                 $nl      = $this->getConfig('delimiter');
585
-                if( $nl == substr( $value, ( 0 - strlen( $nl ))))
586
-                    $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
636
+                if( $nl == substr( $value, ( 0 - strlen( $nl )))) {
637
+                                    $value = substr( $value, 0, ( strlen( $value ) - strlen( $nl )));
638
+                }
587 639
                 if( is_dir( $value )) {
588 640
                     /* local directory */
589 641
                     clearstatcache();
590 642
                     $this->directory = $value;
591 643
                     $this->url       = null;
592 644
                     return TRUE;
645
+                } else {
646
+                                    return FALSE;
593 647
                 }
594
-                else
595
-                    return FALSE;
596 648
                 break;
597 649
             case 'FILENAME':
598 650
                 $value   = trim( $value );
@@ -608,17 +660,16 @@  discard block
 block discarded – undo
608 660
                         clearstatcache();
609 661
                         $this->filename = $value;
610 662
                         return TRUE;
663
+                    } else {
664
+                                            return FALSE;
611 665
                     }
612
-                    else
613
-                        return FALSE;
614
-                }
615
-                elseif( FALSE !== touch( $dirfile )) {
666
+                } elseif( FALSE !== touch( $dirfile )) {
616 667
                     /* new local file created */
617 668
                     $this->filename = $value;
618 669
                     return TRUE;
670
+                } else {
671
+                                    return FALSE;
619 672
                 }
620
-                else
621
-                    return FALSE;
622 673
                 break;
623 674
             case 'FORMAT':
624 675
                 $value   = trim( $value );
@@ -626,8 +677,7 @@  discard block
 block discarded – undo
626 677
                     $this->format             = 'xcal';
627 678
                     $this->attributeDelimiter = $this->nl;
628 679
                     $this->valueInit          = null;
629
-                }
630
-                else {
680
+                } else {
631 681
                     $this->format             = null;
632 682
                     $this->attributeDelimiter = ';';
633 683
                     $this->valueInit          = ':';
@@ -666,13 +716,16 @@  discard block
 block discarded – undo
666 716
                 return $this->setConfig( 'filename',  $parts['basename'] );
667 717
                 break;
668 718
         }
669
-        if( !$res ) return FALSE;
719
+        if( !$res ) {
720
+            return FALSE;
721
+        }
670 722
         if( isset( $subcfg ) && !empty( $this->components )) {
671 723
             foreach( $subcfg as $cfgkey => $cfgvalue ) {
672 724
                 foreach( $this->components as $cix => $component ) {
673 725
                     $res = $component->setConfig( $cfgkey, $cfgvalue );
674
-                    if( !$res )
675
-                        break 2;
726
+                    if( !$res ) {
727
+                                            break 2;
728
+                    }
676 729
                     $this->components[$cix] = $component->copy(); // PHP4 compliant
677 730
                 }
678 731
             }
@@ -707,27 +760,26 @@  discard block
 block discarded – undo
707 760
         if ( ctype_digit( (string) $arg1 )) {
708 761
             $argType = 'INDEX';
709 762
             $index   = (int) $arg1 - 1;
710
-        }
711
-        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
763
+        } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
712 764
             $argType = strtolower( $arg1 );
713 765
             $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
714 766
         }
715 767
         $cix1dC = 0;
716 768
         foreach ( $this->components as $cix => $component) {
717
-            if( empty( $component )) continue;
769
+            if( empty( $component )) {
770
+                continue;
771
+            }
718 772
             unset( $component->propix );
719 773
             if(( 'INDEX' == $argType ) && ( $index == $cix )) {
720 774
                 unset( $this->components[$cix] );
721 775
                 return TRUE;
722
-            }
723
-            elseif( $argType == $component->objName ) {
776
+            } elseif( $argType == $component->objName ) {
724 777
                 if( $index == $cix1dC ) {
725 778
                     unset( $this->components[$cix] );
726 779
                     return TRUE;
727 780
                 }
728 781
                 $cix1dC++;
729
-            }
730
-            elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
782
+            } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
731 783
                 unset( $this->components[$cix] );
732 784
                 return TRUE;
733 785
             }
@@ -749,37 +801,39 @@  discard block
 block discarded – undo
749 801
             $argType = 'INDEX';
750 802
             $index   = $this->compix['INDEX'] =
751 803
                 ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
752
-        }
753
-        elseif ( ctype_digit( (string) $arg1 )) {
804
+        } elseif ( ctype_digit( (string) $arg1 )) {
754 805
             $argType = 'INDEX';
755 806
             $index   = (int) $arg1;
756 807
             unset( $this->compix );
757
-        }
758
-        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
808
+        } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
759 809
             unset( $this->compix['INDEX'] );
760 810
             $argType = strtolower( $arg1 );
761
-            if( !$arg2 )
762
-                $index = $this->compix[$argType] =
811
+            if( !$arg2 ) {
812
+                            $index = $this->compix[$argType] =
763 813
                     ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
764
-            else
765
-                $index = (int) $arg2;
814
+            } else {
815
+                            $index = (int) $arg2;
816
+            }
766 817
         }
767 818
         $index  -= 1;
768 819
         $ckeys =  array_keys( $this->components );
769
-        if( !empty( $index) && ( $index > end(  $ckeys )))
770
-            return FALSE;
820
+        if( !empty( $index) && ( $index > end(  $ckeys ))) {
821
+                    return FALSE;
822
+        }
771 823
         $cix1gC = 0;
772 824
         foreach ( $this->components as $cix => $component) {
773
-            if( empty( $component )) continue;
825
+            if( empty( $component )) {
826
+                continue;
827
+            }
774 828
             unset( $component->propix );
775
-            if(( 'INDEX' == $argType ) && ( $index == $cix ))
776
-                return $component->copy();
777
-            elseif( $argType == $component->objName ) {
778
-                if( $index == $cix1gC )
779
-                    return $component->copy();
829
+            if(( 'INDEX' == $argType ) && ( $index == $cix )) {
830
+                            return $component->copy();
831
+            } elseif( $argType == $component->objName ) {
832
+                if( $index == $cix1gC ) {
833
+                                    return $component->copy();
834
+                }
780 835
                 $cix1gC++;
781
-            }
782
-            elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
836
+            } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
783 837
                 unset( $component->propix );
784 838
                 return $component->copy();
785 839
             }
@@ -814,46 +868,68 @@  discard block
 block discarded – undo
814 868
      */
815 869
     function selectComponents( $startY=FALSE, $startM=FALSE, $startD=FALSE, $endY=FALSE, $endM=FALSE, $endD=FALSE, $cType=FALSE, $flat=FALSE, $any=TRUE, $split=TRUE ) {
816 870
         /* check  if empty calendar */
817
-        if( 0 >= count( $this->components )) return FALSE;
871
+        if( 0 >= count( $this->components )) {
872
+            return FALSE;
873
+        }
818 874
         /* check default dates */
819
-        if( !$startY ) $startY = date( 'Y' );
820
-        if( !$startM ) $startM = date( 'm' );
821
-        if( !$startD ) $startD = date( 'd' );
875
+        if( !$startY ) {
876
+            $startY = date( 'Y' );
877
+        }
878
+        if( !$startM ) {
879
+            $startM = date( 'm' );
880
+        }
881
+        if( !$startD ) {
882
+            $startD = date( 'd' );
883
+        }
822 884
         $startDate = mktime( 0, 0, 0, $startM, $startD, $startY );
823
-        if( !$endY )   $endY   = $startY;
824
-        if( !$endM )   $endM   = $startM;
825
-        if( !$endD )   $endD   = $startD;
885
+        if( !$endY ) {
886
+            $endY   = $startY;
887
+        }
888
+        if( !$endM ) {
889
+            $endM   = $startM;
890
+        }
891
+        if( !$endD ) {
892
+            $endD   = $startD;
893
+        }
826 894
         $endDate   = mktime( 23, 59, 59, $endM, $endD, $endY );
827 895
         /* check component types */
828 896
         $validTypes = array('vevent', 'vtodo', 'vjournal', 'vfreebusy' );
829 897
         if( is_array( $cType )) {
830 898
             foreach( $cType as $cix => $theType ) {
831 899
                 $cType[$cix] = $theType = strtolower( $theType );
832
-                if( !in_array( $theType, $validTypes ))
833
-                    $cType[$cix] = 'vevent';
900
+                if( !in_array( $theType, $validTypes )) {
901
+                                    $cType[$cix] = 'vevent';
902
+                }
834 903
             }
835 904
             $cType = array_unique( $cType );
836
-        }
837
-        elseif( !empty( $cType )) {
905
+        } elseif( !empty( $cType )) {
838 906
             $cType = strtolower( $cType );
839
-            if( !in_array( $cType, $validTypes ))
840
-                $cType = array( 'vevent' );
841
-            else
842
-                $cType = array( $cType );
843
-        }
844
-        else
845
-            $cType = $validTypes;
846
-        if( 0 >= count( $cType ))
847
-            $cType = $validTypes;
907
+            if( !in_array( $cType, $validTypes )) {
908
+                            $cType = array( 'vevent' );
909
+            } else {
910
+                            $cType = array( $cType );
911
+            }
912
+        } else {
913
+                    $cType = $validTypes;
914
+        }
915
+        if( 0 >= count( $cType )) {
916
+                    $cType = $validTypes;
917
+        }
848 918
         /* iterate components */
849 919
         $result = array();
850 920
         foreach ( $this->components as $cix => $component ) {
851
-            if( empty( $component )) continue;
921
+            if( empty( $component )) {
922
+                continue;
923
+            }
852 924
             unset( $component->propix, $start );
853 925
             /* deselect unvalid type components */
854
-            if( !in_array( $component->objName, $cType )) continue;
926
+            if( !in_array( $component->objName, $cType )) {
927
+                continue;
928
+            }
855 929
             /* deselect components without dtstart set */
856
-            if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) continue;
930
+            if( FALSE === ( $start = $component->getProperty( 'dtstart' ))) {
931
+                continue;
932
+            }
857 933
             $dtendExist = $dueExist = $durationExist = $endAllDayEvent = FALSE;
858 934
             unset( $end, $startWdate, $endWdate, $rdurWsecs, $rdur, $exdatelist, $workstart, $workend ); // clean up
859 935
             $startWdate = $component->_date2timestamp( $start );
@@ -887,8 +963,9 @@  discard block
 block discarded – undo
887 963
             }
888 964
             if( empty( $end )) {
889 965
                 $end = $component->getProperty( 'duration', FALSE, FALSE, TRUE );// in dtend (array) format
890
-                if( !empty( $end ))
891
-                    $durationExist = TRUE;
966
+                if( !empty( $end )) {
967
+                                    $durationExist = TRUE;
968
+                }
892 969
                 // if( !empty($end))  echo 'selectComp 4 start='.implode('-',$start).' end='.implode('-',$end)."<br />\n"; // test ###
893 970
             }
894 971
             if( empty( $end )) { // assume one day duration if missing end date
@@ -906,55 +983,75 @@  discard block
 block discarded – undo
906 983
             $exdatelist = array();
907 984
             $workstart  = $component->_timestamp2date(( $startDate - $rdurWsecs ), 6);
908 985
             $workend    = $component->_timestamp2date(( $endDate + $rdurWsecs ), 6);
909
-            while( FALSE !== ( $exrule = $component->getProperty( 'exrule' )))    // check exrule
986
+            while( FALSE !== ( $exrule = $component->getProperty( 'exrule' ))) {
987
+                // check exrule
910 988
                 $component->_recur2date( $exdatelist, $exrule, $start, $workstart, $workend );
989
+            }
911 990
             while( FALSE !== ( $exdate = $component->getProperty( 'exdate' ))) {  // check exdate
912 991
                 foreach( $exdate as $theExdate ) {
913 992
                     $exWdate = $component->_date2timestamp( $theExdate );
914
-                    if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate ))
915
-                        $exdatelist[$exWdate] = TRUE;
993
+                    if((( $startDate - $rdurWsecs ) <= $exWdate ) && ( $endDate >= $exWdate )) {
994
+                                            $exdatelist[$exWdate] = TRUE;
995
+                    }
916 996
                 }
917 997
             }
918 998
             /* if 'any' components, check repeating components, removing all excluding dates */
919 999
             if( TRUE === $any ) {
920 1000
                 /* make a list of optional repeating dates for component occurence, rrule, rdate */
921 1001
                 $recurlist = array();
922
-                while( FALSE !== ( $rrule = $component->getProperty( 'rrule' )))    // check rrule
1002
+                while( FALSE !== ( $rrule = $component->getProperty( 'rrule' ))) {
1003
+                    // check rrule
923 1004
                     $component->_recur2date( $recurlist, $rrule, $start, $workstart, $workend );
924
-                foreach( $recurlist as $recurkey => $recurvalue ) // key=match date as timestamp
925
-                    $recurlist[$recurkey] = $rdurWsecs; // add duration in seconds
1005
+                }
1006
+                foreach( $recurlist as $recurkey => $recurvalue ) {
1007
+                    // key=match date as timestamp
1008
+                    $recurlist[$recurkey] = $rdurWsecs;
1009
+                }
1010
+                // add duration in seconds
926 1011
                 while( FALSE !== ( $rdate = $component->getProperty( 'rdate' ))) {  // check rdate
927 1012
                     foreach( $rdate as $theRdate ) {
928 1013
                         if( is_array( $theRdate ) && ( 2 == count( $theRdate )) &&  // all days within PERIOD
929 1014
                             array_key_exists( '0', $theRdate ) &&  array_key_exists( '1', $theRdate )) {
930 1015
                             $rstart = $component->_date2timestamp( $theRdate[0] );
931
-                            if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate ))
932
-                                continue;
933
-                            if( isset( $theRdate[1]['year'] )) // date-date period
1016
+                            if(( $rstart < ( $startDate - $rdurWsecs )) || ( $rstart > $endDate )) {
1017
+                                                            continue;
1018
+                            }
1019
+                            if( isset( $theRdate[1]['year'] )) {
1020
+                                // date-date period
934 1021
                                 $rend = $component->_date2timestamp( $theRdate[1] );
935
-                            else {                             // date-duration period
1022
+                            } else {                             // date-duration period
936 1023
                                 $rend = $component->duration2date( $theRdate[0], $theRdate[1] );
937 1024
                                 $rend = $component->_date2timestamp( $rend );
938 1025
                             }
939
-                            if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart ))
940
-                                $recurlist[$rstart] = ( $rstart - $rend ); // set start date + rdate duration in seconds
1026
+                            if((( $startDate - $rdurWsecs ) <= $rstart ) && ( $endDate >= $rstart )) {
1027
+                                                            $recurlist[$rstart] = ( $rstart - $rend );
1028
+                            }
1029
+                            // set start date + rdate duration in seconds
941 1030
                         } // PERIOD end
942 1031
                         else { // single date
943 1032
                             $theRdate = $component->_date2timestamp( $theRdate );
944
-                            if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate ))
945
-                                $recurlist[$theRdate] = $rdurWsecs; // set start date + event duration in seconds
1033
+                            if((( $startDate - $rdurWsecs ) <= $theRdate ) && ( $endDate >= $theRdate )) {
1034
+                                                            $recurlist[$theRdate] = $rdurWsecs;
1035
+                            }
1036
+                            // set start date + event duration in seconds
946 1037
                         }
947 1038
                     }
948 1039
                 }
949 1040
                 if( 0 < count( $recurlist )) {
950 1041
                     ksort( $recurlist );
951 1042
                     foreach( $recurlist as $recurkey => $durvalue ) {
952
-                        if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) // not within period
1043
+                        if((( $startDate - $rdurWsecs ) > $recurkey ) || ( $endDate < $recurkey )) {
1044
+                            // not within period
953 1045
                             continue;
954
-                        if( isset( $exdatelist[$recurkey] )) // check excluded dates
1046
+                        }
1047
+                        if( isset( $exdatelist[$recurkey] )) {
1048
+                            // check excluded dates
955 1049
                             continue;
956
-                        if( $startWdate >= $recurkey ) // exclude component start date
1050
+                        }
1051
+                        if( $startWdate >= $recurkey ) {
1052
+                            // exclude component start date
957 1053
                             continue;
1054
+                        }
958 1055
                         $component2   = $component->copy();
959 1056
                         $rstart       = $component2->_timestamp2date( $recurkey, 6);
960 1057
                         $datevalue    = $rstart['month'].'/'.$rstart['day'].'/'.$rstart['year'];
@@ -964,16 +1061,16 @@  discard block
 block discarded – undo
964 1061
                             $datevalue .= ( isset( $rstart['sec'] ))  ? ':'.$rstart['sec']  : ':00';
965 1062
                         }
966 1063
                         $datestring = date( $startDateFormat, strtotime( $datevalue ));
967
-                        if( isset( $start['tz'] ))
968
-                            $datestring .= ' '.$start['tz'];
1064
+                        if( isset( $start['tz'] )) {
1065
+                                                    $datestring .= ' '.$start['tz'];
1066
+                        }
969 1067
                         $component2->setProperty( 'X-CURRENT-DTSTART', $datestring );
970 1068
                         $rend   = $component2->_timestamp2date(( $recurkey + $durvalue ), 6);
971 1069
                         if( $dtendExist || $dueExist ) {
972 1070
                             if( $endAllDayEvent ) {
973 1071
                                 $rend2 = mktime( 0, 0, 0, $rend['month'], ($rend['day'] + 1), $rend['year'] );
974 1072
                                 $datevalue  = date( 'm', $rend2 ).'/'.date( 'd', $rend2 ).'/'.date( 'Y', $rend2 );
975
-                            }
976
-                            else {
1073
+                            } else {
977 1074
                                 $datevalue  = $rend['month'].'/'.$rend['day'].'/'.$rend['year'];
978 1075
                                 if( isset( $end['hour'] ) || isset( $end['min'] ) || isset( $end['sec'] )) {
979 1076
                                     $datevalue .= ( isset( $rend['hour'] )) ? ' '.$rend['hour'] : ' 00';
@@ -982,30 +1079,37 @@  discard block
 block discarded – undo
982 1079
                                 }
983 1080
                             }
984 1081
                             $datestring = date( $endDateFormat, strtotime( $datevalue ));
985
-                            if( isset( $end['tz'] ))
986
-                                $datestring .= ' '.$end['tz'];
987
-                            if( $dtendExist )
988
-                                $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
989
-                            elseif( $dueExist )
990
-                                $component2->setProperty( 'X-CURRENT-DUE', $datestring );
1082
+                            if( isset( $end['tz'] )) {
1083
+                                                            $datestring .= ' '.$end['tz'];
1084
+                            }
1085
+                            if( $dtendExist ) {
1086
+                                                            $component2->setProperty( 'X-CURRENT-DTEND', $datestring );
1087
+                            } elseif( $dueExist ) {
1088
+                                                            $component2->setProperty( 'X-CURRENT-DUE', $datestring );
1089
+                            }
991 1090
                         }
992 1091
                         $rend   = $component2->_date2timestamp( $rend );
993 1092
                         $rstart = $recurkey;
994 1093
                         /* add repeating components within valid dates to output array, only start date */
995
-                        if( $flat )
996
-                            $result[] = $component2->copy(); // copy to output
1094
+                        if( $flat ) {
1095
+                                                    $result[] = $component2->copy();
1096
+                        }
1097
+                        // copy to output
997 1098
                         elseif( $split ) {
998
-                            if( $rend > $endDate )
999
-                                $rend = $endDate;
1099
+                            if( $rend > $endDate ) {
1100
+                                                            $rend = $endDate;
1101
+                            }
1000 1102
                             while( $rstart <= $rend ) { // iterate
1001 1103
                                 $wd = getdate( $rstart );
1002 1104
                                 if(( $rstart > $startDate ) &&      // date after dtstart
1003
-                                    !isset( $exdatelist[$rstart] )) // check exclude date
1004
-                                    $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
1105
+                                    !isset( $exdatelist[$rstart] )) {
1106
+                                    // check exclude date
1107
+                                    $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy();
1108
+                                }
1109
+                                // copy to output
1005 1110
                                 $rstart += ( 24*60*60 ); // step one day
1006 1111
                             }
1007
-                        }
1008
-                        elseif(( $rstart >= $startDate ) &&     // date within period
1112
+                        } elseif(( $rstart >= $startDate ) &&     // date within period
1009 1113
                             !isset( $exdatelist[$rstart] )) { // check exclude date
1010 1114
                             $wd = getdate( $rstart );
1011 1115
                             $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component2->copy(); // copy to output
@@ -1013,19 +1117,29 @@  discard block
 block discarded – undo
1013 1117
                     }
1014 1118
                 }
1015 1119
                 /* deselect components with startdate/enddate not within period */
1016
-                if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1120
+                if(( $endWdate < $startDate ) || ( $startWdate > $endDate )) {
1121
+                    continue;
1122
+                }
1017 1123
             }
1018 1124
             /* deselect components with startdate not within period */
1019
-            elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) continue;
1125
+            elseif(( $startWdate < $startDate ) || ( $startWdate > $endDate )) {
1126
+                continue;
1127
+            }
1020 1128
             /* add selected components within valid dates to output array */
1021
-            if( $flat )
1022
-                $result[] = $component->copy(); // copy to output;
1129
+            if( $flat ) {
1130
+                            $result[] = $component->copy();
1131
+            }
1132
+            // copy to output;
1023 1133
             elseif( $split ) {
1024
-                if( $endWdate > $endDate )
1025
-                    $endWdate = $endDate;     // use period end date
1134
+                if( $endWdate > $endDate ) {
1135
+                                    $endWdate = $endDate;
1136
+                }
1137
+                // use period end date
1026 1138
                 if( !isset( $exdatelist[$startWdate] ))  { // check excluded dates
1027
-                    if( $startWdate < $startDate )
1028
-                        $startWdate = $startDate; // use period start date
1139
+                    if( $startWdate < $startDate ) {
1140
+                                            $startWdate = $startDate;
1141
+                    }
1142
+                    // use period start date
1029 1143
                     while( $startWdate <= $endWdate ) { // iterate
1030 1144
                         $wd = getdate( $startWdate );
1031 1145
                         $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
@@ -1039,8 +1153,9 @@  discard block
 block discarded – undo
1039 1153
                 $result[$wd['year']][$wd['mon']][$wd['mday']][] = $component->copy(); // copy to output
1040 1154
             }
1041 1155
         }
1042
-        if( 0 >= count( $result )) return FALSE;
1043
-        elseif( !$flat ) {
1156
+        if( 0 >= count( $result )) {
1157
+            return FALSE;
1158
+        } elseif( !$flat ) {
1044 1159
             foreach( $result as $y => $yeararr ) {
1045 1160
                 foreach( $yeararr as $m => $montharr ) {
1046 1161
                     ksort( $result[$y][$m] );
@@ -1062,8 +1177,9 @@  discard block
 block discarded – undo
1062 1177
      * @return void
1063 1178
      */
1064 1179
     function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
1065
-        if( '' >= $component->getConfig( 'language'))
1066
-            $component->setConfig( 'language',  $this->getConfig( 'language' ));
1180
+        if( '' >= $component->getConfig( 'language')) {
1181
+                    $component->setConfig( 'language',  $this->getConfig( 'language' ));
1182
+        }
1067 1183
         $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1068 1184
         $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1069 1185
         $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -1082,27 +1198,26 @@  discard block
 block discarded – undo
1082 1198
         if ( ctype_digit( (string) $arg1 )) {
1083 1199
             $argType = 'INDEX';
1084 1200
             $index   = (int) $arg1 - 1;
1085
-        }
1086
-        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1201
+        } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
1087 1202
             $argType = strtolower( $arg1 );
1088 1203
             $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
1089 1204
         }
1090 1205
         $cix1sC = 0;
1091 1206
         foreach ( $this->components as $cix => $component2) {
1092
-            if( empty( $component2 )) continue;
1207
+            if( empty( $component2 )) {
1208
+                continue;
1209
+            }
1093 1210
             unset( $component2->propix );
1094 1211
             if(( 'INDEX' == $argType ) && ( $index == $cix )) {
1095 1212
                 $this->components[$cix] = $component->copy();
1096 1213
                 return TRUE;
1097
-            }
1098
-            elseif( $argType == $component2->objName ) {
1214
+            } elseif( $argType == $component2->objName ) {
1099 1215
                 if( $index == $cix1sC ) {
1100 1216
                     $this->components[$cix] = $component->copy();
1101 1217
                     return TRUE;
1102 1218
                 }
1103 1219
                 $cix1sC++;
1104
-            }
1105
-            elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1220
+            } elseif( !$argType && ( $arg1 == $component2->getProperty( 'uid' ))) {
1106 1221
                 $this->components[$cix] = $component->copy();
1107 1222
                 return TRUE;
1108 1223
             }
@@ -1129,73 +1244,124 @@  discard block
 block discarded – undo
1129 1244
         }
1130 1245
     }
1131 1246
     function _cmpfcn( $a, $b ) {
1132
-        if( empty( $a ))                                   return -1;
1133
-        if( empty( $b ))                                   return  1;
1134
-        if(  'vtimezone' == $a->objName)                   return -1;
1135
-        if(  'vtimezone' == $b->objName)                   return  1;
1247
+        if( empty( $a )) {
1248
+            return -1;
1249
+        }
1250
+        if( empty( $b )) {
1251
+            return  1;
1252
+        }
1253
+        if(  'vtimezone' == $a->objName) {
1254
+            return -1;
1255
+        }
1256
+        if(  'vtimezone' == $b->objName) {
1257
+            return  1;
1258
+        }
1136 1259
         $astart = ( isset( $a->xprop['X-CURRENT-DTSTART']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1137
-        if( empty( $astart ) && isset( $a->dtstart['value'] ))
1138
-            $astart = & $a->dtstart['value'];
1260
+        if( empty( $astart ) && isset( $a->dtstart['value'] )) {
1261
+                    $astart = & $a->dtstart['value'];
1262
+        }
1139 1263
         $bstart = ( isset( $b->xprop['X-CURRENT-DTSTART']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTSTART']['value'] ) : null;
1140
-        if( empty( $bstart ) && isset( $b->dtstart['value'] ))
1141
-            $bstart = & $b->dtstart['value'];
1142
-        if(     empty( $astart ))                          return -1;
1143
-        elseif( empty( $bstart ))                          return  1;
1264
+        if( empty( $bstart ) && isset( $b->dtstart['value'] )) {
1265
+                    $bstart = & $b->dtstart['value'];
1266
+        }
1267
+        if(     empty( $astart )) {
1268
+            return -1;
1269
+        } elseif( empty( $bstart )) {
1270
+            return  1;
1271
+        }
1144 1272
         foreach( $this->_sortkeys as $key ) {
1145
-            if    ( empty( $astart[$key] ))                  return -1;
1146
-            elseif( empty( $bstart[$key] ))                  return  1;
1147
-            if    (        $astart[$key] == $bstart[$key])   continue;
1148
-            if    (( (int) $astart[$key] ) < ((int) $bstart[$key] ))
1273
+            if    ( empty( $astart[$key] )) {
1149 1274
                 return -1;
1150
-            elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] ))
1275
+            } elseif( empty( $bstart[$key] )) {
1151 1276
                 return  1;
1277
+            }
1278
+            if    (        $astart[$key] == $bstart[$key]) {
1279
+                continue;
1280
+            }
1281
+            if    (( (int) $astart[$key] ) < ((int) $bstart[$key] )) {
1282
+                            return -1;
1283
+            } elseif(( (int) $astart[$key] ) > ((int) $bstart[$key] )) {
1284
+                            return  1;
1285
+            }
1152 1286
         }
1153 1287
         $c   = ( isset( $a->xprop['X-CURRENT-DTEND']['value'] )) ? $a->_date_time_string( $a->xprop['X-CURRENT-DTEND']['value'] ) : null;
1154
-        if(     empty( $c ) && !empty( $a->dtend['value'] ))
1155
-            $c = & $a->dtend['value'];
1156
-        if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] ))
1157
-            $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1158
-        if(     empty( $c ) && !empty( $a->due['value'] ))
1159
-            $c = & $a->due['value'];
1160
-        if(     empty( $c ) && !empty( $a->duration['value'] ))
1161
-            $c = $a->duration2date();
1288
+        if(     empty( $c ) && !empty( $a->dtend['value'] )) {
1289
+                    $c = & $a->dtend['value'];
1290
+        }
1291
+        if(     empty( $c ) && isset( $a->xprop['X-CURRENT-DUE']['value'] )) {
1292
+                    $c = $a->_date_time_string( $a->xprop['X-CURRENT-DUE']['value'] );
1293
+        }
1294
+        if(     empty( $c ) && !empty( $a->due['value'] )) {
1295
+                    $c = & $a->due['value'];
1296
+        }
1297
+        if(     empty( $c ) && !empty( $a->duration['value'] )) {
1298
+                    $c = $a->duration2date();
1299
+        }
1162 1300
         $d   = ( isset( $b->xprop['X-CURRENT-DTEND']['value'] )) ? $b->_date_time_string( $b->xprop['X-CURRENT-DTEND']['value'] ) : null;
1163
-        if(     empty( $d ) && !empty( $b->dtend['value'] ))
1164
-            $d = & $b->dtend['value'];
1165
-        if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] ))
1166
-            $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1167
-        if(     empty( $d ) && !empty( $b->due['value'] ))
1168
-            $d = & $b->due['value'];
1169
-        if(     empty( $d ) && !empty( $b->duration['value'] ))
1170
-            $d = $b->duration2date();
1171
-        if(     empty( $c ))                               return -1;
1172
-        elseif( empty( $d ))                               return  1;
1301
+        if(     empty( $d ) && !empty( $b->dtend['value'] )) {
1302
+                    $d = & $b->dtend['value'];
1303
+        }
1304
+        if(     empty( $d ) && isset( $b->xprop['X-CURRENT-DUE']['value'] )) {
1305
+                    $d = $b->_date_time_string( $b->xprop['X-CURRENT-DUE']['value'] );
1306
+        }
1307
+        if(     empty( $d ) && !empty( $b->due['value'] )) {
1308
+                    $d = & $b->due['value'];
1309
+        }
1310
+        if(     empty( $d ) && !empty( $b->duration['value'] )) {
1311
+                    $d = $b->duration2date();
1312
+        }
1313
+        if(     empty( $c )) {
1314
+            return -1;
1315
+        } elseif( empty( $d )) {
1316
+            return  1;
1317
+        }
1173 1318
         foreach( $this->_sortkeys as $key ) {
1174
-            if    ( !isset( $c[$key] ))                      return -1;
1175
-            elseif( !isset( $d[$key] ))                      return  1;
1176
-            if    (         $c[$key] == $d[$key] )           continue;
1177
-            if    ((  (int) $c[$key] ) < ((int) $d[$key]))   return -1;
1178
-            elseif((  (int) $c[$key] ) > ((int) $d[$key]))   return  1;
1179
-        }
1180
-        if( isset( $a->created['value'] ))
1181
-            $e = & $a->created['value'];
1182
-        else
1183
-            $e = & $a->dtstamp['value'];
1184
-        if( isset( $b->created['value'] ))
1185
-            $f = & $b->created['value'];
1186
-        else
1187
-            $f = & $b->dtstamp['value'];
1319
+            if    ( !isset( $c[$key] )) {
1320
+                return -1;
1321
+            } elseif( !isset( $d[$key] )) {
1322
+                return  1;
1323
+            }
1324
+            if    (         $c[$key] == $d[$key] ) {
1325
+                continue;
1326
+            }
1327
+            if    ((  (int) $c[$key] ) < ((int) $d[$key])) {
1328
+                return -1;
1329
+            } elseif((  (int) $c[$key] ) > ((int) $d[$key])) {
1330
+                return  1;
1331
+            }
1332
+        }
1333
+        if( isset( $a->created['value'] )) {
1334
+                    $e = & $a->created['value'];
1335
+        } else {
1336
+                    $e = & $a->dtstamp['value'];
1337
+        }
1338
+        if( isset( $b->created['value'] )) {
1339
+                    $f = & $b->created['value'];
1340
+        } else {
1341
+                    $f = & $b->dtstamp['value'];
1342
+        }
1188 1343
         foreach( $this->_sortkeys as $key ) {
1189
-            if(       !isset( $e[$key] ))                    return -1;
1190
-            elseif(   !isset( $f[$key] ))                    return  1;
1191
-            if    (           $e[$key] == $f[$key] )         continue;
1192
-            if    ((    (int) $e[$key] ) < ((int) $f[$key])) return -1;
1193
-            elseif((    (int) $e[$key] ) > ((int) $f[$key])) return  1;
1344
+            if(       !isset( $e[$key] )) {
1345
+                return -1;
1346
+            } elseif(   !isset( $f[$key] )) {
1347
+                return  1;
1348
+            }
1349
+            if    (           $e[$key] == $f[$key] ) {
1350
+                continue;
1351
+            }
1352
+            if    ((    (int) $e[$key] ) < ((int) $f[$key])) {
1353
+                return -1;
1354
+            } elseif((    (int) $e[$key] ) > ((int) $f[$key])) {
1355
+                return  1;
1356
+            }
1194 1357
         }
1195 1358
         if    ((            $a->uid['value'] ) <
1196
-            (            $b->uid['value'] ))            return -1;
1197
-        elseif((            $a->uid['value'] ) >
1198
-            (            $b->uid['value'] ))            return  1;
1359
+            (            $b->uid['value'] )) {
1360
+            return -1;
1361
+        } elseif((            $a->uid['value'] ) >
1362
+            (            $b->uid['value'] )) {
1363
+            return  1;
1364
+        }
1199 1365
         return 0;
1200 1366
     }
1201 1367
     /**
@@ -1210,42 +1376,57 @@  discard block
 block discarded – undo
1210 1376
     function parse( $filename=FALSE ) {
1211 1377
         if( !$filename ) {
1212 1378
             /* directory/filename previous set via setConfig directory+filename / url */
1213
-            if( FALSE === ( $filename = $this->getConfig( 'url' )))
1214
-                $filename = $this->getConfig( 'dirfile' );
1215
-        }
1216
-        elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1379
+            if( FALSE === ( $filename = $this->getConfig( 'url' ))) {
1380
+                            $filename = $this->getConfig( 'dirfile' );
1381
+            }
1382
+        } elseif(( 'http://'   == strtolower( substr( $filename, 0, 7 ))) ||
1217 1383
             ( 'webcal://' == strtolower( substr( $filename, 0, 9 ))))  {
1218 1384
             /* remote file - URL */
1219 1385
             $this->setConfig( 'URL', $filename );
1220
-            if( !$filename = $this->getConfig( 'url' ))
1221
-                return FALSE;                 /* err 2 */
1222
-        }
1223
-        else {
1386
+            if( !$filename = $this->getConfig( 'url' )) {
1387
+                            return FALSE;
1388
+            }
1389
+            /* err 2 */
1390
+        } else {
1224 1391
             /* local directory/filename */
1225 1392
             $parts = pathinfo( $filename );
1226 1393
             if( !empty( $parts['dirname'] ) && ( '.' != $parts['dirname'] )) {
1227
-                if( !$this->setConfig( 'directory', $parts['dirname'] ))
1228
-                    return FALSE;               /* err 3 */
1394
+                if( !$this->setConfig( 'directory', $parts['dirname'] )) {
1395
+                                    return FALSE;
1396
+                }
1397
+                /* err 3 */
1398
+            }
1399
+            if( !$this->setConfig( 'filename', $parts['basename'] )) {
1400
+                            return FALSE;
1229 1401
             }
1230
-            if( !$this->setConfig( 'filename', $parts['basename'] ))
1231
-                return FALSE;                 /* err 4 */
1402
+            /* err 4 */
1232 1403
         }
1233 1404
         if( 'http://' != substr( $filename, 0, 7 )) {
1234 1405
             /* local file error tests */
1235
-            if( !is_file( $filename ))      /* err 5 */
1406
+            if( !is_file( $filename )) {
1407
+                /* err 5 */
1236 1408
                 return FALSE;
1237
-            if( !is_readable( $filename ))
1238
-                return FALSE;                 /* err 6 */
1239
-            if( !filesize( $filename ))
1240
-                return FALSE;                 /* err 7 */
1409
+            }
1410
+            if( !is_readable( $filename )) {
1411
+                            return FALSE;
1412
+            }
1413
+            /* err 6 */
1414
+            if( !filesize( $filename )) {
1415
+                            return FALSE;
1416
+            }
1417
+            /* err 7 */
1241 1418
             clearstatcache();
1242 1419
         }
1243 1420
         /* READ FILE */
1244
-        if( FALSE === ( $rows = file( $filename )))
1245
-            return FALSE;                   /* err 1 */
1421
+        if( FALSE === ( $rows = file( $filename ))) {
1422
+                    return FALSE;
1423
+        }
1424
+        /* err 1 */
1246 1425
         /* identify BEGIN:VCALENDAR, MUST be first row */
1247
-        if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] )))
1248
-            return FALSE;                   /* err 8 */
1426
+        if( 'BEGIN:VCALENDAR' != strtoupper( trim( $rows[0] ))) {
1427
+                    return FALSE;
1428
+        }
1429
+        /* err 8 */
1249 1430
         /* remove empty trailing lines */
1250 1431
         while( '' == trim( $rows[count( $rows ) - 1] )) {
1251 1432
             unset( $rows[count( $rows ) - 1] );
@@ -1255,34 +1436,37 @@  discard block
 block discarded – undo
1255 1436
         if( 'END:VCALENDAR'   != strtoupper( trim( $rows[count( $rows ) - 1] ))) {
1256 1437
             return FALSE;                   /* err 9 */
1257 1438
         }
1258
-        if( 3 > count( $rows ))
1259
-            return FALSE;                   /* err 10 */
1439
+        if( 3 > count( $rows )) {
1440
+                    return FALSE;
1441
+        }
1442
+        /* err 10 */
1260 1443
         $comp    = $subcomp = null;
1261 1444
         $actcomp = & $this;
1262 1445
         $nl      = $this->getConfig( 'nl' );
1263 1446
         $calsync = 0;
1264 1447
         /* identify components and update unparsed data within component */
1265 1448
         foreach( $rows as $line ) {
1266
-            if( '' == trim( $line ))
1267
-                continue;
1268
-            if( $nl == substr( $line, 0 - strlen( $nl )))
1269
-                $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1449
+            if( '' == trim( $line )) {
1450
+                            continue;
1451
+            }
1452
+            if( $nl == substr( $line, 0 - strlen( $nl ))) {
1453
+                            $line = substr( $line, 0, ( strlen( $line ) - strlen( $nl ))).'\n';
1454
+            }
1270 1455
             if( 'BEGIN:VCALENDAR' == strtoupper( substr( $line, 0, 15 ))) {
1271 1456
                 $calsync++;
1272 1457
                 continue;
1273
-            }
1274
-            elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1458
+            } elseif( 'END:VCALENDAR' == strtoupper( substr( $line, 0, 13 ))) {
1275 1459
                 $calsync--;
1276 1460
                 continue;
1461
+            } elseif( 1 != $calsync ) {
1462
+                            return FALSE;
1277 1463
             }
1278
-            elseif( 1 != $calsync )
1279
-                return FALSE;                 /* err 20 */
1464
+            /* err 20 */
1280 1465
             if( 'END:' == strtoupper( substr( $line, 0, 4 ))) {
1281 1466
                 if( null != $subcomp ) {
1282 1467
                     $comp->setComponent( $subcomp );
1283 1468
                     $subcomp = null;
1284
-                }
1285
-                else {
1469
+                } else {
1286 1470
                     $this->setComponent( $comp );
1287 1471
                     $comp = null;
1288 1472
                 }
@@ -1293,17 +1477,18 @@  discard block
 block discarded – undo
1293 1477
                 $line = str_replace( '\n', '', $line );
1294 1478
                 $compname = trim (strtoupper( substr( $line, 6 )));
1295 1479
                 if( null != $comp ) {
1296
-                    if( 'VALARM' == $compname )
1297
-                        $subcomp = new valarm();
1298
-                    elseif( 'STANDARD' == $compname )
1299
-                        $subcomp = new vtimezone( 'STANDARD' );
1300
-                    elseif( 'DAYLIGHT' == $compname )
1301
-                        $subcomp = new vtimezone( 'DAYLIGHT' );
1302
-                    else
1303
-                        return FALSE; /* err 6 */
1480
+                    if( 'VALARM' == $compname ) {
1481
+                                            $subcomp = new valarm();
1482
+                    } elseif( 'STANDARD' == $compname ) {
1483
+                                            $subcomp = new vtimezone( 'STANDARD' );
1484
+                    } elseif( 'DAYLIGHT' == $compname ) {
1485
+                                            $subcomp = new vtimezone( 'DAYLIGHT' );
1486
+                    } else {
1487
+                                            return FALSE;
1488
+                    }
1489
+                    /* err 6 */
1304 1490
                     $actcomp = & $subcomp;
1305
-                }
1306
-                else {
1491
+                } else {
1307 1492
                     switch( $compname ) {
1308 1493
                         case 'VALARM':
1309 1494
                             $comp = new valarm();
@@ -1352,8 +1537,7 @@  discard block
 block discarded – undo
1352 1537
                     $newProp = FALSE;
1353 1538
                     $lastix++;
1354 1539
                     $proprows[$lastix]  = $line;
1355
-                }
1356
-                else {
1540
+                } else {
1357 1541
                     /* remove line breaks */
1358 1542
                     if(( '\n' == substr( $proprows[$lastix], -2 )) &&
1359 1543
                         (  ' ' == substr( $line, 0, 1 ))) {
@@ -1365,19 +1549,22 @@  discard block
 block discarded – undo
1365 1549
             }
1366 1550
             $toolbox = new calendarComponent();
1367 1551
             foreach( $proprows as $line ) {
1368
-                if( '\n' == substr( $line, -2 ))
1369
-                    $line = substr( $line, 0, strlen( $line ) - 2 );
1552
+                if( '\n' == substr( $line, -2 )) {
1553
+                                    $line = substr( $line, 0, strlen( $line ) - 2 );
1554
+                }
1370 1555
                 /* get propname */
1371 1556
                 $cix = $propname = null;
1372 1557
                 for( $cix=0; $cix < strlen( $line ); $cix++ ) {
1373
-                    if( in_array( $line{$cix}, array( ':', ';' )))
1374
-                        break;
1375
-                    else
1376
-                        $propname .= $line{$cix};
1558
+                    if( in_array( $line{$cix}, array( ':', ';' ))) {
1559
+                                            break;
1560
+                    } else {
1561
+                                            $propname .= $line{$cix};
1562
+                    }
1377 1563
                 }
1378 1564
                 /* ignore version/prodid properties */
1379
-                if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' )))
1380
-                    continue;
1565
+                if( in_array( strtoupper( $propname ), array( 'VERSION', 'PRODID' ))) {
1566
+                                    continue;
1567
+                }
1381 1568
                 $line = substr( $line, $cix);
1382 1569
                 /* separate attributes from value */
1383 1570
                 $attr   = array();
@@ -1402,20 +1589,22 @@  discard block
 block discarded – undo
1402 1589
                             break;
1403 1590
                         }
1404 1591
                     }
1405
-                    if( ';' == $line{$cix} )
1406
-                        $attr[++$attrix] = null;
1407
-                    else
1408
-                        $attr[$attrix] .= $line{$cix};
1592
+                    if( ';' == $line{$cix} ) {
1593
+                                            $attr[++$attrix] = null;
1594
+                    } else {
1595
+                                            $attr[$attrix] .= $line{$cix};
1596
+                    }
1409 1597
                 }
1410 1598
 
1411 1599
                 /* make attributes in array format */
1412 1600
                 $propattr = array();
1413 1601
                 foreach( $attr as $attribute ) {
1414 1602
                     $attrsplit = explode( '=', $attribute, 2 );
1415
-                    if( 1 < count( $attrsplit ))
1416
-                        $propattr[$attrsplit[0]] = $attrsplit[1];
1417
-                    else
1418
-                        $propattr[] = $attribute;
1603
+                    if( 1 < count( $attrsplit )) {
1604
+                                            $propattr[$attrsplit[0]] = $attrsplit[1];
1605
+                    } else {
1606
+                                            $propattr[] = $attribute;
1607
+                    }
1419 1608
                 }
1420 1609
                 /* update Property */
1421 1610
                 if( FALSE !== strpos( $line, ',' )) {
@@ -1429,13 +1618,14 @@  discard block
 block discarded – undo
1429 1618
                         }
1430 1619
                     }
1431 1620
                     if( 1 < count( $content )) {
1432
-                        foreach( $content as $cix => $contentPart )
1433
-                            $content[$cix] = $toolbox->_strunrep( $contentPart );
1621
+                        foreach( $content as $cix => $contentPart ) {
1622
+                                                    $content[$cix] = $toolbox->_strunrep( $contentPart );
1623
+                        }
1434 1624
                         $this->setProperty( $propname, $content, $propattr );
1435 1625
                         continue;
1626
+                    } else {
1627
+                                            $line = reset( $content );
1436 1628
                     }
1437
-                    else
1438
-                        $line = reset( $content );
1439 1629
                     $line = $toolbox->_strunrep( $line );
1440 1630
                 }
1441 1631
                 $this->setProperty( $propname, trim( $line ), $propattr );
@@ -1444,12 +1634,14 @@  discard block
 block discarded – undo
1444 1634
         /* parse Components */
1445 1635
         if( is_array( $this->components ) && ( 0 < count( $this->components ))) {
1446 1636
             for( $six = 0; $six < count( $this->components ); $six++ ) {
1447
-                if( !empty( $this->components[$six] ))
1448
-                    $this->components[$six]->parse();
1637
+                if( !empty( $this->components[$six] )) {
1638
+                                    $this->components[$six]->parse();
1639
+                }
1449 1640
             }
1641
+        } else {
1642
+                    return FALSE;
1450 1643
         }
1451
-        else
1452
-            return FALSE;                   /* err 91 or something.. . */
1644
+        /* err 91 or something.. . */
1453 1645
         return TRUE;
1454 1646
     }
1455 1647
     /*********************************************************************************/
@@ -1481,8 +1673,9 @@  discard block
 block discarded – undo
1481 1673
         switch( $this->format ) {
1482 1674
             case 'xcal':
1483 1675
                 $nlstrlen = strlen( $this->nl );
1484
-                if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen )))
1485
-                    $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1676
+                if( $this->nl == substr( $calendarStart, ( 0 - $nlstrlen ))) {
1677
+                                    $calendarStart = substr( $calendarStart, 0, ( strlen( $calendarStart ) - $nlstrlen ));
1678
+                }
1486 1679
                 $calendarStart .= '>'.$this->nl;
1487 1680
                 break;
1488 1681
             default:
@@ -1490,9 +1683,12 @@  discard block
 block discarded – undo
1490 1683
         }
1491 1684
         $calendar .= $this->createXprop();
1492 1685
         foreach( $this->components as $component ) {
1493
-            if( empty( $component )) continue;
1494
-            if( '' >= $component->getConfig( 'language'))
1495
-                $component->setConfig( 'language',  $this->getConfig( 'language' ));
1686
+            if( empty( $component )) {
1687
+                continue;
1688
+            }
1689
+            if( '' >= $component->getConfig( 'language')) {
1690
+                            $component->setConfig( 'language',  $this->getConfig( 'language' ));
1691
+            }
1496 1692
             $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
1497 1693
             $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
1498 1694
             $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -1505,8 +1701,10 @@  discard block
 block discarded – undo
1505 1701
             foreach( $this->xcaldecl as $declix => $declPart ) {
1506 1702
                 if(( 0 < count( $old_xcaldecl)) &&
1507 1703
                     ( in_array( $declPart['uri'],      $old_xcaldecl['uri'] )) &&
1508
-                    ( in_array( $declPart['external'], $old_xcaldecl['external'] )))
1509
-                    continue; // no duplicate uri and ext. references
1704
+                    ( in_array( $declPart['external'], $old_xcaldecl['external'] ))) {
1705
+                                    continue;
1706
+                }
1707
+                // no duplicate uri and ext. references
1510 1708
                 $calendarxCaldecl .= '<!';
1511 1709
                 foreach( $declPart as $declKey => $declValue ) {
1512 1710
                     switch( $declKey ) {                    // index
@@ -1559,10 +1757,11 @@  discard block
 block discarded – undo
1559 1757
         $filesize = strlen( $output );
1560 1758
 //    if( headers_sent( $filename, $linenum ))
1561 1759
 //      die( "Headers already sent in $filename on line $linenum\n" );
1562
-        if( 'xcal' == $this->format )
1563
-            header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1564
-        else
1565
-            header( 'Content-Type: text/calendar; charset=utf-8' );
1760
+        if( 'xcal' == $this->format ) {
1761
+                    header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1762
+        } else {
1763
+                    header( 'Content-Type: text/calendar; charset=utf-8' );
1764
+        }
1566 1765
         header( 'Content-Length: '.$filesize );
1567 1766
         header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1568 1767
         header( 'Cache-Control: max-age=10' );
@@ -1580,23 +1779,28 @@  discard block
 block discarded – undo
1580 1779
      * @return bool
1581 1780
      */
1582 1781
     function saveCalendar( $directory=FALSE, $filename=FALSE, $delimiter=FALSE ) {
1583
-        if( $directory )
1584
-            $this->setConfig( 'directory', $directory );
1585
-        if( $filename )
1586
-            $this->setConfig( 'filename',  $filename );
1587
-        if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR ))
1588
-            $this->setConfig( 'delimiter', $delimiter );
1589
-        if( FALSE === ( $dirfile = $this->getConfig( 'url' )))
1590
-            $dirfile = $this->getConfig( 'dirfile' );
1782
+        if( $directory ) {
1783
+                    $this->setConfig( 'directory', $directory );
1784
+        }
1785
+        if( $filename ) {
1786
+                    $this->setConfig( 'filename',  $filename );
1787
+        }
1788
+        if( $delimiter && ($delimiter != DIRECTORY_SEPARATOR )) {
1789
+                    $this->setConfig( 'delimiter', $delimiter );
1790
+        }
1791
+        if( FALSE === ( $dirfile = $this->getConfig( 'url' ))) {
1792
+                    $dirfile = $this->getConfig( 'dirfile' );
1793
+        }
1591 1794
         $iCalFile = @fopen( $dirfile, 'w' );
1592 1795
         if( $iCalFile ) {
1593
-            if( FALSE === fwrite( $iCalFile, $this->createCalendar() ))
1594
-                return FALSE;
1796
+            if( FALSE === fwrite( $iCalFile, $this->createCalendar() )) {
1797
+                            return FALSE;
1798
+            }
1595 1799
             fclose( $iCalFile );
1596 1800
             return TRUE;
1801
+        } else {
1802
+                    return FALSE;
1597 1803
         }
1598
-        else
1599
-            return FALSE;
1600 1804
     }
1601 1805
     /**
1602 1806
      * if recent version of calendar file exists (default one hour), an HTTP redirect header is sent
@@ -1615,15 +1819,19 @@  discard block
 block discarded – undo
1615 1819
             $timeout   = (int) $directory;
1616 1820
             $directory = FALSE;
1617 1821
         }
1618
-        if( $directory )
1619
-            $this->setConfig( 'directory', $directory );
1620
-        if( $filename )
1621
-            $this->setConfig( 'filename',  $filename );
1622
-        if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR ))
1623
-            $this->setConfig( 'delimiter', $delimiter );
1822
+        if( $directory ) {
1823
+                    $this->setConfig( 'directory', $directory );
1824
+        }
1825
+        if( $filename ) {
1826
+                    $this->setConfig( 'filename',  $filename );
1827
+        }
1828
+        if( $delimiter && ( $delimiter != DIRECTORY_SEPARATOR )) {
1829
+                    $this->setConfig( 'delimiter', $delimiter );
1830
+        }
1624 1831
         $filesize    = $this->getConfig( 'filesize' );
1625
-        if( 0 >= $filesize )
1626
-            return FALSE;
1832
+        if( 0 >= $filesize ) {
1833
+                    return FALSE;
1834
+        }
1627 1835
         $dirfile     = $this->getConfig( 'dirfile' );
1628 1836
         if( time() - filemtime( $dirfile ) < $timeout) {
1629 1837
             clearstatcache();
@@ -1631,10 +1839,11 @@  discard block
 block discarded – undo
1631 1839
             $filename  = $this->getConfig( 'filename' );
1632 1840
 //    if( headers_sent( $filename, $linenum ))
1633 1841
 //      die( "Headers already sent in $filename on line $linenum\n" );
1634
-            if( 'xcal' == $this->format )
1635
-                header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1636
-            else
1637
-                header( 'Content-Type: text/calendar; charset=utf-8' );
1842
+            if( 'xcal' == $this->format ) {
1843
+                            header( 'Content-Type: application/calendar+xml; charset=utf-8' );
1844
+            } else {
1845
+                            header( 'Content-Type: text/calendar; charset=utf-8' );
1846
+            }
1638 1847
             header( 'Content-Length: '.$filesize );
1639 1848
             header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
1640 1849
             header( 'Cache-Control: max-age=10' );
@@ -1644,9 +1853,9 @@  discard block
 block discarded – undo
1644 1853
                 fclose( $fp );
1645 1854
             }
1646 1855
             die();
1856
+        } else {
1857
+                    return FALSE;
1647 1858
         }
1648
-        else
1649
-            return FALSE;
1650 1859
     }
1651 1860
 }
1652 1861
 /*********************************************************************************/
@@ -1717,9 +1926,12 @@  discard block
 block discarded – undo
1717 1926
      * @return string
1718 1927
      */
1719 1928
     function createAction() {
1720
-        if( empty( $this->action )) return FALSE;
1721
-        if( empty( $this->action['value'] ))
1722
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1929
+        if( empty( $this->action )) {
1930
+            return FALSE;
1931
+        }
1932
+        if( empty( $this->action['value'] )) {
1933
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ACTION' ) : FALSE;
1934
+        }
1723 1935
         $attributes = $this->_createParams( $this->action['params'] );
1724 1936
         return $this->_createElement( 'ACTION', $attributes, $this->action['value'] );
1725 1937
     }
@@ -1733,7 +1945,11 @@  discard block
 block discarded – undo
1733 1945
      * @return bool
1734 1946
      */
1735 1947
     function setAction( $value, $params=FALSE ) {
1736
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1948
+        if( empty( $value )) {
1949
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
1950
+        } else {
1951
+            return FALSE;
1952
+        }
1737 1953
         $this->action = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1738 1954
         return TRUE;
1739 1955
     }
@@ -1749,14 +1965,17 @@  discard block
 block discarded – undo
1749 1965
      * @return string
1750 1966
      */
1751 1967
     function createAttach() {
1752
-        if( empty( $this->attach )) return FALSE;
1968
+        if( empty( $this->attach )) {
1969
+            return FALSE;
1970
+        }
1753 1971
         $output       = null;
1754 1972
         foreach( $this->attach as $attachPart ) {
1755 1973
             if(! empty( $attachPart['value'] )) {
1756 1974
                 $attributes = $this->_createParams( $attachPart['params'] );
1757 1975
                 $output    .= $this->_createElement( 'ATTACH', $attributes, $attachPart['value'] );
1976
+            } elseif( $this->getConfig( 'allowEmpty' )) {
1977
+                $output .= $this->_createElement( 'ATTACH' );
1758 1978
             }
1759
-            elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'ATTACH' );
1760 1979
         }
1761 1980
         return $output;
1762 1981
     }
@@ -1771,7 +1990,11 @@  discard block
 block discarded – undo
1771 1990
      * @return bool
1772 1991
      */
1773 1992
     function setAttach( $value, $params=FALSE, $index=FALSE ) {
1774
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
1993
+        if( empty( $value )) {
1994
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
1995
+        } else {
1996
+            return FALSE;
1997
+        }
1775 1998
         $this->_setMval( $this->attach, $value, $params, FALSE, $index );
1776 1999
         return TRUE;
1777 2000
     }
@@ -1787,19 +2010,22 @@  discard block
 block discarded – undo
1787 2010
      * @return string
1788 2011
      */
1789 2012
     function createAttendee() {
1790
-        if( empty( $this->attendee )) return FALSE;
1791
-        $output = null;
2013
+        if( empty( $this->attendee )) {
2014
+            return FALSE;
2015
+        }
2016
+        $output = null;
1792 2017
         foreach( $this->attendee as $attendeePart ) {                      // start foreach 1
1793 2018
             if( empty( $attendeePart['value'] )) {
1794
-                if( $this->getConfig( 'allowEmpty' ))
1795
-                    $output .= $this->_createElement( 'ATTENDEE' );
2019
+                if( $this->getConfig( 'allowEmpty' )) {
2020
+                                    $output .= $this->_createElement( 'ATTENDEE' );
2021
+                }
1796 2022
                 continue;
1797 2023
             }
1798 2024
             $attendee1 = $attendee2 = $attendeeLANG = $attendeeCN = null;
1799 2025
             foreach( $attendeePart as $paramlabel => $paramvalue ) {         // start foreach 2
1800
-                if( 'value' == $paramlabel )
1801
-                    $attendee2  .= 'MAILTO:'.$paramvalue;
1802
-                elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
2026
+                if( 'value' == $paramlabel ) {
2027
+                                    $attendee2  .= 'MAILTO:'.$paramvalue;
2028
+                } elseif(( 'params' == $paramlabel ) && ( is_array( $paramvalue ))) { // start elseif
1803 2029
                     foreach( $paramvalue as $optparamlabel => $optparamvalue ) { // start foreach 3
1804 2030
                         $attendee11 = $attendee12 = null;
1805 2031
                         if( is_int( $optparamlabel )) {
@@ -1861,7 +2087,11 @@  discard block
 block discarded – undo
1861 2087
      * @return bool
1862 2088
      */
1863 2089
     function setAttendee( $value, $params=FALSE, $index=FALSE ) {
1864
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2090
+        if( empty( $value )) {
2091
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
2092
+        } else {
2093
+            return FALSE;
2094
+        }
1865 2095
         $value = str_replace ( 'MAILTO:', '', $value );
1866 2096
         $value = str_replace ( 'mailto:', '', $value );
1867 2097
         $params2 = array();
@@ -1877,16 +2107,17 @@  discard block
 block discarded – undo
1877 2107
                             foreach( $optparamvalue as $part ) {
1878 2108
                                 $part = str_replace( 'MAILTO:', '', $part );
1879 2109
                                 $part = str_replace( 'mailto:', '', $part );
1880
-                                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1881
-                                    $part = substr( $part, 1, ( strlen($part)-2 ));
2110
+                                if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) {
2111
+                                                                    $part = substr( $part, 1, ( strlen($part)-2 ));
2112
+                                }
1882 2113
                                 $optarrays[$optparamlabel][] = $part;
1883 2114
                             }
1884
-                        }
1885
-                        else {
2115
+                        } else {
1886 2116
                             $part = str_replace( 'MAILTO:', '', $optparamvalue );
1887 2117
                             $part = str_replace( 'mailto:', '', $part );
1888
-                            if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} ))
1889
-                                $part = substr( $part, 1, ( strlen($part)-2 ));
2118
+                            if(( '"' == $part{0} ) && ( '"' == $part{strlen($part)-1} )) {
2119
+                                                            $part = substr( $part, 1, ( strlen($part)-2 ));
2120
+                            }
1890 2121
                             $optarrays[$optparamlabel][] = $part;
1891 2122
                         }
1892 2123
                         break;
@@ -1896,14 +2127,16 @@  discard block
 block discarded – undo
1896 2127
                             $optparamvalue = str_replace( 'mailto:', '', $optparamvalue );
1897 2128
                         }
1898 2129
                         if(( '"' == substr( $optparamvalue, 0, 1 )) &&
1899
-                            ( '"' == substr( $optparamvalue, -1 )))
1900
-                            $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
2130
+                            ( '"' == substr( $optparamvalue, -1 ))) {
2131
+                                                    $optparamvalue = substr( $optparamvalue, 1, ( strlen( $optparamvalue ) - 2 ));
2132
+                        }
1901 2133
                         $params2[$optparamlabel] = $optparamvalue;
1902 2134
                         break;
1903 2135
                 } // end switch( $optparamlabel.. .
1904 2136
             } // end foreach( $optparam.. .
1905
-            foreach( $optarrays as $optparamlabel => $optparams )
1906
-                $params2[$optparamlabel] = $optparams;
2137
+            foreach( $optarrays as $optparamlabel => $optparams ) {
2138
+                            $params2[$optparamlabel] = $optparams;
2139
+            }
1907 2140
         }
1908 2141
         // remove defaults
1909 2142
         $this->_existRem( $params2, 'CUTYPE',   'INDIVIDUAL' );
@@ -1913,8 +2146,9 @@  discard block
 block discarded – undo
1913 2146
         // check language setting
1914 2147
         if( isset( $params2['CN' ] )) {
1915 2148
             $lang = $this->getConfig( 'language' );
1916
-            if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang ))
1917
-                $params2['LANGUAGE' ] = $lang;
2149
+            if( !isset( $params2['LANGUAGE' ] ) && !empty( $lang )) {
2150
+                            $params2['LANGUAGE' ] = $lang;
2151
+            }
1918 2152
         }
1919 2153
         $this->_setMval( $this->attendee, $value, $params2, FALSE, $index );
1920 2154
         return TRUE;
@@ -1931,22 +2165,26 @@  discard block
 block discarded – undo
1931 2165
      * @return string
1932 2166
      */
1933 2167
     function createCategories() {
1934
-        if( empty( $this->categories )) return FALSE;
2168
+        if( empty( $this->categories )) {
2169
+            return FALSE;
2170
+        }
1935 2171
         $output = null;
1936 2172
         foreach( $this->categories as $category ) {
1937 2173
             if( empty( $category['value'] )) {
1938
-                if ( $this->getConfig( 'allowEmpty' ))
1939
-                    $output .= $this->_createElement( 'CATEGORIES' );
2174
+                if ( $this->getConfig( 'allowEmpty' )) {
2175
+                                    $output .= $this->_createElement( 'CATEGORIES' );
2176
+                }
1940 2177
                 continue;
1941 2178
             }
1942 2179
             $attributes = $this->_createParams( $category['params'], array( 'LANGUAGE' ));
1943 2180
             if( is_array( $category['value'] )) {
1944
-                foreach( $category['value'] as $cix => $categoryPart )
1945
-                    $category['value'][$cix] = $this->_strrep( $categoryPart );
2181
+                foreach( $category['value'] as $cix => $categoryPart ) {
2182
+                                    $category['value'][$cix] = $this->_strrep( $categoryPart );
2183
+                }
1946 2184
                 $content  = implode( ',', $category['value'] );
2185
+            } else {
2186
+                            $content  = $this->_strrep( $category['value'] );
1947 2187
             }
1948
-            else
1949
-                $content  = $this->_strrep( $category['value'] );
1950 2188
             $output    .= $this->_createElement( 'CATEGORIES', $attributes, $content );
1951 2189
         }
1952 2190
         return $output;
@@ -1962,7 +2200,11 @@  discard block
 block discarded – undo
1962 2200
      * @return bool
1963 2201
      */
1964 2202
     function setCategories( $value, $params=FALSE, $index=FALSE ) {
1965
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2203
+        if( empty( $value )) {
2204
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
2205
+        } else {
2206
+            return FALSE;
2207
+        }
1966 2208
         $this->_setMval( $this->categories, $value, $params, FALSE, $index );
1967 2209
         return TRUE;
1968 2210
     }
@@ -1978,9 +2220,12 @@  discard block
 block discarded – undo
1978 2220
      * @return string
1979 2221
      */
1980 2222
     function createClass() {
1981
-        if( empty( $this->class )) return FALSE;
1982
-        if( empty( $this->class['value'] ))
1983
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
2223
+        if( empty( $this->class )) {
2224
+            return FALSE;
2225
+        }
2226
+        if( empty( $this->class['value'] )) {
2227
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'CLASS' ) : FALSE;
2228
+        }
1984 2229
         $attributes = $this->_createParams( $this->class['params'] );
1985 2230
         return $this->_createElement( 'CLASS', $attributes, $this->class['value'] );
1986 2231
     }
@@ -1994,7 +2239,11 @@  discard block
 block discarded – undo
1994 2239
      * @return bool
1995 2240
      */
1996 2241
     function setClass( $value, $params=FALSE ) {
1997
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2242
+        if( empty( $value )) {
2243
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
2244
+        } else {
2245
+            return FALSE;
2246
+        }
1998 2247
         $this->class = array( 'value' => $value, 'params' => $this->_setParams( $params ));
1999 2248
         return TRUE;
2000 2249
     }
@@ -2010,11 +2259,15 @@  discard block
 block discarded – undo
2010 2259
      * @return string
2011 2260
      */
2012 2261
     function createComment() {
2013
-        if( empty( $this->comment )) return FALSE;
2262
+        if( empty( $this->comment )) {
2263
+            return FALSE;
2264
+        }
2014 2265
         $output = null;
2015 2266
         foreach( $this->comment as $commentPart ) {
2016 2267
             if( empty( $commentPart['value'] )) {
2017
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'COMMENT' );
2268
+                if( $this->getConfig( 'allowEmpty' )) {
2269
+                    $output .= $this->_createElement( 'COMMENT' );
2270
+                }
2018 2271
                 continue;
2019 2272
             }
2020 2273
             $attributes = $this->_createParams( $commentPart['params'], array( 'ALTREP', 'LANGUAGE' ));
@@ -2034,7 +2287,11 @@  discard block
 block discarded – undo
2034 2287
      * @return bool
2035 2288
      */
2036 2289
     function setComment( $value, $params=FALSE, $index=FALSE ) {
2037
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2290
+        if( empty( $value )) {
2291
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
2292
+        } else {
2293
+            return FALSE;
2294
+        }
2038 2295
         $this->_setMval( $this->comment, $value, $params, FALSE, $index );
2039 2296
         return TRUE;
2040 2297
     }
@@ -2050,16 +2307,20 @@  discard block
 block discarded – undo
2050 2307
      * @return string
2051 2308
      */
2052 2309
     function createCompleted( ) {
2053
-        if( empty( $this->completed )) return FALSE;
2310
+        if( empty( $this->completed )) {
2311
+            return FALSE;
2312
+        }
2054 2313
         if( !isset( $this->completed['value']['year'] )  &&
2055 2314
             !isset( $this->completed['value']['month'] ) &&
2056 2315
             !isset( $this->completed['value']['day'] )   &&
2057 2316
             !isset( $this->completed['value']['hour'] )  &&
2058 2317
             !isset( $this->completed['value']['min'] )   &&
2059
-            !isset( $this->completed['value']['sec'] ))
2060
-            if( $this->getConfig( 'allowEmpty' ))
2318
+            !isset( $this->completed['value']['sec'] )) {
2319
+                    if( $this->getConfig( 'allowEmpty' ))
2061 2320
                 return $this->_createElement( 'COMPLETED' );
2062
-            else return FALSE;
2321
+        } else {
2322
+                return FALSE;
2323
+            }
2063 2324
         $formatted  = $this->_format_date_time( $this->completed['value'], 7 );
2064 2325
         $attributes = $this->_createParams( $this->completed['params'] );
2065 2326
         return $this->_createElement( 'COMPLETED', $attributes, $formatted );
@@ -2083,9 +2344,9 @@  discard block
 block discarded – undo
2083 2344
             if( $this->getConfig( 'allowEmpty' )) {
2084 2345
                 $this->completed = array( 'value' => null, 'params' => $this->_setParams( $params ));
2085 2346
                 return TRUE;
2347
+            } else {
2348
+                            return FALSE;
2086 2349
             }
2087
-            else
2088
-                return FALSE;
2089 2350
         }
2090 2351
         $this->completed = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2091 2352
         return TRUE;
@@ -2102,15 +2363,18 @@  discard block
 block discarded – undo
2102 2363
      * @return string
2103 2364
      */
2104 2365
     function createContact() {
2105
-        if( empty( $this->contact )) return FALSE;
2366
+        if( empty( $this->contact )) {
2367
+            return FALSE;
2368
+        }
2106 2369
         $output = null;
2107 2370
         foreach( $this->contact as $contact ) {
2108 2371
             if( !empty( $contact['value'] )) {
2109 2372
                 $attributes = $this->_createParams( $contact['params'], array( 'ALTREP', 'LANGUAGE' ));
2110 2373
                 $content    = $this->_strrep( $contact['value'] );
2111 2374
                 $output    .= $this->_createElement( 'CONTACT', $attributes, $content );
2375
+            } elseif( $this->getConfig( 'allowEmpty' )) {
2376
+                $output .= $this->_createElement( 'CONTACT' );
2112 2377
             }
2113
-            elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'CONTACT' );
2114 2378
         }
2115 2379
         return $output;
2116 2380
     }
@@ -2125,7 +2389,11 @@  discard block
 block discarded – undo
2125 2389
      * @return bool
2126 2390
      */
2127 2391
     function setContact( $value, $params=FALSE, $index=FALSE ) {
2128
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
2392
+        if( empty( $value )) {
2393
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
2394
+        } else {
2395
+            return FALSE;
2396
+        }
2129 2397
         $this->_setMval( $this->contact, $value, $params, FALSE, $index );
2130 2398
         return TRUE;
2131 2399
     }
@@ -2141,7 +2409,9 @@  discard block
 block discarded – undo
2141 2409
      * @return string
2142 2410
      */
2143 2411
     function createCreated() {
2144
-        if( empty( $this->created )) return FALSE;
2412
+        if( empty( $this->created )) {
2413
+            return FALSE;
2414
+        }
2145 2415
         $formatted  = $this->_format_date_time( $this->created['value'], 7 );
2146 2416
         $attributes = $this->_createParams( $this->created['params'] );
2147 2417
         return $this->_createElement( 'CREATED', $attributes, $formatted );
@@ -2179,15 +2449,18 @@  discard block
 block discarded – undo
2179 2449
      * @return string
2180 2450
      */
2181 2451
     function createDescription() {
2182
-        if( empty( $this->description )) return FALSE;
2452
+        if( empty( $this->description )) {
2453
+            return FALSE;
2454
+        }
2183 2455
         $output       = null;
2184 2456
         foreach( $this->description as $description ) {
2185 2457
             if( !empty( $description['value'] )) {
2186 2458
                 $attributes = $this->_createParams( $description['params'], array( 'ALTREP', 'LANGUAGE' ));
2187 2459
                 $content    = $this->_strrep( $description['value'] );
2188 2460
                 $output    .= $this->_createElement( 'DESCRIPTION', $attributes, $content );
2461
+            } elseif( $this->getConfig( 'allowEmpty' )) {
2462
+                $output .= $this->_createElement( 'DESCRIPTION' );
2189 2463
             }
2190
-            elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'DESCRIPTION' );
2191 2464
         }
2192 2465
         return $output;
2193 2466
     }
@@ -2202,7 +2475,12 @@  discard block
 block discarded – undo
2202 2475
      * @return bool
2203 2476
      */
2204 2477
     function setDescription( $value, $params=FALSE, $index=FALSE ) {
2205
-        if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE; }
2478
+        if( empty( $value )) { if( $this->getConfig( 'allowEmpty' )) {
2479
+            $value = null;
2480
+        } else {
2481
+            return FALSE;
2482
+        }
2483
+        }
2206 2484
         $this->_setMval( $this->description, $value, $params, FALSE, $index );
2207 2485
         return TRUE;
2208 2486
     }
@@ -2218,16 +2496,20 @@  discard block
 block discarded – undo
2218 2496
      * @return string
2219 2497
      */
2220 2498
     function createDtend() {
2221
-        if( empty( $this->dtend )) return FALSE;
2499
+        if( empty( $this->dtend )) {
2500
+            return FALSE;
2501
+        }
2222 2502
         if( !isset( $this->dtend['value']['year'] )  &&
2223 2503
             !isset( $this->dtend['value']['month'] ) &&
2224 2504
             !isset( $this->dtend['value']['day'] )   &&
2225 2505
             !isset( $this->dtend['value']['hour'] )  &&
2226 2506
             !isset( $this->dtend['value']['min'] )   &&
2227
-            !isset( $this->dtend['value']['sec'] ))
2228
-            if( $this->getConfig( 'allowEmpty' ))
2507
+            !isset( $this->dtend['value']['sec'] )) {
2508
+                    if( $this->getConfig( 'allowEmpty' ))
2229 2509
                 return $this->_createElement( 'DTEND' );
2230
-            else return FALSE;
2510
+        } else {
2511
+                return FALSE;
2512
+            }
2231 2513
         $formatted  = $this->_format_date_time( $this->dtend['value'] );
2232 2514
         $attributes = $this->_createParams( $this->dtend['params'] );
2233 2515
         return $this->_createElement( 'DTEND', $attributes, $formatted );
@@ -2252,9 +2534,9 @@  discard block
 block discarded – undo
2252 2534
             if( $this->getConfig( 'allowEmpty' )) {
2253 2535
                 $this->dtend = array( 'value' => null, 'params' => $this->_setParams( $params ));
2254 2536
                 return TRUE;
2537
+            } else {
2538
+                            return FALSE;
2255 2539
             }
2256
-            else
2257
-                return FALSE;
2258 2540
         }
2259 2541
         $this->dtend = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2260 2542
         return TRUE;
@@ -2276,8 +2558,9 @@  discard block
 block discarded – undo
2276 2558
             !isset( $this->dtstamp['value']['day'] )   &&
2277 2559
             !isset( $this->dtstamp['value']['hour'] )  &&
2278 2560
             !isset( $this->dtstamp['value']['min'] )   &&
2279
-            !isset( $this->dtstamp['value']['sec'] ))
2280
-            $this->_makeDtstamp();
2561
+            !isset( $this->dtstamp['value']['sec'] )) {
2562
+                    $this->_makeDtstamp();
2563
+        }
2281 2564
         $formatted  = $this->_format_date_time( $this->dtstamp['value'], 7 );
2282 2565
         $attributes = $this->_createParams( $this->dtstamp['params'] );
2283 2566
         return $this->_createElement( 'DTSTAMP', $attributes, $formatted );
@@ -2313,10 +2596,11 @@  discard block
 block discarded – undo
2313 2596
      * @return TRUE
2314 2597
      */
2315 2598
     function setDtstamp( $year, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2316
-        if( empty( $year ))
2317
-            $this->_makeDtstamp();
2318
-        else
2319
-            $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2599
+        if( empty( $year )) {
2600
+                    $this->_makeDtstamp();
2601
+        } else {
2602
+                    $this->dtstamp = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2603
+        }
2320 2604
         return TRUE;
2321 2605
     }
2322 2606
     /*********************************************************************************/
@@ -2331,18 +2615,23 @@  discard block
 block discarded – undo
2331 2615
      * @return string
2332 2616
      */
2333 2617
     function createDtstart() {
2334
-        if( empty( $this->dtstart )) return FALSE;
2618
+        if( empty( $this->dtstart )) {
2619
+            return FALSE;
2620
+        }
2335 2621
         if( !isset( $this->dtstart['value']['year'] )  &&
2336 2622
             !isset( $this->dtstart['value']['month'] ) &&
2337 2623
             !isset( $this->dtstart['value']['day'] )   &&
2338 2624
             !isset( $this->dtstart['value']['hour'] )  &&
2339 2625
             !isset( $this->dtstart['value']['min'] )   &&
2340
-            !isset( $this->dtstart['value']['sec'] ))
2341
-            if( $this->getConfig( 'allowEmpty' ))
2626
+            !isset( $this->dtstart['value']['sec'] )) {
2627
+                    if( $this->getConfig( 'allowEmpty' ))
2342 2628
                 return $this->_createElement( 'DTSTART' );
2343
-            else return FALSE;
2344
-        if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
2345
-            unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2629
+        } else {
2630
+                return FALSE;
2631
+            }
2632
+        if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
2633
+                    unset( $this->dtstart['value']['tz'], $this->dtstart['params']['TZID'] );
2634
+        }
2346 2635
         $formatted  = $this->_format_date_time( $this->dtstart['value'] );
2347 2636
         $attributes = $this->_createParams( $this->dtstart['params'] );
2348 2637
         return $this->_createElement( 'DTSTART', $attributes, $formatted );
@@ -2367,9 +2656,9 @@  discard block
 block discarded – undo
2367 2656
             if( $this->getConfig( 'allowEmpty' )) {
2368 2657
                 $this->dtstart = array( 'value' => null, 'params' => $this->_setParams( $params ));
2369 2658
                 return TRUE;
2659
+            } else {
2660
+                            return FALSE;
2370 2661
             }
2371
-            else
2372
-                return FALSE;
2373 2662
         }
2374 2663
         $this->dtstart = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params, 'dtstart' );
2375 2664
         return TRUE;
@@ -2386,16 +2675,20 @@  discard block
 block discarded – undo
2386 2675
      * @return string
2387 2676
      */
2388 2677
     function createDue() {
2389
-        if( empty( $this->due )) return FALSE;
2678
+        if( empty( $this->due )) {
2679
+            return FALSE;
2680
+        }
2390 2681
         if( !isset( $this->due['value']['year'] )  &&
2391 2682
             !isset( $this->due['value']['month'] ) &&
2392 2683
             !isset( $this->due['value']['day'] )   &&
2393 2684
             !isset( $this->due['value']['hour'] )  &&
2394 2685
             !isset( $this->due['value']['min'] )   &&
2395
-            !isset( $this->due['value']['sec'] ))
2396
-            if( $this->getConfig( 'allowEmpty' ))
2686
+            !isset( $this->due['value']['sec'] )) {
2687
+                    if( $this->getConfig( 'allowEmpty' ))
2397 2688
                 return $this->_createElement( 'DUE' );
2398
-            else return FALSE;
2689
+        } else {
2690
+                return FALSE;
2691
+            }
2399 2692
         $formatted  = $this->_format_date_time( $this->due['value'] );
2400 2693
         $attributes = $this->_createParams( $this->due['params'] );
2401 2694
         return $this->_createElement( 'DUE', $attributes, $formatted );
@@ -2419,9 +2712,9 @@  discard block
 block discarded – undo
2419 2712
             if( $this->getConfig( 'allowEmpty' )) {
2420 2713
                 $this->due = array( 'value' => null, 'params' => $this->_setParams( $params ));
2421 2714
                 return TRUE;
2715
+            } else {
2716
+                            return FALSE;
2422 2717
             }
2423
-            else
2424
-                return FALSE;
2425 2718
         }
2426 2719
         $this->due = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
2427 2720
         return TRUE;
@@ -2438,15 +2731,19 @@  discard block
 block discarded – undo
2438 2731
      * @return string
2439 2732
      */
2440 2733
     function createDuration() {
2441
-        if( empty( $this->duration )) return FALSE;
2734
+        if( empty( $this->duration )) {
2735
+            return FALSE;
2736
+        }
2442 2737
         if( !isset( $this->duration['value']['week'] ) &&
2443 2738
             !isset( $this->duration['value']['day'] )  &&
2444 2739
             !isset( $this->duration['value']['hour'] ) &&
2445 2740
             !isset( $this->duration['value']['min'] )  &&
2446
-            !isset( $this->duration['value']['sec'] ))
2447
-            if( $this->getConfig( 'allowEmpty' ))
2741
+            !isset( $this->duration['value']['sec'] )) {
2742
+                    if( $this->getConfig( 'allowEmpty' ))
2448 2743
                 return $this->_createElement( 'DURATION', array(), null );
2449
-            else return FALSE;
2744
+        } else {
2745
+                return FALSE;
2746
+            }
2450 2747
         $attributes = $this->_createParams( $this->duration['params'] );
2451 2748
         return $this->_createElement( 'DURATION', $attributes, $this->_format_duration( $this->duration['value'] ));
2452 2749
     }
@@ -2464,19 +2761,24 @@  discard block
 block discarded – undo
2464 2761
      * @return bool
2465 2762
      */
2466 2763
     function setDuration( $week, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2467
-        if( empty( $week )) if( $this->getConfig( 'allowEmpty' )) $week = null; else return FALSE;
2468
-        if( is_array( $week ) && ( 1 <= count( $week )))
2469
-            $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2470
-        elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2764
+        if( empty( $week )) {
2765
+            if( $this->getConfig( 'allowEmpty' )) $week = null;
2766
+        } else {
2767
+            return FALSE;
2768
+        }
2769
+        if( is_array( $week ) && ( 1 <= count( $week ))) {
2770
+                    $this->duration = array( 'value' => $this->_duration_array( $week ), 'params' => $this->_setParams( $day ));
2771
+        } elseif( is_string( $week ) && ( 3 <= strlen( trim( $week )))) {
2471 2772
             $week = trim( $week );
2472
-            if( in_array( substr( $week, 0, 1 ), array( '+', '-' )))
2473
-                $week = substr( $week, 1 );
2773
+            if( in_array( substr( $week, 0, 1 ), array( '+', '-' ))) {
2774
+                            $week = substr( $week, 1 );
2775
+            }
2474 2776
             $this->duration = array( 'value' => $this->_duration_string( $week ), 'params' => $this->_setParams( $day ));
2777
+        } elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec )) {
2778
+                    return FALSE;
2779
+        } else {
2780
+                    $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2475 2781
         }
2476
-        elseif( empty( $week ) && empty( $day ) && empty( $hour ) && empty( $min ) && empty( $sec ))
2477
-            return FALSE;
2478
-        else
2479
-            $this->duration = array( 'value' => $this->_duration_array( array( $week, $day, $hour, $min, $sec )), 'params' => $this->_setParams( $params ));
2480 2782
         return TRUE;
2481 2783
     }
2482 2784
     /*********************************************************************************/
@@ -2491,31 +2793,37 @@  discard block
 block discarded – undo
2491 2793
      * @return string
2492 2794
      */
2493 2795
     function createExdate() {
2494
-        if( empty( $this->exdate )) return FALSE;
2796
+        if( empty( $this->exdate )) {
2797
+            return FALSE;
2798
+        }
2495 2799
         $output = null;
2496 2800
         foreach( $this->exdate as $ex => $theExdate ) {
2497 2801
             if( empty( $theExdate['value'] )) {
2498
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'EXDATE' );
2802
+                if( $this->getConfig( 'allowEmpty' )) {
2803
+                    $output .= $this->_createElement( 'EXDATE' );
2804
+                }
2499 2805
                 continue;
2500 2806
             }
2501 2807
             $content = $attributes = null;
2502 2808
             foreach( $theExdate['value'] as $eix => $exdatePart ) {
2503 2809
                 $parno = count( $exdatePart );
2504 2810
                 $formatted = $this->_format_date_time( $exdatePart, $parno );
2505
-                if( isset( $theExdate['params']['TZID'] ))
2506
-                    $formatted = str_replace( 'Z', '', $formatted);
2811
+                if( isset( $theExdate['params']['TZID'] )) {
2812
+                                    $formatted = str_replace( 'Z', '', $formatted);
2813
+                }
2507 2814
                 if( 0 < $eix ) {
2508 2815
                     if( isset( $theExdate['value'][0]['tz'] )) {
2509 2816
                         if( ctype_digit( substr( $theExdate['value'][0]['tz'], -4 )) ||
2510 2817
                             ( 'Z' == $theExdate['value'][0]['tz'] )) {
2511
-                            if( 'Z' != substr( $formatted, -1 ))
2512
-                                $formatted .= 'Z';
2818
+                            if( 'Z' != substr( $formatted, -1 )) {
2819
+                                                            $formatted .= 'Z';
2820
+                            }
2821
+                        } else {
2822
+                                                    $formatted = str_replace( 'Z', '', $formatted );
2513 2823
                         }
2514
-                        else
2515
-                            $formatted = str_replace( 'Z', '', $formatted );
2824
+                    } else {
2825
+                                            $formatted = str_replace( 'Z', '', $formatted );
2516 2826
                     }
2517
-                    else
2518
-                        $formatted = str_replace( 'Z', '', $formatted );
2519 2827
                 }
2520 2828
                 $content .= ( 0 < $eix ) ? ','.$formatted : $formatted;
2521 2829
             }
@@ -2539,34 +2847,39 @@  discard block
 block discarded – undo
2539 2847
             if( $this->getConfig( 'allowEmpty' )) {
2540 2848
                 $this->_setMval( $this->exdate, null, $params, FALSE, $index );
2541 2849
                 return TRUE;
2850
+            } else {
2851
+                            return FALSE;
2542 2852
             }
2543
-            else
2544
-                return FALSE;
2545 2853
         }
2546 2854
         $input  = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
2547 2855
         /* ev. check 1:st date and save ev. timezone **/
2548 2856
         $this->_chkdatecfg( reset( $exdates ), $parno, $input['params'] );
2549 2857
         $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default parameter
2550 2858
         foreach( $exdates as $eix => $theExdate ) {
2551
-            if( $this->_isArrayTimestampDate( $theExdate ))
2552
-                $exdatea = $this->_timestamp2date( $theExdate, $parno );
2553
-            elseif(  is_array( $theExdate ))
2554
-                $exdatea = $this->_date_time_array( $theExdate, $parno );
2555
-            elseif( 8 <= strlen( trim( $theExdate ))) // ex. 2006-08-03 10:12:18
2859
+            if( $this->_isArrayTimestampDate( $theExdate )) {
2860
+                            $exdatea = $this->_timestamp2date( $theExdate, $parno );
2861
+            } elseif(  is_array( $theExdate )) {
2862
+                            $exdatea = $this->_date_time_array( $theExdate, $parno );
2863
+            } elseif( 8 <= strlen( trim( $theExdate ))) {
2864
+                // ex. 2006-08-03 10:12:18
2556 2865
                 $exdatea = $this->_date_time_string( $theExdate, $parno );
2557
-            if( 3 == $parno )
2558
-                unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2559
-            elseif( isset( $exdatea['tz'] ))
2560
-                $exdatea['tz'] = (string) $exdatea['tz'];
2866
+            }
2867
+            if( 3 == $parno ) {
2868
+                            unset( $exdatea['hour'], $exdatea['min'], $exdatea['sec'], $exdatea['tz'] );
2869
+            } elseif( isset( $exdatea['tz'] )) {
2870
+                            $exdatea['tz'] = (string) $exdatea['tz'];
2871
+            }
2561 2872
             if(  isset( $input['params']['TZID'] ) ||
2562 2873
                 ( isset( $exdatea['tz'] ) && !$this->_isOffset( $exdatea['tz'] )) ||
2563 2874
                 ( isset( $input['value'][0] ) && ( !isset( $input['value'][0]['tz'] ))) ||
2564
-                ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
2565
-                unset( $exdatea['tz'] );
2875
+                ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) {
2876
+                            unset( $exdatea['tz'] );
2877
+            }
2566 2878
             $input['value'][] = $exdatea;
2567 2879
         }
2568
-        if( 0 >= count( $input['value'] ))
2569
-            return FALSE;
2880
+        if( 0 >= count( $input['value'] )) {
2881
+                    return FALSE;
2882
+        }
2570 2883
         if( 3 == $parno ) {
2571 2884
             $input['params']['VALUE'] = 'DATE';
2572 2885
             unset( $input['params']['TZID'] );
@@ -2586,7 +2899,9 @@  discard block
 block discarded – undo
2586 2899
      * @return string
2587 2900
      */
2588 2901
     function createExrule() {
2589
-        if( empty( $this->exrule )) return FALSE;
2902
+        if( empty( $this->exrule )) {
2903
+            return FALSE;
2904
+        }
2590 2905
         return $this->_format_recur( 'EXRULE', $this->exrule );
2591 2906
     }
2592 2907
     /**
@@ -2600,7 +2915,11 @@  discard block
 block discarded – undo
2600 2915
      * @return bool
2601 2916
      */
2602 2917
     function setExrule( $exruleset, $params=FALSE, $index=FALSE ) {
2603
-        if( empty( $exruleset )) if( $this->getConfig( 'allowEmpty' )) $exruleset = null; else return FALSE;
2918
+        if( empty( $exruleset )) {
2919
+            if( $this->getConfig( 'allowEmpty' )) $exruleset = null;
2920
+        } else {
2921
+            return FALSE;
2922
+        }
2604 2923
         $this->_setMval( $this->exrule, $this->_setRexrule( $exruleset ), $params, FALSE, $index );
2605 2924
         return TRUE;
2606 2925
     }
@@ -2616,11 +2935,15 @@  discard block
 block discarded – undo
2616 2935
      * @return string
2617 2936
      */
2618 2937
     function createFreebusy() {
2619
-        if( empty( $this->freebusy )) return FALSE;
2938
+        if( empty( $this->freebusy )) {
2939
+            return FALSE;
2940
+        }
2620 2941
         $output = null;
2621 2942
         foreach( $this->freebusy as $freebusyPart ) {
2622 2943
             if( empty( $freebusyPart['value'] )) {
2623
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'FREEBUSY' );
2944
+                if( $this->getConfig( 'allowEmpty' )) {
2945
+                    $output .= $this->_createElement( 'FREEBUSY' );
2946
+                }
2624 2947
                 continue;
2625 2948
             }
2626 2949
             $attributes = $content = null;
@@ -2628,9 +2951,9 @@  discard block
 block discarded – undo
2628 2951
                 $attributes .= $this->intAttrDelimiter.'FBTYPE='.$freebusyPart['value']['fbtype'];
2629 2952
                 unset( $freebusyPart['value']['fbtype'] );
2630 2953
                 $freebusyPart['value'] = array_values( $freebusyPart['value'] );
2954
+            } else {
2955
+                            $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2631 2956
             }
2632
-            else
2633
-                $attributes .= $this->intAttrDelimiter.'FBTYPE=BUSY';
2634 2957
             $attributes .= $this->_createParams( $freebusyPart['params'] );
2635 2958
             $fno = 1;
2636 2959
             $cnt = count( $freebusyPart['value']);
@@ -2639,21 +2962,24 @@  discard block
 block discarded – undo
2639 2962
                 $content .= $formatted;
2640 2963
                 $content .= '/';
2641 2964
                 $cnt2 = count( $freebusyPeriod[1]);
2642
-                if( array_key_exists( 'year', $freebusyPeriod[1] ))      // date-time
2965
+                if( array_key_exists( 'year', $freebusyPeriod[1] )) {
2966
+                    // date-time
2643 2967
                     $cnt2 = 7;
2644
-                elseif( array_key_exists( 'week', $freebusyPeriod[1] ))  // duration
2968
+                } elseif( array_key_exists( 'week', $freebusyPeriod[1] )) {
2969
+                    // duration
2645 2970
                     $cnt2 = 5;
2971
+                }
2646 2972
                 if(( 7 == $cnt2 )   &&    // period=  -> date-time
2647 2973
                     isset( $freebusyPeriod[1]['year'] )  &&
2648 2974
                     isset( $freebusyPeriod[1]['month'] ) &&
2649 2975
                     isset( $freebusyPeriod[1]['day'] )) {
2650 2976
                     $content .= $this->_format_date_time( $freebusyPeriod[1] );
2651
-                }
2652
-                else {                                  // period=  -> dur-time
2977
+                } else {                                  // period=  -> dur-time
2653 2978
                     $content .= $this->_format_duration( $freebusyPeriod[1] );
2654 2979
                 }
2655
-                if( $fno < $cnt )
2656
-                    $content .= ',';
2980
+                if( $fno < $cnt ) {
2981
+                                    $content .= ',';
2982
+                }
2657 2983
                 $fno++;
2658 2984
             }
2659 2985
             $output .= $this->_createElement( 'FREEBUSY', $attributes, $content );
@@ -2676,14 +3002,15 @@  discard block
 block discarded – undo
2676 3002
             if( $this->getConfig( 'allowEmpty' )) {
2677 3003
                 $this->_setMval( $this->freebusy, null, $params, FALSE, $index );
2678 3004
                 return TRUE;
3005
+            } else {
3006
+                            return FALSE;
2679 3007
             }
2680
-            else
2681
-                return FALSE;
2682 3008
         }
2683 3009
         $fbType = strtoupper( $fbType );
2684 3010
         if(( !in_array( $fbType, array( 'FREE', 'BUSY', 'BUSY-UNAVAILABLE', 'BUSY-TENTATIVE' ))) &&
2685
-            ( 'X-' != substr( $fbType, 0, 2 )))
2686
-            $fbType = 'BUSY';
3011
+            ( 'X-' != substr( $fbType, 0, 2 ))) {
3012
+                    $fbType = 'BUSY';
3013
+        }
2687 3014
         $input = array( 'fbtype' => $fbType );
2688 3015
         foreach( $fbValues as $fbPeriod ) {   // periods => period
2689 3016
             $freebusyPeriod = array();
@@ -2693,22 +3020,19 @@  discard block
 block discarded – undo
2693 3020
                     if( $this->_isArrayDate( $fbMember )) { // date-time value
2694 3021
                         $freebusyPairMember       = $this->_date_time_array( $fbMember, 7 );
2695 3022
                         $freebusyPairMember['tz'] = 'Z';
2696
-                    }
2697
-                    elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
3023
+                    } elseif( $this->_isArrayTimestampDate( $fbMember )) { // timestamp value
2698 3024
                         $freebusyPairMember       = $this->_timestamp2date( $fbMember['timestamp'], 7 );
2699 3025
                         $freebusyPairMember['tz'] = 'Z';
2700
-                    }
2701
-                    else {                                         // array format duration
3026
+                    } else {                                         // array format duration
2702 3027
                         $freebusyPairMember = $this->_duration_array( $fbMember );
2703 3028
                     }
2704
-                }
2705
-                elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
3029
+                } elseif(( 3 <= strlen( trim( $fbMember ))) &&    // string format duration
2706 3030
                     ( in_array( $fbMember{0}, array( 'P', '+', '-' )))) {
2707
-                    if( 'P' != $fbMember{0} )
2708
-                        $fbmember = substr( $fbMember, 1 );
3031
+                    if( 'P' != $fbMember{0} ) {
3032
+                                            $fbmember = substr( $fbMember, 1 );
3033
+                    }
2709 3034
                     $freebusyPairMember = $this->_duration_string( $fbMember );
2710
-                }
2711
-                elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
3035
+                } elseif( 8 <= strlen( trim( $fbMember ))) { // text date ex. 2006-08-03 10:12:18
2712 3036
                     $freebusyPairMember       = $this->_date_time_string( $fbMember, 7 );
2713 3037
                     $freebusyPairMember['tz'] = 'Z';
2714 3038
                 }
@@ -2731,9 +3055,12 @@  discard block
 block discarded – undo
2731 3055
      * @return string
2732 3056
      */
2733 3057
     function createGeo() {
2734
-        if( empty( $this->geo )) return FALSE;
2735
-        if( empty( $this->geo['value'] ))
2736
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
3058
+        if( empty( $this->geo )) {
3059
+            return FALSE;
3060
+        }
3061
+        if( empty( $this->geo['value'] )) {
3062
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'GEO' ) : FALSE;
3063
+        }
2737 3064
         $attributes = $this->_createParams( $this->geo['params'] );
2738 3065
         $content    = null;
2739 3066
         $content   .= number_format( (float) $this->geo['value']['latitude'], 6, '.', '');
@@ -2753,15 +3080,17 @@  discard block
 block discarded – undo
2753 3080
      */
2754 3081
     function setGeo( $latitude, $longitude, $params=FALSE ) {
2755 3082
         if( !empty( $latitude ) && !empty( $longitude )) {
2756
-            if( !is_array( $this->geo )) $this->geo = array();
3083
+            if( !is_array( $this->geo )) {
3084
+                $this->geo = array();
3085
+            }
2757 3086
             $this->geo['value']['latitude']  = $latitude;
2758 3087
             $this->geo['value']['longitude'] = $longitude;
2759 3088
             $this->geo['params'] = $this->_setParams( $params );
3089
+        } elseif( $this->getConfig( 'allowEmpty' )) {
3090
+                    $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
3091
+        } else {
3092
+                    return FALSE;
2760 3093
         }
2761
-        elseif( $this->getConfig( 'allowEmpty' ))
2762
-            $this->geo = array( 'value' => null, 'params' => $this->_setParams( $params ) );
2763
-        else
2764
-            return FALSE;
2765 3094
         return TRUE;
2766 3095
     }
2767 3096
     /*********************************************************************************/
@@ -2776,7 +3105,9 @@  discard block
 block discarded – undo
2776 3105
      * @return string
2777 3106
      */
2778 3107
     function createLastModified() {
2779
-        if( empty( $this->lastmodified )) return FALSE;
3108
+        if( empty( $this->lastmodified )) {
3109
+            return FALSE;
3110
+        }
2780 3111
         $attributes = $this->_createParams( $this->lastmodified['params'] );
2781 3112
         $formatted  = $this->_format_date_time( $this->lastmodified['value'], 7 );
2782 3113
         return $this->_createElement( 'LAST-MODIFIED', $attributes, $formatted );
@@ -2796,8 +3127,9 @@  discard block
 block discarded – undo
2796 3127
      * @return boll
2797 3128
      */
2798 3129
     function setLastModified( $year=FALSE, $month=FALSE, $day=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $params=FALSE ) {
2799
-        if( empty( $year ))
2800
-            $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
3130
+        if( empty( $year )) {
3131
+                    $year = date('Ymd\THis', mktime( date( 'H' ), date( 'i' ), date( 's' ) - date( 'Z'), date( 'm' ), date( 'd' ), date( 'Y' )));
3132
+        }
2801 3133
         $this->lastmodified = $this->_setDate2( $year, $month, $day, $hour, $min, $sec, $params );
2802 3134
         return TRUE;
2803 3135
     }
@@ -2813,9 +3145,12 @@  discard block
 block discarded – undo
2813 3145
      * @return string
2814 3146
      */
2815 3147
     function createLocation() {
2816
-        if( empty( $this->location )) return FALSE;
2817
-        if( empty( $this->location['value'] ))
2818
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
3148
+        if( empty( $this->location )) {
3149
+            return FALSE;
3150
+        }
3151
+        if( empty( $this->location['value'] )) {
3152
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'LOCATION' ) : FALSE;
3153
+        }
2819 3154
         $attributes = $this->_createParams( $this->location['params'], array( 'ALTREP', 'LANGUAGE' ));
2820 3155
         $content    = $this->_strrep( $this->location['value'] );
2821 3156
         return $this->_createElement( 'LOCATION', $attributes, $content );
@@ -2830,7 +3165,11 @@  discard block
 block discarded – undo
2830 3165
      * @return bool
2831 3166
      */
2832 3167
     function setLocation( $value, $params=FALSE ) {
2833
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3168
+        if( empty( $value )) {
3169
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3170
+        } else {
3171
+            return FALSE;
3172
+        }
2834 3173
         $this->location = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2835 3174
         return TRUE;
2836 3175
     }
@@ -2846,9 +3185,12 @@  discard block
 block discarded – undo
2846 3185
      * @return string
2847 3186
      */
2848 3187
     function createOrganizer() {
2849
-        if( empty( $this->organizer )) return FALSE;
2850
-        if( empty( $this->organizer['value'] ))
2851
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
3188
+        if( empty( $this->organizer )) {
3189
+            return FALSE;
3190
+        }
3191
+        if( empty( $this->organizer['value'] )) {
3192
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'ORGANIZER' ) : FALSE;
3193
+        }
2852 3194
         $attributes = $this->_createParams( $this->organizer['params']
2853 3195
             , array( 'CN', 'DIR', 'LANGUAGE', 'SENT-BY' ));
2854 3196
         $content    = 'MAILTO:'.$this->organizer['value'];
@@ -2864,13 +3206,18 @@  discard block
 block discarded – undo
2864 3206
      * @return bool
2865 3207
      */
2866 3208
     function setOrganizer( $value, $params=FALSE ) {
2867
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3209
+        if( empty( $value )) {
3210
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3211
+        } else {
3212
+            return FALSE;
3213
+        }
2868 3214
         $value = str_replace ( 'MAILTO:', '', $value );
2869 3215
         $value = str_replace ( 'mailto:', '', $value );
2870 3216
         $this->organizer = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2871 3217
         if( isset( $this->organizer['params']['SENT-BY'] )) {
2872
-            if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 )))
2873
-                $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
3218
+            if( 'MAILTO' == strtoupper( substr( $this->organizer['params']['SENT-BY'], 0, 6 ))) {
3219
+                            $this->organizer['params']['SENT-BY'] = substr( $this->organizer['params']['SENT-BY'], 7 );
3220
+            }
2874 3221
         }
2875 3222
         return TRUE;
2876 3223
     }
@@ -2886,9 +3233,12 @@  discard block
 block discarded – undo
2886 3233
      * @return string
2887 3234
      */
2888 3235
     function createPercentComplete() {
2889
-        if( empty( $this->percentcomplete )) return FALSE;
2890
-        if( empty( $this->percentcomplete['value'] ))
2891
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
3236
+        if( empty( $this->percentcomplete )) {
3237
+            return FALSE;
3238
+        }
3239
+        if( empty( $this->percentcomplete['value'] )) {
3240
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PERCENT-COMPLETE' ) : FALSE;
3241
+        }
2892 3242
         $attributes = $this->_createParams( $this->percentcomplete['params'] );
2893 3243
         return $this->_createElement( 'PERCENT-COMPLETE', $attributes, $this->percentcomplete['value'] );
2894 3244
     }
@@ -2902,7 +3252,11 @@  discard block
 block discarded – undo
2902 3252
      * @return bool
2903 3253
      */
2904 3254
     function setPercentComplete( $value, $params=FALSE ) {
2905
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3255
+        if( empty( $value )) {
3256
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3257
+        } else {
3258
+            return FALSE;
3259
+        }
2906 3260
         $this->percentcomplete = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2907 3261
         return TRUE;
2908 3262
     }
@@ -2918,9 +3272,12 @@  discard block
 block discarded – undo
2918 3272
      * @return string
2919 3273
      */
2920 3274
     function createPriority() {
2921
-        if( empty( $this->priority )) return FALSE;
2922
-        if( empty( $this->priority['value'] ))
2923
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
3275
+        if( empty( $this->priority )) {
3276
+            return FALSE;
3277
+        }
3278
+        if( empty( $this->priority['value'] )) {
3279
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'PRIORITY' ) : FALSE;
3280
+        }
2924 3281
         $attributes = $this->_createParams( $this->priority['params'] );
2925 3282
         return $this->_createElement( 'PRIORITY', $attributes, $this->priority['value'] );
2926 3283
     }
@@ -2934,7 +3291,11 @@  discard block
 block discarded – undo
2934 3291
      * @return bool
2935 3292
      */
2936 3293
     function setPriority( $value, $params=FALSE  ) {
2937
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3294
+        if( empty( $value )) {
3295
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3296
+        } else {
3297
+            return FALSE;
3298
+        }
2938 3299
         $this->priority = array( 'value' => $value, 'params' => $this->_setParams( $params ));
2939 3300
         return TRUE;
2940 3301
     }
@@ -2950,18 +3311,24 @@  discard block
 block discarded – undo
2950 3311
      * @return string
2951 3312
      */
2952 3313
     function createRdate() {
2953
-        if( empty( $this->rdate )) return FALSE;
3314
+        if( empty( $this->rdate )) {
3315
+            return FALSE;
3316
+        }
2954 3317
         $utctime = ( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
2955 3318
         $output = null;
2956
-        if( $utctime  )
2957
-            unset( $this->rdate['params']['TZID'] );
3319
+        if( $utctime  ) {
3320
+                    unset( $this->rdate['params']['TZID'] );
3321
+        }
2958 3322
         foreach( $this->rdate as $theRdate ) {
2959 3323
             if( empty( $theRdate['value'] )) {
2960
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RDATE' );
3324
+                if( $this->getConfig( 'allowEmpty' )) {
3325
+                    $output .= $this->_createElement( 'RDATE' );
3326
+                }
2961 3327
                 continue;
2962 3328
             }
2963
-            if( $utctime  )
2964
-                unset( $theRdate['params']['TZID'] );
3329
+            if( $utctime  ) {
3330
+                            unset( $theRdate['params']['TZID'] );
3331
+            }
2965 3332
             $attributes = $this->_createParams( $theRdate['params'] );
2966 3333
             $cnt = count( $theRdate['value'] );
2967 3334
             $content = null;
@@ -2970,68 +3337,84 @@  discard block
 block discarded – undo
2970 3337
                 $contentPart = null;
2971 3338
                 if( is_array( $rdatePart ) &&
2972 3339
                     isset( $theRdate['params']['VALUE'] ) && ( 'PERIOD' == $theRdate['params']['VALUE'] )) { // PERIOD
2973
-                    if( $utctime )
2974
-                        unset( $rdatePart[0]['tz'] );
3340
+                    if( $utctime ) {
3341
+                                            unset( $rdatePart[0]['tz'] );
3342
+                    }
2975 3343
                     $formatted = $this->_format_date_time( $rdatePart[0]); // PERIOD part 1
2976
-                    if( $utctime || !empty( $theRdate['params']['TZID'] ))
2977
-                        $formatted = str_replace( 'Z', '', $formatted);
3344
+                    if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3345
+                                            $formatted = str_replace( 'Z', '', $formatted);
3346
+                    }
2978 3347
                     if( 0 < $rpix ) {
2979 3348
                         if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
2980
-                            if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3349
+                            if( 'Z' != substr( $formatted, -1 )) {
3350
+                                $formatted .= 'Z';
3351
+                            }
3352
+                        } else {
3353
+                                                    $formatted = str_replace( 'Z', '', $formatted );
2981 3354
                         }
2982
-                        else
2983
-                            $formatted = str_replace( 'Z', '', $formatted );
2984 3355
                     }
2985 3356
                     $contentPart .= $formatted;
2986 3357
                     $contentPart .= '/';
2987 3358
                     $cnt2 = count( $rdatePart[1]);
2988 3359
                     if( array_key_exists( 'year', $rdatePart[1] )) {
2989
-                        if( array_key_exists( 'hour', $rdatePart[1] ))
2990
-                            $cnt2 = 7;                                      // date-time
2991
-                        else
2992
-                            $cnt2 = 3;                                      // date
2993
-                    }
2994
-                    elseif( array_key_exists( 'week', $rdatePart[1] ))  // duration
3360
+                        if( array_key_exists( 'hour', $rdatePart[1] )) {
3361
+                                                    $cnt2 = 7;
3362
+                        }
3363
+                        // date-time
3364
+                        else {
3365
+                                                    $cnt2 = 3;
3366
+                        }
3367
+                        // date
3368
+                    } elseif( array_key_exists( 'week', $rdatePart[1] )) {
3369
+                        // duration
2995 3370
                         $cnt2 = 5;
3371
+                    }
2996 3372
                     if(( 7 == $cnt2 )   &&    // period=  -> date-time
2997 3373
                         isset( $rdatePart[1]['year'] )  &&
2998 3374
                         isset( $rdatePart[1]['month'] ) &&
2999 3375
                         isset( $rdatePart[1]['day'] )) {
3000
-                        if( $utctime )
3001
-                            unset( $rdatePart[1]['tz'] );
3376
+                        if( $utctime ) {
3377
+                                                    unset( $rdatePart[1]['tz'] );
3378
+                        }
3002 3379
                         $formatted = $this->_format_date_time( $rdatePart[1] ); // PERIOD part 2
3003
-                        if( $utctime || !empty( $theRdate['params']['TZID'] ))
3004
-                            $formatted = str_replace( 'Z', '', $formatted);
3380
+                        if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3381
+                                                    $formatted = str_replace( 'Z', '', $formatted);
3382
+                        }
3005 3383
                         if( !empty( $rdatePart[0]['tz'] ) && $this->_isOffset( $rdatePart[0]['tz'] )) {
3006
-                            if( 'Z' != substr( $formatted, -1 )) $formatted .= 'Z';
3384
+                            if( 'Z' != substr( $formatted, -1 )) {
3385
+                                $formatted .= 'Z';
3386
+                            }
3387
+                        } else {
3388
+                                                    $formatted = str_replace( 'Z', '', $formatted );
3007 3389
                         }
3008
-                        else
3009
-                            $formatted = str_replace( 'Z', '', $formatted );
3010 3390
                         $contentPart .= $formatted;
3011
-                    }
3012
-                    else {                                  // period=  -> dur-time
3391
+                    } else {                                  // period=  -> dur-time
3013 3392
                         $contentPart .= $this->_format_duration( $rdatePart[1] );
3014 3393
                     }
3015 3394
                 } // PERIOD end
3016 3395
                 else { // SINGLE date start
3017
-                    if( $utctime )
3018
-                        unset( $rdatePart['tz'] );
3396
+                    if( $utctime ) {
3397
+                                            unset( $rdatePart['tz'] );
3398
+                    }
3019 3399
                     $formatted = $this->_format_date_time( $rdatePart);
3020
-                    if( $utctime || !empty( $theRdate['params']['TZID'] ))
3021
-                        $formatted = str_replace( 'Z', '', $formatted);
3400
+                    if( $utctime || !empty( $theRdate['params']['TZID'] )) {
3401
+                                            $formatted = str_replace( 'Z', '', $formatted);
3402
+                    }
3022 3403
                     if( !$utctime && ( 0 < $rpix )) {
3023 3404
                         if( !empty( $theRdate['value'][0]['tz'] ) && $this->_isOffset( $theRdate['value'][0]['tz'] )) {
3024
-                            if( 'Z' != substr( $formatted, -1 ))
3025
-                                $formatted .= 'Z';
3405
+                            if( 'Z' != substr( $formatted, -1 )) {
3406
+                                                            $formatted .= 'Z';
3407
+                            }
3408
+                        } else {
3409
+                                                    $formatted = str_replace( 'Z', '', $formatted );
3026 3410
                         }
3027
-                        else
3028
-                            $formatted = str_replace( 'Z', '', $formatted );
3029 3411
                     }
3030 3412
                     $contentPart .= $formatted;
3031 3413
                 }
3032 3414
                 $content .= $contentPart;
3033
-                if( $rno < $cnt )
3034
-                    $content .= ',';
3415
+                if( $rno < $cnt ) {
3416
+                                    $content .= ',';
3417
+                }
3035 3418
                 $rno++;
3036 3419
             }
3037 3420
             $output    .= $this->_createElement( 'RDATE', $attributes, $content );
@@ -3053,9 +3436,9 @@  discard block
 block discarded – undo
3053 3436
             if( $this->getConfig( 'allowEmpty' )) {
3054 3437
                 $this->_setMval( $this->rdate, null, $params, FALSE, $index );
3055 3438
                 return TRUE;
3439
+            } else {
3440
+                            return FALSE;
3056 3441
             }
3057
-            else
3058
-                return FALSE;
3059 3442
         }
3060 3443
         $input = array( 'params' => $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' )));
3061 3444
         if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
@@ -3069,15 +3452,19 @@  discard block
 block discarded – undo
3069 3452
             (( is_array( $rdates[0][0] ) && ( isset( $rdates[0][0]['timestamp'] ) ||
3070 3453
                         $this->_isArrayDate( $rdates[0][0] ))) ||
3071 3454
                 ( is_string( $rdates[0][0] ) && ( 8 <= strlen( trim( $rdates[0][0] )))))  &&
3072
-            ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] ))))))
3073
-            $input['params']['VALUE'] = 'PERIOD';
3455
+            ( is_array( $rdates[0][1] ) || ( is_string( $rdates[0][1] ) && ( 3 <= strlen( trim( $rdates[0][1] )))))) {
3456
+                    $input['params']['VALUE'] = 'PERIOD';
3457
+        }
3074 3458
         /* check 1:st date, upd. $parno (opt) and save ev. timezone **/
3075 3459
         $date  = reset( $rdates );
3076
-        if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) // PERIOD
3460
+        if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) {
3461
+            // PERIOD
3077 3462
             $date  = reset( $date );
3463
+        }
3078 3464
         $this->_chkdatecfg( $date, $parno, $input['params'] );
3079
-        if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' )))
3080
-            unset( $input['params']['TZID'] );
3465
+        if( in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) {
3466
+                    unset( $input['params']['TZID'] );
3467
+        }
3081 3468
         $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME' ); // remove default
3082 3469
         foreach( $rdates as $rpix => $theRdate ) {
3083 3470
             $inputa = null;
@@ -3085,48 +3472,60 @@  discard block
 block discarded – undo
3085 3472
                 if( isset( $input['params']['VALUE'] ) && ( 'PERIOD' == $input['params']['VALUE'] )) { // PERIOD
3086 3473
                     foreach( $theRdate as $rix => $rPeriod ) {
3087 3474
                         if( is_array( $rPeriod )) {
3088
-                            if( $this->_isArrayTimestampDate( $rPeriod ))      // timestamp
3475
+                            if( $this->_isArrayTimestampDate( $rPeriod )) {
3476
+                                // timestamp
3089 3477
                                 $inputab  = ( isset( $rPeriod['tz'] )) ? $this->_timestamp2date( $rPeriod, $parno ) : $this->_timestamp2date( $rPeriod, 6 );
3090
-                            elseif( $this->_isArrayDate( $rPeriod ))
3091
-                                $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3092
-                            elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod ))))  // text-date
3478
+                            } elseif( $this->_isArrayDate( $rPeriod )) {
3479
+                                                            $inputab  = ( 3 < count ( $rPeriod )) ? $this->_date_time_array( $rPeriod, $parno ) : $this->_date_time_array( $rPeriod, 6 );
3480
+                            } elseif (( 1 == count( $rPeriod )) && ( 8 <= strlen( reset( $rPeriod )))) {
3481
+                                // text-date
3093 3482
                                 $inputab  = $this->_date_time_string( reset( $rPeriod ), $parno );
3094
-                            else                                               // array format duration
3483
+                            } else {
3484
+                                // array format duration
3095 3485
                                 $inputab  = $this->_duration_array( $rPeriod );
3096
-                        }
3097
-                        elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3486
+                            }
3487
+                        } elseif(( 3 <= strlen( trim( $rPeriod ))) &&          // string format duration
3098 3488
                             ( in_array( $rPeriod{0}, array( 'P', '+', '-' )))) {
3099
-                            if( 'P' != $rPeriod{0} )
3100
-                                $rPeriod  = substr( $rPeriod, 1 );
3489
+                            if( 'P' != $rPeriod{0} ) {
3490
+                                                            $rPeriod  = substr( $rPeriod, 1 );
3491
+                            }
3101 3492
                             $inputab    = $this->_duration_string( $rPeriod );
3102
-                        }
3103
-                        elseif( 8 <= strlen( trim( $rPeriod )))              // text date ex. 2006-08-03 10:12:18
3493
+                        } elseif( 8 <= strlen( trim( $rPeriod ))) {
3494
+                            // text date ex. 2006-08-03 10:12:18
3104 3495
                             $inputab    = $this->_date_time_string( $rPeriod, $parno );
3496
+                        }
3105 3497
                         if(  isset( $input['params']['TZID'] ) ||
3106 3498
                             ( isset( $inputab['tz'] )   && !$this->_isOffset( $inputab['tz'] )) ||
3107 3499
                             ( isset( $inputa[0] )       && ( !isset( $inputa[0]['tz'] )))       ||
3108
-                            ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] )))
3109
-                            unset( $inputab['tz'] );
3500
+                            ( isset( $inputa[0]['tz'] ) && !$this->_isOffset( $inputa[0]['tz'] ))) {
3501
+                                                    unset( $inputab['tz'] );
3502
+                        }
3110 3503
                         $inputa[]     = $inputab;
3111 3504
                     }
3112 3505
                 } // PERIOD end
3113
-                elseif ( $this->_isArrayTimestampDate( $theRdate ))      // timestamp
3506
+                elseif ( $this->_isArrayTimestampDate( $theRdate )) {
3507
+                    // timestamp
3114 3508
                     $inputa = $this->_timestamp2date( $theRdate, $parno );
3115
-                else                                                     // date[-time]
3509
+                } else {
3510
+                    // date[-time]
3116 3511
                     $inputa = $this->_date_time_array( $theRdate, $parno );
3117
-            }
3118
-            elseif( 8 <= strlen( trim( $theRdate )))                   // text date ex. 2006-08-03 10:12:18
3512
+                }
3513
+            } elseif( 8 <= strlen( trim( $theRdate ))) {
3514
+                // text date ex. 2006-08-03 10:12:18
3119 3515
                 $inputa       = $this->_date_time_string( $theRdate, $parno );
3516
+            }
3120 3517
             if( !isset( $input['params']['VALUE'] ) || ( 'PERIOD' != $input['params']['VALUE'] )) { // no PERIOD
3121
-                if( 3 == $parno )
3122
-                    unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3123
-                elseif( isset( $inputa['tz'] ))
3124
-                    $inputa['tz'] = (string) $inputa['tz'];
3518
+                if( 3 == $parno ) {
3519
+                                    unset( $inputa['hour'], $inputa['min'], $inputa['sec'], $inputa['tz'] );
3520
+                } elseif( isset( $inputa['tz'] )) {
3521
+                                    $inputa['tz'] = (string) $inputa['tz'];
3522
+                }
3125 3523
                 if(  isset( $input['params']['TZID'] ) ||
3126 3524
                     ( isset( $inputa['tz'] )            && !$this->_isOffset( $inputa['tz'] ))     ||
3127 3525
                     ( isset( $input['value'][0] )       && ( !isset( $input['value'][0]['tz'] )))  ||
3128
-                    ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] )))
3129
-                    unset( $inputa['tz'] );
3526
+                    ( isset( $input['value'][0]['tz'] ) && !$this->_isOffset( $input['value'][0]['tz'] ))) {
3527
+                                    unset( $inputa['tz'] );
3528
+                }
3130 3529
             }
3131 3530
             $input['value'][] = $inputa;
3132 3531
         }
@@ -3149,9 +3548,12 @@  discard block
 block discarded – undo
3149 3548
      * @return string
3150 3549
      */
3151 3550
     function createRecurrenceid() {
3152
-        if( empty( $this->recurrenceid )) return FALSE;
3153
-        if( empty( $this->recurrenceid['value'] ))
3154
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3551
+        if( empty( $this->recurrenceid )) {
3552
+            return FALSE;
3553
+        }
3554
+        if( empty( $this->recurrenceid['value'] )) {
3555
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'RECURRENCE-ID' ) : FALSE;
3556
+        }
3155 3557
         $formatted  = $this->_format_date_time( $this->recurrenceid['value'] );
3156 3558
         $attributes = $this->_createParams( $this->recurrenceid['params'] );
3157 3559
         return $this->_createElement( 'RECURRENCE-ID', $attributes, $formatted );
@@ -3175,9 +3577,9 @@  discard block
 block discarded – undo
3175 3577
             if( $this->getConfig( 'allowEmpty' )) {
3176 3578
                 $this->recurrenceid = array( 'value' => null, 'params' => null );
3177 3579
                 return TRUE;
3580
+            } else {
3581
+                            return FALSE;
3178 3582
             }
3179
-            else
3180
-                return FALSE;
3181 3583
         }
3182 3584
         $this->recurrenceid = $this->_setDate( $year, $month, $day, $hour, $min, $sec, $tz, $params );
3183 3585
         return TRUE;
@@ -3194,11 +3596,15 @@  discard block
 block discarded – undo
3194 3596
      * @return string
3195 3597
      */
3196 3598
     function createRelatedTo() {
3197
-        if( empty( $this->relatedto )) return FALSE;
3599
+        if( empty( $this->relatedto )) {
3600
+            return FALSE;
3601
+        }
3198 3602
         $output = null;
3199 3603
         foreach( $this->relatedto as $relation ) {
3200 3604
             if( empty( $relation['value'] )) {
3201
-                if( $this->getConfig( 'allowEmpty' )) $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3605
+                if( $this->getConfig( 'allowEmpty' )) {
3606
+                    $output.= $this->_createElement( 'RELATED-TO', $this->_createParams( $relation['params'] ));
3607
+                }
3202 3608
                 continue;
3203 3609
             }
3204 3610
             $attributes = $this->_createParams( $relation['params'] );
@@ -3220,9 +3626,14 @@  discard block
 block discarded – undo
3220 3626
      * @return bool
3221 3627
      */
3222 3628
     function setRelatedTo( $value, $params=FALSE, $index=FALSE ) {
3223
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3224
-        if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 )))
3225
-            $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3629
+        if( empty( $value )) {
3630
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3631
+        } else {
3632
+            return FALSE;
3633
+        }
3634
+        if(( '<' == substr( $value, 0, 1 )) && ( '>' == substr( $value, -1 ))) {
3635
+                    $value = substr( $value, 1, ( strlen( $value ) - 2 ));
3636
+        }
3226 3637
         $this->_existRem( $params, 'RELTYPE', 'PARENT', TRUE ); // remove default
3227 3638
         $this->_setMval( $this->relatedto, $value, $params, FALSE, $index );
3228 3639
         return TRUE;
@@ -3239,9 +3650,12 @@  discard block
 block discarded – undo
3239 3650
      * @return string
3240 3651
      */
3241 3652
     function createRepeat() {
3242
-        if( empty( $this->repeat )) return FALSE;
3243
-        if( empty( $this->repeat['value'] ))
3244
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3653
+        if( empty( $this->repeat )) {
3654
+            return FALSE;
3655
+        }
3656
+        if( empty( $this->repeat['value'] )) {
3657
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'REPEAT' ) : FALSE;
3658
+        }
3245 3659
         $attributes = $this->_createParams( $this->repeat['params'] );
3246 3660
         return $this->_createElement( 'REPEAT', $attributes, $this->repeat['value'] );
3247 3661
     }
@@ -3255,7 +3669,11 @@  discard block
 block discarded – undo
3255 3669
      * @return void
3256 3670
      */
3257 3671
     function setRepeat( $value, $params=FALSE ) {
3258
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3672
+        if( empty( $value )) {
3673
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3674
+        } else {
3675
+            return FALSE;
3676
+        }
3259 3677
         $this->repeat = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3260 3678
         return TRUE;
3261 3679
     }
@@ -3270,18 +3688,23 @@  discard block
 block discarded – undo
3270 3688
      * @return string
3271 3689
      */
3272 3690
     function createRequestStatus() {
3273
-        if( empty( $this->requeststatus )) return FALSE;
3691
+        if( empty( $this->requeststatus )) {
3692
+            return FALSE;
3693
+        }
3274 3694
         $output = null;
3275 3695
         foreach( $this->requeststatus as $rstat ) {
3276 3696
             if( empty( $rstat['value']['statcode'] )) {
3277
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'REQUEST-STATUS' );
3697
+                if( $this->getConfig( 'allowEmpty' )) {
3698
+                    $output .= $this->_createElement( 'REQUEST-STATUS' );
3699
+                }
3278 3700
                 continue;
3279 3701
             }
3280 3702
             $attributes  = $this->_createParams( $rstat['params'], array( 'LANGUAGE' ));
3281 3703
             $content     = number_format( (float) $rstat['value']['statcode'], 2, '.', '');
3282 3704
             $content    .= ';'.$this->_strrep( $rstat['value']['text'] );
3283
-            if( isset( $rstat['value']['extdata'] ))
3284
-                $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3705
+            if( isset( $rstat['value']['extdata'] )) {
3706
+                            $content  .= ';'.$this->_strrep( $rstat['value']['extdata'] );
3707
+            }
3285 3708
             $output     .= $this->_createElement( 'REQUEST-STATUS', $attributes, $content );
3286 3709
         }
3287 3710
         return $output;
@@ -3299,10 +3722,15 @@  discard block
 block discarded – undo
3299 3722
      * @return bool
3300 3723
      */
3301 3724
     function setRequestStatus( $statcode, $text, $extdata=FALSE, $params=FALSE, $index=FALSE ) {
3302
-        if( empty( $statcode ) || empty( $text )) if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null; else return FALSE;
3725
+        if( empty( $statcode ) || empty( $text )) {
3726
+            if( $this->getConfig( 'allowEmpty' )) $statcode = $text = null;
3727
+        } else {
3728
+            return FALSE;
3729
+        }
3303 3730
         $input              = array( 'statcode' => $statcode, 'text' => $text );
3304
-        if( $extdata )
3305
-            $input['extdata'] = $extdata;
3731
+        if( $extdata ) {
3732
+                    $input['extdata'] = $extdata;
3733
+        }
3306 3734
         $this->_setMval( $this->requeststatus, $input, $params, FALSE, $index );
3307 3735
         return TRUE;
3308 3736
     }
@@ -3318,21 +3746,26 @@  discard block
 block discarded – undo
3318 3746
      * @return string
3319 3747
      */
3320 3748
     function createResources() {
3321
-        if( empty( $this->resources )) return FALSE;
3749
+        if( empty( $this->resources )) {
3750
+            return FALSE;
3751
+        }
3322 3752
         $output = null;
3323 3753
         foreach( $this->resources as $resource ) {
3324 3754
             if( empty( $resource['value'] )) {
3325
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'RESOURCES' );
3755
+                if( $this->getConfig( 'allowEmpty' )) {
3756
+                    $output .= $this->_createElement( 'RESOURCES' );
3757
+                }
3326 3758
                 continue;
3327 3759
             }
3328 3760
             $attributes  = $this->_createParams( $resource['params'], array( 'ALTREP', 'LANGUAGE' ));
3329 3761
             if( is_array( $resource['value'] )) {
3330
-                foreach( $resource['value'] as $rix => $resourcePart )
3331
-                    $resource['value'][$rix] = $this->_strrep( $resourcePart );
3762
+                foreach( $resource['value'] as $rix => $resourcePart ) {
3763
+                                    $resource['value'][$rix] = $this->_strrep( $resourcePart );
3764
+                }
3332 3765
                 $content   = implode( ',', $resource['value'] );
3766
+            } else {
3767
+                            $content   = $this->_strrep( $resource['value'] );
3333 3768
             }
3334
-            else
3335
-                $content   = $this->_strrep( $resource['value'] );
3336 3769
             $output     .= $this->_createElement( 'RESOURCES', $attributes, $content );
3337 3770
         }
3338 3771
         return $output;
@@ -3348,7 +3781,11 @@  discard block
 block discarded – undo
3348 3781
      * @return bool
3349 3782
      */
3350 3783
     function setResources( $value, $params=FALSE, $index=FALSE ) {
3351
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3784
+        if( empty( $value )) {
3785
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3786
+        } else {
3787
+            return FALSE;
3788
+        }
3352 3789
         $this->_setMval( $this->resources, $value, $params, FALSE, $index );
3353 3790
         return TRUE;
3354 3791
     }
@@ -3364,7 +3801,9 @@  discard block
 block discarded – undo
3364 3801
      * @return string
3365 3802
      */
3366 3803
     function createRrule() {
3367
-        if( empty( $this->rrule )) return FALSE;
3804
+        if( empty( $this->rrule )) {
3805
+            return FALSE;
3806
+        }
3368 3807
         return $this->_format_recur( 'RRULE', $this->rrule );
3369 3808
     }
3370 3809
     /**
@@ -3378,7 +3817,11 @@  discard block
 block discarded – undo
3378 3817
      * @return void
3379 3818
      */
3380 3819
     function setRrule( $rruleset, $params=FALSE, $index=FALSE ) {
3381
-        if( empty( $rruleset )) if( $this->getConfig( 'allowEmpty' )) $rruleset = null; else return FALSE;
3820
+        if( empty( $rruleset )) {
3821
+            if( $this->getConfig( 'allowEmpty' )) $rruleset = null;
3822
+        } else {
3823
+            return FALSE;
3824
+        }
3382 3825
         $this->_setMval( $this->rrule, $this->_setRexrule( $rruleset ), $params, FALSE, $index );
3383 3826
         return TRUE;
3384 3827
     }
@@ -3393,9 +3836,12 @@  discard block
 block discarded – undo
3393 3836
      * @return string
3394 3837
      */
3395 3838
     function createSequence() {
3396
-        if( empty( $this->sequence )) return FALSE;
3397
-        if( empty( $this->sequence['value'] ))
3398
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3839
+        if( empty( $this->sequence )) {
3840
+            return FALSE;
3841
+        }
3842
+        if( empty( $this->sequence['value'] )) {
3843
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SEQUENCE' ) : FALSE;
3844
+        }
3399 3845
         $attributes = $this->_createParams( $this->sequence['params'] );
3400 3846
         return $this->_createElement( 'SEQUENCE', $attributes, $this->sequence['value'] );
3401 3847
     }
@@ -3408,8 +3854,9 @@  discard block
 block discarded – undo
3408 3854
      * @return bool
3409 3855
      */
3410 3856
     function setSequence( $value=FALSE, $params=FALSE ) {
3411
-        if( empty( $value ))
3412
-            $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3857
+        if( empty( $value )) {
3858
+                    $value = ( isset( $this->sequence['value'] ) && ( 0 < $this->sequence['value'] )) ? $this->sequence['value'] + 1 : 1;
3859
+        }
3413 3860
         $this->sequence = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3414 3861
         return TRUE;
3415 3862
     }
@@ -3425,9 +3872,12 @@  discard block
 block discarded – undo
3425 3872
      * @return string
3426 3873
      */
3427 3874
     function createStatus() {
3428
-        if( empty( $this->status )) return FALSE;
3429
-        if( empty( $this->status['value'] ))
3430
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3875
+        if( empty( $this->status )) {
3876
+            return FALSE;
3877
+        }
3878
+        if( empty( $this->status['value'] )) {
3879
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'STATUS' ) : FALSE;
3880
+        }
3431 3881
         $attributes = $this->_createParams( $this->status['params'] );
3432 3882
         return $this->_createElement( 'STATUS', $attributes, $this->status['value'] );
3433 3883
     }
@@ -3441,7 +3891,11 @@  discard block
 block discarded – undo
3441 3891
      * @return bool
3442 3892
      */
3443 3893
     function setStatus( $value, $params=FALSE ) {
3444
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3894
+        if( empty( $value )) {
3895
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3896
+        } else {
3897
+            return FALSE;
3898
+        }
3445 3899
         $this->status = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3446 3900
         return TRUE;
3447 3901
     }
@@ -3457,9 +3911,12 @@  discard block
 block discarded – undo
3457 3911
      * @return string
3458 3912
      */
3459 3913
     function createSummary() {
3460
-        if( empty( $this->summary )) return FALSE;
3461
-        if( empty( $this->summary['value'] ))
3462
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3914
+        if( empty( $this->summary )) {
3915
+            return FALSE;
3916
+        }
3917
+        if( empty( $this->summary['value'] )) {
3918
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'SUMMARY' ) : FALSE;
3919
+        }
3463 3920
         $attributes = $this->_createParams( $this->summary['params'], array( 'ALTREP', 'LANGUAGE' ));
3464 3921
         $content    = $this->_strrep( $this->summary['value'] );
3465 3922
         return $this->_createElement( 'SUMMARY', $attributes, $content );
@@ -3474,9 +3931,13 @@  discard block
 block discarded – undo
3474 3931
      * @return bool
3475 3932
      */
3476 3933
     function setSummary( $value, $params=FALSE ) {
3477
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3478
-        $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3479
-        return TRUE;
3934
+        if( empty( $value )) {
3935
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3936
+        } else {
3937
+            return FALSE;
3938
+        }
3939
+        $this->summary = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3940
+        return TRUE;
3480 3941
     }
3481 3942
     /*********************************************************************************/
3482 3943
     /**
@@ -3490,9 +3951,12 @@  discard block
 block discarded – undo
3490 3951
      * @return string
3491 3952
      */
3492 3953
     function createTransp() {
3493
-        if( empty( $this->transp )) return FALSE;
3494
-        if( empty( $this->transp['value'] ))
3495
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3954
+        if( empty( $this->transp )) {
3955
+            return FALSE;
3956
+        }
3957
+        if( empty( $this->transp['value'] )) {
3958
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRANSP' ) : FALSE;
3959
+        }
3496 3960
         $attributes = $this->_createParams( $this->transp['params'] );
3497 3961
         return $this->_createElement( 'TRANSP', $attributes, $this->transp['value'] );
3498 3962
     }
@@ -3506,7 +3970,11 @@  discard block
 block discarded – undo
3506 3970
      * @return bool
3507 3971
      */
3508 3972
     function setTransp( $value, $params=FALSE ) {
3509
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
3973
+        if( empty( $value )) {
3974
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
3975
+        } else {
3976
+            return FALSE;
3977
+        }
3510 3978
         $this->transp = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3511 3979
         return TRUE;
3512 3980
     }
@@ -3522,19 +3990,24 @@  discard block
 block discarded – undo
3522 3990
      * @return string
3523 3991
      */
3524 3992
     function createTrigger() {
3525
-        if( empty( $this->trigger )) return FALSE;
3526
-        if( empty( $this->trigger['value'] ))
3527
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3993
+        if( empty( $this->trigger )) {
3994
+            return FALSE;
3995
+        }
3996
+        if( empty( $this->trigger['value'] )) {
3997
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TRIGGER' ) : FALSE;
3998
+        }
3528 3999
         $content = $attributes = null;
3529 4000
         if( isset( $this->trigger['value']['year'] )   &&
3530 4001
             isset( $this->trigger['value']['month'] )  &&
3531
-            isset( $this->trigger['value']['day'] ))
3532
-            $content      .= $this->_format_date_time( $this->trigger['value'] );
3533
-        else {
3534
-            if( TRUE !== $this->trigger['value']['relatedStart'] )
3535
-                $attributes .= $this->intAttrDelimiter.'RELATED=END';
3536
-            if( $this->trigger['value']['before'] )
3537
-                $content    .= '-';
4002
+            isset( $this->trigger['value']['day'] )) {
4003
+                    $content      .= $this->_format_date_time( $this->trigger['value'] );
4004
+        } else {
4005
+            if( TRUE !== $this->trigger['value']['relatedStart'] ) {
4006
+                            $attributes .= $this->intAttrDelimiter.'RELATED=END';
4007
+            }
4008
+            if( $this->trigger['value']['before'] ) {
4009
+                            $content    .= '-';
4010
+            }
3538 4011
             $content      .= $this->_format_duration( $this->trigger['value'] );
3539 4012
         }
3540 4013
         $attributes     .= $this->_createParams( $this->trigger['params'] );
@@ -3558,28 +4031,30 @@  discard block
 block discarded – undo
3558 4031
      * @return bool
3559 4032
      */
3560 4033
     function setTrigger( $year, $month=null, $day=null, $week=FALSE, $hour=FALSE, $min=FALSE, $sec=FALSE, $relatedStart=TRUE, $before=TRUE, $params=FALSE ) {
3561
-        if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec ))
3562
-            if( $this->getConfig( 'allowEmpty' )) {
4034
+        if( empty( $year ) && empty( $month ) && empty( $day ) && empty( $week ) && empty( $hour ) && empty( $min ) && empty( $sec )) {
4035
+                    if( $this->getConfig( 'allowEmpty' )) {
3563 4036
                 $this->trigger = array( 'value' => null, 'params' => $this->_setParams( $params ) );
4037
+        }
3564 4038
                 return TRUE;
4039
+            } else {
4040
+                            return FALSE;
3565 4041
             }
3566
-            else
3567
-                return FALSE;
3568 4042
         if( $this->_isArrayTimestampDate( $year )) { // timestamp
3569 4043
             $params = $this->_setParams( $month );
3570 4044
             $date   = $this->_timestamp2date( $year, 7 );
3571
-            foreach( $date as $k => $v )
3572
-                $$k = $v;
3573
-        }
3574
-        elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
4045
+            foreach( $date as $k => $v ) {
4046
+                            $$k = $v;
4047
+            }
4048
+        } elseif( is_array( $year ) && ( is_array( $month ) || empty( $month ))) {
3575 4049
             $params = $this->_setParams( $month );
3576 4050
             if(!(array_key_exists( 'year',  $year ) &&   // exclude date-time
3577 4051
                 array_key_exists( 'month', $year ) &&
3578 4052
                 array_key_exists( 'day',   $year ))) {  // so this must be a duration
3579
-                if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] ))
3580
-                    $relatedStart = FALSE;
3581
-                else
3582
-                    $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
4053
+                if( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) {
4054
+                                    $relatedStart = FALSE;
4055
+                } else {
4056
+                                    $relatedStart = ( array_key_exists( 'relatedStart', $year ) && ( TRUE !== $year['relatedStart'] )) ? FALSE : TRUE;
4057
+                }
3583 4058
                 $before         = ( array_key_exists( 'before', $year )       && ( TRUE !== $year['before'] ))       ? FALSE : TRUE;
3584 4059
             }
3585 4060
             $SSYY  = ( array_key_exists( 'year',  $year )) ? $year['year']  : null;
@@ -3590,24 +4065,27 @@  discard block
 block discarded – undo
3590 4065
             $min   = ( array_key_exists( 'min',   $year )) ? $year['min']   : 0; //null;
3591 4066
             $sec   = ( array_key_exists( 'sec',   $year )) ? $year['sec']   : 0; //null;
3592 4067
             $year  = $SSYY;
3593
-        }
3594
-        elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
4068
+        } elseif(is_string( $year ) && ( is_array( $month ) || empty( $month ))) {  // duration or date in a string
3595 4069
             $params = $this->_setParams( $month );
3596 4070
             if( in_array( $year{0}, array( 'P', '+', '-' ))) { // duration
3597 4071
                 $relatedStart = ( isset( $params['RELATED'] ) && ( 'END' == $params['RELATED'] )) ? FALSE : TRUE;
3598 4072
                 $before       = ( '-'  == $year{0} ) ? TRUE : FALSE;
3599
-                if(     'P'  != $year{0} )
3600
-                    $year       = substr( $year, 1 );
4073
+                if(     'P'  != $year{0} ) {
4074
+                                    $year       = substr( $year, 1 );
4075
+                }
3601 4076
                 $date         = $this->_duration_string( $year);
3602
-            }
3603
-            else   // date
4077
+            } else {
4078
+                // date
3604 4079
                 $date    = $this->_date_time_string( $year, 7 );
4080
+            }
3605 4081
             unset( $year, $month, $day );
3606
-            foreach( $date as $k => $v )
3607
-                $$k = $v;
3608
-        }
3609
-        else // single values in function input parameters
4082
+            foreach( $date as $k => $v ) {
4083
+                            $$k = $v;
4084
+            }
4085
+        } else {
4086
+            // single values in function input parameters
3610 4087
             $params = $this->_setParams( $params );
4088
+        }
3611 4089
         if( !empty( $year ) && !empty( $month ) && !empty( $day )) { // date
3612 4090
             $params['VALUE'] = 'DATE-TIME';
3613 4091
             $hour = ( $hour ) ? $hour : 0;
@@ -3622,8 +4100,7 @@  discard block
 block discarded – undo
3622 4100
             , 'sec'   => $sec
3623 4101
             , 'tz'    => 'Z' );
3624 4102
             return TRUE;
3625
-        }
3626
-        elseif(( empty( $year ) && empty( $month )) &&    // duration
4103
+        } elseif(( empty( $year ) && empty( $month )) &&    // duration
3627 4104
             (!empty( $week ) || !empty( $day ) || !empty( $hour ) || !empty( $min ) || !empty( $sec ))) {
3628 4105
             unset( $params['RELATED'] ); // set at output creation (END only)
3629 4106
             unset( $params['VALUE'] );   // 'DURATION' default
@@ -3632,11 +4109,21 @@  discard block
 block discarded – undo
3632 4109
             $before       = ( FALSE !== $before )       ? TRUE : FALSE;
3633 4110
             $this->trigger['value']  = array( 'relatedStart' => $relatedStart
3634 4111
             , 'before'       => $before );
3635
-            if( !empty( $week )) $this->trigger['value']['week'] = $week;
3636
-            if( !empty( $day  )) $this->trigger['value']['day']  = $day;
3637
-            if( !empty( $hour )) $this->trigger['value']['hour'] = $hour;
3638
-            if( !empty( $min  )) $this->trigger['value']['min']  = $min;
3639
-            if( !empty( $sec  )) $this->trigger['value']['sec']  = $sec;
4112
+            if( !empty( $week )) {
4113
+                $this->trigger['value']['week'] = $week;
4114
+            }
4115
+            if( !empty( $day  )) {
4116
+                $this->trigger['value']['day']  = $day;
4117
+            }
4118
+            if( !empty( $hour )) {
4119
+                $this->trigger['value']['hour'] = $hour;
4120
+            }
4121
+            if( !empty( $min  )) {
4122
+                $this->trigger['value']['min']  = $min;
4123
+            }
4124
+            if( !empty( $sec  )) {
4125
+                $this->trigger['value']['sec']  = $sec;
4126
+            }
3640 4127
             return TRUE;
3641 4128
         }
3642 4129
         return FALSE;
@@ -3653,9 +4140,12 @@  discard block
 block discarded – undo
3653 4140
      * @return string
3654 4141
      */
3655 4142
     function createTzid() {
3656
-        if( empty( $this->tzid )) return FALSE;
3657
-        if( empty( $this->tzid['value'] ))
3658
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
4143
+        if( empty( $this->tzid )) {
4144
+            return FALSE;
4145
+        }
4146
+        if( empty( $this->tzid['value'] )) {
4147
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZID' ) : FALSE;
4148
+        }
3659 4149
         $attributes = $this->_createParams( $this->tzid['params'] );
3660 4150
         return $this->_createElement( 'TZID', $attributes, $this->_strrep( $this->tzid['value'] ));
3661 4151
     }
@@ -3669,7 +4159,11 @@  discard block
 block discarded – undo
3669 4159
      * @return bool
3670 4160
      */
3671 4161
     function setTzid( $value, $params=FALSE ) {
3672
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4162
+        if( empty( $value )) {
4163
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4164
+        } else {
4165
+            return FALSE;
4166
+        }
3673 4167
         $this->tzid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3674 4168
         return TRUE;
3675 4169
     }
@@ -3686,14 +4180,17 @@  discard block
 block discarded – undo
3686 4180
      * @return string
3687 4181
      */
3688 4182
     function createTzname() {
3689
-        if( empty( $this->tzname )) return FALSE;
4183
+        if( empty( $this->tzname )) {
4184
+            return FALSE;
4185
+        }
3690 4186
         $output = null;
3691 4187
         foreach( $this->tzname as $theName ) {
3692 4188
             if( !empty( $theName['value'] )) {
3693 4189
                 $attributes = $this->_createParams( $theName['params'], array( 'LANGUAGE' ));
3694 4190
                 $output    .= $this->_createElement( 'TZNAME', $attributes, $this->_strrep( $theName['value'] ));
4191
+            } elseif( $this->getConfig( 'allowEmpty' )) {
4192
+                $output .= $this->_createElement( 'TZNAME' );
3695 4193
             }
3696
-            elseif( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( 'TZNAME' );
3697 4194
         }
3698 4195
         return $output;
3699 4196
     }
@@ -3708,7 +4205,11 @@  discard block
 block discarded – undo
3708 4205
      * @return bool
3709 4206
      */
3710 4207
     function setTzname( $value, $params=FALSE, $index=FALSE ) {
3711
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4208
+        if( empty( $value )) {
4209
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4210
+        } else {
4211
+            return FALSE;
4212
+        }
3712 4213
         $this->_setMval( $this->tzname, $value, $params, FALSE, $index );
3713 4214
         return TRUE;
3714 4215
     }
@@ -3724,9 +4225,12 @@  discard block
 block discarded – undo
3724 4225
      * @return string
3725 4226
      */
3726 4227
     function createTzoffsetfrom() {
3727
-        if( empty( $this->tzoffsetfrom )) return FALSE;
3728
-        if( empty( $this->tzoffsetfrom['value'] ))
3729
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
4228
+        if( empty( $this->tzoffsetfrom )) {
4229
+            return FALSE;
4230
+        }
4231
+        if( empty( $this->tzoffsetfrom['value'] )) {
4232
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETFROM' ) : FALSE;
4233
+        }
3730 4234
         $attributes = $this->_createParams( $this->tzoffsetfrom['params'] );
3731 4235
         return $this->_createElement( 'TZOFFSETFROM', $attributes, $this->tzoffsetfrom['value'] );
3732 4236
     }
@@ -3740,7 +4244,11 @@  discard block
 block discarded – undo
3740 4244
      * @return bool
3741 4245
      */
3742 4246
     function setTzoffsetfrom( $value, $params=FALSE ) {
3743
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4247
+        if( empty( $value )) {
4248
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4249
+        } else {
4250
+            return FALSE;
4251
+        }
3744 4252
         $this->tzoffsetfrom = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3745 4253
         return TRUE;
3746 4254
     }
@@ -3756,9 +4264,12 @@  discard block
 block discarded – undo
3756 4264
      * @return string
3757 4265
      */
3758 4266
     function createTzoffsetto() {
3759
-        if( empty( $this->tzoffsetto )) return FALSE;
3760
-        if( empty( $this->tzoffsetto['value'] ))
3761
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
4267
+        if( empty( $this->tzoffsetto )) {
4268
+            return FALSE;
4269
+        }
4270
+        if( empty( $this->tzoffsetto['value'] )) {
4271
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZOFFSETTO' ) : FALSE;
4272
+        }
3762 4273
         $attributes = $this->_createParams( $this->tzoffsetto['params'] );
3763 4274
         return $this->_createElement( 'TZOFFSETTO', $attributes, $this->tzoffsetto['value'] );
3764 4275
     }
@@ -3772,7 +4283,11 @@  discard block
 block discarded – undo
3772 4283
      * @return bool
3773 4284
      */
3774 4285
     function setTzoffsetto( $value, $params=FALSE ) {
3775
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4286
+        if( empty( $value )) {
4287
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4288
+        } else {
4289
+            return FALSE;
4290
+        }
3776 4291
         $this->tzoffsetto = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3777 4292
         return TRUE;
3778 4293
     }
@@ -3788,9 +4303,12 @@  discard block
 block discarded – undo
3788 4303
      * @return string
3789 4304
      */
3790 4305
     function createTzurl() {
3791
-        if( empty( $this->tzurl )) return FALSE;
3792
-        if( empty( $this->tzurl['value'] ))
3793
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
4306
+        if( empty( $this->tzurl )) {
4307
+            return FALSE;
4308
+        }
4309
+        if( empty( $this->tzurl['value'] )) {
4310
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'TZURL' ) : FALSE;
4311
+        }
3794 4312
         $attributes = $this->_createParams( $this->tzurl['params'] );
3795 4313
         return $this->_createElement( 'TZURL', $attributes, $this->tzurl['value'] );
3796 4314
     }
@@ -3804,7 +4322,11 @@  discard block
 block discarded – undo
3804 4322
      * @return boll
3805 4323
      */
3806 4324
     function setTzurl( $value, $params=FALSE ) {
3807
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4325
+        if( empty( $value )) {
4326
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4327
+        } else {
4328
+            return FALSE;
4329
+        }
3808 4330
         $this->tzurl = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3809 4331
         return TRUE;
3810 4332
     }
@@ -3820,8 +4342,9 @@  discard block
 block discarded – undo
3820 4342
      * @return string
3821 4343
      */
3822 4344
     function createUid() {
3823
-        if( 0 >= count( $this->uid ))
3824
-            $this->_makeuid();
4345
+        if( 0 >= count( $this->uid )) {
4346
+                    $this->_makeuid();
4347
+        }
3825 4348
         $attributes = $this->_createParams( $this->uid['params'] );
3826 4349
         return $this->_createElement( 'UID', $attributes, $this->uid['value'] );
3827 4350
     }
@@ -3840,8 +4363,9 @@  discard block
 block discarded – undo
3840 4363
         $end    = strlen( $base ) - 1;
3841 4364
         $length = 6;
3842 4365
         $str    = null;
3843
-        for( $p = 0; $p < $length; $p++ )
3844
-            $unique .= $base{mt_rand( $start, $end )};
4366
+        for( $p = 0; $p < $length; $p++ ) {
4367
+                    $unique .= $base{mt_rand( $start, $end )};
4368
+        }
3845 4369
         $this->uid = array( 'params' => null );
3846 4370
         $this->uid['value']  = $date.'-'.$unique.'@'.$this->getConfig( 'unique_id' );
3847 4371
     }
@@ -3855,7 +4379,10 @@  discard block
 block discarded – undo
3855 4379
      * @return bool
3856 4380
      */
3857 4381
     function setUid( $value, $params=FALSE ) {
3858
-        if( empty( $value )) return FALSE; // no allowEmpty check here !!!!
4382
+        if( empty( $value )) {
4383
+            return FALSE;
4384
+        }
4385
+        // no allowEmpty check here !!!!
3859 4386
         $this->uid = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3860 4387
         return TRUE;
3861 4388
     }
@@ -3871,9 +4398,12 @@  discard block
 block discarded – undo
3871 4398
      * @return string
3872 4399
      */
3873 4400
     function createUrl() {
3874
-        if( empty( $this->url )) return FALSE;
3875
-        if( empty( $this->url['value'] ))
3876
-            return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
4401
+        if( empty( $this->url )) {
4402
+            return FALSE;
4403
+        }
4404
+        if( empty( $this->url['value'] )) {
4405
+                    return ( $this->getConfig( 'allowEmpty' )) ? $this->_createElement( 'URL' ) : FALSE;
4406
+        }
3877 4407
         $attributes = $this->_createParams( $this->url['params'] );
3878 4408
         return $this->_createElement( 'URL', $attributes, $this->url['value'] );
3879 4409
     }
@@ -3887,7 +4417,11 @@  discard block
 block discarded – undo
3887 4417
      * @return bool
3888 4418
      */
3889 4419
     function setUrl( $value, $params=FALSE ) {
3890
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4420
+        if( empty( $value )) {
4421
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4422
+        } else {
4423
+            return FALSE;
4424
+        }
3891 4425
         $this->url = array( 'value' => $value, 'params' => $this->_setParams( $params ));
3892 4426
         return TRUE;
3893 4427
     }
@@ -3903,21 +4437,26 @@  discard block
 block discarded – undo
3903 4437
      * @return string
3904 4438
      */
3905 4439
     function createXprop() {
3906
-        if( empty( $this->xprop )) return FALSE;
4440
+        if( empty( $this->xprop )) {
4441
+            return FALSE;
4442
+        }
3907 4443
         $output = null;
3908 4444
         foreach( $this->xprop as $label => $xpropPart ) {
3909 4445
             if( empty( $xpropPart['value'] )) {
3910
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $label );
4446
+                if( $this->getConfig( 'allowEmpty' )) {
4447
+                    $output .= $this->_createElement( $label );
4448
+                }
3911 4449
                 continue;
3912 4450
             }
3913 4451
             $attributes = $this->_createParams( $xpropPart['params'], array( 'LANGUAGE' ));
3914 4452
             if( is_array( $xpropPart['value'] )) {
3915
-                foreach( $xpropPart['value'] as $pix => $theXpart )
3916
-                    $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
4453
+                foreach( $xpropPart['value'] as $pix => $theXpart ) {
4454
+                                    $xpropPart['value'][$pix] = $this->_strrep( $theXpart );
4455
+                }
3917 4456
                 $xpropPart['value']  = implode( ',', $xpropPart['value'] );
4457
+            } else {
4458
+                            $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3918 4459
             }
3919
-            else
3920
-                $xpropPart['value'] = $this->_strrep( $xpropPart['value'] );
3921 4460
             $output    .= $this->_createElement( $label, $attributes, $xpropPart['value'] );
3922 4461
         }
3923 4462
         return $output;
@@ -3933,12 +4472,20 @@  discard block
 block discarded – undo
3933 4472
      * @return bool
3934 4473
      */
3935 4474
     function setXprop( $label, $value, $params=FALSE ) {
3936
-        if( empty( $label )) return;
3937
-        if( empty( $value )) if( $this->getConfig( 'allowEmpty' )) $value = null; else return FALSE;
4475
+        if( empty( $label )) {
4476
+            return;
4477
+        }
4478
+        if( empty( $value )) {
4479
+            if( $this->getConfig( 'allowEmpty' )) $value = null;
4480
+        } else {
4481
+            return FALSE;
4482
+        }
3938 4483
         $xprop           = array( 'value' => $value );
3939 4484
         $toolbox         = new calendarComponent();
3940 4485
         $xprop['params'] = $toolbox->_setParams( $params );
3941
-        if( !is_array( $this->xprop )) $this->xprop = array();
4486
+        if( !is_array( $this->xprop )) {
4487
+            $this->xprop = array();
4488
+        }
3942 4489
         $this->xprop[strtoupper( $label )] = $xprop;
3943 4490
         return TRUE;
3944 4491
     }
@@ -4006,30 +4553,29 @@  discard block
 block discarded – undo
4006 4553
                 $attributes  = null;
4007 4554
                 foreach( $attributes2 as $attribute ) {
4008 4555
                     $attrKVarr = explode( '=', $attribute );
4009
-                    if( empty( $attrKVarr[0] ))
4010
-                        continue;
4556
+                    if( empty( $attrKVarr[0] )) {
4557
+                                            continue;
4558
+                    }
4011 4559
                     if( !isset( $attrKVarr[1] )) {
4012 4560
                         $attrValue = $attrKVarr[0];
4013 4561
                         $attrKey   = null;
4014
-                    }
4015
-                    elseif( 2 == count( $attrKVarr)) {
4562
+                    } elseif( 2 == count( $attrKVarr)) {
4016 4563
                         $attrKey   = strtolower( $attrKVarr[0] );
4017 4564
                         $attrValue = $attrKVarr[1];
4018
-                    }
4019
-                    else {
4565
+                    } else {
4020 4566
                         $attrKey   = strtolower( $attrKVarr[0] );
4021 4567
                         unset( $attrKVarr[0] );
4022 4568
                         $attrValue = implode( '=', $attrKVarr );
4023 4569
                     }
4024 4570
                     if(( 'attach' == $label ) && ( in_array( $attrKey, array( 'fmttype', 'encoding', 'value' )))) {
4025 4571
                         $attachInlineBinary = TRUE;
4026
-                        if( 'fmttype' == $attrKey )
4027
-                            $attachfmttype = $attrKey.'='.$attrValue;
4572
+                        if( 'fmttype' == $attrKey ) {
4573
+                                                    $attachfmttype = $attrKey.'='.$attrValue;
4574
+                        }
4028 4575
                         continue;
4029
-                    }
4030
-                    elseif(( 'categories' == $label ) && ( 'language' == $attrKey ))
4031
-                        $categoriesAttrLang = $attrKey.'='.$attrValue;
4032
-                    else {
4576
+                    } elseif(( 'categories' == $label ) && ( 'language' == $attrKey )) {
4577
+                                            $categoriesAttrLang = $attrKey.'='.$attrValue;
4578
+                    } else {
4033 4579
                         $attributes .= ( empty( $attributes )) ? ' ' : $this->attributeDelimiter.' ';
4034 4580
                         $attributes .= ( !empty( $attrKey )) ? $attrKey.'=' : null;
4035 4581
                         if(( '"' == substr( $attrValue, 0, 1 )) && ( '"' == substr( $attrValue, -1 ))) {
@@ -4039,8 +4585,7 @@  discard block
 block discarded – undo
4039 4585
                         $attributes .= '"'.htmlspecialchars( $attrValue ).'"';
4040 4586
                     }
4041 4587
                 }
4042
-            }
4043
-            else {
4588
+            } else {
4044 4589
                 $attributes = str_replace( $this->intAttrDelimiter, $this->attributeDelimiter, $attributes );
4045 4590
             }
4046 4591
         }
@@ -4062,8 +4607,7 @@  discard block
 block discarded – undo
4062 4607
                 $content = $this->_createElement( 'extref', $attributes, null );
4063 4608
                 $attributes = null;
4064 4609
             }
4065
-        }
4066
-        elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4610
+        } elseif(( 'attach' == $label ) && $attachInlineBinary && ( 'xcal' == $this->format)) {
4067 4611
             $content = $this->nl.$this->_createElement( 'b64bin', $attachfmttype, $content ); // max one attribute
4068 4612
         }
4069 4613
         $output .= $attributes;
@@ -4107,30 +4651,30 @@  discard block
 block discarded – undo
4107 4651
         $CNattrExist = $LANGattrExist = FALSE;
4108 4652
         if( is_array( $params )) {
4109 4653
             foreach( $params as $paramKey => $paramValue ) {
4110
-                if( is_int( $paramKey ))
4111
-                    $attr2            .= $this->intAttrDelimiter.$paramValue;
4112
-                elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4654
+                if( is_int( $paramKey )) {
4655
+                                    $attr2            .= $this->intAttrDelimiter.$paramValue;
4656
+                } elseif(( 'LANGUAGE' == $paramKey ) && $LANGattrKey ) {
4113 4657
                     $attrLANG         .= $this->intAttrDelimiter."LANGUAGE=$paramValue";
4114 4658
                     $LANGattrExist     = TRUE;
4115
-                }
4116
-                elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4659
+                } elseif(( 'CN'       == $paramKey ) && $CNattrKey ) {
4117 4660
                     $attr1             = $this->intAttrDelimiter.'CN="'.$paramValue.'"';
4118 4661
                     $CNattrExist       = TRUE;
4662
+                } elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4663
+                                    $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4664
+                } elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4665
+                                    $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4666
+                } elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys )) {
4667
+                                    $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4668
+                } else {
4669
+                                    $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4119 4670
                 }
4120
-                elseif(( 'ALTREP'   == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4121
-                    $attr2            .= $this->intAttrDelimiter.'ALTREP="'.$paramValue.'"';
4122
-                elseif(( 'DIR'      == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4123
-                    $attr2            .= $this->intAttrDelimiter.'DIR="'.$paramValue.'"';
4124
-                elseif(( 'SENT-BY'  == $paramKey ) && in_array( $paramKey, $ctrKeys ))
4125
-                    $attr2            .= $this->intAttrDelimiter.'SENT-BY="MAILTO:'.$paramValue.'"';
4126
-                else
4127
-                    $attr2            .= $this->intAttrDelimiter."$paramKey=$paramValue";
4128 4671
             }
4129 4672
         }
4130 4673
         if( !$LANGattrExist ) {
4131 4674
             $lang = $this->getConfig( 'language' );
4132
-            if(( $CNattrExist || $LANGattrKey ) && $lang )
4133
-                $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4675
+            if(( $CNattrExist || $LANGattrKey ) && $lang ) {
4676
+                            $attrLANG .= $this->intAttrDelimiter.'LANGUAGE='.$lang;
4677
+            }
4134 4678
         }
4135 4679
         return $attrLANG.$attr1.$attr2;
4136 4680
     }
@@ -4144,47 +4688,57 @@  discard block
 block discarded – undo
4144 4688
      * @return array $params, property parameters
4145 4689
      */
4146 4690
     function _chkdatecfg( $theDate, & $parno, & $params ) {
4147
-        if( isset( $params['TZID'] ))
4148
-            $parno = 6;
4149
-        elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))
4150
-            $parno = 3;
4151
-        else {
4152
-            if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] ))
4153
-                $parno = 7;
4691
+        if( isset( $params['TZID'] )) {
4692
+                    $parno = 6;
4693
+        } elseif( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )) {
4694
+                    $parno = 3;
4695
+        } else {
4696
+            if( isset( $params['VALUE'] ) && ( 'PERIOD' == $params['VALUE'] )) {
4697
+                            $parno = 7;
4698
+            }
4154 4699
             if( is_array( $theDate )) {
4155
-                if( isset( $theDate['timestamp'] ))
4156
-                    $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4157
-                else
4158
-                    $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4700
+                if( isset( $theDate['timestamp'] )) {
4701
+                                    $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : null;
4702
+                } else {
4703
+                                    $tzid = ( isset( $theDate['tz'] )) ? $theDate['tz'] : ( 7 == count( $theDate )) ? end( $theDate ) : null;
4704
+                }
4159 4705
                 if( !empty( $tzid )) {
4160 4706
                     $parno = 7;
4161
-                    if( !$this->_isOffset( $tzid ))
4162
-                        $params['TZID'] = $tzid; // save only timezone
4707
+                    if( !$this->_isOffset( $tzid )) {
4708
+                                            $params['TZID'] = $tzid;
4709
+                    }
4710
+                    // save only timezone
4711
+                } elseif( !$parno && ( 3 == count( $theDate )) &&
4712
+                    ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] ))) {
4713
+                                    $parno = 3;
4714
+                } else {
4715
+                                    $parno = 6;
4163 4716
                 }
4164
-                elseif( !$parno && ( 3 == count( $theDate )) &&
4165
-                    ( isset( $params['VALUE'] ) && ( 'DATE' == $params['VALUE'] )))
4166
-                    $parno = 3;
4167
-                else
4168
-                    $parno = 6;
4169
-            }
4170
-            else { // string
4717
+            } else { // string
4171 4718
                 $date = trim( $theDate );
4172
-                if( 'Z' == substr( $date, -1 ))
4173
-                    $parno = 7; // UTC DATE-TIME
4719
+                if( 'Z' == substr( $date, -1 )) {
4720
+                                    $parno = 7;
4721
+                }
4722
+                // UTC DATE-TIME
4174 4723
                 elseif((( 8 == strlen( $date ) && ctype_digit( $date )) || ( 11 >= strlen( $date ))) &&
4175
-                    ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' ))))
4176
-                    $parno = 3; // DATE
4724
+                    ( !isset( $params['VALUE'] ) || !in_array( $params['VALUE'], array( 'DATE-TIME', 'PERIOD' )))) {
4725
+                                    $parno = 3;
4726
+                }
4727
+                // DATE
4177 4728
                 $date = $this->_date_time_string( $date, $parno );
4178 4729
                 if( !empty( $date['tz'] )) {
4179 4730
                     $parno = 7;
4180
-                    if( !$this->_isOffset( $date['tz'] ))
4181
-                        $params['TZID'] = $date['tz']; // save only timezone
4731
+                    if( !$this->_isOffset( $date['tz'] )) {
4732
+                                            $params['TZID'] = $date['tz'];
4733
+                    }
4734
+                    // save only timezone
4735
+                } elseif( empty( $parno )) {
4736
+                                    $parno = 6;
4182 4737
                 }
4183
-                elseif( empty( $parno ))
4184
-                    $parno = 6;
4185 4738
             }
4186
-            if( isset( $params['TZID'] ))
4187
-                $parno = 6;
4739
+            if( isset( $params['TZID'] )) {
4740
+                            $parno = 6;
4741
+            }
4188 4742
         }
4189 4743
     }
4190 4744
     /**
@@ -4200,14 +4754,18 @@  discard block
 block discarded – undo
4200 4754
      */
4201 4755
     function _date2duration( $startdate=FALSE, $enddate=FALSE ) {
4202 4756
         if( !$startdate || !$enddate ) {
4203
-            if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' )))
4204
-                return null;
4205
-            if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' )))    // vevent/vfreebusy
4757
+            if(   FALSE === ( $startdate = $this->getProperty( 'dtstart' ))) {
4758
+                            return null;
4759
+            }
4760
+            if(   FALSE === ( $enddate   = $this->getProperty( 'dtend' ))) {
4761
+                // vevent/vfreebusy
4206 4762
                 if( FALSE === ( $enddate   = $this->getProperty( 'due' )))      // vtodo
4207 4763
                     return null;
4764
+            }
4765
+        }
4766
+        if( !$startdate || !$enddate ) {
4767
+                    return null;
4208 4768
         }
4209
-        if( !$startdate || !$enddate )
4210
-            return null;
4211 4769
         $startWdate  = mktime( 0, 0, 0, $startdate['month'], $startdate['day'], $startdate['year'] );
4212 4770
         $endWdate    = mktime( 0, 0, 0, $enddate['month'],   $enddate['day'],   $enddate['year'] );
4213 4771
         $wduration   = $endWdate - $startWdate;
@@ -4233,15 +4791,23 @@  discard block
 block discarded – undo
4233 4791
      */
4234 4792
     function _date2timestamp( $datetime, $tz=null ) {
4235 4793
         $output = null;
4236
-        if( !isset( $datetime['hour'] )) $datetime['hour'] = '0';
4237
-        if( !isset( $datetime['min'] ))  $datetime['min']  = '0';
4238
-        if( !isset( $datetime['sec'] ))  $datetime['sec']  = '0';
4794
+        if( !isset( $datetime['hour'] )) {
4795
+            $datetime['hour'] = '0';
4796
+        }
4797
+        if( !isset( $datetime['min'] )) {
4798
+            $datetime['min']  = '0';
4799
+        }
4800
+        if( !isset( $datetime['sec'] )) {
4801
+            $datetime['sec']  = '0';
4802
+        }
4239 4803
         foreach( $datetime as $dkey => $dvalue ) {
4240
-            if( 'tz' != $dkey )
4241
-                $datetime[$dkey] = (integer) $dvalue;
4804
+            if( 'tz' != $dkey ) {
4805
+                            $datetime[$dkey] = (integer) $dvalue;
4806
+            }
4807
+        }
4808
+        if( $tz ) {
4809
+                    $datetime['tz'] = $tz;
4242 4810
         }
4243
-        if( $tz )
4244
-            $datetime['tz'] = $tz;
4245 4811
         $offset = ( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) ? $this->_tz2offset( $datetime['tz'] ) : 0;
4246 4812
         $output = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year'] );
4247 4813
         return $output;
@@ -4298,12 +4864,15 @@  discard block
 block discarded – undo
4298 4864
             }
4299 4865
         }
4300 4866
         if( 3 != $parno ) {
4301
-            if( !isset( $output['hour'] ))
4302
-                $output['hour'] = 0;
4303
-            if( !isset( $output['min']  ))
4304
-                $output['min'] = 0;
4305
-            if( !isset( $output['sec']  ))
4306
-                $output['sec'] = 0;
4867
+            if( !isset( $output['hour'] )) {
4868
+                            $output['hour'] = 0;
4869
+            }
4870
+            if( !isset( $output['min']  )) {
4871
+                            $output['min'] = 0;
4872
+            }
4873
+            if( !isset( $output['sec']  )) {
4874
+                            $output['sec'] = 0;
4875
+            }
4307 4876
         }
4308 4877
         return $output;
4309 4878
     }
@@ -4323,39 +4892,37 @@  discard block
 block discarded – undo
4323 4892
         if( 'Z' == substr( $datetime, -1 )) {
4324 4893
             $tz = 'Z';
4325 4894
             $datetime = trim( substr( $datetime, 0, $len ));
4326
-        }
4327
-        elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4895
+        } elseif( ( ctype_digit( substr( $datetime, -2, 2 ))) && // time or date
4328 4896
             ( '-' == substr( $datetime, -3, 1 )) ||
4329 4897
             ( ':' == substr( $datetime, -3, 1 )) ||
4330 4898
             ( '.' == substr( $datetime, -3, 1 ))) {
4331 4899
             $continue = TRUE;
4332
-        }
4333
-        elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4900
+        } elseif( ( ctype_digit( substr( $datetime, -4, 4 ))) && // 4 pos offset
4334 4901
             ( ' +' == substr( $datetime, -6, 2 )) ||
4335 4902
             ( ' -' == substr( $datetime, -6, 2 ))) {
4336 4903
             $tz = substr( $datetime, -5, 5 );
4337 4904
             $datetime = substr( $datetime, 0, ($len - 5));
4338
-        }
4339
-        elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4905
+        } elseif( ( ctype_digit( substr( $datetime, -6, 6 ))) && // 6 pos offset
4340 4906
             ( ' +' == substr( $datetime, -8, 2 )) ||
4341 4907
             ( ' -' == substr( $datetime, -8, 2 ))) {
4342 4908
             $tz = substr( $datetime, -7, 7 );
4343 4909
             $datetime = substr( $datetime, 0, ($len - 7));
4344
-        }
4345
-        elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4910
+        } elseif( ( 6 < $len ) && ( ctype_digit( substr( $datetime, -6, 6 )))) {
4346 4911
             $continue = TRUE;
4347
-        }
4348
-        elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4912
+        } elseif( 'T' ==  substr( $datetime, -7, 1 )) {
4349 4913
             $continue = TRUE;
4350
-        }
4351
-        else {
4914
+        } else {
4352 4915
             $cx  = $tx = 0;    //  19970415T133000 US-Eastern
4353 4916
             for( $cx = -1; $cx > ( 9 - $len ); $cx-- ) {
4354
-                if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 )))
4355
-                    break; // if exists, tz ends here.. . ?
4917
+                if(( ' ' == substr( $datetime, $cx, 1 )) || ctype_digit( substr( $datetime, $cx, 1 ))) {
4918
+                                    break;
4919
+                }
4920
+                // if exists, tz ends here.. . ?
4356 4921
                 elseif( ctype_alpha( substr( $datetime, $cx, 1 )) ||
4357
-                    ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' ))))
4358
-                    $tx--; // tz length counter
4922
+                    ( in_array( substr( $datetime, $cx, 1 ), array( '-', '/' )))) {
4923
+                                    $tx--;
4924
+                }
4925
+                // tz length counter
4359 4926
             }
4360 4927
             if( 0 > $tx ) {
4361 4928
                 $tz = substr( $datetime, $tx );
@@ -4364,8 +4931,7 @@  discard block
 block discarded – undo
4364 4931
         }
4365 4932
         if( 0 < substr_count( $datetime, '-' )) {
4366 4933
             $datetime = str_replace( '-', '/', $datetime );
4367
-        }
4368
-        elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4934
+        } elseif( ctype_digit( substr( $datetime, 0, 8 )) &&
4369 4935
             ( 'T' ==      substr( $datetime, 8, 1 )) &&
4370 4936
             ctype_digit( substr( $datetime, 9, 6 ))) {
4371 4937
             $datetime = substr( $datetime,  4, 2 )
@@ -4385,10 +4951,10 @@  discard block
 block discarded – undo
4385 4951
             $output['hour']  = substr( $datestring, 11, 2 );
4386 4952
             $output['min']   = substr( $datestring, 14, 2 );
4387 4953
             $output['sec']   = substr( $datestring, 17, 2 );
4388
-            if( !empty( $tz ))
4389
-                $output['tz']  = $tz;
4390
-        }
4391
-        elseif( 3 != $parno ) {
4954
+            if( !empty( $tz )) {
4955
+                            $output['tz']  = $tz;
4956
+            }
4957
+        } elseif( 3 != $parno ) {
4392 4958
             if(( '00' < substr( $datestring, 11, 2 )) ||
4393 4959
                 ( '00' < substr( $datestring, 14, 2 )) ||
4394 4960
                 ( '00' < substr( $datestring, 17, 2 ))) {
@@ -4396,8 +4962,9 @@  discard block
 block discarded – undo
4396 4962
                 $output['min']   = substr( $datestring, 14, 2 );
4397 4963
                 $output['sec']   = substr( $datestring, 17, 2 );
4398 4964
             }
4399
-            if( !empty( $tz ))
4400
-                $output['tz']  = $tz;
4965
+            if( !empty( $tz )) {
4966
+                            $output['tz']  = $tz;
4967
+            }
4401 4968
         }
4402 4969
         return $output;
4403 4970
     }
@@ -4424,10 +4991,11 @@  discard block
 block discarded – undo
4424 4991
             $durseconds  =           $durseconds % ( 60 * 60 );
4425 4992
             $output['min']  = floor( $durseconds / ( 60 ));
4426 4993
             $output['sec']  =      ( $durseconds % ( 60 ));
4427
-        }
4428
-        else {
4994
+        } else {
4429 4995
             foreach( $duration as $durKey => $durValue ) {
4430
-                if( empty( $durValue )) continue;
4996
+                if( empty( $durValue )) {
4997
+                    continue;
4998
+                }
4431 4999
                 switch ( $durKey ) {
4432 5000
                     case '0':
4433 5001
                     case 'week':
@@ -4457,14 +5025,22 @@  discard block
 block discarded – undo
4457 5025
             return $output;
4458 5026
         }
4459 5027
         unset( $output['week'] );
4460
-        if( empty( $output['day'] ))
4461
-            unset( $output['day'] );
5028
+        if( empty( $output['day'] )) {
5029
+                    unset( $output['day'] );
5030
+        }
4462 5031
         if ( isset( $output['hour'] ) || isset( $output['min'] ) || isset( $output['sec'] )) {
4463
-            if( !isset( $output['hour'] )) $output['hour'] = 0;
4464
-            if( !isset( $output['min']  )) $output['min']  = 0;
4465
-            if( !isset( $output['sec']  )) $output['sec']  = 0;
4466
-            if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] ))
4467
-                unset( $output['hour'], $output['min'], $output['sec'] );
5032
+            if( !isset( $output['hour'] )) {
5033
+                $output['hour'] = 0;
5034
+            }
5035
+            if( !isset( $output['min']  )) {
5036
+                $output['min']  = 0;
5037
+            }
5038
+            if( !isset( $output['sec']  )) {
5039
+                $output['sec']  = 0;
5040
+            }
5041
+            if(( 0 == $output['hour'] ) && ( 0 == $output['min'] ) && ( 0 == $output['sec'] )) {
5042
+                            unset( $output['hour'], $output['min'], $output['sec'] );
5043
+            }
4468 5044
         }
4469 5045
         return $output;
4470 5046
     }
@@ -4481,28 +5057,32 @@  discard block
 block discarded – undo
4481 5057
         if( $startdate && $duration ) {
4482 5058
             $d1               = $startdate;
4483 5059
             $dur              = $duration;
4484
-        }
4485
-        elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
5060
+        } elseif( isset( $this->dtstart['value'] ) && isset( $this->duration['value'] )) {
4486 5061
             $d1               = $this->dtstart['value'];
4487 5062
             $dur              = $this->duration['value'];
5063
+        } else {
5064
+                    return null;
4488 5065
         }
4489
-        else
4490
-            return null;
4491 5066
         $dateOnly         = ( isset( $d1['hour'] ) || isset( $d1['min'] ) || isset( $d1['sec'] )) ? FALSE : TRUE;
4492 5067
         $d1['hour']       = ( isset( $d1['hour'] )) ? $d1['hour'] : 0;
4493 5068
         $d1['min']        = ( isset( $d1['min'] ))  ? $d1['min']  : 0;
4494 5069
         $d1['sec']        = ( isset( $d1['sec'] ))  ? $d1['sec']  : 0;
4495 5070
         $dtend = mktime( $d1['hour'], $d1['min'], $d1['sec'], $d1['month'], $d1['day'], $d1['year'] );
4496
-        if( isset( $dur['week'] ))
4497
-            $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
4498
-        if( isset( $dur['day'] ))
4499
-            $dtend += ( $dur['day'] * 24 * 60 * 60 );
4500
-        if( isset( $dur['hour'] ))
4501
-            $dtend += ( $dur['hour'] * 60 *60 );
4502
-        if( isset( $dur['min'] ))
4503
-            $dtend += ( $dur['min'] * 60 );
4504
-        if( isset( $dur['sec'] ))
4505
-            $dtend +=   $dur['sec'];
5071
+        if( isset( $dur['week'] )) {
5072
+                    $dtend += ( $dur['week'] * 7 * 24 * 60 * 60 );
5073
+        }
5074
+        if( isset( $dur['day'] )) {
5075
+                    $dtend += ( $dur['day'] * 24 * 60 * 60 );
5076
+        }
5077
+        if( isset( $dur['hour'] )) {
5078
+                    $dtend += ( $dur['hour'] * 60 *60 );
5079
+        }
5080
+        if( isset( $dur['min'] )) {
5081
+                    $dtend += ( $dur['min'] * 60 );
5082
+        }
5083
+        if( isset( $dur['sec'] )) {
5084
+                    $dtend +=   $dur['sec'];
5085
+        }
4506 5086
         $dtend2 = array();
4507 5087
         $dtend2['year']   = date('Y', $dtend );
4508 5088
         $dtend2['month']  = date('m', $dtend );
@@ -4510,10 +5090,12 @@  discard block
 block discarded – undo
4510 5090
         $dtend2['hour']   = date('H', $dtend );
4511 5091
         $dtend2['min']    = date('i', $dtend );
4512 5092
         $dtend2['sec']    = date('s', $dtend );
4513
-        if( isset( $d1['tz'] ))
4514
-            $dtend2['tz']   = $d1['tz'];
4515
-        if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] )))
4516
-            unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
5093
+        if( isset( $d1['tz'] )) {
5094
+                    $dtend2['tz']   = $d1['tz'];
5095
+        }
5096
+        if( $dateOnly && (( 0 == $dtend2['hour'] ) && ( 0 == $dtend2['min'] ) && ( 0 == $dtend2['sec'] ))) {
5097
+                    unset( $dtend2['hour'], $dtend2['min'], $dtend2['sec'] );
5098
+        }
4517 5099
         return $dtend2;
4518 5100
     }
4519 5101
     /**
@@ -4527,10 +5109,12 @@  discard block
 block discarded – undo
4527 5109
     function _duration_string( $duration ) {
4528 5110
         $duration = (string) trim( $duration );
4529 5111
         while( 'P' != strtoupper( substr( $duration, 0, 1 ))) {
4530
-            if( 0 < strlen( $duration ))
4531
-                $duration = substr( $duration, 1 );
4532
-            else
4533
-                return false; // no leading P !?!?
5112
+            if( 0 < strlen( $duration )) {
5113
+                            $duration = substr( $duration, 1 );
5114
+            } else {
5115
+                            return false;
5116
+            }
5117
+            // no leading P !?!?
4534 5118
         }
4535 5119
         $duration = substr( $duration, 1 ); // skip P
4536 5120
         $duration = str_replace ( 't', 'T', $duration );
@@ -4560,10 +5144,13 @@  discard block
 block discarded – undo
4560 5144
                     $val            = null;
4561 5145
                     break;
4562 5146
                 default:
4563
-                    if( !ctype_digit( $duration{$ix} ))
4564
-                        return false; // unknown duration controll character  !?!?
4565
-                    else
4566
-                        $val .= $duration{$ix};
5147
+                    if( !ctype_digit( $duration{$ix} )) {
5148
+                                            return false;
5149
+                    }
5150
+                    // unknown duration controll character  !?!?
5151
+                    else {
5152
+                                            $val .= $duration{$ix};
5153
+                    }
4567 5154
             }
4568 5155
         }
4569 5156
         return $this->_duration_array( $output );
@@ -4582,10 +5169,12 @@  discard block
 block discarded – undo
4582 5169
      * @return int
4583 5170
      */
4584 5171
     function _existRem( &$array, $expkey, $expval=FALSE, $hitVal=null, $elseVal=null, $preSet=null ) {
4585
-        if( $preSet )
4586
-            return $preSet;
4587
-        if( !is_array( $array ) || ( 0 == count( $array )))
4588
-            return $elseVal;
5172
+        if( $preSet ) {
5173
+                    return $preSet;
5174
+        }
5175
+        if( !is_array( $array ) || ( 0 == count( $array ))) {
5176
+                    return $elseVal;
5177
+        }
4589 5178
         foreach( $array as $key => $value ) {
4590 5179
             if( strtoupper( $expkey ) == strtoupper( $key )) {
4591 5180
                 if( !$expval || ( strtoupper( $expval ) == strtoupper( $array[$key] ))) {
@@ -4611,13 +5200,15 @@  discard block
 block discarded – undo
4611 5200
             !isset( $datetime['day'] )   &&
4612 5201
             !isset( $datetime['hour'] )  &&
4613 5202
             !isset( $datetime['min'] )   &&
4614
-            !isset( $datetime['sec'] ))
4615
-            return ;
5203
+            !isset( $datetime['sec'] )) {
5204
+                    return ;
5205
+        }
4616 5206
         $output = null;
4617 5207
         // if( !isset( $datetime['day'] )) { $o=''; foreach($datetime as $k=>$v) {if(is_array($v)) $v=implode('-',$v);$o.=" $k=>$v";} echo " day SAKNAS : $o <br />\n"; }
4618 5208
         foreach( $datetime as $dkey => $dvalue ) {
4619
-            if( 'tz' != $dkey )
4620
-                $datetime[$dkey] = (integer) $dvalue;
5209
+            if( 'tz' != $dkey ) {
5210
+                            $datetime[$dkey] = (integer) $dvalue;
5211
+            }
4621 5212
         }
4622 5213
         $output = date('Ymd', mktime( 0, 0, 0, $datetime['month'], $datetime['day'], $datetime['year']));
4623 5214
         if( isset( $datetime['hour'] )  ||
@@ -4625,29 +5216,33 @@  discard block
 block discarded – undo
4625 5216
             isset( $datetime['sec'] )   ||
4626 5217
             isset( $datetime['tz'] )) {
4627 5218
             if( isset( $datetime['tz'] )  &&
4628
-                !isset( $datetime['hour'] ))
4629
-                $datetime['hour'] = 0;
5219
+                !isset( $datetime['hour'] )) {
5220
+                            $datetime['hour'] = 0;
5221
+            }
4630 5222
             if( isset( $datetime['hour'] )  &&
4631
-                !isset( $datetime['min'] ))
4632
-                $datetime['min'] = 0;
5223
+                !isset( $datetime['min'] )) {
5224
+                            $datetime['min'] = 0;
5225
+            }
4633 5226
             if( isset( $datetime['hour'] )  &&
4634 5227
                 isset( $datetime['min'] )   &&
4635
-                !isset( $datetime['sec'] ))
4636
-                $datetime['sec'] = 0;
5228
+                !isset( $datetime['sec'] )) {
5229
+                            $datetime['sec'] = 0;
5230
+            }
4637 5231
             $date = mktime( $datetime['hour'], $datetime['min'], $datetime['sec'], $datetime['month'], $datetime['day'], $datetime['year']);
4638 5232
             $output .= date('\THis', $date );
4639 5233
             if( isset( $datetime['tz'] ) && ( '' < trim ( $datetime['tz'] ))) {
4640 5234
                 $datetime['tz'] = trim( $datetime['tz'] );
4641
-                if( 'Z' == $datetime['tz'] )
4642
-                    $output .= 'Z';
5235
+                if( 'Z' == $datetime['tz'] ) {
5236
+                                    $output .= 'Z';
5237
+                }
4643 5238
                 $offset = $this->_tz2offset( $datetime['tz'] );
4644 5239
                 if( 0 != $offset ) {
4645 5240
                     $date = mktime( $datetime['hour'], $datetime['min'], ($datetime['sec'] + $offset), $datetime['month'], $datetime['day'], $datetime['year']);
4646 5241
                     $output    = date( 'Ymd\THis\Z', $date );
4647 5242
                 }
5243
+            } elseif( 7 == $parno ) {
5244
+                            $output .= 'Z';
4648 5245
             }
4649
-            elseif( 7 == $parno )
4650
-                $output .= 'Z';
4651 5246
         }
4652 5247
         return $output;
4653 5248
     }
@@ -4664,14 +5259,16 @@  discard block
 block discarded – undo
4664 5259
             !isset( $duration['day'] )  &&
4665 5260
             !isset( $duration['hour'] ) &&
4666 5261
             !isset( $duration['min'] )  &&
4667
-            !isset( $duration['sec'] ))
4668
-            return;
5262
+            !isset( $duration['sec'] )) {
5263
+                    return;
5264
+        }
4669 5265
         $output = 'P';
4670
-        if( isset( $duration['week'] ) && ( 0 < $duration['week'] ))
4671
-            $output   .= $duration['week'].'W';
4672
-        else {
4673
-            if( isset($duration['day'] ) && ( 0 < $duration['day'] ))
4674
-                $output .= $duration['day'].'D';
5266
+        if( isset( $duration['week'] ) && ( 0 < $duration['week'] )) {
5267
+                    $output   .= $duration['week'].'W';
5268
+        } else {
5269
+            if( isset($duration['day'] ) && ( 0 < $duration['day'] )) {
5270
+                            $output .= $duration['day'].'D';
5271
+            }
4675 5272
             if(( isset( $duration['hour']) && ( 0 < $duration['hour'] )) ||
4676 5273
                 ( isset( $duration['min'])  && ( 0 < $duration['min'] ))  ||
4677 5274
                 ( isset( $duration['sec'])  && ( 0 < $duration['sec'] ))) {
@@ -4696,7 +5293,9 @@  discard block
 block discarded – undo
4696 5293
         $output = null;
4697 5294
         foreach( $recurdata as $therule ) {
4698 5295
             if( empty( $therule['value'] )) {
4699
-                if( $this->getConfig( 'allowEmpty' )) $output .= $this->_createElement( $recurlabel );
5296
+                if( $this->getConfig( 'allowEmpty' )) {
5297
+                    $output .= $this->_createElement( $recurlabel );
5298
+                }
4700 5299
                 continue;
4701 5300
             }
4702 5301
             $attributes = ( isset( $therule['params'] )) ? $this->_createParams( $therule['params'] ) : null;
@@ -4741,19 +5340,19 @@  discard block
 block discarded – undo
4741 5340
                             if( is_array( $valuePart )) {
4742 5341
                                 $content2 .= ( $bydaycnt ) ? ',' : null;
4743 5342
                                 foreach( $valuePart as $vix2 => $valuePart2 ) {
4744
-                                    if( 'DAY' != strtoupper( $vix2 ))
4745
-                                        $content21 .= $valuePart2;
4746
-                                    else
4747
-                                        $content22 .= $valuePart2;
5343
+                                    if( 'DAY' != strtoupper( $vix2 )) {
5344
+                                                                            $content21 .= $valuePart2;
5345
+                                    } else {
5346
+                                                                            $content22 .= $valuePart2;
5347
+                                    }
4748 5348
                                 }
4749 5349
                                 $content2 .= $content21.$content22;
4750 5350
                                 $bydaycnt++;
4751
-                            }
4752
-                            else {
5351
+                            } else {
4753 5352
                                 $content2 .= ( $bydaycnt ) ? ',' : null;
4754
-                                if( 'DAY' != strtoupper( $vix ))
4755
-                                    $content21 .= $valuePart;
4756
-                                else {
5353
+                                if( 'DAY' != strtoupper( $vix )) {
5354
+                                                                    $content21 .= $valuePart;
5355
+                                } else {
4757 5356
                                     $content22 .= $valuePart;
4758 5357
                                     $bydaycnt++;
4759 5358
                                 }
@@ -4797,24 +5396,32 @@  discard block
 block discarded – undo
4797 5396
      * @return bool
4798 5397
      */
4799 5398
     function _isArrayDate( $input ) {
4800
-        if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 ))))
4801
-            return FALSE;
4802
-        if( 7 == count( $input ))
4803
-            return TRUE;
4804
-        if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4805
-            return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
4806
-        if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] ))
4807
-            return FALSE;
4808
-        if( in_array( 0, $input ))
4809
-            return FALSE;
4810
-        if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] ))
4811
-            return FALSE;
5399
+        if( isset( $input['week'] ) || ( !in_array( count( $input ), array( 3, 6, 7 )))) {
5400
+                    return FALSE;
5401
+        }
5402
+        if( 7 == count( $input )) {
5403
+                    return TRUE;
5404
+        }
5405
+        if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) {
5406
+                    return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5407
+        }
5408
+        if( isset( $input['day'] ) || isset( $input['hour'] ) || isset( $input['min'] ) || isset( $input['sec'] )) {
5409
+                    return FALSE;
5410
+        }
5411
+        if( in_array( 0, $input )) {
5412
+                    return FALSE;
5413
+        }
5414
+        if(( 1970 > $input[0] ) || ( 12 < $input[1] ) || ( 31 < $input[2] )) {
5415
+                    return FALSE;
5416
+        }
4812 5417
         if(( isset( $input[0] ) && isset( $input[1] ) && isset( $input[2] )) &&
4813
-            checkdate( (int) $input[1], (int) $input[2], (int) $input[0] ))
4814
-            return TRUE;
5418
+            checkdate( (int) $input[1], (int) $input[2], (int) $input[0] )) {
5419
+                    return TRUE;
5420
+        }
4815 5421
         $input = $this->_date_time_string( $input[1].'/'.$input[2].'/'.$input[0], 3 ); //  m - d - Y
4816
-        if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] ))
4817
-            return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5422
+        if( isset( $input['year'] ) && isset( $input['month'] ) && isset( $input['day'] )) {
5423
+                    return checkdate( (int) $input['month'], (int) $input['day'], (int) $input['year'] );
5424
+        }
4818 5425
         return FALSE;
4819 5426
     }
4820 5427
     /**
@@ -4838,16 +5445,17 @@  discard block
 block discarded – undo
4838 5445
      */
4839 5446
     function _isOffset( $input ) {
4840 5447
         $input         = trim( (string) $input );
4841
-        if( 'Z' == substr( $input, -1 ))
4842
-            return TRUE;
4843
-        elseif((   5 <= strlen( $input )) &&
5448
+        if( 'Z' == substr( $input, -1 )) {
5449
+                    return TRUE;
5450
+        } elseif((   5 <= strlen( $input )) &&
4844 5451
             ( in_array( substr( $input, -5, 1 ), array( '+', '-' ))) &&
4845
-            (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 )))
4846
-            return TRUE;
4847
-        elseif((    7 <= strlen( $input )) &&
5452
+            (   '0000'  < substr( $input, -4 )) && (   '9999' >= substr( $input, -4 ))) {
5453
+                    return TRUE;
5454
+        } elseif((    7 <= strlen( $input )) &&
4848 5455
             ( in_array( substr( $input, -7, 1 ), array( '+', '-' ))) &&
4849
-            ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 )))
4850
-            return TRUE;
5456
+            ( '000000'  < substr( $input, -6 )) && ( '999999' >= substr( $input, -6 ))) {
5457
+                    return TRUE;
5458
+        }
4851 5459
         return FALSE;
4852 5460
 
4853 5461
     }
@@ -4860,14 +5468,29 @@  discard block
 block discarded – undo
4860 5468
      * @return bool
4861 5469
      */
4862 5470
     function _notExistProp( $propName ) {
4863
-        if( empty( $propName )) return FALSE; // when deleting x-prop, an empty propName may be used=allowed
5471
+        if( empty( $propName )) {
5472
+            return FALSE;
5473
+        }
5474
+        // when deleting x-prop, an empty propName may be used=allowed
4864 5475
         $propName = strtolower( $propName );
4865
-        if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified ))    return TRUE; }
4866
-        elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) return TRUE; }
4867
-        elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid ))    return TRUE; }
4868
-        elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto ))       return TRUE; }
4869
-        elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus ))   return TRUE; }
4870
-        elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName ))       return TRUE;
5476
+        if(     'last-modified'    == $propName )  { if( !isset( $this->lastmodified )) {
5477
+            return TRUE;
5478
+        }
5479
+        } elseif( 'percent-complete' == $propName )  { if( !isset( $this->percentcomplete )) {
5480
+            return TRUE;
5481
+        }
5482
+        } elseif( 'recurrence-id'    == $propName )  { if( !isset( $this->recurrenceid )) {
5483
+            return TRUE;
5484
+        }
5485
+        } elseif( 'related-to'       == $propName )  { if( !isset( $this->relatedto )) {
5486
+            return TRUE;
5487
+        }
5488
+        } elseif( 'request-status'   == $propName )  { if( !isset( $this->requeststatus )) {
5489
+            return TRUE;
5490
+        }
5491
+        } elseif((       'x-' != substr($propName,0,2)) && !isset( $this->$propName )) {
5492
+            return TRUE;
5493
+        }
4871 5494
         return FALSE;
4872 5495
     }
4873 5496
     /**
@@ -4886,7 +5509,9 @@  discard block
 block discarded – undo
4886 5509
      * @todo BYHOUR, BYMINUTE, BYSECOND, ev. BYSETPOS due to ambiguity, WEEKLY at year end/start
4887 5510
      */
4888 5511
     function _recur2date( & $result, $recur, $wdate, $startdate, $enddate=FALSE ) {
4889
-        foreach( $wdate as $k => $v ) if( ctype_digit( $v )) $wdate[$k] = (int) $v;
5512
+        foreach( $wdate as $k => $v ) {
5513
+            if( ctype_digit( $v )) $wdate[$k] = (int) $v;
5514
+        }
4890 5515
         $wdatets     = $this->_date2timestamp( $wdate );
4891 5516
         $startdatets = $this->_date2timestamp( $startdate );
4892 5517
         if( !$enddate ) {
@@ -4895,43 +5520,54 @@  discard block
 block discarded – undo
4895 5520
 // echo "recur __in_ ".implode('-',$startdate)." period start ".implode('-',$wdate)." period end ".implode('-',$enddate)."<br />\n";print_r($recur);echo "<br />\n";//test###
4896 5521
         }
4897 5522
         $endDatets = $this->_date2timestamp( $enddate ); // fix break
4898
-        if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] ))
4899
-            $recur['UNTIL'] = $enddate; // create break
5523
+        if( !isset( $recur['COUNT'] ) && !isset( $recur['UNTIL'] )) {
5524
+                    $recur['UNTIL'] = $enddate;
5525
+        }
5526
+        // create break
4900 5527
         if( isset( $recur['UNTIL'] )) {
4901 5528
             $tdatets = $this->_date2timestamp( $recur['UNTIL'] );
4902 5529
             if( $endDatets > $tdatets ) {
4903 5530
                 $endDatets = $tdatets; // emergency break
4904 5531
                 $enddate   = $this->_timestamp2date( $endDatets, 6 );
5532
+            } else {
5533
+                            $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4905 5534
             }
4906
-            else
4907
-                $recur['UNTIL'] = $this->_timestamp2date( $endDatets, 6 );
4908 5535
         }
4909 5536
         if( $wdatets > $endDatets ) {
4910 5537
             //echo "recur out of date ".implode('-',$this->_date_time_string(date('Y-m-d H:i:s',$wdatets),6))."<br />\n";//test
4911 5538
             return array(); // nothing to do.. .
4912 5539
         }
4913
-        if( !isset( $recur['FREQ'] )) // "MUST be specified.. ."
4914
-            $recur['FREQ'] = 'DAILY'; // ??
5540
+        if( !isset( $recur['FREQ'] )) {
5541
+            // "MUST be specified.. ."
5542
+            $recur['FREQ'] = 'DAILY';
5543
+        }
5544
+        // ??
4915 5545
         $wkst = ( isset( $recur['WKST'] ) && ( 'SU' == $recur['WKST'] )) ? 24*60*60 : 0; // ??
4916
-        if( !isset( $recur['INTERVAL'] ))
4917
-            $recur['INTERVAL'] = 1;
5546
+        if( !isset( $recur['INTERVAL'] )) {
5547
+                    $recur['INTERVAL'] = 1;
5548
+        }
4918 5549
         $countcnt = ( !isset( $recur['BYSETPOS'] )) ? 1 : 0; // DTSTART counts as the first occurrence
4919 5550
         /* find out how to step up dates and set index for interval count */
4920 5551
         $step = array();
4921
-        if( 'YEARLY' == $recur['FREQ'] )
4922
-            $step['year']  = 1;
4923
-        elseif( 'MONTHLY' == $recur['FREQ'] )
4924
-            $step['month'] = 1;
4925
-        elseif( 'WEEKLY' == $recur['FREQ'] )
4926
-            $step['day']   = 7;
4927
-        else
4928
-            $step['day']   = 1;
4929
-        if( isset( $step['year'] ) && isset( $recur['BYMONTH'] ))
4930
-            $step = array( 'month' => 1 );
4931
-        if( empty( $step ) && isset( $recur['BYWEEKNO'] )) // ??
5552
+        if( 'YEARLY' == $recur['FREQ'] ) {
5553
+                    $step['year']  = 1;
5554
+        } elseif( 'MONTHLY' == $recur['FREQ'] ) {
5555
+                    $step['month'] = 1;
5556
+        } elseif( 'WEEKLY' == $recur['FREQ'] ) {
5557
+                    $step['day']   = 7;
5558
+        } else {
5559
+                    $step['day']   = 1;
5560
+        }
5561
+        if( isset( $step['year'] ) && isset( $recur['BYMONTH'] )) {
5562
+                    $step = array( 'month' => 1 );
5563
+        }
5564
+        if( empty( $step ) && isset( $recur['BYWEEKNO'] )) {
5565
+            // ??
4932 5566
             $step = array( 'day' => 7 );
4933
-        if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] ))
4934
-            $step = array( 'day' => 1 );
5567
+        }
5568
+        if( isset( $recur['BYYEARDAY'] ) || isset( $recur['BYMONTHDAY'] ) || isset( $recur['BYDAY'] )) {
5569
+                    $step = array( 'day' => 1 );
5570
+        }
4935 5571
         $intervalarr = array();
4936 5572
         if( 1 < $recur['INTERVAL'] ) {
4937 5573
             $intervalix = $this->_recurIntervalIx( $recur['FREQ'], $wdate, $wkst );
@@ -4944,11 +5580,12 @@  discard block
 block discarded – undo
4944 5580
             $bysetposMold = $wdate['month'];
4945 5581
             $bysetposDold = $wdate['day'];
4946 5582
             if( is_array( $recur['BYSETPOS'] )) {
4947
-                foreach( $recur['BYSETPOS'] as $bix => $bval )
4948
-                    $recur['BYSETPOS'][$bix] = (int) $bval;
5583
+                foreach( $recur['BYSETPOS'] as $bix => $bval ) {
5584
+                                    $recur['BYSETPOS'][$bix] = (int) $bval;
5585
+                }
5586
+            } else {
5587
+                            $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4949 5588
             }
4950
-            else
4951
-                $recur['BYSETPOS'] = array( (int) $recur['BYSETPOS'] );
4952 5589
             $this->_stepdate( $enddate, $endDatets, $step); // make sure to count whole last period
4953 5590
         }
4954 5591
         $this->_stepdate( $wdate, $wdatets, $step);
@@ -4957,10 +5594,12 @@  discard block
 block discarded – undo
4957 5594
         /* MAIN LOOP */
4958 5595
         // echo "recur start ".implode('-',$wdate)." end ".implode('-',$enddate)."<br />\n";//test
4959 5596
         while( TRUE ) {
4960
-            if( isset( $endDatets ) && ( $wdatets > $endDatets ))
4961
-                break;
4962
-            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
4963
-                break;
5597
+            if( isset( $endDatets ) && ( $wdatets > $endDatets )) {
5598
+                            break;
5599
+            }
5600
+            if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) {
5601
+                            break;
5602
+            }
4964 5603
             if( $year_old != $wdate['year'] ) {
4965 5604
                 $year_old   = $wdate['year'];
4966 5605
                 $daycnts    = array();
@@ -4969,8 +5608,9 @@  discard block
 block discarded – undo
4969 5608
                 for( $m = 1; $m <= 12; $m++ ) { // count up and update up-counters
4970 5609
                     $daycnts[$m] = array();
4971 5610
                     $weekdaycnt = array();
4972
-                    foreach( $daynames as $dn )
4973
-                        $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5611
+                    foreach( $daynames as $dn ) {
5612
+                                            $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5613
+                    }
4974 5614
                     $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
4975 5615
                     for( $d   = 1; $d <= $mcnt; $d++ ) {
4976 5616
                         $daycnts[$m][$d] = array();
@@ -4987,8 +5627,9 @@  discard block
 block discarded – undo
4987 5627
                             $yeardaycnt[$day]++;
4988 5628
                             $daycnts[$m][$d]['yeardayno_up'] = $yeardaycnt[$day];
4989 5629
                         }
4990
-                        if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
4991
-                            $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
5630
+                        if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
5631
+                                                    $daycnts[$m][$d]['weekno_up'] =(int)date('W',mktime(0,0,$wkst,$m,$d,$wdate['year']));
5632
+                        }
4992 5633
                     }
4993 5634
                 }
4994 5635
                 $daycnt = 0;
@@ -4996,9 +5637,9 @@  discard block
 block discarded – undo
4996 5637
                 if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
4997 5638
                     $weekno = null;
4998 5639
                     for( $d=31; $d > 25; $d-- ) { // get last weekno for year
4999
-                        if( !$weekno )
5000
-                            $weekno = $daycnts[12][$d]['weekno_up'];
5001
-                        elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
5640
+                        if( !$weekno ) {
5641
+                                                    $weekno = $daycnts[12][$d]['weekno_up'];
5642
+                        } elseif( $weekno < $daycnts[12][$d]['weekno_up'] ) {
5002 5643
                             $weekno = $daycnts[12][$d]['weekno_up'];
5003 5644
                             break;
5004 5645
                         }
@@ -5006,8 +5647,9 @@  discard block
 block discarded – undo
5006 5647
                 }
5007 5648
                 for( $m = 12; $m > 0; $m-- ) { // count down and update down-counters
5008 5649
                     $weekdaycnt = array();
5009
-                    foreach( $daynames as $dn )
5010
-                        $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5650
+                    foreach( $daynames as $dn ) {
5651
+                                            $yeardaycnt[$dn] = $weekdaycnt[$dn] = 0;
5652
+                    }
5011 5653
                     $monthcnt = 0;
5012 5654
                     $mcnt     = date( 't', mktime( 0, 0, 0, $m, 1, $wdate['year'] ));
5013 5655
                     for( $d   = $mcnt; $d > 0; $d-- ) {
@@ -5026,8 +5668,9 @@  discard block
 block discarded – undo
5026 5668
                             $yeardaycnt[$day] -= 1;
5027 5669
                             $daycnts[$m][$d]['yeardayno_down'] = $yeardaycnt[$day];
5028 5670
                         }
5029
-                        if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' ))
5030
-                            $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
5671
+                        if(  isset( $recur['BYWEEKNO'] ) || ( $recur['FREQ'] == 'WEEKLY' )) {
5672
+                                                    $daycnts[$m][$d]['weekno_down'] = ($daycnts[$m][$d]['weekno_up'] - $weekno - 1);
5673
+                        }
5031 5674
                     }
5032 5675
                 }
5033 5676
             }
@@ -5038,36 +5681,42 @@  discard block
 block discarded – undo
5038 5681
                 /* check interval */
5039 5682
                 $currentKey = array_keys( $intervalarr );
5040 5683
                 $currentKey = end( $currentKey ); // get last index
5041
-                if( $currentKey != $intervalix )
5042
-                    $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5684
+                if( $currentKey != $intervalix ) {
5685
+                                    $intervalarr = array( $intervalix => ( $intervalarr[$currentKey] + 1 ));
5686
+                }
5043 5687
                 if(( $recur['INTERVAL'] != $intervalarr[$intervalix] ) &&
5044 5688
                     ( 0 != $intervalarr[$intervalix] )) {
5045 5689
                     /* step up date */
5046 5690
                     //echo "skip: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5047 5691
                     $this->_stepdate( $wdate, $wdatets, $step);
5048 5692
                     continue;
5049
-                }
5050
-                else // continue within the selected interval
5693
+                } else {
5694
+                    // continue within the selected interval
5051 5695
                     $intervalarr[$intervalix] = 0;
5696
+                }
5052 5697
                 //echo "cont: ".implode('-',$wdate)." ix=$intervalix old=$currentKey interval=".$intervalarr[$intervalix]."<br />\n";//test
5053 5698
             }
5054 5699
             $updateOK = TRUE;
5055
-            if( $updateOK && isset( $recur['BYMONTH'] ))
5056
-                $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5700
+            if( $updateOK && isset( $recur['BYMONTH'] )) {
5701
+                            $updateOK = $this->_recurBYcntcheck( $recur['BYMONTH']
5057 5702
                     , $wdate['month']
5058 5703
                     ,($wdate['month'] - 13));
5059
-            if( $updateOK && isset( $recur['BYWEEKNO'] ))
5060
-                $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5704
+            }
5705
+            if( $updateOK && isset( $recur['BYWEEKNO'] )) {
5706
+                            $updateOK = $this->_recurBYcntcheck( $recur['BYWEEKNO']
5061 5707
                     , $daycnts[$wdate['month']][$wdate['day']]['weekno_up']
5062 5708
                     , $daycnts[$wdate['month']][$wdate['day']]['weekno_down'] );
5063
-            if( $updateOK && isset( $recur['BYYEARDAY'] ))
5064
-                $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5709
+            }
5710
+            if( $updateOK && isset( $recur['BYYEARDAY'] )) {
5711
+                            $updateOK = $this->_recurBYcntcheck( $recur['BYYEARDAY']
5065 5712
                     , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_up']
5066 5713
                     , $daycnts[$wdate['month']][$wdate['day']]['yearcnt_down'] );
5067
-            if( $updateOK && isset( $recur['BYMONTHDAY'] ))
5068
-                $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5714
+            }
5715
+            if( $updateOK && isset( $recur['BYMONTHDAY'] )) {
5716
+                            $updateOK = $this->_recurBYcntcheck( $recur['BYMONTHDAY']
5069 5717
                     , $wdate['day']
5070 5718
                     , $daycnts[$wdate['month']][$wdate['day']]['monthcnt_down'] );
5719
+            }
5071 5720
             //echo "efter BYMONTHDAY: ".implode('-',$wdate).' status: '; echo ($updateOK) ? 'TRUE' : 'FALSE'; echo "<br />\n";//test###
5072 5721
             if( $updateOK && isset( $recur['BYDAY'] )) {
5073 5722
                 $updateOK = FALSE;
@@ -5075,42 +5724,45 @@  discard block
 block discarded – undo
5075 5724
                 $d = $wdate['day'];
5076 5725
                 if( isset( $recur['BYDAY']['DAY'] )) { // single day, opt with year/month day order no
5077 5726
                     $daynoexists = $daynosw = $daynamesw =  FALSE;
5078
-                    if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] )
5079
-                        $daynamesw = TRUE;
5727
+                    if( $recur['BYDAY']['DAY'] == $daycnts[$m][$d]['DAY'] ) {
5728
+                                            $daynamesw = TRUE;
5729
+                    }
5080 5730
                     if( isset( $recur['BYDAY'][0] )) {
5081 5731
                         $daynoexists = TRUE;
5082
-                        if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] ))
5083
-                            $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5732
+                        if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) || isset( $recur['BYMONTH'] )) {
5733
+                                                    $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5084 5734
                                 , $daycnts[$m][$d]['monthdayno_up']
5085 5735
                                 , $daycnts[$m][$d]['monthdayno_down'] );
5086
-                        elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5087
-                            $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5736
+                        } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) {
5737
+                                                    $daynosw = $this->_recurBYcntcheck( $recur['BYDAY'][0]
5088 5738
                                 , $daycnts[$m][$d]['yeardayno_up']
5089 5739
                                 , $daycnts[$m][$d]['yeardayno_down'] );
5740
+                        }
5090 5741
                     }
5091 5742
                     if((  $daynoexists &&  $daynosw && $daynamesw ) ||
5092 5743
                         ( !$daynoexists && !$daynosw && $daynamesw )) {
5093 5744
                         $updateOK = TRUE;
5094 5745
                     }
5095 5746
                     //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5096
-                }
5097
-                else {
5747
+                } else {
5098 5748
                     foreach( $recur['BYDAY'] as $bydayvalue ) {
5099 5749
                         $daynoexists = $daynosw = $daynamesw = FALSE;
5100 5750
                         if( isset( $bydayvalue['DAY'] ) &&
5101
-                            ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] ))
5102
-                            $daynamesw = TRUE;
5751
+                            ( $bydayvalue['DAY'] == $daycnts[$m][$d]['DAY'] )) {
5752
+                                                    $daynamesw = TRUE;
5753
+                        }
5103 5754
                         if( isset( $bydayvalue[0] )) {
5104 5755
                             $daynoexists = TRUE;
5105 5756
                             if(( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'MONTHLY' )) ||
5106
-                                isset( $recur['BYMONTH'] ))
5107
-                                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5757
+                                isset( $recur['BYMONTH'] )) {
5758
+                                                            $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5108 5759
                                     , $daycnts[$m][$d]['monthdayno_up']
5109 5760
                                     , $daycnts[$m][$d]['monthdayno_down'] );
5110
-                            elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' ))
5111
-                                $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5761
+                            } elseif( isset( $recur['FREQ'] ) && ( $recur['FREQ'] == 'YEARLY' )) {
5762
+                                                            $daynosw = $this->_recurBYcntcheck( $bydayvalue['0']
5112 5763
                                     , $daycnts[$m][$d]['yeardayno_up']
5113 5764
                                     , $daycnts[$m][$d]['yeardayno_down'] );
5765
+                            }
5114 5766
                         }
5115 5767
                         //echo "daynoexists:$daynoexists daynosw:$daynosw daynamesw:$daynamesw<br />\n"; // test ###
5116 5768
                         if((  $daynoexists &&  $daynosw && $daynamesw ) ||
@@ -5127,12 +5779,12 @@  discard block
 block discarded – undo
5127 5779
                 if( isset( $recur['BYSETPOS'] ) &&
5128 5780
                     ( in_array( $recur['FREQ'], array( 'YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY' )))) {
5129 5781
                     if( isset( $recur['WEEKLY'] )) {
5130
-                        if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] )
5131
-                            $bysetposw1[] = $wdatets;
5132
-                        else
5133
-                            $bysetposw2[] = $wdatets;
5134
-                    }
5135
-                    else {
5782
+                        if( $bysetposWold == $daycnts[$wdate['month']][$wdate['day']]['weekno_up'] ) {
5783
+                                                    $bysetposw1[] = $wdatets;
5784
+                        } else {
5785
+                                                    $bysetposw2[] = $wdatets;
5786
+                        }
5787
+                    } else {
5136 5788
                         if(( isset( $recur['FREQ'] ) && ( 'YEARLY'      == $recur['FREQ'] )  &&
5137 5789
                                 ( $bysetposYold == $wdate['year'] ))   ||
5138 5790
                             ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
@@ -5141,13 +5793,13 @@  discard block
 block discarded – undo
5141 5793
                             ( isset( $recur['FREQ'] ) && ( 'MONTHLY'     == $recur['FREQ'] )  &&
5142 5794
                                 (( $bysetposYold == $wdate['year'] )  &&
5143 5795
                                     ( $bysetposMold == $wdate['month'])  &&
5144
-                                    ( $bysetposDold == $wdate['sday'] ))))
5145
-                            $bysetposymd1[] = $wdatets;
5146
-                        else
5147
-                            $bysetposymd2[] = $wdatets;
5796
+                                    ( $bysetposDold == $wdate['sday'] )))) {
5797
+                                                    $bysetposymd1[] = $wdatets;
5798
+                        } else {
5799
+                                                    $bysetposymd2[] = $wdatets;
5800
+                        }
5148 5801
                     }
5149
-                }
5150
-                else {
5802
+                } else {
5151 5803
                     /* update result array if BYSETPOS is set */
5152 5804
                     $countcnt++;
5153 5805
                     if( $startdatets <= $wdatets ) { // only output within period
@@ -5167,21 +5819,18 @@  discard block
 block discarded – undo
5167 5819
                     ( $bysetposYold != $wdate['year'] )) {
5168 5820
                     $bysetpos     = TRUE;
5169 5821
                     $bysetposYold = $wdate['year'];
5170
-                }
5171
-                elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5822
+                } elseif( isset( $recur['FREQ'] ) && ( 'MONTHLY' == $recur['FREQ'] &&
5172 5823
                         (( $bysetposYold != $wdate['year'] ) || ( $bysetposMold != $wdate['month'] )))) {
5173 5824
                     $bysetpos     = TRUE;
5174 5825
                     $bysetposYold = $wdate['year'];
5175 5826
                     $bysetposMold = $wdate['month'];
5176
-                }
5177
-                elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5827
+                } elseif( isset( $recur['FREQ'] ) && ( 'WEEKLY'  == $recur['FREQ'] )) {
5178 5828
                     $weekno = (int) date( 'W', mktime( 0, 0, $wkst, $wdate['month'], $wdate['day'], $wdate['year']));
5179 5829
                     if( $bysetposWold != $weekno ) {
5180 5830
                         $bysetposWold = $weekno;
5181 5831
                         $bysetpos     = TRUE;
5182 5832
                     }
5183
-                }
5184
-                elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5833
+                } elseif( isset( $recur['FREQ'] ) && ( 'DAILY'   == $recur['FREQ'] ) &&
5185 5834
                     (( $bysetposYold != $wdate['year'] )  ||
5186 5835
                         ( $bysetposMold != $wdate['month'] ) ||
5187 5836
                         ( $bysetposDold != $wdate['sday'] ))) {
@@ -5194,14 +5843,15 @@  discard block
 block discarded – undo
5194 5843
                     if( isset( $recur['BYWEEKNO'] )) {
5195 5844
                         $bysetposarr1 = & $bysetposw1;
5196 5845
                         $bysetposarr2 = & $bysetposw2;
5197
-                    }
5198
-                    else {
5846
+                    } else {
5199 5847
                         $bysetposarr1 = & $bysetposymd1;
5200 5848
                         $bysetposarr2 = & $bysetposymd2;
5201 5849
                     }
5202 5850
                     foreach( $recur['BYSETPOS'] as $ix ) {
5203
-                        if( 0 > $ix ) // both positive and negative BYSETPOS allowed
5851
+                        if( 0 > $ix ) {
5852
+                            // both positive and negative BYSETPOS allowed
5204 5853
                             $ix = ( count( $bysetposarr1 ) + $ix + 1);
5854
+                        }
5205 5855
                         $ix--;
5206 5856
                         if( isset( $bysetposarr1[$ix] )) {
5207 5857
                             if( $startdatets <= $bysetposarr1[$ix] ) { // only output within period
@@ -5210,8 +5860,9 @@  discard block
 block discarded – undo
5210 5860
                             }
5211 5861
                             $countcnt++;
5212 5862
                         }
5213
-                        if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] ))
5214
-                            break;
5863
+                        if( isset( $recur['COUNT'] ) && ( $countcnt >= $recur['COUNT'] )) {
5864
+                                                    break;
5865
+                        }
5215 5866
                     }
5216 5867
                     $bysetposarr1 = $bysetposarr2;
5217 5868
                     $bysetposarr2 = array();
@@ -5221,12 +5872,13 @@  discard block
 block discarded – undo
5221 5872
     }
5222 5873
     function _recurBYcntcheck( $BYvalue, $upValue, $downValue ) {
5223 5874
         if( is_array( $BYvalue ) &&
5224
-            ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue )))
5225
-            return TRUE;
5226
-        elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue ))
5227
-            return TRUE;
5228
-        else
5229
-            return FALSE;
5875
+            ( in_array( $upValue, $BYvalue ) || in_array( $downValue, $BYvalue ))) {
5876
+                    return TRUE;
5877
+        } elseif(( $BYvalue == $upValue ) || ( $BYvalue == $downValue )) {
5878
+                    return TRUE;
5879
+        } else {
5880
+                    return FALSE;
5881
+        }
5230 5882
     }
5231 5883
     function _recurIntervalIx( $freq, $date, $wkst ) {
5232 5884
         /* create interval index */
@@ -5258,21 +5910,27 @@  discard block
 block discarded – undo
5258 5910
      */
5259 5911
     function _setRexrule( $rexrule ) {
5260 5912
         $input          = array();
5261
-        if( empty( $rexrule ))
5262
-            return $input;
5913
+        if( empty( $rexrule )) {
5914
+                    return $input;
5915
+        }
5263 5916
         foreach( $rexrule as $rexrulelabel => $rexrulevalue ) {
5264 5917
             $rexrulelabel = strtoupper( $rexrulelabel );
5265
-            if( 'UNTIL'  != $rexrulelabel )
5266
-                $input[$rexrulelabel]   = $rexrulevalue;
5267
-            else {
5268
-                if( $this->_isArrayTimestampDate( $rexrulevalue )) // timestamp date
5918
+            if( 'UNTIL'  != $rexrulelabel ) {
5919
+                            $input[$rexrulelabel]   = $rexrulevalue;
5920
+            } else {
5921
+                if( $this->_isArrayTimestampDate( $rexrulevalue )) {
5922
+                    // timestamp date
5269 5923
                     $input[$rexrulelabel] = $this->_timestamp2date( $rexrulevalue, 6 );
5270
-                elseif( $this->_isArrayDate( $rexrulevalue )) // date-time
5924
+                } elseif( $this->_isArrayDate( $rexrulevalue )) {
5925
+                    // date-time
5271 5926
                     $input[$rexrulelabel] = $this->_date_time_array( $rexrulevalue, 6 );
5272
-                elseif( 8 <= strlen( trim( $rexrulevalue ))) // ex. 2006-08-03 10:12:18
5927
+                } elseif( 8 <= strlen( trim( $rexrulevalue ))) {
5928
+                    // ex. 2006-08-03 10:12:18
5273 5929
                     $input[$rexrulelabel] = $this->_date_time_string( $rexrulevalue );
5274
-                if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] ))
5275
-                    $input[$rexrulelabel]['tz'] = 'Z';
5930
+                }
5931
+                if(( 3 < count( $input[$rexrulelabel] )) && !isset( $input[$rexrulelabel]['tz'] )) {
5932
+                                    $input[$rexrulelabel]['tz'] = 'Z';
5933
+                }
5276 5934
             }
5277 5935
         }
5278 5936
         return $input;
@@ -5296,7 +5954,9 @@  discard block
 block discarded – undo
5296 5954
         $input = $parno = null;
5297 5955
         $localtime = (( 'dtstart' == $caller ) && in_array( $this->objName, array( 'vtimezone', 'standard', 'daylight' ))) ? TRUE : FALSE;
5298 5956
         if( $this->_isArrayDate( $year )) {
5299
-            if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5957
+            if( $localtime ) {
5958
+                unset ( $month['VALUE'], $month['TZID'] );
5959
+            }
5300 5960
             $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5301 5961
             if( isset( $input['params']['TZID'] )) {
5302 5962
                 $input['params']['VALUE'] = 'DATE-TIME';
@@ -5306,9 +5966,10 @@  discard block
 block discarded – undo
5306 5966
             $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval );
5307 5967
             $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, count( $year ), $parno );
5308 5968
             $input['value']  = $this->_date_time_array( $year, $parno );
5309
-        }
5310
-        elseif( $this->_isArrayTimestampDate( $year )) {
5311
-            if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5969
+        } elseif( $this->_isArrayTimestampDate( $year )) {
5970
+            if( $localtime ) {
5971
+                unset ( $month['VALUE'], $month['TZID'] );
5972
+            }
5312 5973
             $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5313 5974
             if( isset( $input['params']['TZID'] )) {
5314 5975
                 $input['params']['VALUE'] = 'DATE-TIME';
@@ -5318,9 +5979,10 @@  discard block
 block discarded – undo
5318 5979
             $hitval          = ( isset( $year['tz'] )) ? 7 : 6;
5319 5980
             $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', $hitval, $parno );
5320 5981
             $input['value']  = $this->_timestamp2date( $year, $parno );
5321
-        }
5322
-        elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5323
-            if( $localtime ) unset ( $month['VALUE'], $month['TZID'] );
5982
+        } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5983
+            if( $localtime ) {
5984
+                unset ( $month['VALUE'], $month['TZID'] );
5985
+            }
5324 5986
             $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ));
5325 5987
             if( isset( $input['params']['TZID'] )) {
5326 5988
                 $input['params']['VALUE'] = 'DATE-TIME';
@@ -5329,17 +5991,16 @@  discard block
 block discarded – undo
5329 5991
             $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7, $parno );
5330 5992
             $parno           = $this->_existRem( $input['params'], 'VALUE', 'DATE', 3, $parno, $parno );
5331 5993
             $input['value']  = $this->_date_time_string( $year, $parno );
5332
-        }
5333
-        else {
5994
+        } else {
5334 5995
             if( is_array( $params )) {
5335
-                if( $localtime ) unset ( $params['VALUE'], $params['TZID'] );
5996
+                if( $localtime ) {
5997
+                    unset ( $params['VALUE'], $params['TZID'] );
5998
+                }
5336 5999
                 $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5337
-            }
5338
-            elseif( is_array( $tz )) {
6000
+            } elseif( is_array( $tz )) {
5339 6001
                 $input['params'] = $this->_setParams( $tz,     array( 'VALUE' => 'DATE-TIME' ));
5340 6002
                 $tz = FALSE;
5341
-            }
5342
-            elseif( is_array( $hour )) {
6003
+            } elseif( is_array( $hour )) {
5343 6004
                 $input['params'] = $this->_setParams( $hour,   array( 'VALUE' => 'DATE-TIME' ));
5344 6005
                 $hour = $min = $sec = $tz = FALSE;
5345 6006
             }
@@ -5355,23 +6016,28 @@  discard block
 block discarded – undo
5355 6016
                 $input['value']['hour'] = ( $hour ) ? $hour : '0';
5356 6017
                 $input['value']['min']  = ( $min )  ? $min  : '0';
5357 6018
                 $input['value']['sec']  = ( $sec )  ? $sec  : '0';
5358
-                if( !empty( $tz ))
5359
-                    $input['value']['tz'] = $tz;
6019
+                if( !empty( $tz )) {
6020
+                                    $input['value']['tz'] = $tz;
6021
+                }
5360 6022
             }
5361 6023
         }
5362 6024
         if( 3 == $parno ) {
5363 6025
             $input['params']['VALUE'] = 'DATE';
5364 6026
             unset( $input['value']['tz'] );
5365 6027
             unset( $input['params']['TZID'] );
6028
+        } elseif( isset( $input['params']['TZID'] )) {
6029
+                    unset( $input['value']['tz'] );
6030
+        }
6031
+        if( $localtime ) {
6032
+            unset( $input['value']['tz'], $input['params']['TZID'] );
6033
+        }
6034
+        if( isset( $input['value']['tz'] )) {
6035
+                    $input['value']['tz'] = (string) $input['value']['tz'];
5366 6036
         }
5367
-        elseif( isset( $input['params']['TZID'] ))
5368
-            unset( $input['value']['tz'] );
5369
-        if( $localtime ) unset( $input['value']['tz'], $input['params']['TZID'] );
5370
-        if( isset( $input['value']['tz'] ))
5371
-            $input['value']['tz'] = (string) $input['value']['tz'];
5372 6037
         if( !empty( $input['value']['tz'] ) && ( 'Z' != $input['value']['tz'] ) &&
5373
-            ( !$this->_isOffset( $input['value']['tz'] )))
5374
-            $input['params']['TZID'] = $input['value']['tz'];
6038
+            ( !$this->_isOffset( $input['value']['tz'] ))) {
6039
+                    $input['params']['TZID'] = $input['value']['tz'];
6040
+        }
5375 6041
         return $input;
5376 6042
     }
5377 6043
     /**
@@ -5393,16 +6059,13 @@  discard block
 block discarded – undo
5393 6059
         if( $this->_isArrayDate( $year )) {
5394 6060
             $input['value']  = $this->_date_time_array( $year, 7 );
5395 6061
             $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5396
-        }
5397
-        elseif( $this->_isArrayTimestampDate( $year )) {
6062
+        } elseif( $this->_isArrayTimestampDate( $year )) {
5398 6063
             $input['value']  = $this->_timestamp2date( $year, 7 );
5399 6064
             $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5400
-        }
5401
-        elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
6065
+        } elseif( 8 <= strlen( trim( $year ))) { // ex. 2006-08-03 10:12:18
5402 6066
             $input['value']  = $this->_date_time_string( $year, 7 );
5403 6067
             $input['params'] = $this->_setParams( $month, array( 'VALUE' => 'DATE-TIME' ) );
5404
-        }
5405
-        else {
6068
+        } else {
5406 6069
             $input['value']  = array( 'year'  => $year
5407 6070
             , 'month' => $month
5408 6071
             , 'day'   => $day
@@ -5412,14 +6075,18 @@  discard block
 block discarded – undo
5412 6075
             $input['params'] = $this->_setParams( $params, array( 'VALUE' => 'DATE-TIME' ));
5413 6076
         }
5414 6077
         $parno = $this->_existRem( $input['params'], 'VALUE', 'DATE-TIME', 7 ); // remove default
5415
-        if( !isset( $input['value']['hour'] ))
5416
-            $input['value']['hour'] = 0;
5417
-        if( !isset( $input['value']['min'] ))
5418
-            $input['value']['min'] = 0;
5419
-        if( !isset( $input['value']['sec'] ))
5420
-            $input['value']['sec'] = 0;
5421
-        if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] ))
5422
-            $input['value']['tz'] = 'Z';
6078
+        if( !isset( $input['value']['hour'] )) {
6079
+                    $input['value']['hour'] = 0;
6080
+        }
6081
+        if( !isset( $input['value']['min'] )) {
6082
+                    $input['value']['min'] = 0;
6083
+        }
6084
+        if( !isset( $input['value']['sec'] )) {
6085
+                    $input['value']['sec'] = 0;
6086
+        }
6087
+        if( !isset( $input['value']['tz'] ) || !$this->_isOffset( $input['value']['tz'] )) {
6088
+                    $input['value']['tz'] = 'Z';
6089
+        }
5423 6090
         return $input;
5424 6091
     }
5425 6092
     /**
@@ -5435,15 +6102,17 @@  discard block
 block discarded – undo
5435 6102
      * @return void
5436 6103
      */
5437 6104
     function _setMval( & $valArr, $value, $params=FALSE, $defaults=FALSE, $index=FALSE ) {
5438
-        if( !is_array( $valArr )) $valArr = array();
5439
-        if( $index )
5440
-            $index = $index - 1;
5441
-        elseif( 0 < count( $valArr )) {
6105
+        if( !is_array( $valArr )) {
6106
+            $valArr = array();
6107
+        }
6108
+        if( $index ) {
6109
+                    $index = $index - 1;
6110
+        } elseif( 0 < count( $valArr )) {
5442 6111
             $index = end( array_keys( $valArr ));
5443 6112
             $index += 1;
6113
+        } else {
6114
+                    $index = 0;
5444 6115
         }
5445
-        else
5446
-            $index = 0;
5447 6116
         $valArr[$index] = array( 'value' => $value, 'params' => $this->_setParams( $params, $defaults ));
5448 6117
         ksort( $valArr );
5449 6118
     }
@@ -5459,27 +6128,31 @@  discard block
 block discarded – undo
5459 6128
      * @return array
5460 6129
      */
5461 6130
     function _setParams( $params, $defaults=FALSE ) {
5462
-        if( !is_array( $params))
5463
-            $params = array();
6131
+        if( !is_array( $params)) {
6132
+                    $params = array();
6133
+        }
5464 6134
         $input = array();
5465 6135
         foreach( $params as $paramKey => $paramValue ) {
5466 6136
             if( is_array( $paramValue )) {
5467 6137
                 foreach( $paramValue as $pkey => $pValue ) {
5468
-                    if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 )))
5469
-                        $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
6138
+                    if(( '"' == substr( $pValue, 0, 1 )) && ( '"' == substr( $pValue, -1 ))) {
6139
+                                            $paramValue[$pkey] = substr( $pValue, 1, ( strlen( $pValue ) - 2 ));
6140
+                    }
5470 6141
                 }
6142
+            } elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 ))) {
6143
+                            $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
6144
+            }
6145
+            if( 'VALUE' == strtoupper( $paramKey )) {
6146
+                            $input['VALUE']                 = strtoupper( $paramValue );
6147
+            } else {
6148
+                            $input[strtoupper( $paramKey )] = $paramValue;
5471 6149
             }
5472
-            elseif(( '"' == substr( $paramValue, 0, 1 )) && ( '"' == substr( $paramValue, -1 )))
5473
-                $paramValue = substr( $paramValue, 1, ( strlen( $paramValue ) - 2 ));
5474
-            if( 'VALUE' == strtoupper( $paramKey ))
5475
-                $input['VALUE']                 = strtoupper( $paramValue );
5476
-            else
5477
-                $input[strtoupper( $paramKey )] = $paramValue;
5478 6150
         }
5479 6151
         if( is_array( $defaults )) {
5480 6152
             foreach( $defaults as $paramKey => $paramValue ) {
5481
-                if( !isset( $input[$paramKey] ))
5482
-                    $input[$paramKey] = $paramValue;
6153
+                if( !isset( $input[$paramKey] )) {
6154
+                                    $input[$paramKey] = $paramValue;
6155
+                }
5483 6156
             }
5484 6157
         }
5485 6158
         return (0 < count( $input )) ? $input : null;
@@ -5495,13 +6168,15 @@  discard block
 block discarded – undo
5495 6168
      * @return void
5496 6169
      */
5497 6170
     function _stepdate( &$date, &$timestamp, $step=array( 'day' => 1 )) {
5498
-        foreach( $step as $stepix => $stepvalue )
5499
-            $date[$stepix] += $stepvalue;
6171
+        foreach( $step as $stepix => $stepvalue ) {
6172
+                    $date[$stepix] += $stepvalue;
6173
+        }
5500 6174
         $timestamp  = $this->_date2timestamp( $date );
5501 6175
         $date       = $this->_timestamp2date( $timestamp, 6 );
5502 6176
         foreach( $date as $k => $v ) {
5503
-            if( ctype_digit( $v ))
5504
-                $date[$k] = (int) $v;
6177
+            if( ctype_digit( $v )) {
6178
+                            $date[$k] = (int) $v;
6179
+            }
5505 6180
         }
5506 6181
     }
5507 6182
     /**
@@ -5515,8 +6190,9 @@  discard block
 block discarded – undo
5515 6190
      */
5516 6191
     function _timestamp2date( $timestamp, $parno=6 ) {
5517 6192
         if( is_array( $timestamp )) {
5518
-            if(( 7 == $parno ) && !empty( $timestamp['tz'] ))
5519
-                $tz = $timestamp['tz'];
6193
+            if(( 7 == $parno ) && !empty( $timestamp['tz'] )) {
6194
+                            $tz = $timestamp['tz'];
6195
+            }
5520 6196
             $timestamp = $timestamp['timestamp'];
5521 6197
         }
5522 6198
         $output = array( 'year'  => date( 'Y', $timestamp )
@@ -5526,8 +6202,9 @@  discard block
 block discarded – undo
5526 6202
             $output['hour'] =  date( 'H', $timestamp );
5527 6203
             $output['min']  =  date( 'i', $timestamp );
5528 6204
             $output['sec']  =  date( 's', $timestamp );
5529
-            if( isset( $tz ))
5530
-                $output['tz'] = $tz;
6205
+            if( isset( $tz )) {
6206
+                            $output['tz'] = $tz;
6207
+            }
5531 6208
         }
5532 6209
         return $output;
5533 6210
     }
@@ -5545,8 +6222,9 @@  discard block
 block discarded – undo
5545 6222
         if(((     5  != strlen( $tz )) && ( 7  != strlen( $tz ))) ||
5546 6223
             ((    '+' != substr( $tz, 0, 1 )) && ( '-' != substr( $tz, 0, 1 ))) ||
5547 6224
             (( '0000' >= substr( $tz, 1, 4 )) && ( '9999' < substr( $tz, 1, 4 ))) ||
5548
-            (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 ))))
5549
-            return $offset;
6225
+            (( 7  == strlen( $tz )) && ( '00' > substr( $tz, 5, 2 )) && ( '99' < substr( $tz, 5, 2 )))) {
6226
+                    return $offset;
6227
+        }
5550 6228
         $hours2sec    = (int) substr( $tz, 1, 2 ) * 3600;
5551 6229
         $min2sec      = (int) substr( $tz, 3, 2 ) *   60;
5552 6230
         $sec          = ( 7  == strlen( $tz )) ? (int) substr( $tz, -2 ) : '00';
@@ -5574,7 +6252,9 @@  discard block
 block discarded – undo
5574 6252
                 $info = array();
5575 6253
                 if( isset( $this->components )) {
5576 6254
                     foreach( $this->components as $cix => $component ) {
5577
-                        if( empty( $component )) continue;
6255
+                        if( empty( $component )) {
6256
+                            continue;
6257
+                        }
5578 6258
                         unset( $component->propix );
5579 6259
                         $info[$cix]['ordno'] = $cix + 1;
5580 6260
                         $info[$cix]['type']  = $component->objName;
@@ -5600,57 +6280,146 @@  discard block
 block discarded – undo
5600 6280
             case 'PROPINFO':
5601 6281
                 $output = array();
5602 6282
                 if( !in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
5603
-                    if( empty( $this->uid['value'] )) $this->_makeuid();
6283
+                    if( empty( $this->uid['value'] )) {
6284
+                        $this->_makeuid();
6285
+                    }
5604 6286
                     $output['UID']              = 1;
5605 6287
                 }
5606
-                if( !empty( $this->dtstamp ))         $output['DTSTAMP']          = 1;
5607
-                if( !empty( $this->summary ))         $output['SUMMARY']          = 1;
5608
-                if( !empty( $this->description ))     $output['DESCRIPTION']      = count( $this->description );
5609
-                if( !empty( $this->dtstart ))         $output['DTSTART']          = 1;
5610
-                if( !empty( $this->dtend ))           $output['DTEND']            = 1;
5611
-                if( !empty( $this->due ))             $output['DUE']              = 1;
5612
-                if( !empty( $this->duration ))        $output['DURATION']         = 1;
5613
-                if( !empty( $this->rrule ))           $output['RRULE']            = count( $this->rrule );
5614
-                if( !empty( $this->rdate ))           $output['RDATE']            = count( $this->rdate );
5615
-                if( !empty( $this->exdate ))          $output['EXDATE']           = count( $this->exdate );
5616
-                if( !empty( $this->exrule ))          $output['EXRULE']           = count( $this->exrule );
5617
-                if( !empty( $this->action ))          $output['ACTION']           = 1;
5618
-                if( !empty( $this->attach ))          $output['ATTACH']           = count( $this->attach );
5619
-                if( !empty( $this->attendee ))        $output['ATTENDEE']         = count( $this->attendee );
5620
-                if( !empty( $this->categories ))      $output['CATEGORIES']       = count( $this->categories );
5621
-                if( !empty( $this->class ))           $output['CLASS']            = 1;
5622
-                if( !empty( $this->comment ))         $output['COMMENT']          = count( $this->comment );
5623
-                if( !empty( $this->completed ))       $output['COMPLETED']        = 1;
5624
-                if( !empty( $this->contact ))         $output['CONTACT']          = count( $this->contact );
5625
-                if( !empty( $this->created ))         $output['CREATED']          = 1;
5626
-                if( !empty( $this->freebusy ))        $output['FREEBUSY']         = count( $this->freebusy );
5627
-                if( !empty( $this->geo ))             $output['GEO']              = 1;
5628
-                if( !empty( $this->lastmodified ))    $output['LAST-MODIFIED']    = 1;
5629
-                if( !empty( $this->location ))        $output['LOCATION']         = 1;
5630
-                if( !empty( $this->organizer ))       $output['ORGANIZER']        = 1;
5631
-                if( !empty( $this->percentcomplete )) $output['PERCENT-COMPLETE'] = 1;
5632
-                if( !empty( $this->priority ))        $output['PRIORITY']         = 1;
5633
-                if( !empty( $this->recurrenceid ))    $output['RECURRENCE-ID']    = 1;
5634
-                if( !empty( $this->relatedto ))       $output['RELATED-TO']       = count( $this->relatedto );
5635
-                if( !empty( $this->repeat ))          $output['REPEAT']           = 1;
5636
-                if( !empty( $this->requeststatus ))   $output['REQUEST-STATUS']   = count( $this->requeststatus );
5637
-                if( !empty( $this->resources ))       $output['RESOURCES']        = count( $this->resources );
5638
-                if( !empty( $this->sequence ))        $output['SEQUENCE']         = 1;
5639
-                if( !empty( $this->status ))          $output['STATUS']           = 1;
5640
-                if( !empty( $this->transp ))          $output['TRANSP']           = 1;
5641
-                if( !empty( $this->trigger ))         $output['TRIGGER']          = 1;
5642
-                if( !empty( $this->tzid ))            $output['TZID']             = 1;
5643
-                if( !empty( $this->tzname ))          $output['TZNAME']           = count( $this->tzname );
5644
-                if( !empty( $this->tzoffsetfrom ))    $output['TZOFFSETTFROM']    = 1;
5645
-                if( !empty( $this->tzoffsetto ))      $output['TZOFFSETTO']       = 1;
5646
-                if( !empty( $this->tzurl ))           $output['TZURL']            = 1;
5647
-                if( !empty( $this->url ))             $output['URL']              = 1;
5648
-                if( !empty( $this->xprop ))           $output['X-PROP']           = count( $this->xprop );
6288
+                if( !empty( $this->dtstamp )) {
6289
+                    $output['DTSTAMP']          = 1;
6290
+                }
6291
+                if( !empty( $this->summary )) {
6292
+                    $output['SUMMARY']          = 1;
6293
+                }
6294
+                if( !empty( $this->description )) {
6295
+                    $output['DESCRIPTION']      = count( $this->description );
6296
+                }
6297
+                if( !empty( $this->dtstart )) {
6298
+                    $output['DTSTART']          = 1;
6299
+                }
6300
+                if( !empty( $this->dtend )) {
6301
+                    $output['DTEND']            = 1;
6302
+                }
6303
+                if( !empty( $this->due )) {
6304
+                    $output['DUE']              = 1;
6305
+                }
6306
+                if( !empty( $this->duration )) {
6307
+                    $output['DURATION']         = 1;
6308
+                }
6309
+                if( !empty( $this->rrule )) {
6310
+                    $output['RRULE']            = count( $this->rrule );
6311
+                }
6312
+                if( !empty( $this->rdate )) {
6313
+                    $output['RDATE']            = count( $this->rdate );
6314
+                }
6315
+                if( !empty( $this->exdate )) {
6316
+                    $output['EXDATE']           = count( $this->exdate );
6317
+                }
6318
+                if( !empty( $this->exrule )) {
6319
+                    $output['EXRULE']           = count( $this->exrule );
6320
+                }
6321
+                if( !empty( $this->action )) {
6322
+                    $output['ACTION']           = 1;
6323
+                }
6324
+                if( !empty( $this->attach )) {
6325
+                    $output['ATTACH']           = count( $this->attach );
6326
+                }
6327
+                if( !empty( $this->attendee )) {
6328
+                    $output['ATTENDEE']         = count( $this->attendee );
6329
+                }
6330
+                if( !empty( $this->categories )) {
6331
+                    $output['CATEGORIES']       = count( $this->categories );
6332
+                }
6333
+                if( !empty( $this->class )) {
6334
+                    $output['CLASS']            = 1;
6335
+                }
6336
+                if( !empty( $this->comment )) {
6337
+                    $output['COMMENT']          = count( $this->comment );
6338
+                }
6339
+                if( !empty( $this->completed )) {
6340
+                    $output['COMPLETED']        = 1;
6341
+                }
6342
+                if( !empty( $this->contact )) {
6343
+                    $output['CONTACT']          = count( $this->contact );
6344
+                }
6345
+                if( !empty( $this->created )) {
6346
+                    $output['CREATED']          = 1;
6347
+                }
6348
+                if( !empty( $this->freebusy )) {
6349
+                    $output['FREEBUSY']         = count( $this->freebusy );
6350
+                }
6351
+                if( !empty( $this->geo )) {
6352
+                    $output['GEO']              = 1;
6353
+                }
6354
+                if( !empty( $this->lastmodified )) {
6355
+                    $output['LAST-MODIFIED']    = 1;
6356
+                }
6357
+                if( !empty( $this->location )) {
6358
+                    $output['LOCATION']         = 1;
6359
+                }
6360
+                if( !empty( $this->organizer )) {
6361
+                    $output['ORGANIZER']        = 1;
6362
+                }
6363
+                if( !empty( $this->percentcomplete )) {
6364
+                    $output['PERCENT-COMPLETE'] = 1;
6365
+                }
6366
+                if( !empty( $this->priority )) {
6367
+                    $output['PRIORITY']         = 1;
6368
+                }
6369
+                if( !empty( $this->recurrenceid )) {
6370
+                    $output['RECURRENCE-ID']    = 1;
6371
+                }
6372
+                if( !empty( $this->relatedto )) {
6373
+                    $output['RELATED-TO']       = count( $this->relatedto );
6374
+                }
6375
+                if( !empty( $this->repeat )) {
6376
+                    $output['REPEAT']           = 1;
6377
+                }
6378
+                if( !empty( $this->requeststatus )) {
6379
+                    $output['REQUEST-STATUS']   = count( $this->requeststatus );
6380
+                }
6381
+                if( !empty( $this->resources )) {
6382
+                    $output['RESOURCES']        = count( $this->resources );
6383
+                }
6384
+                if( !empty( $this->sequence )) {
6385
+                    $output['SEQUENCE']         = 1;
6386
+                }
6387
+                if( !empty( $this->status )) {
6388
+                    $output['STATUS']           = 1;
6389
+                }
6390
+                if( !empty( $this->transp )) {
6391
+                    $output['TRANSP']           = 1;
6392
+                }
6393
+                if( !empty( $this->trigger )) {
6394
+                    $output['TRIGGER']          = 1;
6395
+                }
6396
+                if( !empty( $this->tzid )) {
6397
+                    $output['TZID']             = 1;
6398
+                }
6399
+                if( !empty( $this->tzname )) {
6400
+                    $output['TZNAME']           = count( $this->tzname );
6401
+                }
6402
+                if( !empty( $this->tzoffsetfrom )) {
6403
+                    $output['TZOFFSETTFROM']    = 1;
6404
+                }
6405
+                if( !empty( $this->tzoffsetto )) {
6406
+                    $output['TZOFFSETTO']       = 1;
6407
+                }
6408
+                if( !empty( $this->tzurl )) {
6409
+                    $output['TZURL']            = 1;
6410
+                }
6411
+                if( !empty( $this->url )) {
6412
+                    $output['URL']              = 1;
6413
+                }
6414
+                if( !empty( $this->xprop )) {
6415
+                    $output['X-PROP']           = count( $this->xprop );
6416
+                }
5649 6417
                 return $output;
5650 6418
                 break;
5651 6419
             case 'UNIQUE_ID':
5652
-                if( empty( $this->unique_id ))
5653
-                    $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
6420
+                if( empty( $this->unique_id )) {
6421
+                                    $this->unique_id  = ( isset( $_SERVER['SERVER_NAME'] )) ? gethostbyname( $_SERVER['SERVER_NAME'] ) : 'localhost';
6422
+                }
5654 6423
                 return $this->unique_id;
5655 6424
                 break;
5656 6425
         }
@@ -5699,13 +6468,16 @@  discard block
 block discarded – undo
5699 6468
                 $res    = TRUE;
5700 6469
                 break;
5701 6470
         }
5702
-        if( !$res ) return FALSE;
6471
+        if( !$res ) {
6472
+            return FALSE;
6473
+        }
5703 6474
         if( isset( $subcfg ) && !empty( $this->components )) {
5704 6475
             foreach( $subcfg as $cfgkey => $cfgvalue ) {
5705 6476
                 foreach( $this->components as $cix => $component ) {
5706 6477
                     $res = $component->setConfig( $cfgkey, $cfgvalue );
5707
-                    if( !$res )
5708
-                        break 2;
6478
+                    if( !$res ) {
6479
+                                            break 2;
6480
+                    }
5709 6481
                     $this->components[$cix] = $component; // PHP4 compliant
5710 6482
                 }
5711 6483
             }
@@ -5723,12 +6495,15 @@  discard block
 block discarded – undo
5723 6495
      * @return bool, if successfull delete TRUE
5724 6496
      */
5725 6497
     function deleteProperty( $propName, $propix=FALSE ) {
5726
-        if( $this->_notExistProp( $propName )) return FALSE;
6498
+        if( $this->_notExistProp( $propName )) {
6499
+            return FALSE;
6500
+        }
5727 6501
         $propName = strtoupper( $propName );
5728 6502
         if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
5729 6503
             'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
5730
-            if( !$propix )
5731
-                $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
6504
+            if( !$propix ) {
6505
+                            $propix = ( isset( $this->propdelix[$propName] )) ? $this->propdelix[$propName] + 2 : 1;
6506
+            }
5732 6507
             $this->propdelix[$propName] = --$propix;
5733 6508
         }
5734 6509
         $return = FALSE;
@@ -5782,8 +6557,9 @@  discard block
 block discarded – undo
5782 6557
                 }
5783 6558
                 break;
5784 6559
             case 'DTSTAMP':
5785
-                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5786
-                    return FALSE;
6560
+                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6561
+                                    return FALSE;
6562
+                }
5787 6563
                 if( !empty( $this->dtstamp )) {
5788 6564
                     $this->dtstamp = '';
5789 6565
                     $return = TRUE;
@@ -5937,8 +6713,9 @@  discard block
 block discarded – undo
5937 6713
                 }
5938 6714
                 break;
5939 6715
             case 'UID':
5940
-                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
5941
-                    return FALSE;
6716
+                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6717
+                                    return FALSE;
6718
+                }
5942 6719
                 if( !empty( $this->uid )) {
5943 6720
                     $this->uid = '';
5944 6721
                     $return = TRUE;
@@ -5953,18 +6730,23 @@  discard block
 block discarded – undo
5953 6730
             default:
5954 6731
                 $reduced = '';
5955 6732
                 if( $propName != 'X-PROP' ) {
5956
-                    if( !isset( $this->xprop[$propName] )) return FALSE;
6733
+                    if( !isset( $this->xprop[$propName] )) {
6734
+                        return FALSE;
6735
+                    }
5957 6736
                     foreach( $this->xprop as $k => $a ) {
5958
-                        if(( $k != $propName ) && !empty( $a ))
5959
-                            $reduced[$k] = $a;
6737
+                        if(( $k != $propName ) && !empty( $a )) {
6738
+                                                    $reduced[$k] = $a;
6739
+                        }
6740
+                    }
6741
+                } else {
6742
+                    if( count( $this->xprop ) <= $propix ) {
6743
+                        return FALSE;
5960 6744
                     }
5961
-                }
5962
-                else {
5963
-                    if( count( $this->xprop ) <= $propix )  return FALSE;
5964 6745
                     $xpropno = 0;
5965 6746
                     foreach( $this->xprop as $xpropkey => $xpropvalue ) {
5966
-                        if( $propix != $xpropno )
5967
-                            $reduced[$xpropkey] = $xpropvalue;
6747
+                        if( $propix != $xpropno ) {
6748
+                                                    $reduced[$xpropkey] = $xpropvalue;
6749
+                        }
5968 6750
                         $xpropno++;
5969 6751
                     }
5970 6752
                 }
@@ -5984,9 +6766,13 @@  discard block
 block discarded – undo
5984 6766
      * @return bool TRUE
5985 6767
      */
5986 6768
     function deletePropertyM( & $multiprop, $propix=0 ) {
5987
-        if( !isset( $multiprop[$propix])) return FALSE;
6769
+        if( !isset( $multiprop[$propix])) {
6770
+            return FALSE;
6771
+        }
5988 6772
         unset( $multiprop[$propix] );
5989
-        if( empty( $multiprop )) $multiprop = '';
6773
+        if( empty( $multiprop )) {
6774
+            $multiprop = '';
6775
+        }
5990 6776
         return ( isset( $this->multiprop[$propix] )) ? FALSE : TRUE;
5991 6777
     }
5992 6778
     /**
@@ -6003,184 +6789,277 @@  discard block
 block discarded – undo
6003 6789
      * @return mixed
6004 6790
      */
6005 6791
     function getProperty( $propName=FALSE, $propix=FALSE, $inclParam=FALSE, $specform=FALSE ) {
6006
-        if( $this->_notExistProp( $propName )) return FALSE;
6792
+        if( $this->_notExistProp( $propName )) {
6793
+            return FALSE;
6794
+        }
6007 6795
         $propName = ( $propName ) ? strtoupper( $propName ) : 'X-PROP';
6008 6796
         if( in_array( $propName, array( 'ATTACH',   'ATTENDEE', 'CATEGORIES', 'COMMENT',   'CONTACT', 'DESCRIPTION',    'EXDATE', 'EXRULE',
6009 6797
             'FREEBUSY', 'RDATE',    'RELATED-TO', 'RESOURCES', 'RRULE',   'REQUEST-STATUS', 'TZNAME', 'X-PROP'  ))) {
6010
-            if( !$propix )
6011
-                $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
6798
+            if( !$propix ) {
6799
+                            $propix = ( isset( $this->propix[$propName] )) ? $this->propix[$propName] + 2 : 1;
6800
+            }
6012 6801
             $this->propix[$propName] = --$propix;
6013 6802
         }
6014 6803
         switch( $propName ) {
6015 6804
             case 'ACTION':
6016
-                if( !empty( $this->action['value'] )) return ( $inclParam ) ? $this->action : $this->action['value'];
6805
+                if( !empty( $this->action['value'] )) {
6806
+                    return ( $inclParam ) ? $this->action : $this->action['value'];
6807
+                }
6017 6808
                 break;
6018 6809
             case 'ATTACH':
6019
-                if( !isset( $this->attach[$propix] )) return FALSE;
6810
+                if( !isset( $this->attach[$propix] )) {
6811
+                    return FALSE;
6812
+                }
6020 6813
                 return ( $inclParam ) ? $this->attach[$propix] : $this->attach[$propix]['value'];
6021 6814
                 break;
6022 6815
             case 'ATTENDEE':
6023
-                if( !isset( $this->attendee[$propix] )) return FALSE;
6816
+                if( !isset( $this->attendee[$propix] )) {
6817
+                    return FALSE;
6818
+                }
6024 6819
                 return ( $inclParam ) ? $this->attendee[$propix] : $this->attendee[$propix]['value'];
6025 6820
                 break;
6026 6821
             case 'CATEGORIES':
6027
-                if( !isset( $this->categories[$propix] )) return FALSE;
6822
+                if( !isset( $this->categories[$propix] )) {
6823
+                    return FALSE;
6824
+                }
6028 6825
                 return ( $inclParam ) ? $this->categories[$propix] : $this->categories[$propix]['value'];
6029 6826
                 break;
6030 6827
             case 'CLASS':
6031
-                if( !empty( $this->class['value'] )) return ( $inclParam ) ? $this->class : $this->class['value'];
6828
+                if( !empty( $this->class['value'] )) {
6829
+                    return ( $inclParam ) ? $this->class : $this->class['value'];
6830
+                }
6032 6831
                 break;
6033 6832
             case 'COMMENT':
6034
-                if( !isset( $this->comment[$propix] )) return FALSE;
6833
+                if( !isset( $this->comment[$propix] )) {
6834
+                    return FALSE;
6835
+                }
6035 6836
                 return ( $inclParam ) ? $this->comment[$propix] : $this->comment[$propix]['value'];
6036 6837
                 break;
6037 6838
             case 'COMPLETED':
6038
-                if( !empty( $this->completed['value'] )) return ( $inclParam ) ? $this->completed : $this->completed['value'];
6839
+                if( !empty( $this->completed['value'] )) {
6840
+                    return ( $inclParam ) ? $this->completed : $this->completed['value'];
6841
+                }
6039 6842
                 break;
6040 6843
             case 'CONTACT':
6041
-                if( !isset( $this->contact[$propix] )) return FALSE;
6844
+                if( !isset( $this->contact[$propix] )) {
6845
+                    return FALSE;
6846
+                }
6042 6847
                 return ( $inclParam ) ? $this->contact[$propix] : $this->contact[$propix]['value'];
6043 6848
                 break;
6044 6849
             case 'CREATED':
6045
-                if( !empty( $this->created['value'] )) return ( $inclParam ) ? $this->created : $this->created['value'];
6850
+                if( !empty( $this->created['value'] )) {
6851
+                    return ( $inclParam ) ? $this->created : $this->created['value'];
6852
+                }
6046 6853
                 break;
6047 6854
             case 'DESCRIPTION':
6048
-                if( !isset( $this->description[$propix] )) return FALSE;
6855
+                if( !isset( $this->description[$propix] )) {
6856
+                    return FALSE;
6857
+                }
6049 6858
                 return ( $inclParam ) ? $this->description[$propix] : $this->description[$propix]['value'];
6050 6859
                 break;
6051 6860
             case 'DTEND':
6052
-                if( !empty( $this->dtend['value'] )) return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6861
+                if( !empty( $this->dtend['value'] )) {
6862
+                    return ( $inclParam ) ? $this->dtend : $this->dtend['value'];
6863
+                }
6053 6864
                 break;
6054 6865
             case 'DTSTAMP':
6055
-                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6056
-                    return;
6057
-                if( !isset( $this->dtstamp['value'] ))
6058
-                    $this->_makeDtstamp();
6866
+                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
6867
+                                    return;
6868
+                }
6869
+                if( !isset( $this->dtstamp['value'] )) {
6870
+                                    $this->_makeDtstamp();
6871
+                }
6059 6872
                 return ( $inclParam ) ? $this->dtstamp : $this->dtstamp['value'];
6060 6873
                 break;
6061 6874
             case 'DTSTART':
6062
-                if( !empty( $this->dtstart['value'] )) return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6875
+                if( !empty( $this->dtstart['value'] )) {
6876
+                    return ( $inclParam ) ? $this->dtstart : $this->dtstart['value'];
6877
+                }
6063 6878
                 break;
6064 6879
             case 'DUE':
6065
-                if( !empty( $this->due['value'] )) return ( $inclParam ) ? $this->due : $this->due['value'];
6880
+                if( !empty( $this->due['value'] )) {
6881
+                    return ( $inclParam ) ? $this->due : $this->due['value'];
6882
+                }
6066 6883
                 break;
6067 6884
             case 'DURATION':
6068
-                if( !isset( $this->duration['value'] )) return FALSE;
6885
+                if( !isset( $this->duration['value'] )) {
6886
+                    return FALSE;
6887
+                }
6069 6888
                 $value = ( $specform ) ? $this->duration2date() : $this->duration['value'];
6070 6889
                 return ( $inclParam ) ? array( 'value' => $value, 'params' =>  $this->duration['params'] ) : $value;
6071 6890
                 break;
6072 6891
             case 'EXDATE':
6073
-                if( !isset( $this->exdate[$propix] )) return FALSE;
6892
+                if( !isset( $this->exdate[$propix] )) {
6893
+                    return FALSE;
6894
+                }
6074 6895
                 return ( $inclParam ) ? $this->exdate[$propix] : $this->exdate[$propix]['value'];
6075 6896
                 break;
6076 6897
             case 'EXRULE':
6077
-                if( !isset( $this->exrule[$propix] )) return FALSE;
6898
+                if( !isset( $this->exrule[$propix] )) {
6899
+                    return FALSE;
6900
+                }
6078 6901
                 return ( $inclParam ) ? $this->exrule[$propix] : $this->exrule[$propix]['value'];
6079 6902
                 break;
6080 6903
             case 'FREEBUSY':
6081
-                if( !isset( $this->freebusy[$propix] )) return FALSE;
6904
+                if( !isset( $this->freebusy[$propix] )) {
6905
+                    return FALSE;
6906
+                }
6082 6907
                 return ( $inclParam ) ? $this->freebusy[$propix] : $this->freebusy[$propix]['value'];
6083 6908
                 break;
6084 6909
             case 'GEO':
6085
-                if( !empty( $this->geo['value'] )) return ( $inclParam ) ? $this->geo : $this->geo['value'];
6910
+                if( !empty( $this->geo['value'] )) {
6911
+                    return ( $inclParam ) ? $this->geo : $this->geo['value'];
6912
+                }
6086 6913
                 break;
6087 6914
             case 'LAST-MODIFIED':
6088
-                if( !empty( $this->lastmodified['value'] )) return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6915
+                if( !empty( $this->lastmodified['value'] )) {
6916
+                    return ( $inclParam ) ? $this->lastmodified : $this->lastmodified['value'];
6917
+                }
6089 6918
                 break;
6090 6919
             case 'LOCATION':
6091
-                if( !empty( $this->location['value'] )) return ( $inclParam ) ? $this->location : $this->location['value'];
6920
+                if( !empty( $this->location['value'] )) {
6921
+                    return ( $inclParam ) ? $this->location : $this->location['value'];
6922
+                }
6092 6923
                 break;
6093 6924
             case 'ORGANIZER':
6094
-                if( !empty( $this->organizer['value'] )) return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6925
+                if( !empty( $this->organizer['value'] )) {
6926
+                    return ( $inclParam ) ? $this->organizer : $this->organizer['value'];
6927
+                }
6095 6928
                 break;
6096 6929
             case 'PERCENT-COMPLETE':
6097
-                if( !empty( $this->percentcomplete['value'] )) return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6930
+                if( !empty( $this->percentcomplete['value'] )) {
6931
+                    return ( $inclParam ) ? $this->percentcomplete : $this->percentcomplete['value'];
6932
+                }
6098 6933
                 break;
6099 6934
             case 'PRIORITY':
6100
-                if( !empty( $this->priority['value'] )) return ( $inclParam ) ? $this->priority : $this->priority['value'];
6935
+                if( !empty( $this->priority['value'] )) {
6936
+                    return ( $inclParam ) ? $this->priority : $this->priority['value'];
6937
+                }
6101 6938
                 break;
6102 6939
             case 'RDATE':
6103
-                if( !isset( $this->rdate[$propix] )) return FALSE;
6940
+                if( !isset( $this->rdate[$propix] )) {
6941
+                    return FALSE;
6942
+                }
6104 6943
                 return ( $inclParam ) ? $this->rdate[$propix] : $this->rdate[$propix]['value'];
6105 6944
                 break;
6106 6945
             case 'RECURRENCE-ID':
6107
-                if( !empty( $this->recurrenceid['value'] )) return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6946
+                if( !empty( $this->recurrenceid['value'] )) {
6947
+                    return ( $inclParam ) ? $this->recurrenceid : $this->recurrenceid['value'];
6948
+                }
6108 6949
                 break;
6109 6950
             case 'RELATED-TO':
6110
-                if( !isset( $this->relatedto[$propix] )) return FALSE;
6951
+                if( !isset( $this->relatedto[$propix] )) {
6952
+                    return FALSE;
6953
+                }
6111 6954
                 return ( $inclParam ) ? $this->relatedto[$propix] : $this->relatedto[$propix]['value'];
6112 6955
                 break;
6113 6956
             case 'REPEAT':
6114
-                if( !empty( $this->repeat['value'] )) return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6957
+                if( !empty( $this->repeat['value'] )) {
6958
+                    return ( $inclParam ) ? $this->repeat : $this->repeat['value'];
6959
+                }
6115 6960
                 break;
6116 6961
             case 'REQUEST-STATUS':
6117
-                if( !isset( $this->requeststatus[$propix] )) return FALSE;
6962
+                if( !isset( $this->requeststatus[$propix] )) {
6963
+                    return FALSE;
6964
+                }
6118 6965
                 return ( $inclParam ) ? $this->requeststatus[$propix] : $this->requeststatus[$propix]['value'];
6119 6966
                 break;
6120 6967
             case 'RESOURCES':
6121
-                if( !isset( $this->resources[$propix] )) return FALSE;
6968
+                if( !isset( $this->resources[$propix] )) {
6969
+                    return FALSE;
6970
+                }
6122 6971
                 return ( $inclParam ) ? $this->resources[$propix] : $this->resources[$propix]['value'];
6123 6972
                 break;
6124 6973
             case 'RRULE':
6125
-                if( !isset( $this->rrule[$propix] )) return FALSE;
6974
+                if( !isset( $this->rrule[$propix] )) {
6975
+                    return FALSE;
6976
+                }
6126 6977
                 return ( $inclParam ) ? $this->rrule[$propix] : $this->rrule[$propix]['value'];
6127 6978
                 break;
6128 6979
             case 'SEQUENCE':
6129
-                if( !empty( $this->sequence['value'] )) return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6980
+                if( !empty( $this->sequence['value'] )) {
6981
+                    return ( $inclParam ) ? $this->sequence : $this->sequence['value'];
6982
+                }
6130 6983
                 break;
6131 6984
             case 'STATUS':
6132
-                if( !empty( $this->status['value'] )) return ( $inclParam ) ? $this->status : $this->status['value'];
6985
+                if( !empty( $this->status['value'] )) {
6986
+                    return ( $inclParam ) ? $this->status : $this->status['value'];
6987
+                }
6133 6988
                 break;
6134 6989
             case 'SUMMARY':
6135
-                if( !empty( $this->summary['value'] )) return ( $inclParam ) ? $this->summary : $this->summary['value'];
6990
+                if( !empty( $this->summary['value'] )) {
6991
+                    return ( $inclParam ) ? $this->summary : $this->summary['value'];
6992
+                }
6136 6993
                 break;
6137 6994
             case 'TRANSP':
6138
-                if( !empty( $this->transp['value'] )) return ( $inclParam ) ? $this->transp : $this->transp['value'];
6995
+                if( !empty( $this->transp['value'] )) {
6996
+                    return ( $inclParam ) ? $this->transp : $this->transp['value'];
6997
+                }
6139 6998
                 break;
6140 6999
             case 'TRIGGER':
6141
-                if( !empty( $this->trigger['value'] )) return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
7000
+                if( !empty( $this->trigger['value'] )) {
7001
+                    return ( $inclParam ) ? $this->trigger : $this->trigger['value'];
7002
+                }
6142 7003
                 break;
6143 7004
             case 'TZID':
6144
-                if( !empty( $this->tzid['value'] )) return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
7005
+                if( !empty( $this->tzid['value'] )) {
7006
+                    return ( $inclParam ) ? $this->tzid : $this->tzid['value'];
7007
+                }
6145 7008
                 break;
6146 7009
             case 'TZNAME':
6147
-                if( !isset( $this->tzname[$propix] )) return FALSE;
7010
+                if( !isset( $this->tzname[$propix] )) {
7011
+                    return FALSE;
7012
+                }
6148 7013
                 return ( $inclParam ) ? $this->tzname[$propix] : $this->tzname[$propix]['value'];
6149 7014
                 break;
6150 7015
             case 'TZOFFSETFROM':
6151
-                if( !empty( $this->tzoffsetfrom['value'] )) return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
7016
+                if( !empty( $this->tzoffsetfrom['value'] )) {
7017
+                    return ( $inclParam ) ? $this->tzoffsetfrom : $this->tzoffsetfrom['value'];
7018
+                }
6152 7019
                 break;
6153 7020
             case 'TZOFFSETTO':
6154
-                if( !empty( $this->tzoffsetto['value'] )) return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
7021
+                if( !empty( $this->tzoffsetto['value'] )) {
7022
+                    return ( $inclParam ) ? $this->tzoffsetto : $this->tzoffsetto['value'];
7023
+                }
6155 7024
                 break;
6156 7025
             case 'TZURL':
6157
-                if( !empty( $this->tzurl['value'] )) return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
7026
+                if( !empty( $this->tzurl['value'] )) {
7027
+                    return ( $inclParam ) ? $this->tzurl : $this->tzurl['value'];
7028
+                }
6158 7029
                 break;
6159 7030
             case 'UID':
6160
-                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' )))
6161
-                    return FALSE;
6162
-                if( empty( $this->uid['value'] ))
6163
-                    $this->_makeuid();
7031
+                if( in_array( $this->objName, array( 'valarm', 'vtimezone', 'standard', 'daylight' ))) {
7032
+                                    return FALSE;
7033
+                }
7034
+                if( empty( $this->uid['value'] )) {
7035
+                                    $this->_makeuid();
7036
+                }
6164 7037
                 return ( $inclParam ) ? $this->uid : $this->uid['value'];
6165 7038
                 break;
6166 7039
             case 'URL':
6167
-                if( !empty( $this->url['value'] )) return ( $inclParam ) ? $this->url : $this->url['value'];
7040
+                if( !empty( $this->url['value'] )) {
7041
+                    return ( $inclParam ) ? $this->url : $this->url['value'];
7042
+                }
6168 7043
                 break;
6169 7044
             default:
6170 7045
                 if( $propName != 'X-PROP' ) {
6171
-                    if( !isset( $this->xprop[$propName] )) return FALSE;
7046
+                    if( !isset( $this->xprop[$propName] )) {
7047
+                        return FALSE;
7048
+                    }
6172 7049
                     return ( $inclParam ) ? array( $propName, $this->xprop[$propName] )
6173 7050
                         : array( $propName, $this->xprop[$propName]['value'] );
6174
-                }
6175
-                else {
6176
-                    if( empty( $this->xprop )) return FALSE;
7051
+                } else {
7052
+                    if( empty( $this->xprop )) {
7053
+                        return FALSE;
7054
+                    }
6177 7055
                     $xpropno = 0;
6178 7056
                     foreach( $this->xprop as $xpropkey => $xpropvalue ) {
6179
-                        if( $propix == $xpropno )
6180
-                            return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
7057
+                        if( $propix == $xpropno ) {
7058
+                                                    return ( $inclParam ) ? array( $xpropkey, $this->xprop[$xpropkey] )
6181 7059
                                 : array( $xpropkey, $this->xprop[$xpropkey]['value'] );
6182
-                        else
6183
-                            $xpropno++;
7060
+                        } else {
7061
+                                                    $xpropno++;
7062
+                        }
6184 7063
                     }
6185 7064
                     return FALSE; // not found ??
6186 7065
                 }
@@ -6199,15 +7078,21 @@  discard block
 block discarded – undo
6199 7078
      */
6200 7079
     function setProperty() {
6201 7080
         $numargs    = func_num_args();
6202
-        if( 1 > $numargs ) return FALSE;
7081
+        if( 1 > $numargs ) {
7082
+            return FALSE;
7083
+        }
6203 7084
         $arglist    = func_get_args();
6204
-        if( $this->_notExistProp( $arglist[0] )) return FALSE;
6205
-        if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] )))
7085
+        if( $this->_notExistProp( $arglist[0] )) {
6206 7086
             return FALSE;
7087
+        }
7088
+        if( !$this->getConfig( 'allowEmpty' ) && ( !isset( $arglist[1] ) || empty( $arglist[1] ))) {
7089
+                    return FALSE;
7090
+        }
6207 7091
         $arglist[0] = strtoupper( $arglist[0] );
6208 7092
         for( $argix=$numargs; $argix < 12; $argix++ ) {
6209
-            if( !isset( $arglist[$argix] ))
6210
-                $arglist[$argix] = null;
7093
+            if( !isset( $arglist[$argix] )) {
7094
+                            $arglist[$argix] = null;
7095
+            }
6211 7096
         }
6212 7097
         switch( $arglist[0] ) {
6213 7098
             case 'ACTION':
@@ -6321,20 +7206,19 @@  discard block
 block discarded – undo
6321 7206
                         $this->setComponent( $comp );
6322 7207
                         $comp =  & $this;
6323 7208
                         continue;
6324
-                    }
6325
-                    elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
7209
+                    } elseif( 'BEGIN:VALARM' == strtoupper( substr( $line, 0, 12 ))) {
6326 7210
                         $comp = new valarm();
6327 7211
                         continue;
7212
+                    } else {
7213
+                                            $comp->unparsed[] = $line;
6328 7214
                     }
6329
-                    else
6330
-                        $comp->unparsed[] = $line;
6331 7215
                 }
7216
+            } else {
7217
+                            $this->unparsed = array( trim( $unparsedtext ));
6332 7218
             }
6333
-            else
6334
-                $this->unparsed = array( trim( $unparsedtext ));
7219
+        } elseif( !isset( $this->unparsed )) {
7220
+                    $this->unparsed = array();
6335 7221
         }
6336
-        elseif( !isset( $this->unparsed ))
6337
-            $this->unparsed = array();
6338 7222
         /* concatenate property values spread over several lines */
6339 7223
         $lastix    = -1;
6340 7224
         $propnames = array( 'action', 'attach', 'attendee', 'categories', 'comment', 'completed'
@@ -6358,8 +7242,7 @@  discard block
 block discarded – undo
6358 7242
                 $newProp = FALSE;
6359 7243
                 $lastix++;
6360 7244
                 $proprows[$lastix]  = $line;
6361
-            }
6362
-            else {
7245
+            } else {
6363 7246
                 /* remove line breaks */
6364 7247
                 if(( '\n' == substr( $proprows[$lastix], -2 )) &&
6365 7248
                     (  ' ' == substr( $line, 0, 1 ))) {
@@ -6372,14 +7255,15 @@  discard block
 block discarded – undo
6372 7255
         /* parse each property 'line' */
6373 7256
         foreach( $proprows as $line ) {
6374 7257
             $line = str_replace( "\n ", '', $line );
6375
-            if( '\n' == substr( $line, -2 ))
6376
-                $line = substr( $line, 0, strlen( $line ) - 2 );
7258
+            if( '\n' == substr( $line, -2 )) {
7259
+                            $line = substr( $line, 0, strlen( $line ) - 2 );
7260
+            }
6377 7261
             /* get propname, (problem with x-properties, otherwise in previous loop) */
6378 7262
             $cix = $propname = null;
6379 7263
             for( $cix=0; $cix < strlen( $line ); $cix++ ) {
6380
-                if( in_array( $line{$cix}, array( ':', ';' )))
6381
-                    break;
6382
-                else {
7264
+                if( in_array( $line{$cix}, array( ':', ';' ))) {
7265
+                                    break;
7266
+                } else {
6383 7267
                     $propname .= $line{$cix};
6384 7268
                 }
6385 7269
             }
@@ -6412,27 +7296,30 @@  discard block
 block discarded – undo
6412 7296
                         break;
6413 7297
                     }
6414 7298
                 }
6415
-                if( ';' == $line{$cix} )
6416
-                    $attr[++$attrix] = null;
6417
-                else
6418
-                    $attr[$attrix] .= $line{$cix};
7299
+                if( ';' == $line{$cix} ) {
7300
+                                    $attr[++$attrix] = null;
7301
+                } else {
7302
+                                    $attr[$attrix] .= $line{$cix};
7303
+                }
6419 7304
             }
6420 7305
             /* make attributes in array format */
6421 7306
             $propattr = array();
6422 7307
             foreach( $attr as $attribute ) {
6423 7308
                 $attrsplit = explode( '=', $attribute, 2 );
6424
-                if( 1 < count( $attrsplit ))
6425
-                    $propattr[$attrsplit[0]] = $attrsplit[1];
6426
-                else
6427
-                    $propattr[] = $attribute;
7309
+                if( 1 < count( $attrsplit )) {
7310
+                                    $propattr[$attrsplit[0]] = $attrsplit[1];
7311
+                } else {
7312
+                                    $propattr[] = $attribute;
7313
+                }
6428 7314
             }
6429 7315
             /* call setProperty( $propname.. . */
6430 7316
             switch( $propname ) {
6431 7317
                 case 'ATTENDEE':
6432 7318
                     foreach( $propattr as $pix => $attr ) {
6433 7319
                         $attr2 = explode( ',', $attr );
6434
-                        if( 1 < count( $attr2 ))
6435
-                            $propattr[$pix] = $attr2;
7320
+                        if( 1 < count( $attr2 )) {
7321
+                                                    $propattr[$pix] = $attr2;
7322
+                        }
6436 7323
                     }
6437 7324
                     $this->setProperty( $propname, $line, $propattr );
6438 7325
                     break;
@@ -6450,13 +7337,14 @@  discard block
 block discarded – undo
6450 7337
                         }
6451 7338
                         if( 1 < count( $content )) {
6452 7339
                             $content = array_values( $content );
6453
-                            foreach( $content as $cix => $contentPart )
6454
-                                $content[$cix] = $this->_strunrep( $contentPart );
7340
+                            foreach( $content as $cix => $contentPart ) {
7341
+                                                            $content[$cix] = $this->_strunrep( $contentPart );
7342
+                            }
6455 7343
                             $this->setProperty( $propname, $content, $propattr );
6456 7344
                             break;
7345
+                        } else {
7346
+                                                    $line = reset( $content );
6457 7347
                         }
6458
-                        else
6459
-                            $line = reset( $content );
6460 7348
                     }
6461 7349
                 //no break
6462 7350
                 case 'X-':
@@ -6467,8 +7355,9 @@  discard block
 block discarded – undo
6467 7355
                 case 'DESCRIPTION':
6468 7356
                 case 'LOCATION':
6469 7357
                 case 'SUMMARY':
6470
-                    if( empty( $line ))
6471
-                        $propattr = null;
7358
+                    if( empty( $line )) {
7359
+                                            $propattr = null;
7360
+                    }
6472 7361
                     $this->setProperty( $propname, $this->_strunrep( $line ), $propattr );
6473 7362
                     unset( $propname2 );
6474 7363
                     break;
@@ -6488,15 +7377,17 @@  discard block
 block discarded – undo
6488 7377
                     $values = explode( ',', $line );
6489 7378
                     foreach( $values as $vix => $value ) {
6490 7379
                         $value2 = explode( '/', $value );
6491
-                        if( 1 < count( $value2 ))
6492
-                            $values[$vix] = $value2;
7380
+                        if( 1 < count( $value2 )) {
7381
+                                                    $values[$vix] = $value2;
7382
+                        }
6493 7383
                     }
6494 7384
                     $this->setProperty( $propname, $fbtype, $values, $propattr );
6495 7385
                     break;
6496 7386
                 case 'GEO':
6497 7387
                     $value = explode( ';', $line, 2 );
6498
-                    if( 2 > count( $value ))
6499
-                        $value[1] = null;
7388
+                    if( 2 > count( $value )) {
7389
+                                            $value[1] = null;
7390
+                    }
6500 7391
                     $this->setProperty( $propname, $value[0], $value[1], $propattr );
6501 7392
                     break;
6502 7393
                 case 'EXDATE':
@@ -6511,8 +7402,9 @@  discard block
 block discarded – undo
6511 7402
                     $values = explode( ',', $line );
6512 7403
                     foreach( $values as $vix => $value ) {
6513 7404
                         $value2 = explode( '/', $value );
6514
-                        if( 1 < count( $value2 ))
6515
-                            $values[$vix] = $value2;
7405
+                        if( 1 < count( $value2 )) {
7406
+                                                    $values[$vix] = $value2;
7407
+                        }
6516 7408
                     }
6517 7409
                     $this->setProperty( $propname, $values, $propattr );
6518 7410
                     break;
@@ -6521,8 +7413,10 @@  discard block
 block discarded – undo
6521 7413
                     $values = explode( ';', $line );
6522 7414
                     $recur = array();
6523 7415
                     foreach( $values as $value2 ) {
6524
-                        if( empty( $value2 ))
6525
-                            continue; // ;-char in ending position ???
7416
+                        if( empty( $value2 )) {
7417
+                                                    continue;
7418
+                        }
7419
+                        // ;-char in ending position ???
6526 7420
                         $value3 = explode( '=', $value2, 2 );
6527 7421
                         $rulelabel = strtoupper( $value3[0] );
6528 7422
                         switch( $rulelabel ) {
@@ -6536,37 +7430,43 @@  discard block
 block discarded – undo
6536 7430
                                         if(( ctype_alpha( substr( $value5, -1 ))) &&
6537 7431
                                             ( ctype_alpha( substr( $value5, -2, 1 )))) {
6538 7432
                                             $dayname = substr( $value5, -2, 2 );
6539
-                                            if( 2 < strlen( $value5 ))
6540
-                                                $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7433
+                                            if( 2 < strlen( $value5 )) {
7434
+                                                                                            $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7435
+                                            }
7436
+                                        }
7437
+                                        if( $dayno ) {
7438
+                                                                                    $value6[] = $dayno;
7439
+                                        }
7440
+                                        if( $dayname ) {
7441
+                                                                                    $value6['DAY'] = $dayname;
6541 7442
                                         }
6542
-                                        if( $dayno )
6543
-                                            $value6[] = $dayno;
6544
-                                        if( $dayname )
6545
-                                            $value6['DAY'] = $dayname;
6546 7443
                                         $value4[$v5ix] = $value6;
6547 7444
                                     }
6548
-                                }
6549
-                                else {
7445
+                                } else {
6550 7446
                                     $value4 = array();
6551 7447
                                     $dayno  = $dayname = null;
6552 7448
                                     $value5 = trim( (string) $value3[1] );
6553 7449
                                     if(( ctype_alpha( substr( $value5, -1 ))) &&
6554 7450
                                         ( ctype_alpha( substr( $value5, -2, 1 )))) {
6555 7451
                                         $dayname = substr( $value5, -2, 2 );
6556
-                                        if( 2 < strlen( $value5 ))
6557
-                                            $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7452
+                                        if( 2 < strlen( $value5 )) {
7453
+                                                                                    $dayno = substr( $value5, 0, ( strlen( $value5 ) - 2 ));
7454
+                                        }
7455
+                                    }
7456
+                                    if( $dayno ) {
7457
+                                                                            $value4[] = $dayno;
7458
+                                    }
7459
+                                    if( $dayname ) {
7460
+                                                                            $value4['DAY'] = $dayname;
6558 7461
                                     }
6559
-                                    if( $dayno )
6560
-                                        $value4[] = $dayno;
6561
-                                    if( $dayname )
6562
-                                        $value4['DAY'] = $dayname;
6563 7462
                                 }
6564 7463
                                 $recur[$rulelabel] = $value4;
6565 7464
                                 break;
6566 7465
                             default:
6567 7466
                                 $value4 = explode( ',', $value3[1] );
6568
-                                if( 1 < count( $value4 ))
6569
-                                    $value3[1] = $value4;
7467
+                                if( 1 < count( $value4 )) {
7468
+                                                                    $value3[1] = $value4;
7469
+                                }
6570 7470
                                 $recur[$rulelabel] = $value3[1];
6571 7471
                                 break;
6572 7472
                         } // end - switch $rulelabel
@@ -6581,8 +7481,9 @@  discard block
 block discarded – undo
6581 7481
         unset( $this->unparsed, $proprows );
6582 7482
         if( isset( $this->components ) && is_array( $this->components ) && ( 0 < count( $this->components ))) {
6583 7483
             for( $six = 0; $six < count( $this->components ); $six++ ) {
6584
-                if( !empty( $this->components[$six]->unparsed ))
6585
-                    $this->components[$six]->parse();
7484
+                if( !empty( $this->components[$six]->unparsed )) {
7485
+                                    $this->components[$six]->parse();
7486
+                }
6586 7487
             }
6587 7488
         }
6588 7489
     }
@@ -6613,32 +7514,33 @@  discard block
 block discarded – undo
6613 7514
      * @return void
6614 7515
      */
6615 7516
     function deleteComponent( $arg1, $arg2=FALSE  ) {
6616
-        if( !isset( $this->components )) return FALSE;
7517
+        if( !isset( $this->components )) {
7518
+            return FALSE;
7519
+        }
6617 7520
         $argType = $index = null;
6618 7521
         if ( ctype_digit( (string) $arg1 )) {
6619 7522
             $argType = 'INDEX';
6620 7523
             $index   = (int) $arg1 - 1;
6621
-        }
6622
-        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7524
+        } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6623 7525
             $argType = strtolower( $arg1 );
6624 7526
             $index   = ( !empty( $arg2 ) && ctype_digit( (string) $arg2 )) ? (( int ) $arg2 - 1 ) : 0;
6625 7527
         }
6626 7528
         $cix2dC = 0;
6627 7529
         foreach ( $this->components as $cix => $component) {
6628
-            if( empty( $component )) continue;
7530
+            if( empty( $component )) {
7531
+                continue;
7532
+            }
6629 7533
             unset( $component->propix );
6630 7534
             if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6631 7535
                 unset( $this->components[$cix] );
6632 7536
                 return TRUE;
6633
-            }
6634
-            elseif( $argType == $component->objName ) {
7537
+            } elseif( $argType == $component->objName ) {
6635 7538
                 if( $index == $cix2dC ) {
6636 7539
                     unset( $this->components[$cix] );
6637 7540
                     return TRUE;
6638 7541
                 }
6639 7542
                 $cix2dC++;
6640
-            }
6641
-            elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
7543
+            } elseif( !$argType && ($arg1 == $component->getProperty( 'uid' ))) {
6642 7544
                 unset( $this->components[$cix] );
6643 7545
                 return TRUE;
6644 7546
             }
@@ -6655,43 +7557,47 @@  discard block
 block discarded – undo
6655 7557
      * @return object
6656 7558
      */
6657 7559
     function getComponent ( $arg1=FALSE, $arg2=FALSE ) {
6658
-        if( !isset( $this->components )) return FALSE;
7560
+        if( !isset( $this->components )) {
7561
+            return FALSE;
7562
+        }
6659 7563
         $index = $argType = null;
6660 7564
         if ( !$arg1 ) {
6661 7565
             $argType = 'INDEX';
6662 7566
             $index   = $this->compix['INDEX'] =
6663 7567
                 ( isset( $this->compix['INDEX'] )) ? $this->compix['INDEX'] + 1 : 1;
6664
-        }
6665
-        elseif ( ctype_digit( (string) $arg1 )) {
7568
+        } elseif ( ctype_digit( (string) $arg1 )) {
6666 7569
             $argType = 'INDEX';
6667 7570
             $index   = (int) $arg1;
6668 7571
             unset( $this->compix );
6669
-        }
6670
-        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7572
+        } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6671 7573
             unset( $this->compix['INDEX'] );
6672 7574
             $argType = strtolower( $arg1 );
6673
-            if( !$arg2 )
6674
-                $index = $this->compix[$argType] =
7575
+            if( !$arg2 ) {
7576
+                            $index = $this->compix[$argType] =
6675 7577
                     ( isset( $this->compix[$argType] )) ? $this->compix[$argType] + 1 : 1;
6676
-            else
6677
-                $index = (int) $arg2;
7578
+            } else {
7579
+                            $index = (int) $arg2;
7580
+            }
6678 7581
         }
6679 7582
         $index  -= 1;
6680 7583
         $ckeys = array_keys( $this->components );
6681
-        if( !empty( $index) && ( $index > end( $ckeys )))
6682
-            return FALSE;
7584
+        if( !empty( $index) && ( $index > end( $ckeys ))) {
7585
+                    return FALSE;
7586
+        }
6683 7587
         $cix2gC = 0;
6684 7588
         foreach( $this->components as $cix => $component ) {
6685
-            if( empty( $component )) continue;
7589
+            if( empty( $component )) {
7590
+                continue;
7591
+            }
6686 7592
             unset( $component->propix );
6687
-            if(( 'INDEX' == $argType ) && ( $index == $cix ))
6688
-                return $component->copy();
6689
-            elseif( $argType == $component->objName ) {
6690
-                if( $index == $cix2gC )
6691
-                    return $component->copy();
7593
+            if(( 'INDEX' == $argType ) && ( $index == $cix )) {
7594
+                            return $component->copy();
7595
+            } elseif( $argType == $component->objName ) {
7596
+                if( $index == $cix2gC ) {
7597
+                                    return $component->copy();
7598
+                }
6692 7599
                 $cix2gC++;
6693
-            }
6694
-            elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
7600
+            } elseif( !$argType && ( $arg1 == $component->getProperty( 'uid' ))) {
6695 7601
                 unset( $component->propix );
6696 7602
                 return $component->copy();
6697 7603
             }
@@ -6722,9 +7628,12 @@  discard block
 block discarded – undo
6722 7628
      * @return bool
6723 7629
      */
6724 7630
     function setComponent( $component, $arg1=FALSE, $arg2=FALSE  ) {
6725
-        if( !isset( $this->components )) return FALSE;
6726
-        if( '' >= $component->getConfig( 'language'))
6727
-            $component->setConfig( 'language',  $this->getConfig( 'language' ));
7631
+        if( !isset( $this->components )) {
7632
+            return FALSE;
7633
+        }
7634
+        if( '' >= $component->getConfig( 'language')) {
7635
+                    $component->setConfig( 'language',  $this->getConfig( 'language' ));
7636
+        }
6728 7637
         $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6729 7638
         $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6730 7639
         $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -6743,27 +7652,26 @@  discard block
 block discarded – undo
6743 7652
         if ( ctype_digit( (string) $arg1 )) {
6744 7653
             $argType = 'INDEX';
6745 7654
             $index   = (int) $arg1 - 1;
6746
-        }
6747
-        elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
7655
+        } elseif(( strlen( $arg1 ) <= strlen( 'vfreebusy' )) && ( FALSE === strpos( $arg1, '@' ))) {
6748 7656
             $argType = strtolower( $arg1 );
6749 7657
             $index = ( ctype_digit( (string) $arg2 )) ? ((int) $arg2) - 1 : 0;
6750 7658
         }
6751 7659
         $cix2sC = 0;
6752 7660
         foreach ( $this->components as $cix => $component2 ) {
6753
-            if( empty( $component2 )) continue;
7661
+            if( empty( $component2 )) {
7662
+                continue;
7663
+            }
6754 7664
             unset( $component2->propix );
6755 7665
             if(( 'INDEX' == $argType ) && ( $index == $cix )) {
6756 7666
                 $this->components[$cix] = $component->copy();
6757 7667
                 return TRUE;
6758
-            }
6759
-            elseif( $argType == $component2->objName ) {
7668
+            } elseif( $argType == $component2->objName ) {
6760 7669
                 if( $index == $cix2sC ) {
6761 7670
                     $this->components[$cix] = $component->copy();
6762 7671
                     return TRUE;
6763 7672
                 }
6764 7673
                 $cix2sC++;
6765
-            }
6766
-            elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
7674
+            } elseif( !$argType && ($arg1 == $component2->getProperty( 'uid' ))) {
6767 7675
                 $this->components[$cix] = $component->copy();
6768 7676
                 return TRUE;
6769 7677
             }
@@ -6782,9 +7690,12 @@  discard block
 block discarded – undo
6782 7690
     function createSubComponent() {
6783 7691
         $output = null;
6784 7692
         foreach( $this->components as $component ) {
6785
-            if( empty( $component )) continue;
6786
-            if( '' >= $component->getConfig( 'language'))
6787
-                $component->setConfig( 'language',  $this->getConfig( 'language' ));
7693
+            if( empty( $component )) {
7694
+                continue;
7695
+            }
7696
+            if( '' >= $component->getConfig( 'language')) {
7697
+                            $component->setConfig( 'language',  $this->getConfig( 'language' ));
7698
+            }
6788 7699
             $component->setConfig( 'allowEmpty',  $this->getConfig( 'allowEmpty' ));
6789 7700
             $component->setConfig( 'nl',          $this->getConfig( 'nl' ));
6790 7701
             $component->setConfig( 'unique_id',   $this->getConfig( 'unique_id' ));
@@ -6822,16 +7733,18 @@  discard block
 block discarded – undo
6822 7733
         $string = null;
6823 7734
         while( $strlen > 75 ) {
6824 7735
             $breakAtChar = 75;
6825
-            if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' )
6826
-                $breakAtChar = $breakAtChar - 1;
7736
+            if( substr( $tmp, ( $breakAtChar - 1 ), strlen( '\n' )) == '\n' ) {
7737
+                            $breakAtChar = $breakAtChar - 1;
7738
+            }
6827 7739
             $string .= substr( $tmp, 0, $breakAtChar );
6828 7740
             $string .= $this->nl;
6829 7741
             $tmp     = ' '.substr( $tmp, $breakAtChar );
6830 7742
             $strlen  = strlen( $tmp );
6831 7743
         } // while
6832 7744
         $string .= rtrim( $tmp ); // the rest
6833
-        if( $this->nl != substr( $string, ( 0 - strlen( $this->nl ))))
6834
-            $string .= $this->nl;
7745
+        if( $this->nl != substr( $string, ( 0 - strlen( $this->nl )))) {
7746
+                    $string .= $this->nl;
7747
+        }
6835 7748
         return $string;
6836 7749
     }
6837 7750
     /**
@@ -6852,27 +7765,33 @@  discard block
 block discarded – undo
6852 7765
                 $pos = 0;
6853 7766
                 while( $pos <= strlen( $string )) {
6854 7767
                     $pos = strpos( $string, "\\", $pos );
6855
-                    if( FALSE === $pos )
6856
-                        break;
7768
+                    if( FALSE === $pos ) {
7769
+                                            break;
7770
+                    }
6857 7771
                     if( !in_array( $string{($pos + 1)}, array( 'n', 'N', 'r', ',', ';' ))) {
6858 7772
                         $string = substr( $string, 0, $pos )."\\".substr( $string, ( $pos + 1 ));
6859 7773
                         $pos += 1;
6860 7774
                     }
6861 7775
                     $pos += 1;
6862 7776
                 }
6863
-                if( FALSE !== strpos( $string, '"' ))
6864
-                    $string = str_replace('"',   "'",       $string);
6865
-                if( FALSE !== strpos( $string, ',' ))
6866
-                    $string = str_replace(',',   '\,',      $string);
6867
-                if( FALSE !== strpos( $string, ';' ))
6868
-                    $string = str_replace(';',   '\;',      $string);
6869
-                if( FALSE !== strpos( $string, "\r\n" ))
6870
-                    $string = str_replace( "\r\n", '\n',    $string);
6871
-                elseif( FALSE !== strpos( $string, "\r" ))
6872
-                    $string = str_replace( "\r", '\n',      $string);
6873
-                if( FALSE !== strpos( $string, '\N' ))
6874
-                    $string = str_replace( '\N', '\n',      $string);
6875
-//        if( FALSE !== strpos( $string, $this->nl ))
7777
+                if( FALSE !== strpos( $string, '"' )) {
7778
+                                    $string = str_replace('"',   "'",       $string);
7779
+                }
7780
+                if( FALSE !== strpos( $string, ',' )) {
7781
+                                    $string = str_replace(',',   '\,',      $string);
7782
+                }
7783
+                if( FALSE !== strpos( $string, ';' )) {
7784
+                                    $string = str_replace(';',   '\;',      $string);
7785
+                }
7786
+                if( FALSE !== strpos( $string, "\r\n" )) {
7787
+                                    $string = str_replace( "\r\n", '\n',    $string);
7788
+                } elseif( FALSE !== strpos( $string, "\r" )) {
7789
+                                    $string = str_replace( "\r", '\n',      $string);
7790
+                }
7791
+                if( FALSE !== strpos( $string, '\N' )) {
7792
+                                    $string = str_replace( '\N', '\n',      $string);
7793
+                }
7794
+                //        if( FALSE !== strpos( $string, $this->nl ))
6876 7795
                 $string = str_replace( $this->nl, '\n', $string);
6877 7796
                 break;
6878 7797
         }
@@ -7024,8 +7943,9 @@  discard block
 block discarded – undo
7024 7943
         $component    .= $this->createSubComponent();
7025 7944
         $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7026 7945
         if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7027
-            foreach( $this->xcaldecl as $localxcaldecl )
7028
-                $xcaldecl[] = $localxcaldecl;
7946
+            foreach( $this->xcaldecl as $localxcaldecl ) {
7947
+                            $xcaldecl[] = $localxcaldecl;
7948
+            }
7029 7949
         }
7030 7950
         return $component;
7031 7951
     }
@@ -7162,8 +8082,9 @@  discard block
 block discarded – undo
7162 8082
         $component    .= $this->createSubComponent();
7163 8083
         $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7164 8084
         if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7165
-            foreach( $this->xcaldecl as $localxcaldecl )
7166
-                $xcaldecl[] = $localxcaldecl;
8085
+            foreach( $this->xcaldecl as $localxcaldecl ) {
8086
+                            $xcaldecl[] = $localxcaldecl;
8087
+            }
7167 8088
         }
7168 8089
         return $component;
7169 8090
     }
@@ -7271,8 +8192,9 @@  discard block
 block discarded – undo
7271 8192
         $component .= $this->createXprop();
7272 8193
         $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7273 8194
         if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7274
-            foreach( $this->xcaldecl as $localxcaldecl )
7275
-                $xcaldecl[] = $localxcaldecl;
8195
+            foreach( $this->xcaldecl as $localxcaldecl ) {
8196
+                            $xcaldecl[] = $localxcaldecl;
8197
+            }
7276 8198
         }
7277 8199
         return $component;
7278 8200
     }
@@ -7346,8 +8268,9 @@  discard block
 block discarded – undo
7346 8268
         $component .= $this->createXprop();
7347 8269
         $component .= $this->componentEnd1.$objectname.$this->componentEnd2;
7348 8270
         if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7349
-            foreach( $this->xcaldecl as $localxcaldecl )
7350
-                $xcaldecl[] = $localxcaldecl;
8271
+            foreach( $this->xcaldecl as $localxcaldecl ) {
8272
+                            $xcaldecl[] = $localxcaldecl;
8273
+            }
7351 8274
         }
7352 8275
         return $component;
7353 8276
     }
@@ -7492,8 +8415,9 @@  discard block
 block discarded – undo
7492 8415
         $component    .= $this->createSubComponent();
7493 8416
         $component    .= $this->componentEnd1.$objectname.$this->componentEnd2;
7494 8417
         if( is_array( $this->xcaldecl ) && ( 0 < count( $this->xcaldecl ))) {
7495
-            foreach( $this->xcaldecl as $localxcaldecl )
7496
-                $xcaldecl[] = $localxcaldecl;
8418
+            foreach( $this->xcaldecl as $localxcaldecl ) {
8419
+                            $xcaldecl[] = $localxcaldecl;
8420
+            }
7497 8421
         }
7498 8422
         return $component;
7499 8423
     }
Please login to merge, or discard this patch.